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>
This commit is contained in:
@@ -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"
|
||||
>
|
||||
<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
|
||||
<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"
|
||||
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,6 @@ public class KeyguardSecurityViewFlipperController
|
||||
|
||||
@Override
|
||||
public void onStartingToHide() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user