Merge "A11y: Fix battery icon and clock descriptions" into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
206748d10e
@@ -381,6 +381,9 @@
|
||||
<!-- Content description of the battery level icon for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_battery_level">Battery <xliff:g id="number">%d</xliff:g> percent.</string>
|
||||
|
||||
<!-- Content description of the battery level icon for accessibility while the device is charging (not shown on the screen). [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_battery_level_charging">Battery charging, <xliff:g id="battery_percentage">%d</xliff:g> percent.</string>
|
||||
|
||||
<!-- Content description of the button for showing a settings panel in the notification panel for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
|
||||
<string name="accessibility_settings_button">System settings.</string>
|
||||
|
||||
|
||||
@@ -89,7 +89,8 @@ public class BatteryMeterView extends ImageView implements
|
||||
@Override
|
||||
public void onBatteryLevelChanged(int level, boolean pluggedIn, boolean charging) {
|
||||
setContentDescription(
|
||||
getContext().getString(R.string.accessibility_battery_level, level));
|
||||
getContext().getString(charging ? R.string.accessibility_battery_level_charging
|
||||
: R.string.accessibility_battery_level, level));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -61,6 +61,7 @@ public class Clock extends TextView implements DemoMode, Tunable {
|
||||
private Calendar mCalendar;
|
||||
private String mClockFormatString;
|
||||
private SimpleDateFormat mClockFormat;
|
||||
private SimpleDateFormat mContentDescriptionFormat;
|
||||
private Locale mLocale;
|
||||
|
||||
private static final int AM_PM_STYLE_NORMAL = 0;
|
||||
@@ -158,6 +159,7 @@ public class Clock extends TextView implements DemoMode, Tunable {
|
||||
if (mDemoMode) return;
|
||||
mCalendar.setTimeInMillis(System.currentTimeMillis());
|
||||
setText(getSmallTime());
|
||||
setContentDescription(mContentDescriptionFormat.format(mCalendar.getTime()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -207,6 +209,7 @@ public class Clock extends TextView implements DemoMode, Tunable {
|
||||
? is24 ? d.timeFormat_Hms : d.timeFormat_hms
|
||||
: is24 ? d.timeFormat_Hm : d.timeFormat_hm;
|
||||
if (!format.equals(mClockFormatString)) {
|
||||
mContentDescriptionFormat = new SimpleDateFormat(format);
|
||||
/*
|
||||
* Search for an unquoted "a" in the format string, so we can
|
||||
* add dummy characters around it to let us find it again after
|
||||
@@ -295,6 +298,7 @@ public class Clock extends TextView implements DemoMode, Tunable {
|
||||
mCalendar.set(Calendar.MINUTE, mm);
|
||||
}
|
||||
setText(getSmallTime());
|
||||
setContentDescription(mContentDescriptionFormat.format(mCalendar.getTime()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user