am 91949b20: Merge "New battery meter view bolt shape + color." into klp-dev
* commit '91949b20c9e430eaba8cf2cf21abe403eb298a94': New battery meter view bolt shape + color.
|
Before Width: | Height: | Size: 724 B After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 757 B After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 757 B After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 803 B After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 808 B After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 809 B After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 794 B After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 783 B After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 593 B After Width: | Height: | Size: 872 B |
|
Before Width: | Height: | Size: 594 B After Width: | Height: | Size: 756 B |
|
Before Width: | Height: | Size: 606 B After Width: | Height: | Size: 865 B |
|
Before Width: | Height: | Size: 628 B After Width: | Height: | Size: 859 B |
|
Before Width: | Height: | Size: 626 B After Width: | Height: | Size: 829 B |
|
Before Width: | Height: | Size: 648 B After Width: | Height: | Size: 828 B |
|
Before Width: | Height: | Size: 624 B After Width: | Height: | Size: 800 B |
|
Before Width: | Height: | Size: 618 B After Width: | Height: | Size: 781 B |
|
Before Width: | Height: | Size: 904 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 968 B After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 996 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 981 B After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1004 B After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.9 KiB |
@@ -95,12 +95,12 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<!-- battery must be padded below by 1px to match assets -->
|
||||
<!-- battery must be padded below by 2px to match assets -->
|
||||
<com.android.systemui.BatteryMeterView
|
||||
android:id="@+id/battery"
|
||||
android:layout_height="16dp"
|
||||
android:layout_width="10dp"
|
||||
android:paddingBottom="1px"
|
||||
android:layout_width="10.5dp"
|
||||
android:layout_marginBottom="2px"
|
||||
android:layout_marginStart="4dip"
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
@@ -52,13 +52,12 @@
|
||||
<item>#FFFFFFFF</item>
|
||||
</array>
|
||||
<array name="batterymeter_bolt_points">
|
||||
<item>88</item> <item>0</item>
|
||||
<item>459</item><item>1</item>
|
||||
<item>238</item><item>333</item>
|
||||
<item>525</item><item>310</item>
|
||||
<item>120</item><item>840</item>
|
||||
<item>82</item> <item>818</item>
|
||||
<item>246</item><item>373</item>
|
||||
<item>0</item> <item>408</item>
|
||||
<item>73</item> <item>0</item>
|
||||
<item>392</item><item>0</item>
|
||||
<item>201</item><item>259</item>
|
||||
<item>442</item><item>259</item>
|
||||
<item>4</item> <item>703</item>
|
||||
<item>157</item><item>334</item>
|
||||
<item>0</item> <item>334</item>
|
||||
</array>
|
||||
</resources>
|
||||
|
||||
@@ -35,5 +35,6 @@
|
||||
<color name="notification_panel_scrim_color">#B0000000</color>
|
||||
<color name="batterymeter_frame_color">#66FFFFFF</color><!-- 40% white -->
|
||||
<color name="batterymeter_charge_color">#FFFFFFFF</color>
|
||||
<color name="batterymeter_bolt_color">#B2000000</color><!-- 70% black -->
|
||||
<color name="status_bar_clock_color">#FFFFFFFF</color>
|
||||
</resources>
|
||||
|
||||
@@ -47,6 +47,8 @@ public class BatteryMeterView extends View implements DemoMode {
|
||||
public static final int FULL = 96;
|
||||
public static final int EMPTY = 4;
|
||||
|
||||
public static final float SUBPIXEL = 0.4f; // inset rects for softer edges
|
||||
|
||||
int[] mColors;
|
||||
|
||||
boolean mShowPercent = true;
|
||||
@@ -186,8 +188,15 @@ public class BatteryMeterView extends View implements DemoMode {
|
||||
|
||||
mFramePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
mFramePaint.setColor(res.getColor(R.color.batterymeter_frame_color));
|
||||
mFramePaint.setDither(true);
|
||||
mFramePaint.setStrokeWidth(0);
|
||||
mFramePaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||
mFramePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_ATOP));
|
||||
|
||||
mBatteryPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
mBatteryPaint.setColor(0xFF00FF00); // will be replaced by something from mColors
|
||||
mBatteryPaint.setDither(true);
|
||||
mBatteryPaint.setStrokeWidth(0);
|
||||
mBatteryPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||
|
||||
mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
mTextPaint.setColor(0xFFFFFFFF);
|
||||
@@ -205,9 +214,9 @@ public class BatteryMeterView extends View implements DemoMode {
|
||||
|
||||
mBoltPaint = new Paint();
|
||||
mBoltPaint.setAntiAlias(true);
|
||||
mBoltPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); // punch hole
|
||||
setLayerType(LAYER_TYPE_HARDWARE, null);
|
||||
mBoltPaint.setColor(res.getColor(R.color.batterymeter_bolt_color));
|
||||
mBoltPoints = loadBoltPoints(res);
|
||||
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
}
|
||||
|
||||
private static float[] loadBoltPoints(Resources res) {
|
||||
@@ -264,16 +273,23 @@ public class BatteryMeterView extends View implements DemoMode {
|
||||
mFrame.left + width * 0.25f,
|
||||
mFrame.top,
|
||||
mFrame.right - width * 0.25f,
|
||||
mFrame.top + mButtonHeight);
|
||||
mFrame.top + mButtonHeight + 5 /*cover frame border of intersecting area*/);
|
||||
|
||||
mButtonFrame.top += SUBPIXEL;
|
||||
mButtonFrame.left += SUBPIXEL;
|
||||
mButtonFrame.right -= SUBPIXEL;
|
||||
|
||||
mFrame.top += mButtonHeight;
|
||||
mFrame.left += SUBPIXEL;
|
||||
mFrame.top += SUBPIXEL;
|
||||
mFrame.right -= SUBPIXEL;
|
||||
mFrame.bottom -= SUBPIXEL;
|
||||
|
||||
// first, draw the battery shape
|
||||
c.drawRect(mFrame, mFramePaint);
|
||||
|
||||
// fill 'er up
|
||||
final int pct = tracker.level;
|
||||
final int color = tracker.plugged ? mChargeColor : getColorForLevel(pct);
|
||||
final int color = tracker.plugged ? mChargeColor : getColorForLevel(level);
|
||||
mBatteryPaint.setColor(color);
|
||||
|
||||
if (level >= FULL) {
|
||||
@@ -294,10 +310,10 @@ public class BatteryMeterView extends View implements DemoMode {
|
||||
|
||||
if (tracker.plugged) {
|
||||
// draw the bolt
|
||||
final int bl = (int)(mFrame.left + width / 4f);
|
||||
final int bt = (int)(mFrame.top + height / 6f);
|
||||
final int br = (int)(mFrame.right - width / 5f);
|
||||
final int bb = (int)(mFrame.bottom - height / 6f);
|
||||
final int bl = (int)(mFrame.left + mFrame.width() / 4.5f);
|
||||
final int bt = (int)(mFrame.top + mFrame.height() / 6f);
|
||||
final int br = (int)(mFrame.right - mFrame.width() / 7f);
|
||||
final int bb = (int)(mFrame.bottom - mFrame.height() / 10f);
|
||||
if (mBoltFrame.left != bl || mBoltFrame.top != bt
|
||||
|| mBoltFrame.right != br || mBoltFrame.bottom != bb) {
|
||||
mBoltFrame.set(bl, bt, br, bb);
|
||||
@@ -325,7 +341,7 @@ public class BatteryMeterView extends View implements DemoMode {
|
||||
: (tracker.level == 100 ? 0.38f : 0.5f)));
|
||||
mTextHeight = -mTextPaint.getFontMetrics().ascent;
|
||||
|
||||
final String str = String.valueOf(SINGLE_DIGIT_PERCENT ? (pct/10) : pct);
|
||||
final String str = String.valueOf(SINGLE_DIGIT_PERCENT ? (level/10) : level);
|
||||
final float x = mWidth * 0.5f;
|
||||
final float y = (mHeight + mTextHeight) * 0.47f;
|
||||
c.drawText(str,
|
||||
|
||||