diff options
| author | 2015-07-20 09:08:15 -0700 | |
|---|---|---|
| committer | 2015-07-20 15:09:08 -0700 | |
| commit | 93de2f7ffe31352c82d72ebd79770a56d18f93ab (patch) | |
| tree | 73f263e1fe898ba12d8975f739ed37cc3d1e93a9 | |
| parent | c9275e764de52ff5e59f02469ee95dbdc7928c95 (diff) | |
Fix accessibility labels for app shelf
* Label the pinned and recent buttons with human-readable names.
* Set the divider line to non-focusable so it doesn't participate
in accessibility.
Bug: 22568004
Change-Id: I298a927325fb23c357ed035e71013ef4f6965607
3 files changed, 34 insertions, 5 deletions
diff --git a/packages/SystemUI/res/layout/navigation_bar_with_apps.xml b/packages/SystemUI/res/layout/navigation_bar_with_apps.xml index 0a111e8e8d65..01c239e0f0a4 100644 --- a/packages/SystemUI/res/layout/navigation_bar_with_apps.xml +++ b/packages/SystemUI/res/layout/navigation_bar_with_apps.xml @@ -82,8 +82,9 @@ android:layout_width="wrap_content" android:layout_height="match_parent" /> - + <ImageView android:id="@+id/app_divider" + android:focusable="false" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" @@ -91,7 +92,7 @@ android:layout_marginRight="10dp" android:src="@drawable/nav_app_divider" /> - + <com.android.systemui.statusbar.phone.NavigationBarRecents android:layout_width="wrap_content" android:layout_height="match_parent" @@ -247,8 +248,9 @@ android:layout_width="wrap_content" android:layout_height="match_parent" /> - + <ImageView android:id="@+id/app_divider" + android:focusable="false" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" @@ -256,7 +258,7 @@ android:layout_marginRight="10dp" android:src="@drawable/nav_app_divider" /> - + <com.android.systemui.statusbar.phone.NavigationBarRecents android:layout_width="wrap_content" android:layout_height="match_parent" diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarApps.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarApps.java index ab951d9b6b8f..d0607562fcd7 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarApps.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarApps.java @@ -17,12 +17,14 @@ package com.android.systemui.statusbar.phone; import android.animation.LayoutTransition; +import android.annotation.Nullable; import android.app.ActivityOptions; import android.content.ClipData; import android.content.ClipDescription; import android.content.ComponentName; import android.content.Context; import android.content.Intent; +import android.content.pm.ApplicationInfo; import android.content.pm.LauncherApps; import android.content.pm.PackageManager; import android.graphics.Rect; @@ -119,8 +121,11 @@ class NavigationBarApps extends LinearLayout { ImageView button = createAppButton(); addView(button); - // Load the icon asynchronously. ComponentName activityName = sAppsModel.getApp(i); + CharSequence appLabel = getAppLabel(mPackageManager, activityName); + button.setContentDescription(getAppLabel(mPackageManager, activityName)); + + // Load the icon asynchronously. new GetActivityIconTask(mPackageManager, button).execute(activityName); } } @@ -151,6 +156,24 @@ class NavigationBarApps extends LinearLayout { } } + /** + * Returns the human-readable name for an activity's package or null. + * TODO: Cache the labels, perhaps in an LruCache. + */ + @Nullable + static CharSequence getAppLabel(PackageManager packageManager, + ComponentName activityName) { + String packageName = activityName.getPackageName(); + ApplicationInfo info; + try { + info = packageManager.getApplicationInfo(packageName, 0x0 /* flags */); + } catch (PackageManager.NameNotFoundException e) { + Slog.w(TAG, "Package not found " + packageName); + return null; + } + return packageManager.getApplicationLabel(info); + } + /** Helper function to start dragging an app icon (either pinned or recent). */ static void startAppDrag(ImageView icon, ComponentName activityName) { // The drag data is an Intent to launch the activity. diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarRecents.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarRecents.java index 2509c337bdc9..c7fae9207647 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarRecents.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarRecents.java @@ -151,6 +151,10 @@ class NavigationBarRecents extends LinearLayout { button.setOnLongClickListener(mAppLongClickListener); addView(button); + ComponentName activityName = getRealActivityForTask(task); + CharSequence appLabel = NavigationBarApps.getAppLabel(mPackageManager, activityName); + button.setContentDescription(appLabel); + // Use the View's tag to store metadata for drag and drop. button.setTag(task); |