Merge "Battery saver color changes" into pi-dev
diff --git a/packages/SettingsLib/res/values/arrays.xml b/packages/SettingsLib/res/values/arrays.xml
index 59e5cfb..c926e1f 100644
--- a/packages/SettingsLib/res/values/arrays.xml
+++ b/packages/SettingsLib/res/values/arrays.xml
@@ -563,18 +563,18 @@
<item>0</item> <item>334</item>
</array>
<array name="batterymeter_plus_points">
+ <item>3</item><item>0</item>
<item>5</item><item>0</item>
- <item>11</item><item>0</item>
- <item>11</item><item>5</item>
- <item>16</item><item>5</item>
- <item>16</item><item>11</item>
- <item>11</item><item>11</item>
- <item>11</item><item>16</item>
- <item>5</item><item>16</item>
- <item>5</item><item>11</item>
- <item>0</item><item>11</item>
- <item>0</item><item>5</item>
+ <item>5</item><item>3</item>
+ <item>8</item><item>3</item>
+ <item>8</item><item>5</item>
<item>5</item><item>5</item>
+ <item>5</item><item>8</item>
+ <item>3</item><item>8</item>
+ <item>3</item><item>5</item>
+ <item>0</item><item>5</item>
+ <item>0</item><item>3</item>
+ <item>3</item><item>3</item>
</array>
</resources>
diff --git a/packages/SettingsLib/res/values/dimens.xml b/packages/SettingsLib/res/values/dimens.xml
index cf4261c..aeb0a21 100644
--- a/packages/SettingsLib/res/values/dimens.xml
+++ b/packages/SettingsLib/res/values/dimens.xml
@@ -57,6 +57,7 @@
<dimen name="battery_height">14.5dp</dimen>
<dimen name="battery_width">9.5dp</dimen>
+ <dimen name="battery_powersave_outline_thickness">1dp</dimen>
<dimen name="bt_battery_padding">2dp</dimen>
diff --git a/packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java b/packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java
index 343191d..5b8e1fc 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.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 @@
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 @@
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 @@
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 @@
}
protected int batteryColorForLevel(int level) {
- return mCharging ? mChargeColor : getColorForLevel(level);
+ return (mCharging || (mPowerSaveEnabled && mPowerSaveAsColorError))
+ ? mChargeColor
+ : getColorForLevel(level);
}
@Override
@@ -331,10 +343,15 @@
// 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 @@
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 258b82a..9237477 100644
--- a/packages/SystemUI/res/layout/system_icons.xml
+++ b/packages/SystemUI/res/layout/system_icons.xml
@@ -31,5 +31,6 @@
<com.android.systemui.BatteryMeterView android:id="@+id/battery"
android:layout_height="match_parent"
android:layout_width="wrap_content"
- />
+ android:clipToPadding="false"
+ android:clipChildren="false" />
</LinearLayout>
\ No newline at end of file