Band aid to fix overly long text in donut.

In the Storage Settings, if the text is too long, it will overlap with
the donut. After discussing with UX, we've opted to shrink the text in
the extenuating circumstances. This is because this text is more of a
helper and the full information is on the left.

Bug: 38030457
Test: Manual with Telugu
Change-Id: I18bcaaae74d049c42eaff50868d3861ae258839d
This commit is contained in:
Daniel Nishi
2017-05-24 16:25:08 -07:00
parent 98b67a4e94
commit 9f84622be4
2 changed files with 21 additions and 2 deletions

View File

@@ -310,6 +310,12 @@
<!-- Padding between the donut and the storage summary. --> <!-- Padding between the donut and the storage summary. -->
<dimen name="storage_summary_padding_end">16dp</dimen> <dimen name="storage_summary_padding_end">16dp</dimen>
<!-- Text size of the big number in the donut. -->
<dimen name="storage_donut_view_percent_text_size">30sp</dimen>
<!-- Text size of the label text in the donut. -->
<dimen name="storage_donut_view_label_text_size">14sp</dimen>
<!-- Text size of the label text in the donut if the label text is long. -->
<dimen name="storage_donut_view_shrunken_label_text_size">10sp</dimen>
<!-- Battery meter view size --> <!-- Battery meter view size -->
<dimen name="battery_meter_width">66dp</dimen> <dimen name="battery_meter_width">66dp</dimen>

View File

@@ -16,6 +16,7 @@
package com.android.settings.widget; package com.android.settings.widget;
import android.content.Context; import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.ColorFilter; import android.graphics.ColorFilter;
import android.graphics.Paint; import android.graphics.Paint;
@@ -34,6 +35,8 @@ import com.android.settings.Utils;
*/ */
public class DonutView extends View { public class DonutView extends View {
private static final int TOP = -90; private static final int TOP = -90;
// From manual testing, this is the longest we can go without visual errors.
private static final int LINE_CHARACTER_LIMIT = 10;
private float mStrokeWidth; private float mStrokeWidth;
private float mDeviceDensity; private float mDeviceDensity;
private int mPercent; private int mPercent;
@@ -73,16 +76,19 @@ public class DonutView extends View {
mFilledArc.setColor(Utils.getDefaultColor(mContext, R.color.meter_consumed_color)); mFilledArc.setColor(Utils.getDefaultColor(mContext, R.color.meter_consumed_color));
mFilledArc.setColorFilter(mAccentColorFilter); mFilledArc.setColorFilter(mAccentColorFilter);
Resources resources = context.getResources();
mTextPaint = new TextPaint(); mTextPaint = new TextPaint();
mTextPaint.setColor(Utils.getColorAccent(getContext())); mTextPaint.setColor(Utils.getColorAccent(getContext()));
mTextPaint.setAntiAlias(true); mTextPaint.setAntiAlias(true);
mTextPaint.setTextSize(14f * mDeviceDensity); mTextPaint.setTextSize(
resources.getDimension(R.dimen.storage_donut_view_label_text_size));
mTextPaint.setTextAlign(Paint.Align.CENTER); mTextPaint.setTextAlign(Paint.Align.CENTER);
mBigNumberPaint = new TextPaint(); mBigNumberPaint = new TextPaint();
mBigNumberPaint.setColor(Utils.getColorAccent(getContext())); mBigNumberPaint.setColor(Utils.getColorAccent(getContext()));
mBigNumberPaint.setAntiAlias(true); mBigNumberPaint.setAntiAlias(true);
mBigNumberPaint.setTextSize(30f * mDeviceDensity); mBigNumberPaint.setTextSize(
resources.getDimension(R.dimen.storage_donut_view_percent_text_size));
mBigNumberPaint.setTextAlign(Paint.Align.CENTER); mBigNumberPaint.setTextAlign(Paint.Align.CENTER);
} }
@@ -136,6 +142,13 @@ public class DonutView extends View {
mPercent = percent; mPercent = percent;
mPercentString = Utils.formatPercentage(mPercent); mPercentString = Utils.formatPercentage(mPercent);
mFullString = getContext().getString(R.string.storage_percent_full); mFullString = getContext().getString(R.string.storage_percent_full);
if (mFullString.length() > LINE_CHARACTER_LIMIT) {
mTextPaint.setTextSize(
getContext()
.getResources()
.getDimension(
R.dimen.storage_donut_view_shrunken_label_text_size));
}
invalidate(); invalidate();
} }