Merge "Battery saver color changes" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
4ee9b14c14
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user