diff options
author | Jorim Jaggi <jjaggi@google.com> | 2015-03-20 14:39:24 -0700 |
---|---|---|
committer | Jorim Jaggi <jjaggi@google.com> | 2015-04-02 11:44:16 -0700 |
commit | 5443cc563cf4581a8ea9ada3b27fac7107d72099 (patch) | |
tree | 317dc6c6082dd0078ca042561db286da3459308c /packages/SystemUI/src/com/android/systemui/statusbar | |
parent | 0feaaafd7a9206e6bf1d9dc9a1f285937b9def8e (diff) | |
download | frameworks_base-5443cc563cf4581a8ea9ada3b27fac7107d72099.zip frameworks_base-5443cc563cf4581a8ea9ada3b27fac7107d72099.tar.gz frameworks_base-5443cc563cf4581a8ea9ada3b27fac7107d72099.tar.bz2 |
Change light status bar tint color to spec
Bug: 19233606
Change-Id: I0586e006b6783d3af23defb67da666477484c1ee
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/statusbar')
3 files changed, 54 insertions, 36 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java index 7286907..a82afcf 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/SignalClusterView.java @@ -59,9 +59,10 @@ public class SignalClusterView private String mWifiDescription; private ArrayList<PhoneState> mPhoneStates = new ArrayList<PhoneState>(); private int mIconTint = Color.WHITE; + private float mDarkIntensity; ViewGroup mWifiGroup; - ImageView mVpn, mWifi, mAirplane, mNoSims; + ImageView mVpn, mWifi, mAirplane, mNoSims, mWifiDark, mNoSimsDark; View mWifiAirplaneSpacer; View mWifiSignalSpacer; LinearLayout mMobileSignalGroup; @@ -115,8 +116,10 @@ public class SignalClusterView mVpn = (ImageView) findViewById(R.id.vpn); mWifiGroup = (ViewGroup) findViewById(R.id.wifi_combo); mWifi = (ImageView) findViewById(R.id.wifi_signal); + mWifiDark = (ImageView) findViewById(R.id.wifi_signal_dark); mAirplane = (ImageView) findViewById(R.id.airplane); mNoSims = (ImageView) findViewById(R.id.no_sims); + mNoSimsDark = (ImageView) findViewById(R.id.no_sims_dark); mWifiAirplaneSpacer = findViewById(R.id.wifi_airplane_spacer); mWifiSignalSpacer = findViewById(R.id.wifi_signal_spacer); mMobileSignalGroup = (LinearLayout) findViewById(R.id.mobile_signal_group); @@ -273,6 +276,7 @@ public class SignalClusterView if (DEBUG) Log.d(TAG, String.format("vpn: %s", mVpnVisible ? "VISIBLE" : "GONE")); if (mWifiVisible) { mWifi.setImageResource(mWifiStrengthId); + mWifiDark.setImageResource(mWifiStrengthId); mWifiGroup.setContentDescription(mWifiDescription); mWifiGroup.setVisibility(View.VISIBLE); } else { @@ -317,15 +321,17 @@ public class SignalClusterView } mNoSims.setVisibility(mNoSimsVisible ? View.VISIBLE : View.GONE); + mNoSimsDark.setVisibility(mNoSimsVisible ? View.VISIBLE : View.GONE); boolean anythingVisible = mNoSimsVisible || mWifiVisible || mIsAirplaneMode || anyMobileVisible || mVpnVisible; setPaddingRelative(0, 0, anythingVisible ? mEndPadding : mEndPaddingNothingVisible, 0); } - public void setIconTint(int tint) { - boolean changed = tint != mIconTint; + public void setIconTint(int tint, float darkIntensity) { + boolean changed = tint != mIconTint || darkIntensity != mDarkIntensity; mIconTint = tint; + mDarkIntensity = darkIntensity; if (changed && isAttachedToWindow()) { applyIconTint(); } @@ -333,14 +339,19 @@ public class SignalClusterView private void applyIconTint() { setTint(mVpn, mIconTint); - setTint(mWifi, mIconTint); - setTint(mNoSims, mIconTint); setTint(mAirplane, mIconTint); + applyDarkIntensity(mDarkIntensity, mNoSims, mNoSimsDark); + applyDarkIntensity(mDarkIntensity, mWifi, mWifiDark); for (int i = 0; i < mPhoneStates.size(); i++) { - mPhoneStates.get(i).setIconTint(mIconTint); + mPhoneStates.get(i).setIconTint(mIconTint, mDarkIntensity); } } + private void applyDarkIntensity(float darkIntensity, View lightIcon, View darkIcon) { + lightIcon.setAlpha(1 - darkIntensity); + darkIcon.setAlpha(darkIntensity); + } + private void setTint(ImageView v, int tint) { v.setImageTintMode(PorterDuff.Mode.SRC_ATOP); v.setImageTintList(ColorStateList.valueOf(tint)); @@ -354,7 +365,7 @@ public class SignalClusterView private String mMobileDescription, mMobileTypeDescription; private ViewGroup mMobileGroup; - private ImageView mMobile, mMobileType; + private ImageView mMobile, mMobileDark, mMobileType; public PhoneState(int subId, Context context) { ViewGroup root = (ViewGroup) LayoutInflater.from(context) @@ -366,12 +377,14 @@ public class SignalClusterView public void setViews(ViewGroup root) { mMobileGroup = root; mMobile = (ImageView) root.findViewById(R.id.mobile_signal); + mMobileDark = (ImageView) root.findViewById(R.id.mobile_signal_dark); mMobileType = (ImageView) root.findViewById(R.id.mobile_type); } public boolean apply(boolean isSecondaryIcon) { if (mMobileVisible && !mIsAirplaneMode) { mMobile.setImageResource(mMobileStrengthId); + mMobileDark.setImageResource(mMobileStrengthId); mMobileType.setImageResource(mMobileTypeId); mMobileGroup.setContentDescription(mMobileTypeDescription + " " + mMobileDescription); @@ -385,6 +398,8 @@ public class SignalClusterView 0, 0, 0); mMobile.setPaddingRelative(mIsMobileTypeIconWide ? mWideTypeIconStartPadding : 0, 0, 0, 0); + mMobileDark.setPaddingRelative(mIsMobileTypeIconWide ? mWideTypeIconStartPadding : 0, + 0, 0, 0); if (DEBUG) Log.d(TAG, String.format("mobile: %s sig=%d typ=%d", (mMobileVisible ? "VISIBLE" : "GONE"), mMobileStrengthId, mMobileTypeId)); @@ -401,8 +416,8 @@ public class SignalClusterView } } - public void setIconTint(int tint) { - setTint(mMobile, tint); + public void setIconTint(int tint, float darkIntensity) { + applyDarkIntensity(darkIntensity, mMobile, mMobileDark); setTint(mMobileType, tint); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java index 2c389fb..f046c63 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java @@ -49,7 +49,6 @@ import android.content.res.Resources; import android.database.ContentObserver; import android.graphics.Bitmap; import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.ColorFilter; import android.graphics.PixelFormat; import android.graphics.Point; @@ -225,8 +224,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, /** Allow some time inbetween the long press for back and recents. */ private static final int LOCK_TO_APP_GESTURE_TOLERENCE = 200; - private int mLightModeIconColor; - PhoneStatusBarPolicy mIconPolicy; // These are no longer handled by the policy, because we need custom strategies for them @@ -535,7 +532,6 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, updateDisplaySize(); mScrimSrcModeEnabled = mContext.getResources().getBoolean( R.bool.config_status_bar_scrim_behind_use_src); - mLightModeIconColor = mContext.getColor(R.color.light_mode_icon_color); super.start(); // calls createAndAddWindows() @@ -2324,9 +2320,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode, boolean allowLight = isTransparentBar && !mBatteryController.isPowerSave(); boolean light = (vis & View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR) != 0; - mIconController.setIconTint( - (allowLight && light) ? mLightModeIconColor : Color.WHITE); - + mIconController.setIconsDark(allowLight && light); } // restore the recents bit if (wasRecentsVisible) { diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconController.java index c49f620..45da297 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconController.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarIconController.java @@ -16,11 +16,11 @@ package com.android.systemui.statusbar.phone; +import android.animation.ArgbEvaluator; import android.animation.ValueAnimator; import android.content.Context; import android.content.res.ColorStateList; import android.graphics.Color; -import android.graphics.PorterDuff; import android.os.Bundle; import android.os.Handler; import android.os.SystemClock; @@ -74,12 +74,16 @@ public class StatusBarIconController { private int mIconHPadding; private int mIconTint = Color.WHITE; + private float mDarkIntensity; private boolean mTransitionPending; private boolean mTintChangePending; - private int mPendingIconTint; + private float mPendingDarkIntensity; private ValueAnimator mTintAnimator; + private int mDarkModeIconColorSingleTone; + private int mLightModeIconColorSingleTone; + private final Handler mHandler; private boolean mTransitionDeferring; private long mTransitionDeferringStartTime; @@ -111,6 +115,8 @@ public class StatusBarIconController { android.R.interpolator.linear_out_slow_in); mFastOutSlowIn = AnimationUtils.loadInterpolator(mContext, android.R.interpolator.fast_out_slow_in); + mDarkModeIconColorSingleTone = context.getColor(R.color.dark_mode_icon_color_single_tone); + mLightModeIconColorSingleTone = context.getColor(R.color.light_mode_icon_color_single_tone); mHandler = new Handler(); updateResources(); } @@ -296,30 +302,31 @@ public class StatusBarIconController { } } - public void setIconTint(int tint) { + public void setIconsDark(boolean dark) { if (mTransitionPending) { - deferIconTintChange(tint); + deferIconTintChange(dark ? 1.0f : 0.0f); } else if (mTransitionDeferring) { - animateIconTint(tint, + animateIconTint(dark ? 1.0f : 0.0f, Math.max(0, mTransitionDeferringStartTime - SystemClock.uptimeMillis()), mTransitionDeferringDuration); } else { - animateIconTint(tint, 0 /* delay */, DEFAULT_TINT_ANIMATION_DURATION); + animateIconTint(dark ? 1.0f : 0.0f, 0 /* delay */, DEFAULT_TINT_ANIMATION_DURATION); } } - private void animateIconTint(int targetTint, long delay, long duration) { + private void animateIconTint(float targetDarkIntensity, long delay, + long duration) { if (mTintAnimator != null) { mTintAnimator.cancel(); } - if (mIconTint == targetTint) { + if (mDarkIntensity == targetDarkIntensity) { return; } - mTintAnimator = ValueAnimator.ofArgb(mIconTint, targetTint); + mTintAnimator = ValueAnimator.ofFloat(mDarkIntensity, targetDarkIntensity); mTintAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { - setIconTintInternal((Integer) animation.getAnimatedValue()); + setIconTintInternal((Float) animation.getAnimatedValue()); } }); mTintAnimator.setDuration(duration); @@ -327,17 +334,20 @@ public class StatusBarIconController { mTintAnimator.setInterpolator(mFastOutSlowIn); mTintAnimator.start(); } - private void setIconTintInternal(int tint) { - mIconTint = tint; + + private void setIconTintInternal(float darkIntensity) { + mDarkIntensity = darkIntensity; + mIconTint = (int) ArgbEvaluator.getInstance().evaluate(darkIntensity, + mLightModeIconColorSingleTone, mDarkModeIconColorSingleTone); applyIconTint(); } - private void deferIconTintChange(int tint) { - if (mTintChangePending && tint == mPendingIconTint) { + private void deferIconTintChange(float darkIntensity) { + if (mTintChangePending && darkIntensity == mPendingDarkIntensity) { return; } mTintChangePending = true; - mPendingIconTint = tint; + mPendingDarkIntensity = darkIntensity; } private void applyIconTint() { @@ -345,9 +355,9 @@ public class StatusBarIconController { StatusBarIconView v = (StatusBarIconView) mStatusIcons.getChildAt(i); v.setImageTintList(ColorStateList.valueOf(mIconTint)); } - mSignalCluster.setIconTint(mIconTint); + mSignalCluster.setIconTint(mIconTint, mDarkIntensity); mMoreIcon.setImageTintList(ColorStateList.valueOf(mIconTint)); - mBatteryMeterView.setIconTint(mIconTint); + mBatteryMeterView.setDarkIntensity(mDarkIntensity); mClock.setTextColor(mIconTint); applyNotificationIconsTint(); } @@ -358,7 +368,6 @@ public class StatusBarIconController { boolean isPreL = Boolean.TRUE.equals(v.getTag(R.id.icon_is_pre_L)); boolean colorize = !isPreL || isGrayscale(v); if (colorize) { - v.setImageTintMode(PorterDuff.Mode.SRC_ATOP); v.setImageTintList(ColorStateList.valueOf(mIconTint)); } } @@ -381,7 +390,7 @@ public class StatusBarIconController { public void appTransitionCancelled() { if (mTransitionPending && mTintChangePending) { mTintChangePending = false; - animateIconTint(mPendingIconTint, 0 /* delay */, DEFAULT_TINT_ANIMATION_DURATION); + animateIconTint(mPendingDarkIntensity, 0 /* delay */, DEFAULT_TINT_ANIMATION_DURATION); } mTransitionPending = false; } @@ -389,7 +398,7 @@ public class StatusBarIconController { public void appTransitionStarting(long startTime, long duration) { if (mTransitionPending && mTintChangePending) { mTintChangePending = false; - animateIconTint(mPendingIconTint, + animateIconTint(mPendingDarkIntensity, Math.max(0, startTime - SystemClock.uptimeMillis()), duration); |