Merge "PIN bouncer - Update animations" into sc-dev

This commit is contained in:
Matt Pietal
2021-02-17 19:51:53 +00:00
committed by Android (Google) Code Review
8 changed files with 48 additions and 31 deletions

View File

@@ -1,5 +1,5 @@
<!--
~ Copyright (C) 2017 The Android Open Source Project
~ Copyright (C) 2021 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.
@@ -20,6 +20,6 @@
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:fillColor="?android:attr/colorBackground"
android:pathData="M9,15.59L12.59,12L9,8.41L10.41,7L14,10.59L17.59,7L19,8.41L15.41,12L19,15.59L17.59,17L14,13.41L10.41,17L9,15.59zM21,6H8l-4.5,6L8,18h13V6M21,4c1.1,0 2,0.9 2,2v12c0,1.1 -0.9,2 -2,2H8c-0.63,0 -1.22,-0.3 -1.6,-0.8L1,12l5.4,-7.2C6.78,4.3 7.37,4 8,4H21L21,4z"/>
</vector>

View File

@@ -16,8 +16,23 @@
* limitations under the License.
*/
-->
<shape
xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="?android:attr/colorBackground" />
<corners android:radius="10dp" />
</shape>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/background">
<shape>
<solid android:color="?android:attr/colorControlNormal" />
<corners android:radius="10dp" />
</shape>
</item>
<item android:id="@+id/ripple">
<ripple
android:color="?android:attr/colorControlHighlight">
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<solid android:color="?android:attr/colorControlNormal" />
<corners android:radius="10dp" />
</shape>
</item>
</ripple>
</item>
</layer-list>

View File

@@ -40,7 +40,7 @@
<dimen name="keyguard_security_view_top_margin">8dp</dimen>
<dimen name="keyguard_security_view_lateral_margin">36dp</dimen>
<dimen name="keyguard_eca_top_margin">24dp</dimen>
<dimen name="keyguard_eca_top_margin">18dp</dimen>
<!-- EmergencyCarrierArea overlap - amount to overlap the emergency button and carrier text.
Should be 0 on devices with plenty of room (e.g. tablets) -->

View File

@@ -52,9 +52,8 @@
<item name="android:textColor">?android:attr/textColorPrimary</item>
</style>
<style name="NumPadKey.Delete">
<item name="android:src">@drawable/ic_backspace_black_24dp</item>
<item name="android:tint">?android:attr/textColorSecondary</item>
<item name="android:tintMode">src_in</item>
<item name="android:colorControlNormal">?android:attr/textColorSecondary</item>
<item name="android:src">@drawable/ic_backspace_24dp</item>
</style>
<style name="NumPadKey.Enter">
<item name="android:colorControlNormal">?android:attr/textColorSecondary</item>

View File

@@ -24,14 +24,12 @@ import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_TIMEOUT;
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_USER_REQUEST;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.View;
import com.android.internal.widget.LockscreenCredential;
import com.android.settingslib.Utils;
import com.android.systemui.R;
/**
@@ -188,10 +186,6 @@ public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView
key.reloadColors();
}
mPasswordEntry.reloadColors();
int deleteColor = Utils.getColorAttr(getContext(), android.R.attr.textColorSecondary)
.getDefaultColor();
mDeleteButton.setImageTintList(ColorStateList.valueOf(deleteColor));
mDeleteButton.reloadColors();
mOkButton.reloadColors();
}

View File

@@ -17,14 +17,16 @@ package com.android.keyguard;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.RippleDrawable;
import android.view.ContextThemeWrapper;
import android.view.ViewGroup;
import androidx.annotation.StyleRes;
import com.android.internal.graphics.ColorUtils;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
@@ -34,13 +36,18 @@ import com.android.systemui.R;
class NumPadAnimator {
private ValueAnimator mAnimator;
private GradientDrawable mBackground;
private RippleDrawable mRipple;
private GradientDrawable mRippleMask;
private int mMargin;
private int mNormalColor;
private int mHighlightColor;
private int mStyle;
NumPadAnimator(Context context, final GradientDrawable background, @StyleRes int style) {
mBackground = (GradientDrawable) background.mutate();
NumPadAnimator(Context context, LayerDrawable drawable, @StyleRes int style) {
LayerDrawable ld = (LayerDrawable) drawable.mutate();
mBackground = (GradientDrawable) ld.findDrawableByLayerId(R.id.background);
mRipple = (RippleDrawable) ld.findDrawableByLayerId(R.id.ripple);
mRippleMask = (GradientDrawable) mRipple.findDrawableByLayerId(android.R.id.mask);
mStyle = style;
reloadColors(context);
@@ -49,13 +56,14 @@ class NumPadAnimator {
// Actual values will be updated later, usually during an onLayout() call
mAnimator = ValueAnimator.ofFloat(0f);
mAnimator.setDuration(250);
mAnimator.setInterpolator(Interpolators.LINEAR);
mAnimator.setDuration(100);
mAnimator.setInterpolator(Interpolators.FAST_OUT_LINEAR_IN);
mAnimator.setRepeatMode(ValueAnimator.REVERSE);
mAnimator.setRepeatCount(1);
mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator anim) {
mBackground.setCornerRadius((float) anim.getAnimatedValue());
mBackground.setColor(ColorUtils.blendARGB(mHighlightColor, mNormalColor,
anim.getAnimatedFraction()));
mRippleMask.setCornerRadius((float) anim.getAnimatedValue());
}
});
@@ -66,9 +74,9 @@ class NumPadAnimator {
}
void onLayout(int height) {
float startRadius = height / 10f;
float endRadius = height / 2f;
mBackground.setCornerRadius(endRadius);
float startRadius = height / 2f;
float endRadius = height / 4f;
mBackground.setCornerRadius(startRadius);
mAnimator.setFloatValues(startRadius, endRadius);
}
@@ -91,6 +99,7 @@ class NumPadAnimator {
a.recycle();
mBackground.setColor(mNormalColor);
mRipple.setColor(ColorStateList.valueOf(mHighlightColor));
}
}

View File

@@ -17,7 +17,7 @@ package com.android.keyguard;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.VectorDrawable;
import android.util.AttributeSet;
import android.view.ContextThemeWrapper;
@@ -37,7 +37,7 @@ public class NumPadButton extends AlphaOptimizedImageButton {
public NumPadButton(Context context, AttributeSet attrs) {
super(context, attrs);
mAnimator = new NumPadAnimator(context, (GradientDrawable) getBackground(),
mAnimator = new NumPadAnimator(context, (LayerDrawable) getBackground(),
attrs.getStyleAttribute());
}

View File

@@ -18,7 +18,7 @@ package com.android.keyguard;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.LayerDrawable;
import android.os.PowerManager;
import android.os.SystemClock;
import android.util.AttributeSet;
@@ -127,7 +127,7 @@ public class NumPadKey extends ViewGroup {
setContentDescription(mDigitText.getText().toString());
mAnimator = new NumPadAnimator(context, (GradientDrawable) getBackground(),
mAnimator = new NumPadAnimator(context, (LayerDrawable) getBackground(),
R.style.NumPadKey);
}