Merge "[Bouncer] Update colors for pin pad" into tm-dev
This commit is contained in:
@@ -30,7 +30,6 @@ import android.widget.TextView;
|
|||||||
|
|
||||||
import androidx.annotation.StyleRes;
|
import androidx.annotation.StyleRes;
|
||||||
|
|
||||||
import com.android.settingslib.Utils;
|
|
||||||
import com.android.systemui.animation.Interpolators;
|
import com.android.systemui.animation.Interpolators;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,24 +41,29 @@ class NumPadAnimator {
|
|||||||
private ValueAnimator mContractAnimator;
|
private ValueAnimator mContractAnimator;
|
||||||
private AnimatorSet mContractAnimatorSet;
|
private AnimatorSet mContractAnimatorSet;
|
||||||
private GradientDrawable mBackground;
|
private GradientDrawable mBackground;
|
||||||
private int mNormalColor;
|
private Drawable mImageButton;
|
||||||
private int mHighlightColor;
|
|
||||||
private int mStyle;
|
|
||||||
private TextView mDigitTextView;
|
private TextView mDigitTextView;
|
||||||
|
private int mNormalBackgroundColor;
|
||||||
|
private int mPressedBackgroundColor;
|
||||||
|
private int mTextColorPrimary;
|
||||||
|
private int mTextColorPressed;
|
||||||
|
private int mStyle;
|
||||||
private static final int EXPAND_ANIMATION_MS = 100;
|
private static final int EXPAND_ANIMATION_MS = 100;
|
||||||
private static final int EXPAND_COLOR_ANIMATION_MS = 50;
|
private static final int EXPAND_COLOR_ANIMATION_MS = 50;
|
||||||
private static final int CONTRACT_ANIMATION_DELAY_MS = 33;
|
private static final int CONTRACT_ANIMATION_DELAY_MS = 33;
|
||||||
private static final int CONTRACT_ANIMATION_MS = 417;
|
private static final int CONTRACT_ANIMATION_MS = 417;
|
||||||
|
|
||||||
NumPadAnimator(Context context, final Drawable drawable, @StyleRes int style) {
|
NumPadAnimator(Context context, final Drawable drawable,
|
||||||
this(context, drawable, style, null);
|
@StyleRes int style, Drawable buttonImage) {
|
||||||
|
this(context, drawable, style, null, buttonImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
NumPadAnimator(Context context, final Drawable drawable, @StyleRes int style,
|
NumPadAnimator(Context context, final Drawable drawable, @StyleRes int style,
|
||||||
@Nullable TextView digitTextView) {
|
@Nullable TextView digitTextView, @Nullable Drawable buttonImage) {
|
||||||
mStyle = style;
|
mStyle = style;
|
||||||
mBackground = (GradientDrawable) drawable;
|
mBackground = (GradientDrawable) drawable;
|
||||||
mDigitTextView = digitTextView;
|
mDigitTextView = digitTextView;
|
||||||
|
mImageButton = buttonImage;
|
||||||
|
|
||||||
reloadColors(context);
|
reloadColors(context);
|
||||||
}
|
}
|
||||||
@@ -88,26 +92,28 @@ class NumPadAnimator {
|
|||||||
* Reload colors from resources.
|
* Reload colors from resources.
|
||||||
**/
|
**/
|
||||||
void reloadColors(Context context) {
|
void reloadColors(Context context) {
|
||||||
int[] customAttrs = {android.R.attr.colorControlNormal,
|
boolean isNumPadKey = mImageButton == null;
|
||||||
android.R.attr.colorControlHighlight};
|
|
||||||
|
|
||||||
|
int[] customAttrs = {android.R.attr.colorControlNormal};
|
||||||
ContextThemeWrapper ctw = new ContextThemeWrapper(context, mStyle);
|
ContextThemeWrapper ctw = new ContextThemeWrapper(context, mStyle);
|
||||||
TypedArray a = ctw.obtainStyledAttributes(customAttrs);
|
TypedArray a = ctw.obtainStyledAttributes(customAttrs);
|
||||||
mNormalColor = getPrivateAttrColorIfUnset(ctw, a, 0, 0,
|
mNormalBackgroundColor = getPrivateAttrColorIfUnset(ctw, a, 0, 0,
|
||||||
com.android.internal.R.attr.colorSurface);
|
com.android.internal.R.attr.colorSurface);
|
||||||
mHighlightColor = a.getColor(1, 0);
|
|
||||||
a.recycle();
|
a.recycle();
|
||||||
|
mBackground.setColor(mNormalBackgroundColor);
|
||||||
|
|
||||||
mBackground.setColor(mNormalColor);
|
mPressedBackgroundColor = context.getColor(android.R.color.system_accent1_200);
|
||||||
createAnimators(context);
|
mTextColorPrimary = isNumPadKey
|
||||||
|
? com.android.settingslib.Utils
|
||||||
|
.getColorAttrDefaultColor(context, android.R.attr.textColorPrimary)
|
||||||
|
: com.android.settingslib.Utils
|
||||||
|
.getColorAttrDefaultColor(context, android.R.attr.textColorPrimaryInverse);
|
||||||
|
mTextColorPressed = com.android.settingslib.Utils
|
||||||
|
.getColorAttrDefaultColor(context, com.android.internal.R.attr.textColorOnAccent);
|
||||||
|
createAnimators();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createAnimators(Context context) {
|
private void createAnimators() {
|
||||||
int textColorPrimary = Utils.getColorAttrDefaultColor(context,
|
|
||||||
android.R.attr.textColorPrimary);
|
|
||||||
int textColorPrimaryInverse = Utils.getColorAttrDefaultColor(context,
|
|
||||||
android.R.attr.textColorPrimaryInverse);
|
|
||||||
|
|
||||||
// Actual values will be updated later, usually during an onLayout() call
|
// Actual values will be updated later, usually during an onLayout() call
|
||||||
mExpandAnimator = ValueAnimator.ofFloat(0f, 1f);
|
mExpandAnimator = ValueAnimator.ofFloat(0f, 1f);
|
||||||
mExpandAnimator.setDuration(EXPAND_ANIMATION_MS);
|
mExpandAnimator.setDuration(EXPAND_ANIMATION_MS);
|
||||||
@@ -116,7 +122,7 @@ class NumPadAnimator {
|
|||||||
anim -> mBackground.setCornerRadius((float) anim.getAnimatedValue()));
|
anim -> mBackground.setCornerRadius((float) anim.getAnimatedValue()));
|
||||||
|
|
||||||
ValueAnimator expandBackgroundColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(),
|
ValueAnimator expandBackgroundColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(),
|
||||||
mNormalColor, mHighlightColor);
|
mNormalBackgroundColor, mPressedBackgroundColor);
|
||||||
expandBackgroundColorAnimator.setDuration(EXPAND_COLOR_ANIMATION_MS);
|
expandBackgroundColorAnimator.setDuration(EXPAND_COLOR_ANIMATION_MS);
|
||||||
expandBackgroundColorAnimator.setInterpolator(Interpolators.LINEAR);
|
expandBackgroundColorAnimator.setInterpolator(Interpolators.LINEAR);
|
||||||
expandBackgroundColorAnimator.addUpdateListener(
|
expandBackgroundColorAnimator.addUpdateListener(
|
||||||
@@ -124,13 +130,16 @@ class NumPadAnimator {
|
|||||||
|
|
||||||
ValueAnimator expandTextColorAnimator =
|
ValueAnimator expandTextColorAnimator =
|
||||||
ValueAnimator.ofObject(new ArgbEvaluator(),
|
ValueAnimator.ofObject(new ArgbEvaluator(),
|
||||||
textColorPrimary, textColorPrimaryInverse);
|
mTextColorPrimary, mTextColorPressed);
|
||||||
expandTextColorAnimator.setInterpolator(Interpolators.LINEAR);
|
expandTextColorAnimator.setInterpolator(Interpolators.LINEAR);
|
||||||
expandTextColorAnimator.setDuration(EXPAND_COLOR_ANIMATION_MS);
|
expandTextColorAnimator.setDuration(EXPAND_COLOR_ANIMATION_MS);
|
||||||
expandTextColorAnimator.addUpdateListener(valueAnimator -> {
|
expandTextColorAnimator.addUpdateListener(valueAnimator -> {
|
||||||
if (mDigitTextView != null) {
|
if (mDigitTextView != null) {
|
||||||
mDigitTextView.setTextColor((int) valueAnimator.getAnimatedValue());
|
mDigitTextView.setTextColor((int) valueAnimator.getAnimatedValue());
|
||||||
}
|
}
|
||||||
|
if (mImageButton != null) {
|
||||||
|
mImageButton.setTint((int) valueAnimator.getAnimatedValue());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mExpandAnimatorSet = new AnimatorSet();
|
mExpandAnimatorSet = new AnimatorSet();
|
||||||
@@ -144,7 +153,7 @@ class NumPadAnimator {
|
|||||||
mContractAnimator.addUpdateListener(
|
mContractAnimator.addUpdateListener(
|
||||||
anim -> mBackground.setCornerRadius((float) anim.getAnimatedValue()));
|
anim -> mBackground.setCornerRadius((float) anim.getAnimatedValue()));
|
||||||
ValueAnimator contractBackgroundColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(),
|
ValueAnimator contractBackgroundColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(),
|
||||||
mHighlightColor, mNormalColor);
|
mPressedBackgroundColor, mNormalBackgroundColor);
|
||||||
contractBackgroundColorAnimator.setInterpolator(Interpolators.LINEAR);
|
contractBackgroundColorAnimator.setInterpolator(Interpolators.LINEAR);
|
||||||
contractBackgroundColorAnimator.setStartDelay(CONTRACT_ANIMATION_DELAY_MS);
|
contractBackgroundColorAnimator.setStartDelay(CONTRACT_ANIMATION_DELAY_MS);
|
||||||
contractBackgroundColorAnimator.setDuration(CONTRACT_ANIMATION_MS);
|
contractBackgroundColorAnimator.setDuration(CONTRACT_ANIMATION_MS);
|
||||||
@@ -152,8 +161,8 @@ class NumPadAnimator {
|
|||||||
animator -> mBackground.setColor((int) animator.getAnimatedValue()));
|
animator -> mBackground.setColor((int) animator.getAnimatedValue()));
|
||||||
|
|
||||||
ValueAnimator contractTextColorAnimator =
|
ValueAnimator contractTextColorAnimator =
|
||||||
ValueAnimator.ofObject(new ArgbEvaluator(), textColorPrimaryInverse,
|
ValueAnimator.ofObject(new ArgbEvaluator(), mTextColorPressed,
|
||||||
textColorPrimary);
|
mTextColorPrimary);
|
||||||
contractTextColorAnimator.setInterpolator(Interpolators.LINEAR);
|
contractTextColorAnimator.setInterpolator(Interpolators.LINEAR);
|
||||||
contractTextColorAnimator.setStartDelay(CONTRACT_ANIMATION_DELAY_MS);
|
contractTextColorAnimator.setStartDelay(CONTRACT_ANIMATION_DELAY_MS);
|
||||||
contractTextColorAnimator.setDuration(CONTRACT_ANIMATION_MS);
|
contractTextColorAnimator.setDuration(CONTRACT_ANIMATION_MS);
|
||||||
@@ -161,6 +170,9 @@ class NumPadAnimator {
|
|||||||
if (mDigitTextView != null) {
|
if (mDigitTextView != null) {
|
||||||
mDigitTextView.setTextColor((int) valueAnimator.getAnimatedValue());
|
mDigitTextView.setTextColor((int) valueAnimator.getAnimatedValue());
|
||||||
}
|
}
|
||||||
|
if (mImageButton != null) {
|
||||||
|
mImageButton.setTint((int) valueAnimator.getAnimatedValue());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
mContractAnimatorSet = new AnimatorSet();
|
mContractAnimatorSet = new AnimatorSet();
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class NumPadButton extends AlphaOptimizedImageButton {
|
|||||||
Drawable background = getBackground();
|
Drawable background = getBackground();
|
||||||
if (background instanceof GradientDrawable) {
|
if (background instanceof GradientDrawable) {
|
||||||
mAnimator = new NumPadAnimator(context, background.mutate(),
|
mAnimator = new NumPadAnimator(context, background.mutate(),
|
||||||
attrs.getStyleAttribute());
|
attrs.getStyleAttribute(), getDrawable());
|
||||||
} else {
|
} else {
|
||||||
mAnimator = null;
|
mAnimator = null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ public class NumPadKey extends ViewGroup {
|
|||||||
Drawable background = getBackground();
|
Drawable background = getBackground();
|
||||||
if (background instanceof GradientDrawable) {
|
if (background instanceof GradientDrawable) {
|
||||||
mAnimator = new NumPadAnimator(context, background.mutate(),
|
mAnimator = new NumPadAnimator(context, background.mutate(),
|
||||||
R.style.NumPadKey, mDigitText);
|
R.style.NumPadKey, mDigitText, null);
|
||||||
} else {
|
} else {
|
||||||
mAnimator = null;
|
mAnimator = null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user