diff options
author | d34d <clark@cyngn.com> | 2016-05-22 10:40:04 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-05-23 14:22:50 -0700 |
commit | d37a5aa57bb1c5d958abe036b5558ba4dac270c5 (patch) | |
tree | 96b9cd3bebd11c2486d0e0d4412f0563b7ea4657 /packages | |
parent | 5953be013f1f3fe14b5f4176b743c4032e114bfc (diff) | |
download | frameworks_base-d37a5aa57bb1c5d958abe036b5558ba4dac270c5.zip frameworks_base-d37a5aa57bb1c5d958abe036b5558ba4dac270c5.tar.gz frameworks_base-d37a5aa57bb1c5d958abe036b5558ba4dac270c5.tar.bz2 |
SysUI: Fix coloring of frame and bolt
This patch should address issues with the frame and bolt being
incorrectly colored in dark/light scenarios. We also keep track
of the darkness intensity level so that it can be set when changing
meter modes.
Change-Id: Iaec8b88d39bbb7f6dbcbbf078c91d20b54ab29c8
Diffstat (limited to 'packages')
4 files changed, 21 insertions, 7 deletions
diff --git a/packages/SystemUI/res/drawable/ic_battery_circle_frame.xml b/packages/SystemUI/res/drawable/ic_battery_circle_frame.xml index 8528c00..675c030 100644 --- a/packages/SystemUI/res/drawable/ic_battery_circle_frame.xml +++ b/packages/SystemUI/res/drawable/ic_battery_circle_frame.xml @@ -20,9 +20,10 @@ android:viewportWidth="24" android:viewportHeight="24"> + <!-- Path will be tinted based on light/dark modes --> <path android:name="frame" - android:strokeColor="@color/batterymeter_frame_color" + android:strokeColor="#000000" android:strokeLineJoin="round" android:strokeWidth="3" android:pathData="@string/battery_circle_path"/> diff --git a/packages/SystemUI/res/drawable/ic_battery_landscape_frame.xml b/packages/SystemUI/res/drawable/ic_battery_landscape_frame.xml index 789316f..bb66797 100644 --- a/packages/SystemUI/res/drawable/ic_battery_landscape_frame.xml +++ b/packages/SystemUI/res/drawable/ic_battery_landscape_frame.xml @@ -24,8 +24,9 @@ android:name="mask" android:pathData="@string/battery_landscape_clip_path" /> + <!-- Path will be tinted based on light/dark modes --> <path android:name="frame" - android:fillColor="@color/batterymeter_frame_color" + android:fillColor="#000000" android:pathData="M 1 4 H 25 V 20 H 1 V 4 Z" /> </vector>
\ No newline at end of file diff --git a/packages/SystemUI/res/drawable/ic_battery_portrait_frame.xml b/packages/SystemUI/res/drawable/ic_battery_portrait_frame.xml index f530727..6bf92fb 100644 --- a/packages/SystemUI/res/drawable/ic_battery_portrait_frame.xml +++ b/packages/SystemUI/res/drawable/ic_battery_portrait_frame.xml @@ -24,9 +24,10 @@ android:name="mask" android:pathData="@string/battery_portrait_clip_path" /> + <!-- Path will be tinted based on light/dark modes --> <path android:name="frame" - android:fillColor="@color/batterymeter_frame_color" + android:fillColor="#000000" android:pathData="M19,2v19H5V2H19z" /> </vector>
\ No newline at end of file diff --git a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java index 7440fc5..06c2957 100755 --- a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java +++ b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java @@ -94,6 +94,9 @@ public class BatteryMeterView extends View implements DemoMode, private BatteryMeterDrawable mBatteryMeterDrawable; private int mIconTint = Color.WHITE; + private int mCurrentBackgroundColor = 0; + private int mCurrentFillColor = 0; + protected class BatteryTracker extends BroadcastReceiver { public static final int UNKNOWN_LEVEL = -1; @@ -395,9 +398,9 @@ public class BatteryMeterView extends View implements DemoMode, public void setDarkIntensity(float darkIntensity) { if (mBatteryMeterDrawable != null) { - int backgroundColor = getBackgroundColor(darkIntensity); - int fillColor = getFillColor(darkIntensity); - mBatteryMeterDrawable.setDarkIntensity(backgroundColor, fillColor); + mCurrentBackgroundColor = getBackgroundColor(darkIntensity); + mCurrentFillColor = getFillColor(darkIntensity); + mBatteryMeterDrawable.setDarkIntensity(mCurrentBackgroundColor, mCurrentFillColor); } } @@ -511,6 +514,9 @@ public class BatteryMeterView extends View implements DemoMode, mTextAndBoltPaint.setTypeface(font); mTextAndBoltPaint.setTextAlign(getPaintAlignmentFromGravity(mTextGravity)); mTextAndBoltPaint.setXfermode(new PorterDuffXfermode(xferMode)); + mTextAndBoltPaint.setColor(mCurrentFillColor != 0 + ? mCurrentFillColor + : res.getColor(R.color.batterymeter_bolt_color)); mWarningTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mWarningTextPaint.setColor(mColors[1]); @@ -544,7 +550,9 @@ public class BatteryMeterView extends View implements DemoMode, @Override public void setDarkIntensity(int backgroundColor, int fillColor) { mIconTint = fillColor; - mBoltDrawable.setTint(fillColor); + // Make bolt fully opaque for increased visibility + mBoltDrawable.setTint(0xff000000 | fillColor); + mFrameDrawable.setTint(backgroundColor); updateBoltDrawableLayer(mBatteryDrawable, mBoltDrawable); invalidate(); } @@ -628,6 +636,9 @@ public class BatteryMeterView extends View implements DemoMode, int drawableResId = getBatteryDrawableResourceForMode(mode); mBatteryDrawable = (LayerDrawable) res.getDrawable(drawableResId); mFrameDrawable = mBatteryDrawable.findDrawableByLayerId(R.id.battery_frame); + mFrameDrawable.setTint(mCurrentBackgroundColor != 0 + ? mCurrentBackgroundColor + : res.getColor(R.color.batterymeter_frame_color)); // set the animated vector drawable we will be stop animating Drawable levelDrawable = mBatteryDrawable.findDrawableByLayerId(R.id.battery_fill); mLevelDrawable = new StopMotionVectorDrawable(levelDrawable); |