diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java index 5302188ccb31ff..166bcc0a2f6544 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java @@ -22,6 +22,7 @@ import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.animation.ValueAnimator; +import android.provider.Settings; import android.app.Notification; import android.content.Context; import android.content.pm.ApplicationInfo; @@ -123,6 +124,7 @@ public Float get(StatusBarIconView object) { }; private boolean mAlwaysScaleIcon; + private static boolean mIsSystemUI; private int mStatusBarIconDrawingSizeIncreased = 1; private int mStatusBarIconDrawingSize = 1; private int mStatusBarIconSize = 1; @@ -439,7 +441,15 @@ public static Drawable getIcon(Context sysuiContext, userId = UserHandle.USER_SYSTEM; } - Drawable icon = statusBarIcon.icon.loadDrawableAsUser(context, userId); + Drawable icon; + String pkgName = statusBarIcon.pkg; + mIsSystemUI = pkgName.contains("systemui"); + try { + icon = mIsSystemUI ? statusBarIcon.icon.loadDrawableAsUser(context, userId) + : context.getPackageManager().getApplicationIcon(pkgName); + } catch (android.content.pm.PackageManager.NameNotFoundException e) { + icon = statusBarIcon.icon.loadDrawableAsUser(context, userId); + } TypedValue typedValue = new TypedValue(); sysuiContext.getResources().getValue(R.dimen.status_bar_icon_scale_factor, @@ -612,9 +622,11 @@ public void setDecorColor(int iconTint) { private void initializeDecorColor() { if (mNotification != null) { - setDecorColor(getContext().getColor(mNightMode - ? com.android.internal.R.color.notification_default_color_dark - : com.android.internal.R.color.notification_default_color_light)); + if (mNotification.getPackageName().contains("systemui")) { + setDecorColor(getContext().getColor(mNightMode + ? com.android.internal.R.color.notification_default_color_dark + : com.android.internal.R.color.notification_default_color_light)); + } } } @@ -634,16 +646,22 @@ private void updateDecorColor() { * transitioning this also immediately sets the color. */ public void setStaticDrawableColor(int color) { - mDrawableColor = color; - setColorInternal(color); - updateContrastedStaticColor(); - mIconColor = color; - mDozer.setColor(color); + if (mNotification == null) return; + if (mNotification.getPackageName().contains("systemui")) { //if (mIsSystemUI) { + mDrawableColor = color; + setColorInternal(color); + updateContrastedStaticColor(); + mIconColor = color; + mDozer.setColor(color); + } } private void setColorInternal(int color) { - mCurrentSetColor = color; - updateIconColor(); + if (mNotification == null) return; + if (mNotification.getPackageName().contains("systemui")) { //if (mIsSystemUI) { + mCurrentSetColor = color; + updateIconColor(); + } } private void updateIconColor() { @@ -652,19 +670,22 @@ private void updateIconColor() { return; } - if (mCurrentSetColor != NO_COLOR) { - if (mMatrixColorFilter == null) { - mMatrix = new float[4 * 5]; - mMatrixColorFilter = new ColorMatrixColorFilter(mMatrix); + if (mNotification == null) return; + if (mNotification.getPackageName().contains("systemui")) { //if (mIsSystemUI) { + if (mCurrentSetColor != NO_COLOR) { + if (mMatrixColorFilter == null) { + mMatrix = new float[4 * 5]; + mMatrixColorFilter = new ColorMatrixColorFilter(mMatrix); + } + int color = NotificationUtils.interpolateColors( + mCurrentSetColor, Color.WHITE, mDozeAmount); + updateTintMatrix(mMatrix, color, DARK_ALPHA_BOOST * mDozeAmount); + mMatrixColorFilter.setColorMatrixArray(mMatrix); + setColorFilter(null); // setColorFilter only invalidates if the instance changed. + setColorFilter(mMatrixColorFilter); + } else { + mDozer.updateGrayscale(this, mDozeAmount); } - int color = NotificationUtils.interpolateColors( - mCurrentSetColor, Color.WHITE, mDozeAmount); - updateTintMatrix(mMatrix, color, DARK_ALPHA_BOOST * mDozeAmount); - mMatrixColorFilter.setColorMatrixArray(mMatrix); - setColorFilter(null); // setColorFilter only invalidates if the instance changed. - setColorFilter(mMatrixColorFilter); - } else { - mDozer.updateGrayscale(this, mDozeAmount); } } @@ -681,36 +702,40 @@ private static void updateTintMatrix(float[] array, int color, float alphaBoost) } public void setIconColor(int iconColor, boolean animate) { - if (mIconColor != iconColor) { - mIconColor = iconColor; - if (mColorAnimator != null) { - mColorAnimator.cancel(); - } - if (mCurrentSetColor == iconColor) { - return; - } - if (animate && mCurrentSetColor != NO_COLOR) { - mAnimationStartColor = mCurrentSetColor; - mColorAnimator = ValueAnimator.ofFloat(0.0f, 1.0f); - mColorAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN); - mColorAnimator.setDuration(ANIMATION_DURATION_FAST); - mColorAnimator.addUpdateListener(mColorUpdater); - mColorAnimator.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - mColorAnimator = null; - mAnimationStartColor = NO_COLOR; - } - }); - mColorAnimator.start(); - } else { - setColorInternal(iconColor); + if (mNotification == null) return; + if (mNotification.getPackageName().contains("systemui")) { //if (mIsSystemUI) { + if (mIconColor != iconColor) { + mIconColor = iconColor; + if (mColorAnimator != null) { + mColorAnimator.cancel(); + } + if (mCurrentSetColor == iconColor) { + return; + } + if (animate && mCurrentSetColor != NO_COLOR) { + mAnimationStartColor = mCurrentSetColor; + mColorAnimator = ValueAnimator.ofFloat(0.0f, 1.0f); + mColorAnimator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN); + mColorAnimator.setDuration(ANIMATION_DURATION_FAST); + mColorAnimator.addUpdateListener(mColorUpdater); + mColorAnimator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + mColorAnimator = null; + mAnimationStartColor = NO_COLOR; + } + }); + mColorAnimator.start(); + } else { + setColorInternal(iconColor); + } } } } public int getStaticDrawableColor() { - return mDrawableColor; + if (mNotification == null) return mDrawableColor; + return mNotification.getPackageName().contains("systemui") /*mIsSystemUI*/ ? mDrawableColor : 0; } /** @@ -729,26 +754,29 @@ int getContrastedStaticDrawableColor(int backgroundColor) { } private void updateContrastedStaticColor() { - if (Color.alpha(mCachedContrastBackgroundColor) != 255) { - mContrastedDrawableColor = mDrawableColor; - return; - } - // We'll modify the color if it doesn't pass GAR - int contrastedColor = mDrawableColor; - if (!ContrastColorUtil.satisfiesTextContrast(mCachedContrastBackgroundColor, - contrastedColor)) { - float[] hsl = new float[3]; - ColorUtils.colorToHSL(mDrawableColor, hsl); - // This is basically a light grey, pushing the color will only distort it. - // Best thing to do in here is to fallback to the default color. - if (hsl[1] < 0.2f) { - contrastedColor = Notification.COLOR_DEFAULT; + if (mNotification == null) return; + if (mNotification.getPackageName().contains("systemui")) { //if (mIsSystemUI) { + if (Color.alpha(mCachedContrastBackgroundColor) != 255) { + mContrastedDrawableColor = mDrawableColor; + return; + } + // We'll modify the color if it doesn't pass GAR + int contrastedColor = mDrawableColor; + if (!ContrastColorUtil.satisfiesTextContrast(mCachedContrastBackgroundColor, + contrastedColor)) { + float[] hsl = new float[3]; + ColorUtils.colorToHSL(mDrawableColor, hsl); + // This is basically a light grey, pushing the color will only distort it. + // Best thing to do in here is to fallback to the default color. + if (hsl[1] < 0.2f) { + contrastedColor = Notification.COLOR_DEFAULT; + } + boolean isDark = !ContrastColorUtil.isColorLight(mCachedContrastBackgroundColor); + contrastedColor = ContrastColorUtil.resolveContrastColor(mContext, + contrastedColor, mCachedContrastBackgroundColor, isDark); } - boolean isDark = !ContrastColorUtil.isColorLight(mCachedContrastBackgroundColor); - contrastedColor = ContrastColorUtil.resolveContrastColor(mContext, - contrastedColor, mCachedContrastBackgroundColor, isDark); + mContrastedDrawableColor = contrastedColor; } - mContrastedDrawableColor = contrastedColor; } @Override diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java index 6516abd143edfd..8a67480f0665c7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java @@ -547,8 +547,12 @@ private void updateTintForIcon(StatusBarIconView v, int tint) { if (colorize) { color = DarkIconDispatcher.getTint(mTintArea, v, tint); } - v.setStaticDrawableColor(color); - v.setDecorColor(tint); + if (v.getStatusBarIcon().pkg.contains("systemui")) { + v.setStaticDrawableColor(color); + v.setDecorColor(tint); + } else { + return; + } } /** diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java index 7a9ecd126225df..ad7072370a9a70 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconContainer.java @@ -790,6 +790,7 @@ && indexOfChild(view) > mCannedAnimationStartIndex } } icon.setVisibleState(visibleState, animationsAllowed); + if (icon.getStatusBarIcon().pkg.contains("systemui")) icon.setIconColor(mInNotificationIconShelf ? mThemedTextColorPrimary : iconColor, needsCannedAnimation && animationsAllowed); if (animate) { @@ -810,7 +811,11 @@ && indexOfChild(view) > mCannedAnimationStartIndex public void initFrom(View view) { super.initFrom(view); if (view instanceof StatusBarIconView) { - iconColor = ((StatusBarIconView) view).getStaticDrawableColor(); + StatusBarIconView icon = (StatusBarIconView) view; + if (icon.getStatusBarIcon().pkg.contains("systemui")) + iconColor = ((StatusBarIconView) view).getStaticDrawableColor(); + else + return; } } }