Merge "AOD: Increase alpha values when dozing" into oc-dr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
19d8e4e04e
@@ -23,11 +23,12 @@ import android.animation.ValueAnimator;
|
||||
import android.app.Notification;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorMatrix;
|
||||
import android.graphics.ColorMatrixColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
@@ -54,9 +55,16 @@ import com.android.systemui.statusbar.notification.NotificationIconDozeHelper;
|
||||
import com.android.systemui.statusbar.notification.NotificationUtils;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class StatusBarIconView extends AnimatedImageView {
|
||||
public static final int NO_COLOR = 0;
|
||||
|
||||
/**
|
||||
* Multiply alpha values with (1+DARK_ALPHA_BOOST) when dozing. The chosen value boosts
|
||||
* everything above 30% to 50%, making it appear on 1bit color depths.
|
||||
*/
|
||||
private static final float DARK_ALPHA_BOOST = 0.67f;
|
||||
private final int ANIMATION_DURATION_FAST = 100;
|
||||
|
||||
public static final int STATE_ICON = 0;
|
||||
@@ -131,6 +139,8 @@ public class StatusBarIconView extends AnimatedImageView {
|
||||
private final NotificationIconDozeHelper mDozer;
|
||||
private int mContrastedDrawableColor;
|
||||
private int mCachedContrastBackgroundColor = NO_COLOR;
|
||||
private float[] mMatrix;
|
||||
private ColorMatrixColorFilter mMatrixColorFilter;
|
||||
|
||||
public StatusBarIconView(Context context, String slot, StatusBarNotification sbn) {
|
||||
this(context, slot, sbn, false);
|
||||
@@ -544,14 +554,33 @@ public class StatusBarIconView extends AnimatedImageView {
|
||||
|
||||
private void updateIconColor() {
|
||||
if (mCurrentSetColor != NO_COLOR) {
|
||||
setImageTintList(ColorStateList.valueOf(NotificationUtils.interpolateColors(
|
||||
mCurrentSetColor, Color.WHITE, mDarkAmount)));
|
||||
if (mMatrixColorFilter == null) {
|
||||
mMatrix = new float[4 * 5];
|
||||
mMatrixColorFilter = new ColorMatrixColorFilter(mMatrix);
|
||||
}
|
||||
int color = NotificationUtils.interpolateColors(
|
||||
mCurrentSetColor, Color.WHITE, mDarkAmount);
|
||||
updateTintMatrix(mMatrix, color, DARK_ALPHA_BOOST * mDarkAmount);
|
||||
mMatrixColorFilter.setColorMatrixArray(mMatrix);
|
||||
setColorFilter(mMatrixColorFilter);
|
||||
invalidate(); // setColorFilter only invalidates if the filter instance changed.
|
||||
} else {
|
||||
setImageTintList(null);
|
||||
mDozer.updateGrayscale(this, mDarkAmount);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates {@param array} such that it represents a matrix that changes RGB to {@param color}
|
||||
* and multiplies A with 1+{@param alphaBoost}.
|
||||
*/
|
||||
private static void updateTintMatrix(float[] array, int color, float alphaBoost) {
|
||||
Arrays.fill(array, 0);
|
||||
array[4] = Color.red(color);
|
||||
array[9] = Color.green(color);
|
||||
array[14] = Color.blue(color);
|
||||
array[18] = 1 + alphaBoost;
|
||||
}
|
||||
|
||||
public void setIconColor(int iconColor, boolean animate) {
|
||||
if (mIconColor != iconColor) {
|
||||
mIconColor = iconColor;
|
||||
|
||||
Reference in New Issue
Block a user