// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java
// static boolean getBooleanPreference(Context context, @StringRes int keyId, boolean defaultValue) {
//     SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
//     return preferences.getBoolean(context.getString(keyId), defaultValue);
// }
// 
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java
// static int getIntPreference(Context context, @StringRes int keyId, int defaultValue) {
//     SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
//     return preferences.getInt(context.getString(keyId), defaultValue);
// }


import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.method.ScrollingMovementMethod;
import android.view.Choreographer;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.Description;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import static org.chromium.latency.walt.Utils.getBooleanPreference;
import static org.chromium.latency.walt.Utils.getIntPreference;
    int initiatedBlinks = 0;
    int detectedBlinks = 0;
    boolean isBoxWhite = false;
    long lastFrameStartTime;
    long lastFrameCallbackTime;
    long lastSetBackgroundTime;
    ArrayList<Double> deltas_w2b = new ArrayList<>();
    ArrayList<Double> deltas_b2w = new ArrayList<>();
    ArrayList<Double> deltas = new ArrayList<>();
    private static final int color_gray = Color.argb(0xFF, 0xBB, 0xBB, 0xBB);
    private StringBuilder brightnessCurveData;

    private BroadcastReceiver logReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (!isTestRunning) {
                String msg = intent.getStringExtra("message");
                blackBox.append(msg + "\n");
            }
        }
    };

    public ScreenResponseFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        timesToBlink = getIntPreference(getContext(), R.string.preference_screen_blinks, 20);
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java
// static boolean getBooleanPreference(Context context, @StringRes int keyId, boolean defaultValue) {
//     SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
//     return preferences.getBoolean(context.getString(keyId), defaultValue);
// }
// 
// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/Utils.java
// static int getIntPreference(Context context, @StringRes int keyId, int defaultValue) {
//     SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
//     return preferences.getInt(context.getString(keyId), defaultValue);
// }


// Path: android/WALT/app/src/main/java/org/chromium/latency/walt/ScreenResponseFragment.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.method.ScrollingMovementMethod;
import android.view.Choreographer;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.Description;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import static org.chromium.latency.walt.Utils.getBooleanPreference;
import static org.chromium.latency.walt.Utils.getIntPreference;

    int initiatedBlinks = 0;
    int detectedBlinks = 0;
    boolean isBoxWhite = false;
    long lastFrameStartTime;
    long lastFrameCallbackTime;
    long lastSetBackgroundTime;
    ArrayList<Double> deltas_w2b = new ArrayList<>();
    ArrayList<Double> deltas_b2w = new ArrayList<>();
    ArrayList<Double> deltas = new ArrayList<>();
    private static final int color_gray = Color.argb(0xFF, 0xBB, 0xBB, 0xBB);
    private StringBuilder brightnessCurveData;

    private BroadcastReceiver logReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            if (!isTestRunning) {
                String msg = intent.getStringExtra("message");
                blackBox.append(msg + "\n");
            }
        }
    };

    public ScreenResponseFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        timesToBlink = getIntPreference(getContext(), R.string.preference_screen_blinks, 20);
        shouldShowLatencyChart = getBooleanPreference(getContext(), R.string.preference_show_blink_histogram, true);