summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/location
diff options
context:
space:
mode:
authorZoltan Szatmary-Ban <szatmz@google.com>2014-07-23 11:02:46 +0100
committerZoltan Szatmary-Ban <szatmz@google.com>2014-08-07 14:15:14 +0100
commitebb36ec9207c9519f6ae6a1aa39909279aa1d0e9 (patch)
tree7c85ef5e23b7eebad8d9eef33d5b13878f113d74 /src/com/android/settings/location
parentf34c3501948190acf44defefba8eb161ec6dc07b (diff)
downloadpackages_apps_Settings-ebb36ec9207c9519f6ae6a1aa39909279aa1d0e9.zip
packages_apps_Settings-ebb36ec9207c9519f6ae6a1aa39909279aa1d0e9.tar.gz
packages_apps_Settings-ebb36ec9207c9519f6ae6a1aa39909279aa1d0e9.tar.bz2
Badge texts correctly for accessibility in Settings
If an app is a managed profile's app then its label should read correctly by TalkBack. Affected screens: Data Usage, Location, Battery. Bug:16053981 Change-Id: I393c0ebf56917032d619b1e39b4bf141ee236981
Diffstat (limited to 'src/com/android/settings/location')
-rw-r--r--src/com/android/settings/location/RecentLocationApps.java42
1 files changed, 36 insertions, 6 deletions
diff --git a/src/com/android/settings/location/RecentLocationApps.java b/src/com/android/settings/location/RecentLocationApps.java
index 8e1ec05..5506181 100644
--- a/src/com/android/settings/location/RecentLocationApps.java
+++ b/src/com/android/settings/location/RecentLocationApps.java
@@ -22,6 +22,7 @@ import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.IPackageManager;
+import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Process;
@@ -30,6 +31,8 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.preference.Preference;
import android.util.Log;
+import android.view.View;
+import android.widget.TextView;
import com.android.settings.R;
import com.android.settings.SettingsActivity;
@@ -74,12 +77,35 @@ public class RecentLocationApps {
}
}
- private Preference createRecentLocationEntry(
+ /**
+ * Subclass of {@link Preference} to intercept views and allow content description to be set on
+ * them for accessibility purposes.
+ */
+ private static class AccessiblePreference extends Preference {
+ public String mContentDescription;
+
+ public AccessiblePreference(Context context, String contentDescription) {
+ super(context);
+ mContentDescription = contentDescription;
+ }
+
+ @Override
+ protected void onBindView(View view) {
+ super.onBindView(view);
+ if (mContentDescription != null) {
+ final TextView titleView = (TextView) view.findViewById(android.R.id.title);
+ titleView.setContentDescription(mContentDescription);
+ }
+ }
+ }
+
+ private AccessiblePreference createRecentLocationEntry(
Drawable icon,
CharSequence label,
boolean isHighBattery,
+ String contentDescription,
Preference.OnPreferenceClickListener listener) {
- Preference pref = new Preference(mActivity);
+ AccessiblePreference pref = new AccessiblePreference(mActivity, contentDescription);
pref.setIcon(icon);
pref.setTitle(label);
if (isHighBattery) {
@@ -172,16 +198,20 @@ public class RecentLocationApps {
int uid = ops.getUid();
int userId = UserHandle.getUserId(uid);
- Preference preference = null;
+ AccessiblePreference preference = null;
try {
IPackageManager ipm = AppGlobals.getPackageManager();
ApplicationInfo appInfo =
ipm.getApplicationInfo(packageName, PackageManager.GET_META_DATA, userId);
+ Resources res = mActivity.getResources();
- Drawable icon = um.getBadgedDrawableForUser(
- mPackageManager.getApplicationIcon(appInfo), new UserHandle(userId));
+ final UserHandle userHandle = new UserHandle(userId);
+ Drawable appIcon = mPackageManager.getApplicationIcon(appInfo);
+ Drawable icon = um.getBadgedDrawableForUser(appIcon, userHandle);
+ CharSequence appLabel = mPackageManager.getApplicationLabel(appInfo);
+ String badgedAppLabel = um.getBadgedLabelForUser(appLabel.toString(), userHandle);
preference = createRecentLocationEntry(icon,
- mPackageManager.getApplicationLabel(appInfo), highBattery,
+ appLabel, highBattery, badgedAppLabel,
new PackageEntryClickedListener(packageName));
} catch (RemoteException e) {
Log.w(TAG, "Error while retrieving application info", e);