diff options
6 files changed, 172 insertions, 37 deletions
diff --git a/packages/SystemUI/res-keyguard/values/dimens.xml b/packages/SystemUI/res-keyguard/values/dimens.xml index 8c817330953c..d1067a9960bf 100644 --- a/packages/SystemUI/res-keyguard/values/dimens.xml +++ b/packages/SystemUI/res-keyguard/values/dimens.xml @@ -105,6 +105,13 @@ screen. --> <item name="half_opened_bouncer_height_ratio" type="dimen" format="float">0.0</item> + <!-- Proportion of the screen height to use to set the maximum height of the bouncer to when + the device is in the DEVICE_POSTURE_HALF_OPENED posture. + + This value is only used when motion layout bouncer is used - when flag + landscape.enable_lockscreen (b/293252410) is on --> + <item name="motion_layout_half_fold_bouncer_height_ratio" type="dimen" format="float">0.55</item> + <!-- The actual amount of translation that is applied to the security when it animates from one side of the screen to the other in one-handed or user switcher mode. Note that it will always translate from the side of the screen to the other (it will "jump" closer to the diff --git a/packages/SystemUI/res-keyguard/xml/keyguard_pattern_scene.xml b/packages/SystemUI/res-keyguard/xml/keyguard_pattern_scene.xml index 6112411402c4..751d6d8d04e7 100644 --- a/packages/SystemUI/res-keyguard/xml/keyguard_pattern_scene.xml +++ b/packages/SystemUI/res-keyguard/xml/keyguard_pattern_scene.xml @@ -10,9 +10,34 @@ motion:duration="0" motion:autoTransition="none"/> + <Transition + motion:constraintSetStart="@id/single_constraints" + motion:constraintSetEnd="@+id/half_folded_single_constraints" + motion:duration="@integer/material_motion_duration_short_1" + motion:autoTransition="none"/> + <!-- No changes to default layout --> <ConstraintSet android:id="@+id/single_constraints"/> + <ConstraintSet android:id="@+id/half_folded_single_constraints"> + + <Constraint + android:id="@+id/pattern_top_guideline" + androidprv:layout_constraintGuide_percent= + "@dimen/motion_layout_half_fold_bouncer_height_ratio"/> + + <Constraint + android:id="@+id/keyguard_selector_fade_container" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="0dp" + android:layout_marginTop="@dimen/keyguard_eca_top_margin" + android:orientation="vertical" + androidprv:layout_constraintBottom_toBottomOf="parent" + androidprv:layout_constraintTop_toBottomOf="@+id/flow1"/> + + </ConstraintSet> + <ConstraintSet android:id="@+id/split_constraints"> <Constraint diff --git a/packages/SystemUI/res-keyguard/xml/keyguard_pin_scene.xml b/packages/SystemUI/res-keyguard/xml/keyguard_pin_scene.xml index 2a1270c80b75..cc498f4a7ab3 100644 --- a/packages/SystemUI/res-keyguard/xml/keyguard_pin_scene.xml +++ b/packages/SystemUI/res-keyguard/xml/keyguard_pin_scene.xml @@ -26,11 +26,35 @@ motion:constraintSetStart="@id/single_constraints" motion:constraintSetEnd="@+id/split_constraints" motion:duration="0" - motion:autoTransition="none"/> + motion:autoTransition="none" /> + + <Transition + motion:constraintSetStart="@id/single_constraints" + motion:constraintSetEnd="@+id/half_folded_single_constraints" + motion:duration="@integer/material_motion_duration_short_1" /> <!-- No changes to default layout --> <ConstraintSet android:id="@+id/single_constraints"/> + <ConstraintSet android:id="@+id/half_folded_single_constraints"> + + <Constraint + android:id="@+id/pin_pad_top_guideline" + androidprv:layout_constraintGuide_percent= + "@dimen/motion_layout_half_fold_bouncer_height_ratio"/> + + <Constraint + android:id="@+id/keyguard_selector_fade_container" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginBottom="0dp" + android:layout_marginTop="@dimen/keyguard_eca_top_margin" + android:orientation="vertical" + androidprv:layout_constraintBottom_toBottomOf="parent" + androidprv:layout_constraintTop_toBottomOf="@+id/flow1"/> + + </ConstraintSet> + <ConstraintSet android:id="@+id/split_constraints"> <Constraint @@ -68,4 +92,5 @@ android:layout_marginTop="@dimen/keyguard_eca_top_margin" /> </ConstraintSet> + </MotionScene>
\ No newline at end of file diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java index 1741e306c29f..622b67f25da3 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java @@ -17,6 +17,7 @@ package com.android.keyguard; import static android.content.res.Configuration.ORIENTATION_LANDSCAPE; +import static android.content.res.Configuration.ORIENTATION_PORTRAIT; import static com.android.internal.jank.InteractionJankMonitor.CUJ_LOCKSCREEN_PIN_APPEAR; import static com.android.internal.jank.InteractionJankMonitor.CUJ_LOCKSCREEN_PIN_DISAPPEAR; @@ -52,6 +53,8 @@ public class KeyguardPINView extends KeyguardPinBasedInputView { private final DisappearAnimationUtils mDisappearAnimationUtils; private final DisappearAnimationUtils mDisappearAnimationUtilsLocked; @Nullable private MotionLayout mContainerMotionLayout; + // TODO (b/293252410) - usage of mContainerConstraintLayout should be removed + // when the flag is enabled/removed @Nullable private ConstraintLayout mContainerConstraintLayout; private int mDisappearYTranslation; private View[][] mViews; @@ -59,7 +62,7 @@ public class KeyguardPINView extends KeyguardPinBasedInputView { private int mYTransOffset; private View mBouncerMessageArea; private boolean mAlreadyUsingSplitBouncer = false; - private boolean mIsLockScreenLandscapeEnabled = false; + private boolean mIsSmallLockScreenLandscapeEnabled = false; @DevicePostureInt private int mLastDevicePosture = DEVICE_POSTURE_UNKNOWN; public static final long ANIMATION_DURATION = 650; @@ -87,12 +90,12 @@ public class KeyguardPINView extends KeyguardPinBasedInputView { /** Use motion layout (new bouncer implementation) if LOCKSCREEN_ENABLE_LANDSCAPE flag is * enabled, instead of constraint layout (old bouncer implementation) */ public void setIsLockScreenLandscapeEnabled(boolean isLockScreenLandscapeEnabled) { - mIsLockScreenLandscapeEnabled = isLockScreenLandscapeEnabled; + mIsSmallLockScreenLandscapeEnabled = isLockScreenLandscapeEnabled; findContainerLayout(); } private void findContainerLayout() { - if (mIsLockScreenLandscapeEnabled) { + if (mIsSmallLockScreenLandscapeEnabled) { mContainerMotionLayout = findViewById(R.id.pin_container); } else { mContainerConstraintLayout = findViewById(R.id.pin_container); @@ -109,7 +112,7 @@ public class KeyguardPINView extends KeyguardPinBasedInputView { if (mLastDevicePosture == posture) return; mLastDevicePosture = posture; - if (mIsLockScreenLandscapeEnabled) { + if (mIsSmallLockScreenLandscapeEnabled) { boolean useSplitBouncerAfterFold = mLastDevicePosture == DEVICE_POSTURE_CLOSED && getResources().getConfiguration().orientation == ORIENTATION_LANDSCAPE @@ -166,21 +169,45 @@ public class KeyguardPINView extends KeyguardPinBasedInputView { } } + if (mIsSmallLockScreenLandscapeEnabled) { + updateHalfFoldedConstraints(); + } else { + updateHalfFoldedGuideline(); + } + } + + private void updateHalfFoldedConstraints() { + // Update the constraints based on the device posture... + if (mAlreadyUsingSplitBouncer) return; + + boolean shouldCollapsePin = + mLastDevicePosture == DEVICE_POSTURE_HALF_OPENED + && mContext.getResources().getConfiguration().orientation + == ORIENTATION_PORTRAIT; + + int expectedMotionLayoutState = shouldCollapsePin + ? R.id.half_folded_single_constraints + : R.id.single_constraints; + + transitionToMotionLayoutState(expectedMotionLayoutState); + } + + // TODO (b/293252410) - this method can be removed when the flag is enabled/removed + private void updateHalfFoldedGuideline() { // Update the guideline based on the device posture... float halfOpenPercentage = mContext.getResources().getFloat(R.dimen.half_opened_bouncer_height_ratio); - if (mIsLockScreenLandscapeEnabled) { - ConstraintSet cs = mContainerMotionLayout.getConstraintSet(R.id.single_constraints); - cs.setGuidelinePercent(R.id.pin_pad_top_guideline, - mLastDevicePosture == DEVICE_POSTURE_HALF_OPENED ? halfOpenPercentage : 0.0f); - cs.applyTo(mContainerMotionLayout); - } else { - ConstraintSet cs = new ConstraintSet(); - cs.clone(mContainerConstraintLayout); - cs.setGuidelinePercent(R.id.pin_pad_top_guideline, - mLastDevicePosture == DEVICE_POSTURE_HALF_OPENED ? halfOpenPercentage : 0.0f); - cs.applyTo(mContainerConstraintLayout); + ConstraintSet cs = new ConstraintSet(); + cs.clone(mContainerConstraintLayout); + cs.setGuidelinePercent(R.id.pin_pad_top_guideline, + mLastDevicePosture == DEVICE_POSTURE_HALF_OPENED ? halfOpenPercentage : 0.0f); + cs.applyTo(mContainerConstraintLayout); + } + + private void transitionToMotionLayoutState(int state) { + if (mContainerMotionLayout.getCurrentState() != state) { + mContainerMotionLayout.transitionToState(state); } } @@ -189,12 +216,24 @@ public class KeyguardPINView extends KeyguardPinBasedInputView { * Only called when flag LANDSCAPE_ENABLE_LOCKSCREEN is enabled. */ @Override protected void updateConstraints(boolean useSplitBouncer) { + if (!mIsSmallLockScreenLandscapeEnabled) return; + mAlreadyUsingSplitBouncer = useSplitBouncer; + if (useSplitBouncer) { mContainerMotionLayout.jumpToState(R.id.split_constraints); mContainerMotionLayout.setMaxWidth(Integer.MAX_VALUE); } else { - mContainerMotionLayout.jumpToState(R.id.single_constraints); + boolean useHalfFoldedConstraints = + mLastDevicePosture == DEVICE_POSTURE_HALF_OPENED + && mContext.getResources().getConfiguration().orientation + == ORIENTATION_PORTRAIT; + + if (useHalfFoldedConstraints) { + mContainerMotionLayout.jumpToState(R.id.half_folded_single_constraints); + } else { + mContainerMotionLayout.jumpToState(R.id.single_constraints); + } mContainerMotionLayout.setMaxWidth(getResources() .getDimensionPixelSize(R.dimen.keyguard_security_width)); } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java index 802e222b3897..5c206e95966b 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPatternView.java @@ -16,6 +16,7 @@ package com.android.keyguard; import static android.content.res.Configuration.ORIENTATION_LANDSCAPE; +import static android.content.res.Configuration.ORIENTATION_PORTRAIT; import static com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_CLOSED; import static com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_HALF_OPENED; @@ -81,9 +82,11 @@ public class KeyguardPatternView extends KeyguardInputView BouncerKeyguardMessageArea mSecurityMessageDisplay; private View mEcaView; @Nullable private MotionLayout mContainerMotionLayout; + // TODO (b/293252410) - usage of mContainerConstraintLayout should be removed + // when the flag is enabled/removed @Nullable private ConstraintLayout mContainerConstraintLayout; private boolean mAlreadyUsingSplitBouncer = false; - private boolean mIsLockScreenLandscapeEnabled = false; + private boolean mIsSmallLockScreenLandscapeEnabled = false; @DevicePostureInt private int mLastDevicePosture = DEVICE_POSTURE_UNKNOWN; public KeyguardPatternView(Context context) { @@ -111,12 +114,12 @@ public class KeyguardPatternView extends KeyguardInputView * enabled, instead of constraint layout (old bouncer implementation) */ public void setIsLockScreenLandscapeEnabled(boolean isLockScreenLandscapeEnabled) { - mIsLockScreenLandscapeEnabled = isLockScreenLandscapeEnabled; + mIsSmallLockScreenLandscapeEnabled = isLockScreenLandscapeEnabled; findContainerLayout(); } private void findContainerLayout() { - if (mIsLockScreenLandscapeEnabled) { + if (mIsSmallLockScreenLandscapeEnabled) { mContainerMotionLayout = findViewById(R.id.pattern_container); } else { mContainerConstraintLayout = findViewById(R.id.pattern_container); @@ -132,7 +135,7 @@ public class KeyguardPatternView extends KeyguardInputView if (mLastDevicePosture == posture) return; mLastDevicePosture = posture; - if (mIsLockScreenLandscapeEnabled) { + if (mIsSmallLockScreenLandscapeEnabled) { boolean useSplitBouncerAfterFold = mLastDevicePosture == DEVICE_POSTURE_CLOSED && getResources().getConfiguration().orientation == ORIENTATION_LANDSCAPE @@ -147,21 +150,45 @@ public class KeyguardPatternView extends KeyguardInputView } private void updateMargins() { + if (mIsSmallLockScreenLandscapeEnabled) { + updateHalfFoldedConstraints(); + } else { + updateHalfFoldedGuideline(); + } + } + + private void updateHalfFoldedConstraints() { + // Update the constraints based on the device posture... + if (mAlreadyUsingSplitBouncer) return; + + boolean shouldCollapsePattern = + mLastDevicePosture == DEVICE_POSTURE_HALF_OPENED + && mContext.getResources().getConfiguration().orientation + == ORIENTATION_PORTRAIT; + + int expectedMotionLayoutState = shouldCollapsePattern + ? R.id.half_folded_single_constraints + : R.id.single_constraints; + + transitionToMotionLayoutState(expectedMotionLayoutState); + } + + // TODO (b/293252410) - this method can be removed when the flag is enabled/removed + private void updateHalfFoldedGuideline() { // Update the guideline based on the device posture... float halfOpenPercentage = mContext.getResources().getFloat(R.dimen.half_opened_bouncer_height_ratio); - if (mIsLockScreenLandscapeEnabled) { - ConstraintSet cs = mContainerMotionLayout.getConstraintSet(R.id.single_constraints); - cs.setGuidelinePercent(R.id.pattern_top_guideline, - mLastDevicePosture == DEVICE_POSTURE_HALF_OPENED ? halfOpenPercentage : 0.0f); - cs.applyTo(mContainerMotionLayout); - } else { - ConstraintSet cs = new ConstraintSet(); - cs.clone(mContainerConstraintLayout); - cs.setGuidelinePercent(R.id.pattern_top_guideline, - mLastDevicePosture == DEVICE_POSTURE_HALF_OPENED ? halfOpenPercentage : 0.0f); - cs.applyTo(mContainerConstraintLayout); + ConstraintSet cs = new ConstraintSet(); + cs.clone(mContainerConstraintLayout); + cs.setGuidelinePercent(R.id.pattern_top_guideline, + mLastDevicePosture == DEVICE_POSTURE_HALF_OPENED ? halfOpenPercentage : 0.0f); + cs.applyTo(mContainerConstraintLayout); + } + + private void transitionToMotionLayoutState(int state) { + if (mContainerMotionLayout.getCurrentState() != state) { + mContainerMotionLayout.transitionToState(state); } } @@ -172,12 +199,24 @@ public class KeyguardPatternView extends KeyguardInputView */ @Override protected void updateConstraints(boolean useSplitBouncer) { + if (!mIsSmallLockScreenLandscapeEnabled) return; + mAlreadyUsingSplitBouncer = useSplitBouncer; + if (useSplitBouncer) { mContainerMotionLayout.jumpToState(R.id.split_constraints); mContainerMotionLayout.setMaxWidth(Integer.MAX_VALUE); } else { - mContainerMotionLayout.jumpToState(R.id.single_constraints); + boolean useHalfFoldedConstraints = + mLastDevicePosture == DEVICE_POSTURE_HALF_OPENED + && mContext.getResources().getConfiguration().orientation + == ORIENTATION_PORTRAIT; + + if (useHalfFoldedConstraints) { + mContainerMotionLayout.jumpToState(R.id.half_folded_single_constraints); + } else { + mContainerMotionLayout.jumpToState(R.id.single_constraints); + } mContainerMotionLayout.setMaxWidth(getResources() .getDimensionPixelSize(R.dimen.biometric_auth_pattern_view_max_size)); } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipperController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipperController.java index 9c4d224115b2..ec2999ffcfe1 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipperController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipperController.java @@ -139,12 +139,12 @@ public class KeyguardSecurityViewFlipperController onViewInflatedListener.onViewInflated(childController); // Single bouncer constrains are default - if (mFeatureFlags.isEnabled(LOCKSCREEN_ENABLE_LANDSCAPE) - && - getResources().getBoolean(R.bool.update_bouncer_constraints)) { + if (mFeatureFlags.isEnabled(LOCKSCREEN_ENABLE_LANDSCAPE)) { boolean useSplitBouncer = - getResources().getConfiguration().orientation + getResources().getBoolean(R.bool.update_bouncer_constraints) + && getResources().getConfiguration().orientation == ORIENTATION_LANDSCAPE; + updateConstraints(useSplitBouncer); } } |