OSDN Git Service

Accounts & Sync - sync status indicators missing contentDescription attributes.
authorSvetoslav Ganov <svetoslavganov@google.com>
Sat, 23 Jul 2011 02:34:12 +0000 (19:34 -0700)
committerSvetoslav Ganov <svetoslavganov@google.com>
Sun, 24 Jul 2011 03:35:55 +0000 (20:35 -0700)
1. Added the content descriptions.

bug:5033572

Change-Id: I4d04f4c6e7b79dcc9720b69505aa64e798a02fad

res/values/strings.xml
src/com/android/settings/AccountPreference.java

index 78a8069..1e362d1 100644 (file)
@@ -3201,6 +3201,13 @@ found in the list of installed applications.</string>
     <!-- Do not translate. This is a stub which will be removed soon. -->
     <string name="time_zone_auto_stub" translatable="false">Select Time Zone</string>
 
+    <!-- Content description of the enabled sync icon for accessibility. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_sync_enabled">Sync enabled</string>
+    <!-- Content description of the disabled sync icon for accessibility. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_sync_disabled">Sync disabled</string>
+    <!-- Content description of the disabled sync icon for accessibility. [CHAR LIMIT=NONE] -->
+    <string name="accessibility_sync_error">Sync error.</string>
+
     <!-- Account specific sync settings title [CHAR LIMIT=35] -->
     <string name="account_sync_settings_title">Sync settings</string>
     <!-- Message when sync is currently failing [CHAR LIMIT=100] -->
index f3d7d51..f76d5cb 100644 (file)
@@ -71,6 +71,7 @@ public class AccountPreference extends Preference {
         setSummary(getSyncStatusMessage(mStatus));
         mSyncStatusIcon = (ImageView) view.findViewById(R.id.syncStatusIcon);
         mSyncStatusIcon.setImageResource(getSyncStatusIcon(mStatus));
+        mSyncStatusIcon.setContentDescription(getSyncContentDescription(mStatus));
     }
 
     public void setProviderIcon(Drawable icon) {
@@ -126,6 +127,20 @@ public class AccountPreference extends Preference {
         return res;
     }
 
+    private String getSyncContentDescription(int status) {
+        switch (status) {
+            case SYNC_ENABLED:
+                return getContext().getString(R.string.accessibility_sync_enabled);
+            case SYNC_DISABLED:
+                return getContext().getString(R.string.accessibility_sync_disabled);
+            case SYNC_ERROR:
+                return getContext().getString(R.string.accessibility_sync_error);
+            default:
+                Log.e(TAG, "Unknown sync status: " + status);
+                return getContext().getString(R.string.accessibility_sync_error);
+        }
+    }
+
     @Override
     public int compareTo(Preference other) {
         if (!(other instanceof AccountPreference)) {