diff options
author | Lucas Dupin <dupin@google.com> | 2019-05-15 14:32:50 -0700 |
---|---|---|
committer | Lucas Dupin <dupin@google.com> | 2019-05-15 14:32:50 -0700 |
commit | 727890f180bd580aee4f5e51d308a63c460afe7e (patch) | |
tree | 267f35faa93b9bd978477bac61f7e34612272ad2 /packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java | |
parent | 8575ede8fc2e3eb2d2e288a073e55d460c0961f3 (diff) |
Calculate pattern bounds correctly
Use stable position on screen to calculate if pattern should be
dragged or not. Before we were only comparing bounds to events,
that would be on different coordinates (on a parent for example.)
Test: draw pattern starting at top left
Test: draw pattern starting at bottom right
Fixes: 132687980
Change-Id: Ibe2d7fc113bf8bc3a9ab4910b3ab21062b59e7f3
Diffstat (limited to 'packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java')
-rw-r--r-- | packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java index 55499dab05f3..0e91e4109ec0 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java @@ -68,6 +68,9 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit private final AppearAnimationUtils mAppearAnimationUtils; private final DisappearAnimationUtils mDisappearAnimationUtils; private final DisappearAnimationUtils mDisappearAnimationUtilsLocked; + private final int[] mTmpPosition = new int[2]; + private final Rect mTempRect = new Rect(); + private final Rect mLockPatternScreenBounds = new Rect(); private CountDownTimer mCountdownTimer = null; private LockPatternUtils mLockPatternUtils; @@ -92,7 +95,6 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit mLockPatternView.clearPattern(); } }; - private Rect mTempRect = new Rect(); @VisibleForTesting KeyguardMessageArea mSecurityMessageDisplay; private View mEcaView; @@ -199,6 +201,15 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit } @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + super.onLayout(changed, l, t, r, b); + mLockPatternView.getLocationOnScreen(mTmpPosition); + mLockPatternScreenBounds.set(mTmpPosition[0], mTmpPosition[1], + mTmpPosition[0] + mLockPatternView.getWidth(), + mTmpPosition[1] + mLockPatternView.getHeight()); + } + + @Override public void reset() { // reset lock pattern mLockPatternView.setInStealthMode(!mLockPatternUtils.isVisiblePatternEnabled( @@ -233,9 +244,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit @Override public boolean disallowInterceptTouch(MotionEvent event) { - mTempRect.set(mLockPatternView.getLeft(), mLockPatternView.getTop(), - mLockPatternView.getRight(), mLockPatternView.getBottom()); - return mTempRect.contains((int) event.getX(), (int) event.getY()); + return mLockPatternScreenBounds.contains((int) event.getRawX(), (int) event.getRawY()); } /** TODO: hook this up */ |