Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2a029127 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[TouchLatency] Add intent extra arg to set the mode on start" into main

parents 7fd4ab25 896c4cca
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -43,6 +43,8 @@ public class TouchLatencyActivity extends AppCompatActivity {
    private float mSliderPreferredRefreshRate;
    private DisplayManager mDisplayManager;

    public static final String ACTION_MODE_ON_CREATE = "action_mode_on_create";

    private final DisplayManager.DisplayListener mDisplayListener =
            new DisplayManager.DisplayListener() {
        @Override
@@ -112,6 +114,15 @@ public class TouchLatencyActivity extends AppCompatActivity {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_touch_latency, mMenu);
        updateOptionsMenu();
        int initActionMode = getIntent().getIntExtra(ACTION_MODE_ON_CREATE, 0);
        if (initActionMode < mTouchView.ACTION_MODES.length) {
            MenuItem menuItem = mMenu.findItem(R.id.action_settings);
            // Calling changeMode() cycles through the supported modes. So loop
            // through the modes to get the request one.
            for (int i = 0; i < initActionMode; i++) {
                mTouchView.changeMode(menuItem);
            }
        }
        Trace.endSection();
        return true;
    }
+3 −4
Original line number Diff line number Diff line
@@ -198,16 +198,15 @@ class TouchLatencyView extends View implements View.OnTouchListener {

    public void changeMode(MenuItem item) {
        Trace.beginSection("TouchLatencyView changeMode");
        final int NUM_MODES = 2;
        final String modes[] = {"Touch", "Ball"};
        mMode = (mMode + 1) % NUM_MODES;
        mMode = (mMode + 1) % ACTION_MODES.length;
        invalidate();
        item.setTitle(modes[mMode]);
        item.setTitle(ACTION_MODES[mMode]);
        Trace.endSection();
    }

    private final Paint mBluePaint, mGreenPaint, mYellowPaint, mRedPaint, mTextPaint;
    private int mMode;
    public static final String ACTION_MODES[] = {"Touch", "Ball"};

    private boolean mTouching;
    private float mTouchX, mTouchY;