// 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);
// }


import java.util.ArrayList;
import java.util.Locale;
import static org.chromium.latency.walt.Utils.getBooleanPreference;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.method.ScrollingMovementMethod;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;
import java.io.IOException;
                            physicalToKernelTime, kernelToCallbackTime));
                }
            }
            traceLogEvent(tapEvent);

            updateCountsDisplay();
            return true;
        }
    };

    private void traceLogEvent(UsMotionEvent tapEvent) {
        if (!tapEvent.isOk) return;
        if (traceLogger == null) return;
        if (tapEvent.action != MotionEvent.ACTION_DOWN && tapEvent.action != MotionEvent.ACTION_UP) return;
        final String title = tapEvent.action == MotionEvent.ACTION_UP ? "Tap-Up" : "Tap-Down";
        traceLogger.log(tapEvent.physicalTime + waltDevice.clock.baseTime,
                tapEvent.kernelTime + waltDevice.clock.baseTime, title + " Physical",
                "Bar starts at accelerometer shock and ends at kernel time of tap event");
        traceLogger.log(tapEvent.kernelTime + waltDevice.clock.baseTime,
                tapEvent.createTime + waltDevice.clock.baseTime, title + " App Callback",
                "Bar starts at kernel time of tap event and ends at app callback time");
    }

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

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
// 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/TapLatencyFragment.java
import java.util.ArrayList;
import java.util.Locale;
import static org.chromium.latency.walt.Utils.getBooleanPreference;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.method.ScrollingMovementMethod;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;
import java.io.IOException;

                            physicalToKernelTime, kernelToCallbackTime));
                }
            }
            traceLogEvent(tapEvent);

            updateCountsDisplay();
            return true;
        }
    };

    private void traceLogEvent(UsMotionEvent tapEvent) {
        if (!tapEvent.isOk) return;
        if (traceLogger == null) return;
        if (tapEvent.action != MotionEvent.ACTION_DOWN && tapEvent.action != MotionEvent.ACTION_UP) return;
        final String title = tapEvent.action == MotionEvent.ACTION_UP ? "Tap-Up" : "Tap-Down";
        traceLogger.log(tapEvent.physicalTime + waltDevice.clock.baseTime,
                tapEvent.kernelTime + waltDevice.clock.baseTime, title + " Physical",
                "Bar starts at accelerometer shock and ends at kernel time of tap event");
        traceLogger.log(tapEvent.kernelTime + waltDevice.clock.baseTime,
                tapEvent.createTime + waltDevice.clock.baseTime, title + " App Callback",
                "Bar starts at kernel time of tap event and ends at app callback time");
    }

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

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