Merge "Make the keyguard pattern view shrink when the device is half open." into sc-v2-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
6d351b595d
@@ -27,49 +27,44 @@
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
androidprv:layout_maxWidth="@dimen/keyguard_security_width"
|
||||
androidprv:layout_maxHeight="@dimen/keyguard_security_height"
|
||||
android:gravity="center_horizontal">
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false">
|
||||
|
||||
<FrameLayout
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/pattern_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/pattern_container"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:layout_weight="1"
|
||||
android:layoutDirection="ltr">
|
||||
<androidx.constraintlayout.widget.Guideline
|
||||
android:id="@+id/pattern_top_guideline"
|
||||
android:layout_width="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_gravity="center_horizontal|bottom"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false">
|
||||
android:layout_height="wrap_content"
|
||||
androidprv:layout_constraintGuide_percent="0"
|
||||
android:orientation="horizontal" />
|
||||
|
||||
<com.android.internal.widget.LockPatternView
|
||||
android:id="@+id/lockPatternView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginEnd="8dip"
|
||||
android:layout_marginBottom="4dip"
|
||||
android:layout_marginStart="8dip"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center"
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false" />
|
||||
<com.android.internal.widget.LockPatternView
|
||||
android:id="@+id/lockPatternView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
androidprv:layout_constraintTop_toBottomOf="@id/pattern_top_guideline"
|
||||
androidprv:layout_constraintBottom_toBottomOf="parent"
|
||||
androidprv:layout_constraintLeft_toLeftOf="parent"
|
||||
androidprv:layout_constraintRight_toRightOf="parent"
|
||||
androidprv:layout_constraintDimensionRatio="1.0"
|
||||
androidprv:layout_constraintVertical_bias="1.0"
|
||||
/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<include layout="@layout/keyguard_eca"
|
||||
android:id="@+id/keyguard_selector_fade_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:layout_marginTop="@dimen/keyguard_eca_top_margin"
|
||||
android:gravity="center_horizontal" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
<include layout="@layout/keyguard_eca"
|
||||
android:id="@+id/keyguard_selector_fade_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_gravity="bottom|center_horizontal"
|
||||
android:layout_marginTop="@dimen/keyguard_eca_top_margin"
|
||||
android:gravity="center_horizontal" />
|
||||
|
||||
</com.android.keyguard.KeyguardPatternView>
|
||||
|
||||
@@ -204,7 +204,8 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
|
||||
return new KeyguardPatternViewController((KeyguardPatternView) keyguardInputView,
|
||||
mKeyguardUpdateMonitor, securityMode, mLockPatternUtils,
|
||||
keyguardSecurityCallback, mLatencyTracker, mFalsingCollector,
|
||||
emergencyButtonController, mMessageAreaControllerFactory);
|
||||
emergencyButtonController, mMessageAreaControllerFactory,
|
||||
mDevicePostureController);
|
||||
} else if (keyguardInputView instanceof KeyguardPasswordView) {
|
||||
return new KeyguardPasswordViewController((KeyguardPasswordView) keyguardInputView,
|
||||
mKeyguardUpdateMonitor, securityMode, mLockPatternUtils,
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.android.keyguard;
|
||||
|
||||
import static com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_HALF_OPENED;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.os.SystemClock;
|
||||
@@ -22,16 +24,19 @@ import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.constraintlayout.widget.ConstraintSet;
|
||||
|
||||
import com.android.internal.jank.InteractionJankMonitor;
|
||||
import com.android.internal.widget.LockPatternView;
|
||||
import com.android.settingslib.animation.AppearAnimationCreator;
|
||||
import com.android.settingslib.animation.AppearAnimationUtils;
|
||||
import com.android.settingslib.animation.DisappearAnimationUtils;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.statusbar.policy.DevicePostureController.DevicePostureInt;
|
||||
|
||||
public class KeyguardPatternView extends KeyguardInputView
|
||||
implements AppearAnimationCreator<LockPatternView.CellState> {
|
||||
@@ -68,7 +73,7 @@ public class KeyguardPatternView extends KeyguardInputView
|
||||
|
||||
KeyguardMessageArea mSecurityMessageDisplay;
|
||||
private View mEcaView;
|
||||
private ViewGroup mContainer;
|
||||
private ConstraintLayout mContainer;
|
||||
|
||||
public KeyguardPatternView(Context context) {
|
||||
this(context, null);
|
||||
@@ -90,6 +95,18 @@ public class KeyguardPatternView extends KeyguardInputView
|
||||
mContext, android.R.interpolator.fast_out_linear_in));
|
||||
}
|
||||
|
||||
void onDevicePostureChanged(@DevicePostureInt int posture) {
|
||||
// Update the guideline based on the device posture...
|
||||
float halfOpenPercentage =
|
||||
mContext.getResources().getFloat(R.dimen.half_opened_bouncer_height_ratio);
|
||||
|
||||
ConstraintSet cs = new ConstraintSet();
|
||||
cs.clone(mContainer);
|
||||
cs.setGuidelinePercent(R.id.pin_pad_top_guideline, posture == DEVICE_POSTURE_HALF_OPENED
|
||||
? halfOpenPercentage : 0.0f);
|
||||
cs.applyTo(mContainer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
|
||||
@@ -38,6 +38,7 @@ import com.android.settingslib.Utils;
|
||||
import com.android.systemui.R;
|
||||
import com.android.systemui.classifier.FalsingClassifier;
|
||||
import com.android.systemui.classifier.FalsingCollector;
|
||||
import com.android.systemui.statusbar.policy.DevicePostureController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -56,6 +57,9 @@ public class KeyguardPatternViewController
|
||||
private final FalsingCollector mFalsingCollector;
|
||||
private final EmergencyButtonController mEmergencyButtonController;
|
||||
private final KeyguardMessageAreaController.Factory mMessageAreaControllerFactory;
|
||||
private final DevicePostureController mPostureController;
|
||||
private final DevicePostureController.Callback mPostureCallback =
|
||||
posture -> mView.onDevicePostureChanged(posture);
|
||||
|
||||
private KeyguardMessageAreaController mMessageAreaController;
|
||||
private LockPatternView mLockPatternView;
|
||||
@@ -192,7 +196,8 @@ public class KeyguardPatternViewController
|
||||
LatencyTracker latencyTracker,
|
||||
FalsingCollector falsingCollector,
|
||||
EmergencyButtonController emergencyButtonController,
|
||||
KeyguardMessageAreaController.Factory messageAreaControllerFactory) {
|
||||
KeyguardMessageAreaController.Factory messageAreaControllerFactory,
|
||||
DevicePostureController postureController) {
|
||||
super(view, securityMode, keyguardSecurityCallback, emergencyButtonController);
|
||||
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
|
||||
mLockPatternUtils = lockPatternUtils;
|
||||
@@ -203,6 +208,7 @@ public class KeyguardPatternViewController
|
||||
KeyguardMessageArea kma = KeyguardMessageArea.findSecurityMessageDisplay(mView);
|
||||
mMessageAreaController = mMessageAreaControllerFactory.create(kma);
|
||||
mLockPatternView = mView.findViewById(R.id.lockPatternView);
|
||||
mPostureController = postureController;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -235,6 +241,7 @@ public class KeyguardPatternViewController
|
||||
getKeyguardSecurityCallback().onCancelClicked();
|
||||
});
|
||||
}
|
||||
mPostureController.addCallback(mPostureCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -247,6 +254,7 @@ public class KeyguardPatternViewController
|
||||
if (cancelBtn != null) {
|
||||
cancelBtn.setOnClickListener(null);
|
||||
}
|
||||
mPostureController.removeCallback(mPostureCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.android.systemui.R
|
||||
import com.android.systemui.SysuiTestCase
|
||||
import com.android.systemui.classifier.FalsingCollector
|
||||
import com.android.systemui.classifier.FalsingCollectorFake
|
||||
import com.android.systemui.statusbar.policy.DevicePostureController
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
@@ -62,6 +63,8 @@ class KeyguardPatternViewControllerTest : SysuiTestCase() {
|
||||
private lateinit var mKeyguardMessageAreaController: KeyguardMessageAreaController
|
||||
@Mock
|
||||
private lateinit var mLockPatternView: LockPatternView
|
||||
@Mock
|
||||
private lateinit var mPostureController: DevicePostureController
|
||||
|
||||
private lateinit var mKeyguardPatternViewController: KeyguardPatternViewController
|
||||
|
||||
@@ -78,7 +81,7 @@ class KeyguardPatternViewControllerTest : SysuiTestCase() {
|
||||
mKeyguardPatternViewController = KeyguardPatternViewController(mKeyguardPatternView,
|
||||
mKeyguardUpdateMonitor, mSecurityMode, mLockPatternUtils, mKeyguardSecurityCallback,
|
||||
mLatencyTracker, mFalsingCollector, mEmergencyButtonController,
|
||||
mKeyguardMessageAreaControllerFactory)
|
||||
mKeyguardMessageAreaControllerFactory, mPostureController)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user