diff options
| author | 2022-09-08 18:05:35 +0000 | |
|---|---|---|
| committer | 2022-09-08 18:05:35 +0000 | |
| commit | 328503ee1ac6fba6cab65e8d30baddcd3821d898 (patch) | |
| tree | 0b0a9c27b3c20b12c91deef9bb067bf6838f1a73 | |
| parent | cfd5ffebf8144a6aae04999cfe0dd78b75881d9d (diff) | |
| parent | fc3eb20df743b23486414d00ad86d42569633a05 (diff) | |
Merge "[Bouncer] Add entry animation" into tm-qpr-dev am: fc3eb20df7
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19803128
Change-Id: I2731348fe7d3ef67a8c5eb6c55b48595c95ee629
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
9 files changed, 114 insertions, 48 deletions
diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml b/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml index 712f657a20ae..5936ead18f4a 100644 --- a/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml +++ b/packages/SystemUI/res-keyguard/layout/keyguard_pin_view.xml @@ -17,23 +17,24 @@ */ --> -<com.android.keyguard.KeyguardPINView - xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:androidprv="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - android:id="@+id/keyguard_pin_view" - android:layout_width="match_parent" - android:layout_height="match_parent" - androidprv:layout_maxWidth="@dimen/keyguard_security_width" - android:layout_gravity="center_horizontal|bottom" - android:orientation="vertical" - > - - <androidx.constraintlayout.widget.ConstraintLayout +<com.android.keyguard.KeyguardPINView xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:androidprv="http://schemas.android.com/apk/res-auto" + android:id="@+id/keyguard_pin_view" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_gravity="center_horizontal|bottom" + android:clipChildren="false" + android:clipToPadding="false" + android:orientation="vertical" + androidprv:layout_maxWidth="@dimen/keyguard_security_width"> + +<androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/pin_container" android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginBottom="8dp" + android:clipChildren="false" + android:clipToPadding="false" android:layout_weight="1" android:layoutDirection="ltr" android:orientation="vertical"> @@ -79,6 +80,8 @@ android:layout_width="0dp" android:layout_height="0dp" android:orientation="horizontal" + android:clipChildren="false" + android:clipToPadding="false" androidprv:constraint_referenced_ids="key1,key2,key3,key4,key5,key6,key7,key8,key9,delete_button,key0,key_enter" diff --git a/packages/SystemUI/res-keyguard/values/styles.xml b/packages/SystemUI/res-keyguard/values/styles.xml index 625ffd3aa3ec..a1d12668d27a 100644 --- a/packages/SystemUI/res-keyguard/values/styles.xml +++ b/packages/SystemUI/res-keyguard/values/styles.xml @@ -50,7 +50,7 @@ <item name="android:background">@null</item> <item name="android:textSize">32sp</item> <item name="android:textColor">?android:attr/textColorPrimary</item> - <item name="android:fontFamily">@*android:string/config_headlineFontFamily</item> + <item name="android:fontFamily">@*android:string/config_bodyFontFamily</item> <item name="android:paddingBottom">-16dp</item> </style> <style name="Widget.TextView.Password" parent="@android:style/Widget.TextView"> diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardInputViewController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardInputViewController.java index 87300c3f0504..50c9193cbbd1 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardInputViewController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardInputViewController.java @@ -45,7 +45,6 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView> private final EmergencyButtonController mEmergencyButtonController; private boolean mPaused; - // The following is used to ignore callbacks from SecurityViews that are no longer current // (e.g. face unlock). This avoids unwanted asynchronous events from messing with the // state for the current security method. diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java index 6844b655629a..20fa8f817dc0 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardPINView.java @@ -16,23 +16,25 @@ package com.android.keyguard; -import static com.android.internal.jank.InteractionJankMonitor.CUJ_LOCKSCREEN_PIN_APPEAR; import static com.android.internal.jank.InteractionJankMonitor.CUJ_LOCKSCREEN_PIN_DISAPPEAR; import static com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_HALF_OPENED; import static com.android.systemui.statusbar.policy.DevicePostureController.DEVICE_POSTURE_UNKNOWN; +import android.animation.ValueAnimator; import android.content.Context; import android.content.res.Configuration; import android.util.AttributeSet; +import android.util.MathUtils; import android.view.View; import android.view.animation.AnimationUtils; +import android.view.animation.Interpolator; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintSet; -import com.android.settingslib.animation.AppearAnimationUtils; import com.android.settingslib.animation.DisappearAnimationUtils; import com.android.systemui.R; +import com.android.systemui.animation.Interpolators; import com.android.systemui.statusbar.policy.DevicePostureController.DevicePostureInt; /** @@ -40,7 +42,7 @@ import com.android.systemui.statusbar.policy.DevicePostureController.DevicePostu */ public class KeyguardPINView extends KeyguardPinBasedInputView { - private final AppearAnimationUtils mAppearAnimationUtils; + ValueAnimator mAppearAnimator = ValueAnimator.ofFloat(0f, 1f); private final DisappearAnimationUtils mDisappearAnimationUtils; private final DisappearAnimationUtils mDisappearAnimationUtilsLocked; private ConstraintLayout mContainer; @@ -54,7 +56,6 @@ public class KeyguardPINView extends KeyguardPinBasedInputView { public KeyguardPINView(Context context, AttributeSet attrs) { super(context, attrs); - mAppearAnimationUtils = new AppearAnimationUtils(context); mDisappearAnimationUtils = new DisappearAnimationUtils(context, 125, 0.6f /* translationScale */, 0.45f /* delayScale */, AnimationUtils.loadInterpolator( @@ -169,25 +170,20 @@ public class KeyguardPINView extends KeyguardPinBasedInputView { @Override public void startAppearAnimation() { - enableClipping(false); - setAlpha(1f); - setTranslationY(mAppearAnimationUtils.getStartTranslation()); - AppearAnimationUtils.startTranslationYAnimation(this, 0 /* delay */, 500 /* duration */, - 0, mAppearAnimationUtils.getInterpolator(), - getAnimationListener(CUJ_LOCKSCREEN_PIN_APPEAR)); - mAppearAnimationUtils.startAnimation2d(mViews, - new Runnable() { - @Override - public void run() { - enableClipping(true); - } - }); + if (mAppearAnimator.isRunning()) { + mAppearAnimator.cancel(); + } + mAppearAnimator.setDuration(650); + mAppearAnimator.addUpdateListener(animation -> animate(animation.getAnimatedFraction())); + mAppearAnimator.start(); } public boolean startDisappearAnimation(boolean needsSlowUnlockTransition, final Runnable finishRunnable) { + if (mAppearAnimator.isRunning()) { + mAppearAnimator.cancel(); + } - enableClipping(false); setTranslationY(0); DisappearAnimationUtils disappearAnimationUtils = needsSlowUnlockTransition ? mDisappearAnimationUtilsLocked @@ -195,7 +191,6 @@ public class KeyguardPINView extends KeyguardPinBasedInputView { disappearAnimationUtils.createAnimation( this, 0, 200, mDisappearYTranslation, false, mDisappearAnimationUtils.getInterpolator(), () -> { - enableClipping(true); if (finishRunnable != null) { finishRunnable.run(); } @@ -204,14 +199,32 @@ public class KeyguardPINView extends KeyguardPinBasedInputView { return true; } - private void enableClipping(boolean enable) { - mContainer.setClipToPadding(enable); - mContainer.setClipChildren(enable); - setClipChildren(enable); - } - @Override public boolean hasOverlappingRendering() { return false; } + + /** Animate subviews according to expansion or time. */ + private void animate(float progress) { + for (int i = 0; i < mViews.length; i++) { + View[] row = mViews[i]; + for (View view : row) { + if (view == null) { + continue; + } + + float scaledProgress = MathUtils.constrain( + (progress - 0.075f * i) / (1f - 0.075f * mViews.length), + 0f, + 1f + ); + view.setAlpha(scaledProgress); + Interpolator interpolator = Interpolators.STANDARD_ACCELERATE; + view.setTranslationY(40 - (40 * interpolator.getInterpolation(scaledProgress))); + if (view instanceof NumPadAnimationListener) { + ((NumPadAnimationListener) view).setProgress(scaledProgress); + } + } + } + } } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipperController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipperController.java index 3aa5ada0794d..51b68b72da30 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipperController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardSecurityViewFlipperController.java @@ -156,7 +156,6 @@ public class KeyguardSecurityViewFlipperController @Override public void onStartingToHide() { - } } } diff --git a/packages/SystemUI/src/com/android/keyguard/NumPadAnimationListener.kt b/packages/SystemUI/src/com/android/keyguard/NumPadAnimationListener.kt new file mode 100644 index 000000000000..f449edf8e894 --- /dev/null +++ b/packages/SystemUI/src/com/android/keyguard/NumPadAnimationListener.kt @@ -0,0 +1,23 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.keyguard + +/** Interface for classes to track animation progress. */ +interface NumPadAnimationListener { + /** Track the progress of the animation. */ + fun setProgress(progress: Float) +} diff --git a/packages/SystemUI/src/com/android/keyguard/NumPadAnimator.java b/packages/SystemUI/src/com/android/keyguard/NumPadAnimator.java index c91c8992780c..e0cafaed5a35 100644 --- a/packages/SystemUI/src/com/android/keyguard/NumPadAnimator.java +++ b/packages/SystemUI/src/com/android/keyguard/NumPadAnimator.java @@ -48,6 +48,10 @@ class NumPadAnimator { private int mTextColorPrimary; private int mTextColorPressed; private int mStyle; + private float mStartRadius; + private float mEndRadius; + private int mHeight; + private static final int EXPAND_ANIMATION_MS = 100; private static final int EXPAND_COLOR_ANIMATION_MS = 50; private static final int CONTRACT_ANIMATION_DELAY_MS = 33; @@ -80,12 +84,20 @@ class NumPadAnimator { mContractAnimatorSet.start(); } + public void setProgress(float progress) { + mBackground.setCornerRadius(mEndRadius + (mStartRadius - mEndRadius) * progress); + int height = (int) (mHeight * 0.8f + mHeight * 0.2 * progress); + int difference = mHeight - height; + mBackground.setBounds(0, difference / 2, mHeight, mHeight - difference / 2); + } + void onLayout(int height) { - float startRadius = height / 2f; - float endRadius = height / 4f; - mBackground.setCornerRadius(startRadius); - mExpandAnimator.setFloatValues(startRadius, endRadius); - mContractAnimator.setFloatValues(endRadius, startRadius); + mHeight = height; + mStartRadius = height / 2f; + mEndRadius = height / 4f; + mBackground.setCornerRadius(mStartRadius); + mExpandAnimator.setFloatValues(mStartRadius, mEndRadius); + mContractAnimator.setFloatValues(mEndRadius, mStartRadius); } /** diff --git a/packages/SystemUI/src/com/android/keyguard/NumPadButton.java b/packages/SystemUI/src/com/android/keyguard/NumPadButton.java index 8099f75ed7d4..37060987cb21 100644 --- a/packages/SystemUI/src/com/android/keyguard/NumPadButton.java +++ b/packages/SystemUI/src/com/android/keyguard/NumPadButton.java @@ -30,7 +30,7 @@ import androidx.annotation.Nullable; /** * Similar to the {@link NumPadKey}, but displays an image. */ -public class NumPadButton extends AlphaOptimizedImageButton { +public class NumPadButton extends AlphaOptimizedImageButton implements NumPadAnimationListener { @Nullable private NumPadAnimator mAnimator; @@ -104,4 +104,11 @@ public class NumPadButton extends AlphaOptimizedImageButton { a.recycle(); ((VectorDrawable) getDrawable()).setTintList(ColorStateList.valueOf(imageColor)); } + + @Override + public void setProgress(float progress) { + if (mAnimator != null) { + mAnimator.setProgress(progress); + } + } } diff --git a/packages/SystemUI/src/com/android/keyguard/NumPadKey.java b/packages/SystemUI/src/com/android/keyguard/NumPadKey.java index 4aed2513d4f2..0a4880e1ce66 100644 --- a/packages/SystemUI/src/com/android/keyguard/NumPadKey.java +++ b/packages/SystemUI/src/com/android/keyguard/NumPadKey.java @@ -37,7 +37,10 @@ import com.android.internal.widget.LockPatternUtils; import com.android.settingslib.Utils; import com.android.systemui.R; -public class NumPadKey extends ViewGroup { +/** + * Viewgroup for the bouncer numpad button, specifically for digits. + */ +public class NumPadKey extends ViewGroup implements NumPadAnimationListener { // list of "ABC", etc per digit, starting with '0' static String sKlondike[]; @@ -221,4 +224,11 @@ public class NumPadKey extends ViewGroup { performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); } + + @Override + public void setProgress(float progress) { + if (mAnimator != null) { + mAnimator.setProgress(progress); + } + } } |