From 63fcd2a00a09a1bfc137b702b49d49b438c8e4e5 Mon Sep 17 00:00:00 2001 From: Jamie Garside Date: Thu, 25 Mar 2021 18:47:57 +0000 Subject: [PATCH] Open bouncer on screen side of swipe in one-handed mode. This detects where the swipe to open the bouncer comes from when the device is in left-handed mode, and moves the bouncer to that side. Currently, this is just a simple case of opening it on the screen half where the first swipe was, rather than following the finger during the swipe or anything like that. Bug: 170858298 Test: atest SystemUITests Change-Id: I4b18cee7d56fedf792a1923e316778bda077e75f --- .../keyguard/KeyguardHostViewController.java | 7 +++ .../keyguard/KeyguardSecurityContainer.java | 17 ++++++-- .../KeyguardSecurityContainerController.java | 5 +++ .../statusbar/phone/KeyguardBouncer.java | 7 +++ .../NotificationPanelViewController.java | 6 +++ .../phone/StatusBarKeyguardViewManager.java | 7 +++ .../KeyguardHostViewControllerTest.java | 7 +++ ...yguardSecurityContainerControllerTest.java | 6 +++ .../KeyguardSecurityContainerTest.java | 43 +++++++++++++++++++ .../statusbar/phone/KeyguardBouncerTest.java | 8 ++++ .../StatusBarKeyguardViewManagerTest.java | 7 +++ 11 files changed, 117 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java index 02a8958ef6574..31f1332b265c7 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java @@ -492,4 +492,11 @@ public class KeyguardHostViewController extends ViewController mKeyguardSecurityContainerController.updateResources(); } } + + /** Update keyguard position based on a tapped X coordinate. */ + public void updateKeyguardPosition(float x) { + if (mKeyguardSecurityContainerController != null) { + mKeyguardSecurityContainerController.updateKeyguardPosition(x); + } + } } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java index 708b2d55b75aa..7ed63375a3342 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainer.java @@ -267,6 +267,13 @@ public class KeyguardSecurityContainer extends FrameLayout { updateSecurityViewLocation(false); } + /** Update keyguard position based on a tapped X coordinate. */ + public void updateKeyguardPosition(float x) { + if (mOneHandedMode) { + moveBouncerForXCoordinate(x, /* animate= */false); + } + } + /** Return whether the one-handed keyguard should be enabled. */ private boolean canUseOneHandedBouncer() { // Is it enabled? @@ -488,9 +495,13 @@ public class KeyguardSecurityContainer extends FrameLayout { return; } + moveBouncerForXCoordinate(event.getX(), /* animate= */true); + } + + private void moveBouncerForXCoordinate(float x, boolean animate) { // Did the tap hit the "other" side of the bouncer? - if ((mIsSecurityViewLeftAligned && (event.getX() > getWidth() / 2f)) - || (!mIsSecurityViewLeftAligned && (event.getX() < getWidth() / 2f))) { + if ((mIsSecurityViewLeftAligned && (x > getWidth() / 2f)) + || (!mIsSecurityViewLeftAligned && (x < getWidth() / 2f))) { mIsSecurityViewLeftAligned = !mIsSecurityViewLeftAligned; Settings.Global.putInt( @@ -499,7 +510,7 @@ public class KeyguardSecurityContainer extends FrameLayout { mIsSecurityViewLeftAligned ? Settings.Global.ONE_HANDED_KEYGUARD_SIDE_LEFT : Settings.Global.ONE_HANDED_KEYGUARD_SIDE_RIGHT); - updateSecurityViewLocation(true); + updateSecurityViewLocation(animate); } } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java index 760eaecae2471..4827cab3b5c01 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityContainerController.java @@ -515,6 +515,11 @@ public class KeyguardSecurityContainerController extends ViewController