<commit_before>package com.snowplowanalytics.snowplow.tracker.tracker;

import android.app.Activity;
import android.app.Fragment;

import com.snowplowanalytics.snowplow.tracker.constants.Parameters;
import com.snowplowanalytics.snowplow.tracker.constants.TrackerConstants;
import com.snowplowanalytics.snowplow.tracker.payload.SelfDescribingJson;
import com.snowplowanalytics.snowplow.tracker.payload.TrackerPayload;

import java.lang.reflect.Field;
import java.util.UUID;

public class ScreenState {
    private String name;
    private String type;
    private String id;
    private String previousName;
    private String previousId;
    private String previousType;
    private String transitionType;
    private String fragmentClassName;
    private String fragmentTag;
    private String activityClassName;
    private String activityTag;

    public ScreenState() {
        this.generateNewId();
    }

    public ScreenState(String name, String type, String transitionType) {
        this();
        this.name = name;
        this.type = type;
        this.transitionType = transitionType;
    }

    public ScreenState(String name, String type, String transitionType,
                       ScreenState previousState) {
        this(name, type, transitionType);
        this.previousId = previousState.id;
        this.previousName = previousState.name;
        this.previousType = previousState.type;
    }

    public void newScreenState(String name, String type, String transitionType) {
        this.populatePreviousFields();
        this.name = name;
        this.type = type;
        this.transitionType = transitionType;
        this.generateNewId();
    }

    public static String getSnowplowScreenId(Activity activity) {
        try {
            Field field = activity.getClass().getField("snowplowScreenId");
            Object reflectedValue = field.get(activity);
            if (reflectedValue instanceof String) {
                return (String)reflectedValue;<commit_msg>Fix ScreenState incompatibility with Screen schema (close #336)<commit_after>package com.snowplowanalytics.snowplow.tracker.tracker;

import android.app.Activity;
import android.app.Fragment;

import com.snowplowanalytics.snowplow.tracker.constants.Parameters;
import com.snowplowanalytics.snowplow.tracker.constants.TrackerConstants;
import com.snowplowanalytics.snowplow.tracker.payload.SelfDescribingJson;
import com.snowplowanalytics.snowplow.tracker.payload.TrackerPayload;

import java.lang.reflect.Field;
import java.util.UUID;

public class ScreenState {
    private String name;
    private String type;
    private String id;
    private String previousName;
    private String previousId;
    private String previousType;
    private String transitionType;
    private String fragmentClassName;
    private String fragmentTag;
    private String activityClassName;
    private String activityTag;

    public ScreenState() {
        this.generateNewId();
        this.name = this.getAutomaticName();
    }

    public ScreenState(String name, String type, String transitionType) {
        this();
        this.name = name;
        this.type = type;
        this.transitionType = transitionType;
    }

    public ScreenState(String name, String type, String transitionType,
                       ScreenState previousState) {
        this(name, type, transitionType);
        this.previousId = previousState.id;
        this.previousName = previousState.name;
        this.previousType = previousState.type;
    }

    public void newScreenState(String name, String type, String transitionType) {
        this.populatePreviousFields();
        this.name = name;
        this.type = type;
        this.transitionType = transitionType;
        this.generateNewId();
    }

    public static String getSnowplowScreenId(Activity activity) {
        try {
            Field field = activity.getClass().getField("snowplowScreenId");
            Object reflectedValue = field.get(activity);
            if (reflectedValue instanceof String) {
                return (String)reflectedValue;
{'fraction_non_alphanumeric': 0.07797604497677829, 'fraction_numerical': 0.0007333170373991689, 'mean_word_length': 3.1712538226299696, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6748698', 'n_tokens_mistral': 1093, 'n_tokens_neox': 1078, 'n_words': 254}