blob: 4fe9d56a4179e82005d551dd37143cb350b48855 [file] [log] [blame]
jackqdyulei597b10f2017-01-27 13:31:40 -08001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.settingslib.graph;
18
jackqdyulei597b10f2017-01-27 13:31:40 -080019import android.annotation.Nullable;
20import android.content.Context;
21import android.content.res.Resources;
22import android.content.res.TypedArray;
23import android.graphics.Canvas;
24import android.graphics.Color;
25import android.graphics.ColorFilter;
26import android.graphics.Paint;
27import android.graphics.Path;
Jason Monk6a600b82017-04-03 15:08:42 -040028import android.graphics.Path.Direction;
29import android.graphics.Path.FillType;
Evan Laird6f4179c2017-06-23 16:05:33 -040030import android.graphics.Rect;
jackqdyulei597b10f2017-01-27 13:31:40 -080031import android.graphics.RectF;
32import android.graphics.Typeface;
33import android.graphics.drawable.Drawable;
Jason Monk58be7a62017-02-01 20:17:51 -050034import android.util.TypedValue;
35
jackqdyulei597b10f2017-01-27 13:31:40 -080036import com.android.settingslib.R;
37import com.android.settingslib.Utils;
38
39public class BatteryMeterDrawableBase extends Drawable {
40
Jason Monk6a600b82017-04-03 15:08:42 -040041 private static final float ASPECT_RATIO = .58f;
jackqdyulei597b10f2017-01-27 13:31:40 -080042 public static final String TAG = BatteryMeterDrawableBase.class.getSimpleName();
Evan Laird706d9682017-05-30 15:03:29 -040043 private static final float RADIUS_RATIO = 1.0f / 17f;
jackqdyulei597b10f2017-01-27 13:31:40 -080044
45 protected final Context mContext;
jackqdyuleiff5bd942017-04-04 10:54:21 -070046 protected final Paint mFramePaint;
47 protected final Paint mBatteryPaint;
48 protected final Paint mWarningTextPaint;
49 protected final Paint mTextPaint;
50 protected final Paint mBoltPaint;
51 protected final Paint mPlusPaint;
jackqdyuleid94a9382017-08-09 09:57:05 -070052 protected float mButtonHeightFraction;
jackqdyulei597b10f2017-01-27 13:31:40 -080053
Dan Sandler6aa6e6e2017-02-07 19:12:25 -080054 private int mLevel = -1;
jackqdyuleiff5bd942017-04-04 10:54:21 -070055 private boolean mCharging;
Dan Sandler6aa6e6e2017-02-07 19:12:25 -080056 private boolean mPowerSaveEnabled;
57 private boolean mShowPercent;
jackqdyulei597b10f2017-01-27 13:31:40 -080058
59 private static final boolean SINGLE_DIGIT_PERCENT = false;
60
61 private static final int FULL = 96;
62
63 private static final float BOLT_LEVEL_THRESHOLD = 0.3f; // opaque bolt below this fraction
64
65 private final int[] mColors;
66 private final int mIntrinsicWidth;
67 private final int mIntrinsicHeight;
68
jackqdyulei597b10f2017-01-27 13:31:40 -080069 private float mSubpixelSmoothingLeft;
70 private float mSubpixelSmoothingRight;
jackqdyulei597b10f2017-01-27 13:31:40 -080071 private float mTextHeight, mWarningTextHeight;
72 private int mIconTint = Color.WHITE;
Jason Monkd866b8a2017-03-29 15:30:44 -040073 private float mOldDarkIntensity = -1f;
jackqdyulei597b10f2017-01-27 13:31:40 -080074
75 private int mHeight;
76 private int mWidth;
77 private String mWarningString;
78 private final int mCriticalLevel;
79 private int mChargeColor;
80 private final float[] mBoltPoints;
81 private final Path mBoltPath = new Path();
82 private final float[] mPlusPoints;
83 private final Path mPlusPath = new Path();
84
Evan Laird6f4179c2017-06-23 16:05:33 -040085 private final Rect mPadding = new Rect();
jackqdyulei597b10f2017-01-27 13:31:40 -080086 private final RectF mFrame = new RectF();
87 private final RectF mButtonFrame = new RectF();
88 private final RectF mBoltFrame = new RectF();
89 private final RectF mPlusFrame = new RectF();
90
91 private final Path mShapePath = new Path();
jackqdyulei597b10f2017-01-27 13:31:40 -080092 private final Path mTextPath = new Path();
93
jackqdyulei597b10f2017-01-27 13:31:40 -080094 public BatteryMeterDrawableBase(Context context, int frameColor) {
95 mContext = context;
96 final Resources res = context.getResources();
97 TypedArray levels = res.obtainTypedArray(R.array.batterymeter_color_levels);
98 TypedArray colors = res.obtainTypedArray(R.array.batterymeter_color_values);
99
100 final int N = levels.length();
101 mColors = new int[2 * N];
jackqdyuleiaf68d722017-11-07 14:24:49 -0800102 for (int i = 0; i < N; i++) {
jackqdyulei597b10f2017-01-27 13:31:40 -0800103 mColors[2 * i] = levels.getInt(i, 0);
Jason Monk58be7a62017-02-01 20:17:51 -0500104 if (colors.getType(i) == TypedValue.TYPE_ATTRIBUTE) {
Jason Monk7c8564e2017-03-29 15:21:36 -0400105 mColors[2 * i + 1] = Utils.getColorAttr(context, colors.getThemeAttributeId(i, 0));
Jason Monk58be7a62017-02-01 20:17:51 -0500106 } else {
107 mColors[2 * i + 1] = colors.getColor(i, 0);
108 }
jackqdyulei597b10f2017-01-27 13:31:40 -0800109 }
110 levels.recycle();
111 colors.recycle();
Dan Sandler6aa6e6e2017-02-07 19:12:25 -0800112
jackqdyulei597b10f2017-01-27 13:31:40 -0800113 mWarningString = context.getString(R.string.battery_meter_very_low_overlay_symbol);
114 mCriticalLevel = mContext.getResources().getInteger(
115 com.android.internal.R.integer.config_criticalBatteryWarningLevel);
116 mButtonHeightFraction = context.getResources().getFraction(
117 R.fraction.battery_button_height_fraction, 1, 1);
118 mSubpixelSmoothingLeft = context.getResources().getFraction(
119 R.fraction.battery_subpixel_smoothing_left, 1, 1);
120 mSubpixelSmoothingRight = context.getResources().getFraction(
121 R.fraction.battery_subpixel_smoothing_right, 1, 1);
122
123 mFramePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
124 mFramePaint.setColor(frameColor);
125 mFramePaint.setDither(true);
126 mFramePaint.setStrokeWidth(0);
127 mFramePaint.setStyle(Paint.Style.FILL_AND_STROKE);
128
129 mBatteryPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
130 mBatteryPaint.setDither(true);
131 mBatteryPaint.setStrokeWidth(0);
132 mBatteryPaint.setStyle(Paint.Style.FILL_AND_STROKE);
133
134 mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
135 Typeface font = Typeface.create("sans-serif-condensed", Typeface.BOLD);
136 mTextPaint.setTypeface(font);
137 mTextPaint.setTextAlign(Paint.Align.CENTER);
138
139 mWarningTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
140 font = Typeface.create("sans-serif", Typeface.BOLD);
141 mWarningTextPaint.setTypeface(font);
142 mWarningTextPaint.setTextAlign(Paint.Align.CENTER);
143 if (mColors.length > 1) {
144 mWarningTextPaint.setColor(mColors[1]);
145 }
146
Daniel Nishi8af93cb2017-05-15 14:37:20 -0700147 mChargeColor = Utils.getDefaultColor(mContext, R.color.meter_consumed_color);
jackqdyulei597b10f2017-01-27 13:31:40 -0800148
149 mBoltPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
150 mBoltPaint.setColor(Utils.getDefaultColor(mContext, R.color.batterymeter_bolt_color));
Dan Sandler6aa6e6e2017-02-07 19:12:25 -0800151 mBoltPoints = loadPoints(res, R.array.batterymeter_bolt_points);
jackqdyulei597b10f2017-01-27 13:31:40 -0800152
153 mPlusPaint = new Paint(mBoltPaint);
Dan Sandler6aa6e6e2017-02-07 19:12:25 -0800154 mPlusPoints = loadPoints(res, R.array.batterymeter_plus_points);
jackqdyulei597b10f2017-01-27 13:31:40 -0800155
jackqdyulei597b10f2017-01-27 13:31:40 -0800156 mIntrinsicWidth = context.getResources().getDimensionPixelSize(R.dimen.battery_width);
157 mIntrinsicHeight = context.getResources().getDimensionPixelSize(R.dimen.battery_height);
158 }
159
160 @Override
161 public int getIntrinsicHeight() {
162 return mIntrinsicHeight;
163 }
164
165 @Override
166 public int getIntrinsicWidth() {
167 return mIntrinsicWidth;
168 }
169
Dan Sandler6aa6e6e2017-02-07 19:12:25 -0800170 public void setShowPercent(boolean show) {
171 mShowPercent = show;
jackqdyulei597b10f2017-01-27 13:31:40 -0800172 postInvalidate();
173 }
174
jackqdyuleiff5bd942017-04-04 10:54:21 -0700175 public void setCharging(boolean val) {
176 mCharging = val;
Dan Sandler6aa6e6e2017-02-07 19:12:25 -0800177 postInvalidate();
178 }
179
jackqdyuleiff5bd942017-04-04 10:54:21 -0700180 public boolean getCharging() {
181 return mCharging;
182 }
183
Dan Sandler6aa6e6e2017-02-07 19:12:25 -0800184 public void setBatteryLevel(int val) {
185 mLevel = val;
186 postInvalidate();
187 }
188
jackqdyuleiff5bd942017-04-04 10:54:21 -0700189 public int getBatteryLevel() {
190 return mLevel;
191 }
192
Dan Sandler6aa6e6e2017-02-07 19:12:25 -0800193 public void setPowerSave(boolean val) {
194 mPowerSaveEnabled = val;
195 postInvalidate();
196 }
197
198 // an approximation of View.postInvalidate()
jackqdyulei597b10f2017-01-27 13:31:40 -0800199 protected void postInvalidate() {
Dan Sandler6aa6e6e2017-02-07 19:12:25 -0800200 unscheduleSelf(this::invalidateSelf);
jackqdyulei597b10f2017-01-27 13:31:40 -0800201 scheduleSelf(this::invalidateSelf, 0);
202 }
203
Dan Sandler6aa6e6e2017-02-07 19:12:25 -0800204 private static float[] loadPoints(Resources res, int pointArrayRes) {
205 final int[] pts = res.getIntArray(pointArrayRes);
jackqdyulei597b10f2017-01-27 13:31:40 -0800206 int maxX = 0, maxY = 0;
207 for (int i = 0; i < pts.length; i += 2) {
208 maxX = Math.max(maxX, pts[i]);
209 maxY = Math.max(maxY, pts[i + 1]);
210 }
211 final float[] ptsF = new float[pts.length];
212 for (int i = 0; i < pts.length; i += 2) {
213 ptsF[i] = (float) pts[i] / maxX;
214 ptsF[i + 1] = (float) pts[i + 1] / maxY;
215 }
216 return ptsF;
217 }
218
219 @Override
220 public void setBounds(int left, int top, int right, int bottom) {
221 super.setBounds(left, top, right, bottom);
Evan Laird6f4179c2017-06-23 16:05:33 -0400222 updateSize();
223 }
224
225 private void updateSize() {
226 final Rect bounds = getBounds();
227
228 mHeight = (bounds.bottom - mPadding.bottom) - (bounds.top + mPadding.top);
229 mWidth = (bounds.right - mPadding.right) - (bounds.left + mPadding.left);
jackqdyulei597b10f2017-01-27 13:31:40 -0800230 mWarningTextPaint.setTextSize(mHeight * 0.75f);
231 mWarningTextHeight = -mWarningTextPaint.getFontMetrics().ascent;
232 }
233
Evan Laird6f4179c2017-06-23 16:05:33 -0400234 @Override
235 public boolean getPadding(Rect padding) {
236 if (mPadding.left == 0
237 && mPadding.top == 0
238 && mPadding.right == 0
239 && mPadding.bottom == 0) {
240 return super.getPadding(padding);
241 }
242
243 padding.set(mPadding);
244 return true;
245 }
246
247 public void setPadding(int left, int top, int right, int bottom) {
248 mPadding.left = left;
249 mPadding.top = top;
250 mPadding.right = right;
251 mPadding.bottom = bottom;
252
253 updateSize();
254 }
255
jackqdyulei597b10f2017-01-27 13:31:40 -0800256 private int getColorForLevel(int percent) {
257 // If we are in power save mode, always use the normal color.
258 if (mPowerSaveEnabled) {
Jason Monkbb769052017-05-10 10:39:16 -0400259 return mIconTint;
jackqdyulei597b10f2017-01-27 13:31:40 -0800260 }
261 int thresh, color = 0;
262 for (int i = 0; i < mColors.length; i += 2) {
263 thresh = mColors[i];
264 color = mColors[i + 1];
265 if (percent <= thresh) {
266
267 // Respect tinting for "normal" level
268 if (i == mColors.length - 2) {
269 return mIconTint;
270 } else {
271 return color;
272 }
273 }
274 }
275 return color;
276 }
277
jackqdyulei597b10f2017-01-27 13:31:40 -0800278 public void setColors(int fillColor, int backgroundColor) {
279 mIconTint = fillColor;
280 mFramePaint.setColor(backgroundColor);
281 mBoltPaint.setColor(fillColor);
Evan Lairde955df12017-06-27 15:32:56 -0400282 mPlusPaint.setColor(fillColor);
jackqdyulei597b10f2017-01-27 13:31:40 -0800283 mChargeColor = fillColor;
284 invalidateSelf();
285 }
286
Evan Laird6f4179c2017-06-23 16:05:33 -0400287 protected int batteryColorForLevel(int level) {
288 return mCharging ? mChargeColor : getColorForLevel(level);
289 }
290
jackqdyulei597b10f2017-01-27 13:31:40 -0800291 @Override
292 public void draw(Canvas c) {
293 final int level = mLevel;
jackqdyulei98b7fdb2017-09-06 16:38:23 -0700294 final Rect bounds = getBounds();
jackqdyulei597b10f2017-01-27 13:31:40 -0800295
296 if (level == -1) return;
297
298 float drawFrac = (float) level / 100f;
299 final int height = mHeight;
jackqdyuleid94a9382017-08-09 09:57:05 -0700300 final int width = (int) (getAspectRatio() * mHeight);
Evan Laird6f4179c2017-06-23 16:05:33 -0400301 final int px = (mWidth - width) / 2;
Jason Monk6a600b82017-04-03 15:08:42 -0400302 final int buttonHeight = Math.round(height * mButtonHeightFraction);
jackqdyulei98b7fdb2017-09-06 16:38:23 -0700303 final int left = mPadding.left + bounds.left;
304 final int top = bounds.bottom - mPadding.bottom - height;
jackqdyulei597b10f2017-01-27 13:31:40 -0800305
jackqdyulei98b7fdb2017-09-06 16:38:23 -0700306 mFrame.set(left, top, width + left, height + top);
jackqdyulei597b10f2017-01-27 13:31:40 -0800307 mFrame.offset(px, 0);
308
309 // button-frame: area above the battery body
310 mButtonFrame.set(
Evan Laird706d9682017-05-30 15:03:29 -0400311 mFrame.left + Math.round(width * 0.28f),
jackqdyulei597b10f2017-01-27 13:31:40 -0800312 mFrame.top,
Evan Laird706d9682017-05-30 15:03:29 -0400313 mFrame.right - Math.round(width * 0.28f),
jackqdyulei597b10f2017-01-27 13:31:40 -0800314 mFrame.top + buttonHeight);
315
jackqdyulei597b10f2017-01-27 13:31:40 -0800316 // frame: battery body area
317 mFrame.top += buttonHeight;
jackqdyulei597b10f2017-01-27 13:31:40 -0800318
319 // set the battery charging color
Evan Laird6f4179c2017-06-23 16:05:33 -0400320 mBatteryPaint.setColor(batteryColorForLevel(level));
jackqdyulei597b10f2017-01-27 13:31:40 -0800321
322 if (level >= FULL) {
323 drawFrac = 1f;
324 } else if (level <= mCriticalLevel) {
325 drawFrac = 0f;
326 }
327
328 final float levelTop = drawFrac == 1f ? mButtonFrame.top
329 : (mFrame.top + (mFrame.height() * (1f - drawFrac)));
330
331 // define the battery shape
332 mShapePath.reset();
jackqdyuleid94a9382017-08-09 09:57:05 -0700333 final float radius = getRadiusRatio() * (mFrame.height() + buttonHeight);
Jason Monk6a600b82017-04-03 15:08:42 -0400334 mShapePath.setFillType(FillType.WINDING);
335 mShapePath.addRoundRect(mFrame, radius, radius, Direction.CW);
336 mShapePath.addRect(mButtonFrame, Direction.CW);
jackqdyulei597b10f2017-01-27 13:31:40 -0800337
jackqdyuleiff5bd942017-04-04 10:54:21 -0700338 if (mCharging) {
jackqdyulei597b10f2017-01-27 13:31:40 -0800339 // define the bolt shape
Evan Laird706d9682017-05-30 15:03:29 -0400340 // Shift right by 1px for maximal bolt-goodness
341 final float bl = mFrame.left + mFrame.width() / 4f + 1;
jackqdyulei597b10f2017-01-27 13:31:40 -0800342 final float bt = mFrame.top + mFrame.height() / 6f;
Evan Laird706d9682017-05-30 15:03:29 -0400343 final float br = mFrame.right - mFrame.width() / 4f + 1;
jackqdyulei597b10f2017-01-27 13:31:40 -0800344 final float bb = mFrame.bottom - mFrame.height() / 10f;
345 if (mBoltFrame.left != bl || mBoltFrame.top != bt
346 || mBoltFrame.right != br || mBoltFrame.bottom != bb) {
347 mBoltFrame.set(bl, bt, br, bb);
348 mBoltPath.reset();
349 mBoltPath.moveTo(
350 mBoltFrame.left + mBoltPoints[0] * mBoltFrame.width(),
351 mBoltFrame.top + mBoltPoints[1] * mBoltFrame.height());
352 for (int i = 2; i < mBoltPoints.length; i += 2) {
353 mBoltPath.lineTo(
354 mBoltFrame.left + mBoltPoints[i] * mBoltFrame.width(),
355 mBoltFrame.top + mBoltPoints[i + 1] * mBoltFrame.height());
356 }
357 mBoltPath.lineTo(
358 mBoltFrame.left + mBoltPoints[0] * mBoltFrame.width(),
359 mBoltFrame.top + mBoltPoints[1] * mBoltFrame.height());
360 }
361
362 float boltPct = (mBoltFrame.bottom - levelTop) / (mBoltFrame.bottom - mBoltFrame.top);
363 boltPct = Math.min(Math.max(boltPct, 0), 1);
364 if (boltPct <= BOLT_LEVEL_THRESHOLD) {
365 // draw the bolt if opaque
366 c.drawPath(mBoltPath, mBoltPaint);
367 } else {
368 // otherwise cut the bolt out of the overall shape
369 mShapePath.op(mBoltPath, Path.Op.DIFFERENCE);
370 }
371 } else if (mPowerSaveEnabled) {
372 // define the plus shape
373 final float pw = mFrame.width() * 2 / 3;
374 final float pl = mFrame.left + (mFrame.width() - pw) / 2;
375 final float pt = mFrame.top + (mFrame.height() - pw) / 2;
376 final float pr = mFrame.right - (mFrame.width() - pw) / 2;
377 final float pb = mFrame.bottom - (mFrame.height() - pw) / 2;
378 if (mPlusFrame.left != pl || mPlusFrame.top != pt
379 || mPlusFrame.right != pr || mPlusFrame.bottom != pb) {
380 mPlusFrame.set(pl, pt, pr, pb);
381 mPlusPath.reset();
382 mPlusPath.moveTo(
383 mPlusFrame.left + mPlusPoints[0] * mPlusFrame.width(),
384 mPlusFrame.top + mPlusPoints[1] * mPlusFrame.height());
385 for (int i = 2; i < mPlusPoints.length; i += 2) {
386 mPlusPath.lineTo(
387 mPlusFrame.left + mPlusPoints[i] * mPlusFrame.width(),
388 mPlusFrame.top + mPlusPoints[i + 1] * mPlusFrame.height());
389 }
390 mPlusPath.lineTo(
391 mPlusFrame.left + mPlusPoints[0] * mPlusFrame.width(),
392 mPlusFrame.top + mPlusPoints[1] * mPlusFrame.height());
393 }
394
395 float boltPct = (mPlusFrame.bottom - levelTop) / (mPlusFrame.bottom - mPlusFrame.top);
396 boltPct = Math.min(Math.max(boltPct, 0), 1);
397 if (boltPct <= BOLT_LEVEL_THRESHOLD) {
398 // draw the bolt if opaque
399 c.drawPath(mPlusPath, mPlusPaint);
400 } else {
401 // otherwise cut the bolt out of the overall shape
402 mShapePath.op(mPlusPath, Path.Op.DIFFERENCE);
403 }
404 }
405
406 // compute percentage text
407 boolean pctOpaque = false;
408 float pctX = 0, pctY = 0;
409 String pctText = null;
jackqdyuleiff5bd942017-04-04 10:54:21 -0700410 if (!mCharging && !mPowerSaveEnabled && level > mCriticalLevel && mShowPercent) {
jackqdyulei597b10f2017-01-27 13:31:40 -0800411 mTextPaint.setColor(getColorForLevel(level));
412 mTextPaint.setTextSize(height *
413 (SINGLE_DIGIT_PERCENT ? 0.75f
414 : (mLevel == 100 ? 0.38f : 0.5f)));
415 mTextHeight = -mTextPaint.getFontMetrics().ascent;
416 pctText = String.valueOf(SINGLE_DIGIT_PERCENT ? (level / 10) : level);
jackqdyulei5466c8f2017-10-23 14:02:49 -0700417 pctX = mWidth * 0.5f + left;
418 pctY = (mHeight + mTextHeight) * 0.47f + top;
jackqdyulei597b10f2017-01-27 13:31:40 -0800419 pctOpaque = levelTop > pctY;
420 if (!pctOpaque) {
421 mTextPath.reset();
422 mTextPaint.getTextPath(pctText, 0, pctText.length(), pctX, pctY, mTextPath);
423 // cut the percentage text out of the overall shape
424 mShapePath.op(mTextPath, Path.Op.DIFFERENCE);
425 }
426 }
427
428 // draw the battery shape background
429 c.drawPath(mShapePath, mFramePaint);
430
431 // draw the battery shape, clipped to charging level
432 mFrame.top = levelTop;
Derek Sollenberger003db4e2017-08-28 11:07:46 -0400433 c.save();
434 c.clipRect(mFrame);
jackqdyulei597b10f2017-01-27 13:31:40 -0800435 c.drawPath(mShapePath, mBatteryPaint);
Derek Sollenberger003db4e2017-08-28 11:07:46 -0400436 c.restore();
jackqdyulei597b10f2017-01-27 13:31:40 -0800437
jackqdyuleiff5bd942017-04-04 10:54:21 -0700438 if (!mCharging && !mPowerSaveEnabled) {
jackqdyulei597b10f2017-01-27 13:31:40 -0800439 if (level <= mCriticalLevel) {
440 // draw the warning text
jackqdyulei5466c8f2017-10-23 14:02:49 -0700441 final float x = mWidth * 0.5f + left;
442 final float y = (mHeight + mWarningTextHeight) * 0.48f + top;
jackqdyulei597b10f2017-01-27 13:31:40 -0800443 c.drawText(mWarningString, x, y, mWarningTextPaint);
444 } else if (pctOpaque) {
445 // draw the percentage text
446 c.drawText(pctText, pctX, pctY, mTextPaint);
447 }
448 }
449 }
450
451 // Some stuff required by Drawable.
452 @Override
453 public void setAlpha(int alpha) {
454 }
455
456 @Override
457 public void setColorFilter(@Nullable ColorFilter colorFilter) {
458 mFramePaint.setColorFilter(colorFilter);
459 mBatteryPaint.setColorFilter(colorFilter);
460 mWarningTextPaint.setColorFilter(colorFilter);
461 mBoltPaint.setColorFilter(colorFilter);
462 mPlusPaint.setColorFilter(colorFilter);
463 }
464
465 @Override
466 public int getOpacity() {
467 return 0;
468 }
jackqdyuleiff5bd942017-04-04 10:54:21 -0700469
470 public int getCriticalLevel() {
471 return mCriticalLevel;
472 }
jackqdyuleid94a9382017-08-09 09:57:05 -0700473
474 protected float getAspectRatio() {
475 return ASPECT_RATIO;
476 }
477
478 protected float getRadiusRatio() {
479 return RADIUS_RATIO;
480 }
jackqdyulei597b10f2017-01-27 13:31:40 -0800481}