Loading packages/SettingsLib/res/color/batterymeter_plus_color.xml 0 → 100644 +18 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2018 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:color="?android:attr/colorError" /> </selector> packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java +14 −11 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ public class BatteryMeterDrawableBase extends Drawable { private int mLevel = -1; private boolean mCharging; private boolean mPowerSaveEnabled; private boolean mPowerSaveAsColorError = true; private boolean mShowPercent; private static final boolean SINGLE_DIGIT_PERCENT = false; Loading Loading @@ -150,7 +151,8 @@ public class BatteryMeterDrawableBase extends Drawable { mBoltPaint.setColor(Utils.getDefaultColor(mContext, R.color.batterymeter_bolt_color)); mBoltPoints = loadPoints(res, R.array.batterymeter_bolt_points); mPlusPaint = new Paint(mBoltPaint); mPlusPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPlusPaint.setColor(Utils.getDefaultColor(mContext, R.color.batterymeter_plus_color)); mPlusPoints = loadPoints(res, R.array.batterymeter_plus_points); mIntrinsicWidth = context.getResources().getDimensionPixelSize(R.dimen.battery_width); Loading Loading @@ -195,6 +197,10 @@ public class BatteryMeterDrawableBase extends Drawable { postInvalidate(); } protected void setPowerSaveAsColorError(boolean asError) { mPowerSaveAsColorError = asError; } // an approximation of View.postInvalidate() protected void postInvalidate() { unscheduleSelf(this::invalidateSelf); Loading Loading @@ -254,10 +260,6 @@ public class BatteryMeterDrawableBase extends Drawable { } private int getColorForLevel(int percent) { // If we are in power save mode, always use the normal color. if (mPowerSaveEnabled) { return mIconTint; } int thresh, color = 0; for (int i = 0; i < mColors.length; i += 2) { thresh = mColors[i]; Loading @@ -279,7 +281,6 @@ public class BatteryMeterDrawableBase extends Drawable { mIconTint = fillColor; mFramePaint.setColor(backgroundColor); mBoltPaint.setColor(fillColor); mPlusPaint.setColor(fillColor); mChargeColor = fillColor; invalidateSelf(); } Loading Loading @@ -392,14 +393,16 @@ public class BatteryMeterDrawableBase extends Drawable { mPlusFrame.top + mPlusPoints[1] * mPlusFrame.height()); } float boltPct = (mPlusFrame.bottom - levelTop) / (mPlusFrame.bottom - mPlusFrame.top); boltPct = Math.min(Math.max(boltPct, 0), 1); if (boltPct <= BOLT_LEVEL_THRESHOLD) { // draw the bolt if opaque float fillPct = (mPlusFrame.bottom - levelTop) / (mPlusFrame.bottom - mPlusFrame.top); fillPct = Math.min(Math.max(fillPct, 0), 1); if (fillPct <= BOLT_LEVEL_THRESHOLD) { // draw the plus if opaque c.drawPath(mPlusPath, mPlusPaint); } else { // otherwise cut the bolt out of the overall shape mShapePath.op(mPlusPath, Path.Op.DIFFERENCE); if (mPowerSaveAsColorError) { c.drawPath(mPlusPath, mPlusPaint); } } } Loading packages/SystemUI/src/com/android/systemui/qs/tiles/BatterySaverTile.java +1 −0 Original line number Diff line number Diff line Loading @@ -129,6 +129,7 @@ public class BatterySaverTile extends QSTileImpl<BooleanState> implements super.setBatteryLevel(MAX_BATTERY); setPowerSave(true); setCharging(false); setPowerSaveAsColorError(false); } @Override Loading Loading
packages/SettingsLib/res/color/batterymeter_plus_color.xml 0 → 100644 +18 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="utf-8"?> <!-- Copyright (C) 2018 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:color="?android:attr/colorError" /> </selector>
packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java +14 −11 Original line number Diff line number Diff line Loading @@ -54,6 +54,7 @@ public class BatteryMeterDrawableBase extends Drawable { private int mLevel = -1; private boolean mCharging; private boolean mPowerSaveEnabled; private boolean mPowerSaveAsColorError = true; private boolean mShowPercent; private static final boolean SINGLE_DIGIT_PERCENT = false; Loading Loading @@ -150,7 +151,8 @@ public class BatteryMeterDrawableBase extends Drawable { mBoltPaint.setColor(Utils.getDefaultColor(mContext, R.color.batterymeter_bolt_color)); mBoltPoints = loadPoints(res, R.array.batterymeter_bolt_points); mPlusPaint = new Paint(mBoltPaint); mPlusPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPlusPaint.setColor(Utils.getDefaultColor(mContext, R.color.batterymeter_plus_color)); mPlusPoints = loadPoints(res, R.array.batterymeter_plus_points); mIntrinsicWidth = context.getResources().getDimensionPixelSize(R.dimen.battery_width); Loading Loading @@ -195,6 +197,10 @@ public class BatteryMeterDrawableBase extends Drawable { postInvalidate(); } protected void setPowerSaveAsColorError(boolean asError) { mPowerSaveAsColorError = asError; } // an approximation of View.postInvalidate() protected void postInvalidate() { unscheduleSelf(this::invalidateSelf); Loading Loading @@ -254,10 +260,6 @@ public class BatteryMeterDrawableBase extends Drawable { } private int getColorForLevel(int percent) { // If we are in power save mode, always use the normal color. if (mPowerSaveEnabled) { return mIconTint; } int thresh, color = 0; for (int i = 0; i < mColors.length; i += 2) { thresh = mColors[i]; Loading @@ -279,7 +281,6 @@ public class BatteryMeterDrawableBase extends Drawable { mIconTint = fillColor; mFramePaint.setColor(backgroundColor); mBoltPaint.setColor(fillColor); mPlusPaint.setColor(fillColor); mChargeColor = fillColor; invalidateSelf(); } Loading Loading @@ -392,14 +393,16 @@ public class BatteryMeterDrawableBase extends Drawable { mPlusFrame.top + mPlusPoints[1] * mPlusFrame.height()); } float boltPct = (mPlusFrame.bottom - levelTop) / (mPlusFrame.bottom - mPlusFrame.top); boltPct = Math.min(Math.max(boltPct, 0), 1); if (boltPct <= BOLT_LEVEL_THRESHOLD) { // draw the bolt if opaque float fillPct = (mPlusFrame.bottom - levelTop) / (mPlusFrame.bottom - mPlusFrame.top); fillPct = Math.min(Math.max(fillPct, 0), 1); if (fillPct <= BOLT_LEVEL_THRESHOLD) { // draw the plus if opaque c.drawPath(mPlusPath, mPlusPaint); } else { // otherwise cut the bolt out of the overall shape mShapePath.op(mPlusPath, Path.Op.DIFFERENCE); if (mPowerSaveAsColorError) { c.drawPath(mPlusPath, mPlusPaint); } } } Loading
packages/SystemUI/src/com/android/systemui/qs/tiles/BatterySaverTile.java +1 −0 Original line number Diff line number Diff line Loading @@ -129,6 +129,7 @@ public class BatterySaverTile extends QSTileImpl<BooleanState> implements super.setBatteryLevel(MAX_BATTERY); setPowerSave(true); setCharging(false); setPowerSaveAsColorError(false); } @Override Loading