diff --git a/packages/SettingsLib/res/values/arrays.xml b/packages/SettingsLib/res/values/arrays.xml index 59e5cfb204401..c926e1ff48a71 100644 --- a/packages/SettingsLib/res/values/arrays.xml +++ b/packages/SettingsLib/res/values/arrays.xml @@ -563,18 +563,18 @@ 0 334 + 30 50 - 110 - 115 - 165 - 1611 - 1111 - 1116 - 516 - 511 - 011 - 05 + 53 + 83 + 85 55 + 58 + 38 + 35 + 05 + 03 + 33 diff --git a/packages/SettingsLib/res/values/dimens.xml b/packages/SettingsLib/res/values/dimens.xml index cf4261c6bc914..aeb0a21b7d41a 100644 --- a/packages/SettingsLib/res/values/dimens.xml +++ b/packages/SettingsLib/res/values/dimens.xml @@ -57,6 +57,7 @@ 14.5dp 9.5dp + 1dp 2dp diff --git a/packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java b/packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java index 343191dd35fa3..5b8e1fc7f6f8a 100644 --- a/packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java +++ b/packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java @@ -24,9 +24,11 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.ColorFilter; import android.graphics.Paint; +import android.graphics.Paint.Style; import android.graphics.Path; import android.graphics.Path.Direction; import android.graphics.Path.FillType; +import android.graphics.Path.Op; import android.graphics.Rect; import android.graphics.RectF; import android.graphics.Typeface; @@ -49,6 +51,7 @@ public class BatteryMeterDrawableBase extends Drawable { protected final Paint mTextPaint; protected final Paint mBoltPaint; protected final Paint mPlusPaint; + protected final Paint mPowersavePaint; protected float mButtonHeightFraction; private int mLevel = -1; @@ -90,6 +93,7 @@ public class BatteryMeterDrawableBase extends Drawable { private final RectF mPlusFrame = new RectF(); private final Path mShapePath = new Path(); + private final Path mOutlinePath = new Path(); private final Path mTextPath = new Path(); public BatteryMeterDrawableBase(Context context, int frameColor) { @@ -155,6 +159,12 @@ public class BatteryMeterDrawableBase extends Drawable { mPlusPaint.setColor(Utils.getDefaultColor(mContext, R.color.batterymeter_plus_color)); mPlusPoints = loadPoints(res, R.array.batterymeter_plus_points); + mPowersavePaint = new Paint(Paint.ANTI_ALIAS_FLAG); + mPowersavePaint.setColor(mPlusPaint.getColor()); + mPowersavePaint.setStyle(Style.STROKE); + mPowersavePaint.setStrokeWidth(context.getResources() + .getDimensionPixelSize(R.dimen.battery_powersave_outline_thickness)); + mIntrinsicWidth = context.getResources().getDimensionPixelSize(R.dimen.battery_width); mIntrinsicHeight = context.getResources().getDimensionPixelSize(R.dimen.battery_height); } @@ -286,7 +296,9 @@ public class BatteryMeterDrawableBase extends Drawable { } protected int batteryColorForLevel(int level) { - return mCharging ? mChargeColor : getColorForLevel(level); + return (mCharging || (mPowerSaveEnabled && mPowerSaveAsColorError)) + ? mChargeColor + : getColorForLevel(level); } @Override @@ -331,10 +343,15 @@ public class BatteryMeterDrawableBase extends Drawable { // define the battery shape mShapePath.reset(); + mOutlinePath.reset(); final float radius = getRadiusRatio() * (mFrame.height() + buttonHeight); mShapePath.setFillType(FillType.WINDING); mShapePath.addRoundRect(mFrame, radius, radius, Direction.CW); mShapePath.addRect(mButtonFrame, Direction.CW); + mOutlinePath.addRoundRect(mFrame, radius, radius, Direction.CW); + Path p = new Path(); + p.addRect(mButtonFrame, Direction.CW); + mOutlinePath.op(p, Op.XOR); if (mCharging) { // define the bolt shape @@ -443,6 +460,11 @@ public class BatteryMeterDrawableBase extends Drawable { c.drawText(pctText, pctX, pctY, mTextPaint); } } + + // Draw the powersave outline last + if (!mCharging && mPowerSaveEnabled && mPowerSaveAsColorError) { + c.drawPath(mOutlinePath, mPowersavePaint); + } } // Some stuff required by Drawable. diff --git a/packages/SystemUI/res/layout/system_icons.xml b/packages/SystemUI/res/layout/system_icons.xml index 258b82aacb2e3..9237477f17e88 100644 --- a/packages/SystemUI/res/layout/system_icons.xml +++ b/packages/SystemUI/res/layout/system_icons.xml @@ -31,5 +31,6 @@ + android:clipToPadding="false" + android:clipChildren="false" /> \ No newline at end of file