Add content description string for '<1%'.

Bug: 322855583
Test: atest SettingsRoboTests:com.android.settings.fuelgauge.batteryusage
Change-Id: I704a591ab4cba21644e86457c2dd1000ceecc291
This commit is contained in:
mxyyiyi
2024-04-18 18:59:25 +08:00
parent 3950632041
commit 6853021975
5 changed files with 47 additions and 10 deletions

View File

@@ -18,6 +18,7 @@ package com.android.settings.fuelgauge.batteryusage;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
@@ -47,6 +48,7 @@ public class PowerGaugePreference extends AppPreference {
private BatteryDiffEntry mBatteryDiffEntry;
private CharSequence mContentDescription;
private CharSequence mProgress;
private CharSequence mProgressContentDescription;
private boolean mShowAnomalyIcon;
public PowerGaugePreference(
@@ -87,6 +89,13 @@ public class PowerGaugePreference extends AppPreference {
/** Sets the percentage to show. */
public void setPercentage(CharSequence percentage) {
mProgress = percentage;
mProgressContentDescription = percentage;
notifyChanged();
}
/** Sets the content description of the percentage. */
public void setPercentageContentDescription(CharSequence contentDescription) {
mProgressContentDescription = contentDescription;
notifyChanged();
}
@@ -133,6 +142,9 @@ public class PowerGaugePreference extends AppPreference {
final TextView subtitle = (TextView) view.findViewById(R.id.widget_summary);
subtitle.setText(mProgress);
if (!TextUtils.isEmpty(mProgressContentDescription)) {
subtitle.setContentDescription(mProgressContentDescription);
}
if (mShowAnomalyIcon) {
subtitle.setCompoundDrawablesRelativeWithIntrinsicBounds(
R.drawable.ic_warning_24dp, 0, 0, 0);