From c8d6603644ee6e8bb7388bb585538bc8d7b684ca Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Mon, 28 Nov 2016 14:03:11 +0100 Subject: [PATCH] Fix deadzone in seascape orientation Test: Enable config_dead_zone_flash, make sure deadzone gets drawn on the right side in seascape/landscape/portrait and deadzone is consuming clicks on the right side. Change-Id: Icc88967cfa7bf8ba7f6f3b797ca001eba78e5cdc Fixes: 32870901 (cherry picked from commit 7aaa3d7d196c5afac4c54de44f5b7728a9a16d1b) --- .../statusbar/phone/NavigationBarView.java | 1 + .../systemui/statusbar/policy/DeadZone.java | 28 +++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java index 0bc70b53ac524..3f764b4b291b6 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarView.java @@ -565,6 +565,7 @@ public class NavigationBarView extends LinearLayout { getImeSwitchButton().setOnClickListener(mImeSwitcherClickListener); mDeadZone = (DeadZone) mCurrentView.findViewById(R.id.deadzone); + mDeadZone.setDisplayRotation(mCurrentRotation); // force the low profile & disabled states into compliance mBarTransitions.init(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeadZone.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeadZone.java index 1cad61fb67283..4c879c68f2ff0 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeadZone.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/DeadZone.java @@ -24,6 +24,7 @@ import android.os.SystemClock; import android.util.AttributeSet; import android.util.Slog; import android.view.MotionEvent; +import android.view.Surface; import android.view.View; import com.android.systemui.R; @@ -54,6 +55,7 @@ public class DeadZone extends View { private int mHold, mDecay; private boolean mVertical; private long mLastPokeTime; + private int mDisplayRotation; private final Runnable mDebugFlash = new Runnable() { @Override @@ -132,7 +134,16 @@ public class DeadZone extends View { int size = (int) getSize(event.getEventTime()); // In the vertical orientation consume taps along the left edge. // In horizontal orientation consume taps along the top edge. - final boolean consumeEvent = mVertical ? event.getX() < size : event.getY() < size; + final boolean consumeEvent; + if (mVertical) { + if (mDisplayRotation == Surface.ROTATION_270) { + consumeEvent = event.getX() > getWidth() - size; + } else { + consumeEvent = event.getX() < size; + } + } else { + consumeEvent = event.getY() < size; + } if (consumeEvent) { if (CHATTY) { Slog.v(TAG, "consuming errant click: (" + event.getX() + "," + event.getY() + ")"); @@ -170,7 +181,16 @@ public class DeadZone extends View { } final int size = (int) getSize(SystemClock.uptimeMillis()); - can.clipRect(0, 0, mVertical ? size : can.getWidth(), mVertical ? can.getHeight() : size); + if (mVertical) { + if (mDisplayRotation == Surface.ROTATION_270) { + can.clipRect(can.getWidth() - size, 0, can.getWidth(), can.getHeight()); + } else { + can.clipRect(0, 0, size, can.getHeight()); + } + } else { + can.clipRect(0, 0, can.getWidth(), size); + } + final float frac = DEBUG ? (mFlashFrac - 0.5f) + 0.5f : mFlashFrac; can.drawARGB((int) (frac * 0xFF), 0xDD, 0xEE, 0xAA); @@ -178,4 +198,8 @@ public class DeadZone extends View { // crazy aggressive redrawing here, for debugging only postInvalidateDelayed(100); } + + public void setDisplayRotation(int rotation) { + mDisplayRotation = rotation; + } }