From d37a5aa57bb1c5d958abe036b5558ba4dac270c5 Mon Sep 17 00:00:00 2001 From: d34d Date: Sun, 22 May 2016 10:40:04 -0700 Subject: 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 --- .../SystemUI/res/drawable/ic_battery_circle_frame.xml | 3 ++- .../res/drawable/ic_battery_landscape_frame.xml | 3 ++- .../res/drawable/ic_battery_portrait_frame.xml | 3 ++- .../src/com/android/systemui/BatteryMeterView.java | 19 +++++++++++++++---- 4 files changed, 21 insertions(+), 7 deletions(-) (limited to 'packages') 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"> + 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" /> + \ 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" /> + \ 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); -- cgit v1.1