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

Commit 86bc0b4e authored by Tracy Zhou's avatar Tracy Zhou Committed by Android (Google) Code Review
Browse files

Merge "Add a boolean variable to signal whether we use deadzone with nav bar,...

Merge "Add a boolean variable to signal whether we use deadzone with nav bar, and use that signal in our existing logic." into main
parents e4f46b41 da661016
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -37,6 +37,9 @@
        <item>400</item>
    </integer-array>

    <!-- Whether to use deadzone with nav bar -->
    <bool name="config_useDeadZone">true</bool>

    <!-- decay duration (from size_max -> size), in ms -->
    <integer name="navigation_bar_deadzone_hold">333</integer>
    <integer name="navigation_bar_deadzone_decay">333</integer>
+19 −3
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ public class DeadZone {
        }
    };

    private final boolean mUseDeadZone;
    private final NavigationBarController mNavBarController;
    private final NavigationBarView mNavigationBarView;

@@ -86,9 +87,12 @@ public class DeadZone {

    @Inject
    public DeadZone(NavigationBarView view) {
        mUseDeadZone = view.getResources().getBoolean(R.bool.config_useDeadZone);

        mNavigationBarView = view;
        mNavBarController = Dependency.get(NavigationBarController.class);
        mDisplayId = view.getContext().getDisplayId();

        onConfigurationChanged(HORIZONTAL);
    }

@@ -108,12 +112,20 @@ public class DeadZone {
    }

    public void setFlashOnTouchCapture(boolean dbg) {
        if (!mUseDeadZone) {
            return;
        }

        mShouldFlash = dbg;
        mFlashFrac = 0f;
        mNavigationBarView.postInvalidate();
    }

    public void onConfigurationChanged(int rotation) {
        if (!mUseDeadZone) {
            return;
        }

        mDisplayRotation = rotation;

        final Resources res = mNavigationBarView.getResources();
@@ -134,6 +146,10 @@ public class DeadZone {

    // I made you a touch event...
    public boolean onTouchEvent(MotionEvent event) {
        if (!mUseDeadZone) {
            return false;
        }

        if (DEBUG) {
            Slog.v(TAG, this + " onTouch: " + MotionEvent.actionToString(event.getAction()));
        }
@@ -187,17 +203,17 @@ public class DeadZone {
        if (mShouldFlash) mNavigationBarView.postInvalidate();
    }

    public void setFlash(float f) {
    private void setFlash(float f) {
        mFlashFrac = f;
        mNavigationBarView.postInvalidate();
    }

    public float getFlash() {
    private float getFlash() {
        return mFlashFrac;
    }

    public void onDraw(Canvas can) {
        if (!mShouldFlash || mFlashFrac <= 0f) {
        if (!mUseDeadZone || !mShouldFlash || mFlashFrac <= 0f) {
            return;
        }