From 70dcf8392c5b24fb8e41f96f9c7df8d8dbe15783 Mon Sep 17 00:00:00 2001 From: Adrian Roos Date: Wed, 20 Apr 2016 15:51:42 -0700 Subject: [PATCH] A11y: Fix battery icon and clock descriptions Now announces charging state on the battery icon and AM/PM on the clock. Change-Id: Ib8d249e60b555834e5e224287ea332178ce7c165 Fixes: 27552350 --- packages/SystemUI/res/values/strings.xml | 3 +++ .../SystemUI/src/com/android/systemui/BatteryMeterView.java | 3 ++- .../src/com/android/systemui/statusbar/policy/Clock.java | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index 37b00bbfdc27f..9d42f31a9910c 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -381,6 +381,9 @@ Battery %d percent. + + Battery charging, %d percent. + System settings. diff --git a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java index 0bf81e9654bed..d8b95cc28b57c 100644 --- a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java +++ b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java @@ -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 diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java index 32939641f95b6..66152fcd965e3 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/Clock.java @@ -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())); } }