Merge "Open bouncer on screen side of swipe in one-handed mode." into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ee55a8451a
@@ -492,4 +492,11 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView>
|
|||||||
mKeyguardSecurityContainerController.updateResources();
|
mKeyguardSecurityContainerController.updateResources();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Update keyguard position based on a tapped X coordinate. */
|
||||||
|
public void updateKeyguardPosition(float x) {
|
||||||
|
if (mKeyguardSecurityContainerController != null) {
|
||||||
|
mKeyguardSecurityContainerController.updateKeyguardPosition(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -267,6 +267,13 @@ public class KeyguardSecurityContainer extends FrameLayout {
|
|||||||
updateSecurityViewLocation(false);
|
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. */
|
/** Return whether the one-handed keyguard should be enabled. */
|
||||||
private boolean canUseOneHandedBouncer() {
|
private boolean canUseOneHandedBouncer() {
|
||||||
// Is it enabled?
|
// Is it enabled?
|
||||||
@@ -488,9 +495,13 @@ public class KeyguardSecurityContainer extends FrameLayout {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
moveBouncerForXCoordinate(event.getX(), /* animate= */true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void moveBouncerForXCoordinate(float x, boolean animate) {
|
||||||
// Did the tap hit the "other" side of the bouncer?
|
// Did the tap hit the "other" side of the bouncer?
|
||||||
if ((mIsSecurityViewLeftAligned && (event.getX() > getWidth() / 2f))
|
if ((mIsSecurityViewLeftAligned && (x > getWidth() / 2f))
|
||||||
|| (!mIsSecurityViewLeftAligned && (event.getX() < getWidth() / 2f))) {
|
|| (!mIsSecurityViewLeftAligned && (x < getWidth() / 2f))) {
|
||||||
mIsSecurityViewLeftAligned = !mIsSecurityViewLeftAligned;
|
mIsSecurityViewLeftAligned = !mIsSecurityViewLeftAligned;
|
||||||
|
|
||||||
Settings.Global.putInt(
|
Settings.Global.putInt(
|
||||||
@@ -499,7 +510,7 @@ public class KeyguardSecurityContainer extends FrameLayout {
|
|||||||
mIsSecurityViewLeftAligned ? Settings.Global.ONE_HANDED_KEYGUARD_SIDE_LEFT
|
mIsSecurityViewLeftAligned ? Settings.Global.ONE_HANDED_KEYGUARD_SIDE_LEFT
|
||||||
: Settings.Global.ONE_HANDED_KEYGUARD_SIDE_RIGHT);
|
: Settings.Global.ONE_HANDED_KEYGUARD_SIDE_RIGHT);
|
||||||
|
|
||||||
updateSecurityViewLocation(true);
|
updateSecurityViewLocation(animate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 {
|
static class Factory {
|
||||||
|
|
||||||
private final KeyguardSecurityContainer mView;
|
private final KeyguardSecurityContainer mView;
|
||||||
|
|||||||
@@ -555,6 +555,13 @@ public class KeyguardBouncer {
|
|||||||
pw.println(" mIsAnimatingAway: " + mIsAnimatingAway);
|
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 {
|
public interface BouncerExpansionCallback {
|
||||||
void onFullyShown();
|
void onFullyShown();
|
||||||
void onStartingToHide();
|
void onStartingToHide();
|
||||||
|
|||||||
@@ -3494,6 +3494,12 @@ public class NotificationPanelViewController extends PanelViewController {
|
|||||||
updateHorizontalPanelPosition(event.getX());
|
updateHorizontalPanelPosition(event.getX());
|
||||||
handled = true;
|
handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.getActionMasked() == MotionEvent.ACTION_DOWN && isFullyExpanded()
|
||||||
|
&& mStatusBarKeyguardViewManager.isShowing()) {
|
||||||
|
mStatusBarKeyguardViewManager.updateKeyguardPosition(event.getX());
|
||||||
|
}
|
||||||
|
|
||||||
handled |= super.onTouch(v, event);
|
handled |= super.onTouch(v, event);
|
||||||
return !mDozing || mPulsing || handled || showingOrAnimatingAltAuth;
|
return !mDozing || mPulsing || handled || showingOrAnimatingAltAuth;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1150,6 +1150,13 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
|
|||||||
|| mAlternateAuthInterceptor.isAnimating());
|
|| 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 {
|
private static class DismissWithActionRequest {
|
||||||
final OnDismissAction dismissAction;
|
final OnDismissAction dismissAction;
|
||||||
final Runnable cancelAction;
|
final Runnable cancelAction;
|
||||||
|
|||||||
@@ -124,4 +124,11 @@ public class KeyguardHostViewControllerTest extends SysuiTestCase {
|
|||||||
((FrameLayout.LayoutParams) mKeyguardHostView.getLayoutParams()).gravity,
|
((FrameLayout.LayoutParams) mKeyguardHostView.getLayoutParams()).gravity,
|
||||||
Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM);
|
Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateKeyguardPositionDelegatesToSecurityContainer() {
|
||||||
|
mKeyguardHostViewController.updateKeyguardPosition(1.0f);
|
||||||
|
|
||||||
|
verify(mKeyguardSecurityContainerController).updateKeyguardPosition(1.0f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,4 +177,10 @@ public class KeyguardSecurityContainerControllerTest extends SysuiTestCase {
|
|||||||
mKeyguardSecurityContainerController.updateResources();
|
mKeyguardSecurityContainerController.updateResources();
|
||||||
verify(mView, times(1)).updateLayoutForSecurityMode(any());
|
verify(mView, times(1)).updateLayoutForSecurityMode(any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateKeyguardPosition_callsThroughToView() {
|
||||||
|
mKeyguardSecurityContainerController.updateKeyguardPosition(1.0f);
|
||||||
|
verify(mView).updateKeyguardPosition(1.0f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ package com.android.keyguard;
|
|||||||
import static android.view.WindowInsets.Type.ime;
|
import static android.view.WindowInsets.Type.ime;
|
||||||
import static android.view.WindowInsets.Type.systemBars;
|
import static android.view.WindowInsets.Type.systemBars;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
|
import static org.mockito.Mockito.never;
|
||||||
|
import static org.mockito.Mockito.reset;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
@@ -198,6 +201,46 @@ public class KeyguardSecurityContainerTest extends SysuiTestCase {
|
|||||||
verify(mSecurityViewFlipper).measure(FAKE_MEASURE_SPEC, expectedHeightMeasureSpec);
|
verify(mSecurityViewFlipper).measure(FAKE_MEASURE_SPEC, expectedHeightMeasureSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupForUpdateKeyguardPosition(SecurityMode securityMode) {
|
||||||
|
setUpKeyguard(
|
||||||
|
/* deviceConfigCanUseOneHandedKeyguard= */true,
|
||||||
|
/* sysuiResourceCanUseOneHandedKeyguard= */ true,
|
||||||
|
securityMode);
|
||||||
|
|
||||||
|
mKeyguardSecurityContainer.measure(FAKE_MEASURE_SPEC, FAKE_MEASURE_SPEC);
|
||||||
|
mKeyguardSecurityContainer.layout(0, 0, SCREEN_WIDTH, SCREEN_WIDTH);
|
||||||
|
|
||||||
|
// Start off left-aligned. This should happen anyway, but just do this to ensure
|
||||||
|
// definitely move to the left.
|
||||||
|
mKeyguardSecurityContainer.updateKeyguardPosition(0.0f);
|
||||||
|
|
||||||
|
// Clear any interactions with the mock so we know the interactions definitely come from the
|
||||||
|
// below testing.
|
||||||
|
reset(mSecurityViewFlipper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateKeyguardPosition_movesKeyguard() {
|
||||||
|
setupForUpdateKeyguardPosition(ONE_HANDED_SECURITY_MODE);
|
||||||
|
|
||||||
|
mKeyguardSecurityContainer.updateKeyguardPosition((SCREEN_WIDTH / 4f) * 3f);
|
||||||
|
verify(mSecurityViewFlipper).setTranslationX(SCREEN_WIDTH / 2.0f);
|
||||||
|
|
||||||
|
mKeyguardSecurityContainer.updateKeyguardPosition(0.0f);
|
||||||
|
verify(mSecurityViewFlipper).setTranslationX(0.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateKeyguardPosition_doesntMoveTwoHandedKeyguard() {
|
||||||
|
setupForUpdateKeyguardPosition(TWO_HANDED_SECURITY_MODE);
|
||||||
|
|
||||||
|
mKeyguardSecurityContainer.updateKeyguardPosition((SCREEN_WIDTH / 4f) * 3f);
|
||||||
|
verify(mSecurityViewFlipper, never()).setTranslationX(anyInt());
|
||||||
|
|
||||||
|
mKeyguardSecurityContainer.updateKeyguardPosition(0.0f);
|
||||||
|
verify(mSecurityViewFlipper, never()).setTranslationX(anyInt());
|
||||||
|
}
|
||||||
|
|
||||||
private void setUpKeyguard(
|
private void setUpKeyguard(
|
||||||
boolean deviceConfigCanUseOneHandedKeyguard,
|
boolean deviceConfigCanUseOneHandedKeyguard,
|
||||||
boolean sysuiResourceCanUseOneHandedKeyguard,
|
boolean sysuiResourceCanUseOneHandedKeyguard,
|
||||||
|
|||||||
@@ -441,4 +441,12 @@ public class KeyguardBouncerTest extends SysuiTestCase {
|
|||||||
// mKeyguardViewController.init(), only updateResources above.
|
// mKeyguardViewController.init(), only updateResources above.
|
||||||
verify(mKeyguardHostViewController).updateResources();
|
verify(mKeyguardHostViewController).updateResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdateKeyguardPosition_delegatesToRootView() {
|
||||||
|
mBouncer.ensureView();
|
||||||
|
mBouncer.updateKeyguardPosition(1.0f);
|
||||||
|
|
||||||
|
verify(mKeyguardHostViewController).updateKeyguardPosition(1.0f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -283,4 +283,11 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
verify(mBouncer).updateResources();
|
verify(mBouncer).updateResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateKeyguardPosition_delegatesToBouncer() {
|
||||||
|
mStatusBarKeyguardViewManager.updateKeyguardPosition(1.0f);
|
||||||
|
|
||||||
|
verify(mBouncer).updateKeyguardPosition(1.0f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user