Merge "Add 25% and 75% lines to improve the readability of the battery level as a short-term fix." into udc-qpr-dev am: 6c12390bab
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/24037114 Change-Id: Ia9abd00ab92335a2752b053e06861e2cedcf0b57 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -61,6 +61,7 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
|||||||
private static final String TAG = "BatteryChartView";
|
private static final String TAG = "BatteryChartView";
|
||||||
|
|
||||||
private static final int DIVIDER_COLOR = Color.parseColor("#CDCCC5");
|
private static final int DIVIDER_COLOR = Color.parseColor("#CDCCC5");
|
||||||
|
private static final int HORIZONTAL_DIVIDER_COUNT = 5;
|
||||||
|
|
||||||
/** A callback listener for selected group index is updated. */
|
/** A callback listener for selected group index is updated. */
|
||||||
public interface OnSelectListener {
|
public interface OnSelectListener {
|
||||||
@@ -335,23 +336,24 @@ public class BatteryChartView extends AppCompatImageView implements View.OnClick
|
|||||||
private void drawHorizontalDividers(Canvas canvas) {
|
private void drawHorizontalDividers(Canvas canvas) {
|
||||||
final int width = getWidth() - mIndent.right;
|
final int width = getWidth() - mIndent.right;
|
||||||
final int height = getHeight() - mIndent.top - mIndent.bottom;
|
final int height = getHeight() - mIndent.top - mIndent.bottom;
|
||||||
// Draws the top divider line for 100% curve.
|
final float topOffsetY = mIndent.top + mDividerWidth * .5f;
|
||||||
float offsetY = mIndent.top + mDividerWidth * .5f;
|
final float bottomOffsetY = mIndent.top + (height - mDividerHeight - mDividerWidth * .5f);
|
||||||
|
final float availableSpace = bottomOffsetY - topOffsetY;
|
||||||
|
|
||||||
mDividerPaint.setColor(DIVIDER_COLOR);
|
mDividerPaint.setColor(DIVIDER_COLOR);
|
||||||
canvas.drawLine(0, offsetY, width, offsetY, mDividerPaint);
|
final float dividerOffsetUnit =
|
||||||
drawPercentage(canvas, /*index=*/ 0, offsetY);
|
availableSpace / (float) (HORIZONTAL_DIVIDER_COUNT - 1);
|
||||||
|
|
||||||
// Draws the center divider line for 50% curve.
|
// Draws 5 divider lines.
|
||||||
final float availableSpace =
|
for (int index = 0; index < HORIZONTAL_DIVIDER_COUNT; index++) {
|
||||||
height - mDividerWidth * 2 - mTrapezoidVOffset - mDividerHeight;
|
float offsetY = topOffsetY + dividerOffsetUnit * index;
|
||||||
offsetY = mIndent.top + mDividerWidth + availableSpace * .5f;
|
|
||||||
canvas.drawLine(0, offsetY, width, offsetY, mDividerPaint);
|
canvas.drawLine(0, offsetY, width, offsetY, mDividerPaint);
|
||||||
drawPercentage(canvas, /*index=*/ 1, offsetY);
|
|
||||||
|
|
||||||
// Draws the bottom divider line for 0% curve.
|
// Draws percentage text only for 100% / 50% / 0%
|
||||||
offsetY = mIndent.top + (height - mDividerHeight - mDividerWidth * .5f);
|
if (index % 2 == 0) {
|
||||||
canvas.drawLine(0, offsetY, width, offsetY, mDividerPaint);
|
drawPercentage(canvas, /*index=*/ (index + 1) / 2, offsetY);
|
||||||
drawPercentage(canvas, /*index=*/ 2, offsetY);
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawPercentage(Canvas canvas, int index, float offsetY) {
|
private void drawPercentage(Canvas canvas, int index, float offsetY) {
|
||||||
|
Reference in New Issue
Block a user