Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 93de2f7f authored by James Cook's avatar James Cook
Browse files

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
parent c9275e76
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -84,6 +84,7 @@
                    />

                <ImageView android:id="@+id/app_divider"
                    android:focusable="false"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
@@ -249,6 +250,7 @@
                    />

                <ImageView android:id="@+id/app_divider"
                    android:focusable="false"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="center"
+24 −1
Original line number Diff line number Diff line
@@ -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.
+4 −0
Original line number Diff line number Diff line
@@ -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);