Merge "A11y: Fix battery icon and clock descriptions" into nyc-dev

am: 206748d10e

* commit '206748d10e5f3b42e198af6a2e0801fb47ec3c01':
  A11y: Fix battery icon and clock descriptions

Change-Id: I1d428b3c3f0d70ad275fb9d9bb1b39bcda8d3ac1
This commit is contained in:
Adrian Roos
2016-04-21 00:34:32 +00:00
committed by android-build-merger
3 changed files with 9 additions and 1 deletions

View File

@@ -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>

View File

@@ -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

View File

@@ -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()));
}
}