Loading res/values/dimens.xml +2 −0 Original line number Diff line number Diff line Loading @@ -295,6 +295,8 @@ <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 percentage sign in the donut. --> <dimen name="storage_donut_view_percent_sign_size">20sp</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. --> Loading res/values/strings.xml +1 −1 Original line number Diff line number Diff line Loading @@ -9620,7 +9620,7 @@ <string name="storage_files">Files</string> <!-- Summary of a single storage volume used space. [CHAR LIMIT=24] --> <string name="storage_size_large_alternate"><xliff:g id="number" example="128">^1</xliff:g><small> <xliff:g id="unit" example="KB">^2</xliff:g></small></string> <string name="storage_size_large_alternate"><xliff:g id="number" example="128">^1</xliff:g><small> <font size="20"><xliff:g id="unit" example="KB">^2</xliff:g></font></small></string> <!-- Summary of a single storage volume total space. [CHAR LIMIT=48]--> <string name="storage_volume_total">Used of <xliff:g id="total" example="32GB">%1$s</xliff:g></string> <!-- Follows the percent of storage used by a storage volume. Exposed inside of a donut graph. [CHAR LIMIT=7]--> src/com/android/settings/widget/DonutView.java +25 −5 Original line number Diff line number Diff line Loading @@ -24,9 +24,16 @@ import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.Typeface; import android.icu.text.DecimalFormatSymbols; import android.support.annotation.ColorRes; import android.text.Layout; import android.text.Spannable; import android.text.SpannableString; import android.text.Spanned; import android.text.StaticLayout; import android.text.TextPaint; import android.text.TextUtils; import android.text.style.RelativeSizeSpan; import android.util.AttributeSet; import android.view.View; Loading Loading @@ -124,7 +131,6 @@ public class DonutView extends View { mBigNumberPaint.setAntiAlias(true); mBigNumberPaint.setTextSize( resources.getDimension(R.dimen.storage_donut_view_percent_text_size)); mBigNumberPaint.setTextAlign(Paint.Align.CENTER); mBigNumberPaint.setTypeface(Typeface.create( context.getString(com.android.internal.R.string.config_headlineFontFamily), Typeface.NORMAL)); Loading Loading @@ -167,11 +173,25 @@ public class DonutView extends View { final float centerY = getHeight() / 2; final float totalHeight = getTextHeight(mTextPaint) + getTextHeight(mBigNumberPaint); final float startY = centerY + totalHeight / 2; final float fontProportion = getResources().getDimension( R.dimen.storage_donut_view_percent_sign_size) / getResources().getDimension(R.dimen.storage_donut_view_percent_text_size); // Support from Android P final String localizedPercentSign = new DecimalFormatSymbols().getPercentString(); final int startIndex = mPercentString.indexOf(localizedPercentSign); final int endIndex = startIndex + localizedPercentSign.length(); // The first line y-coordinates start at (total height - all TextPaint height) / 2 canvas.save(); final Spannable percentStringSpan = new SpannableString(mPercentString); percentStringSpan.setSpan(new RelativeSizeSpan(fontProportion), startIndex, endIndex, Spanned.SPAN_INCLUSIVE_INCLUSIVE); final StaticLayout percentStringLayout = new StaticLayout(percentStringSpan, mBigNumberPaint, getWidth(), Layout.Alignment.ALIGN_CENTER, 1, 0, false); canvas.translate(0, (getHeight() - totalHeight) / 2); percentStringLayout.draw(canvas); canvas.restore(); // The first line is the height of the bottom text + its descender above the bottom line. canvas.drawText(mPercentString, centerX, startY - getTextHeight(mTextPaint) - mBigNumberPaint.descent(), mBigNumberPaint); // The second line starts at the bottom + room for the descender. canvas.drawText(mFullString, centerX, startY - mTextPaint.descent(), mTextPaint); } Loading Loading
res/values/dimens.xml +2 −0 Original line number Diff line number Diff line Loading @@ -295,6 +295,8 @@ <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 percentage sign in the donut. --> <dimen name="storage_donut_view_percent_sign_size">20sp</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. --> Loading
res/values/strings.xml +1 −1 Original line number Diff line number Diff line Loading @@ -9620,7 +9620,7 @@ <string name="storage_files">Files</string> <!-- Summary of a single storage volume used space. [CHAR LIMIT=24] --> <string name="storage_size_large_alternate"><xliff:g id="number" example="128">^1</xliff:g><small> <xliff:g id="unit" example="KB">^2</xliff:g></small></string> <string name="storage_size_large_alternate"><xliff:g id="number" example="128">^1</xliff:g><small> <font size="20"><xliff:g id="unit" example="KB">^2</xliff:g></font></small></string> <!-- Summary of a single storage volume total space. [CHAR LIMIT=48]--> <string name="storage_volume_total">Used of <xliff:g id="total" example="32GB">%1$s</xliff:g></string> <!-- Follows the percent of storage used by a storage volume. Exposed inside of a donut graph. [CHAR LIMIT=7]-->
src/com/android/settings/widget/DonutView.java +25 −5 Original line number Diff line number Diff line Loading @@ -24,9 +24,16 @@ import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.Typeface; import android.icu.text.DecimalFormatSymbols; import android.support.annotation.ColorRes; import android.text.Layout; import android.text.Spannable; import android.text.SpannableString; import android.text.Spanned; import android.text.StaticLayout; import android.text.TextPaint; import android.text.TextUtils; import android.text.style.RelativeSizeSpan; import android.util.AttributeSet; import android.view.View; Loading Loading @@ -124,7 +131,6 @@ public class DonutView extends View { mBigNumberPaint.setAntiAlias(true); mBigNumberPaint.setTextSize( resources.getDimension(R.dimen.storage_donut_view_percent_text_size)); mBigNumberPaint.setTextAlign(Paint.Align.CENTER); mBigNumberPaint.setTypeface(Typeface.create( context.getString(com.android.internal.R.string.config_headlineFontFamily), Typeface.NORMAL)); Loading Loading @@ -167,11 +173,25 @@ public class DonutView extends View { final float centerY = getHeight() / 2; final float totalHeight = getTextHeight(mTextPaint) + getTextHeight(mBigNumberPaint); final float startY = centerY + totalHeight / 2; final float fontProportion = getResources().getDimension( R.dimen.storage_donut_view_percent_sign_size) / getResources().getDimension(R.dimen.storage_donut_view_percent_text_size); // Support from Android P final String localizedPercentSign = new DecimalFormatSymbols().getPercentString(); final int startIndex = mPercentString.indexOf(localizedPercentSign); final int endIndex = startIndex + localizedPercentSign.length(); // The first line y-coordinates start at (total height - all TextPaint height) / 2 canvas.save(); final Spannable percentStringSpan = new SpannableString(mPercentString); percentStringSpan.setSpan(new RelativeSizeSpan(fontProportion), startIndex, endIndex, Spanned.SPAN_INCLUSIVE_INCLUSIVE); final StaticLayout percentStringLayout = new StaticLayout(percentStringSpan, mBigNumberPaint, getWidth(), Layout.Alignment.ALIGN_CENTER, 1, 0, false); canvas.translate(0, (getHeight() - totalHeight) / 2); percentStringLayout.draw(canvas); canvas.restore(); // The first line is the height of the bottom text + its descender above the bottom line. canvas.drawText(mPercentString, centerX, startY - getTextHeight(mTextPaint) - mBigNumberPaint.descent(), mBigNumberPaint); // The second line starts at the bottom + room for the descender. canvas.drawText(mFullString, centerX, startY - mTextPaint.descent(), mTextPaint); } Loading