diff options
author | Jamie Garside <jgarside@google.com> | 2021-03-25 18:47:57 +0000 |
---|---|---|
committer | Jamie Garside <jgarside@google.com> | 2021-04-01 13:08:10 +0000 |
commit | 63fcd2a00a09a1bfc137b702b49d49b438c8e4e5 (patch) | |
tree | 40ab3172b95483d1eb4a2527e473599aaf91afe4 /packages/SystemUI/src | |
parent | 6230fca3d904d0acd134ece115c475edf65f491c (diff) |
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
Diffstat (limited to 'packages/SystemUI/src')
6 files changed, 46 insertions, 3 deletions
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardHostViewController.java index 02a8958ef657..31f1332b265c 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<KeyguardHostView> 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 708b2d55b75a..7ed63375a334 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 760eaecae247..4827cab3b5c0 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<Keyguard } } + /** Update keyguard position based on a tapped X coordinate. */ + public void updateKeyguardPosition(float x) { + mView.updateKeyguardPosition(x); + } + static class Factory { private final KeyguardSecurityContainer mView; diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java index 6b69103f6030..5ff9b703924e 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBouncer.java @@ -555,6 +555,13 @@ public class KeyguardBouncer { pw.println(" mIsAnimatingAway: " + mIsAnimatingAway); } + /** Update keyguard position based on a tapped X coordinate. */ + public void updateKeyguardPosition(float x) { + if (mKeyguardViewController != null) { + mKeyguardViewController.updateKeyguardPosition(x); + } + } + public interface BouncerExpansionCallback { void onFullyShown(); void onStartingToHide(); diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java index d3da0bce0a15..51e4267b32f1 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelViewController.java @@ -3495,6 +3495,12 @@ public class NotificationPanelViewController extends PanelViewController { updateHorizontalPanelPosition(event.getX()); handled = true; } + + if (event.getActionMasked() == MotionEvent.ACTION_DOWN && isFullyExpanded() + && mStatusBarKeyguardViewManager.isShowing()) { + mStatusBarKeyguardViewManager.updateKeyguardPosition(event.getX()); + } + handled |= super.onTouch(v, event); return !mDozing || mPulsing || handled || showingOrAnimatingAltAuth; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java index 7ee7aa4100d4..0b6bbcd407f2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java @@ -1150,6 +1150,13 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb || mAlternateAuthInterceptor.isAnimating()); } + /** Update keyguard position based on a tapped X coordinate. */ + public void updateKeyguardPosition(float x) { + if (mBouncer != null) { + mBouncer.updateKeyguardPosition(x); + } + } + private static class DismissWithActionRequest { final OnDismissAction dismissAction; final Runnable cancelAction; |