diff options
author | 2025-02-27 09:34:58 -0800 | |
---|---|---|
committer | 2025-02-27 09:58:31 -0800 | |
commit | 536097dec202066c5ef2d4509ac26b71fd99d54a (patch) | |
tree | c4b37a63e9957253f2718298783fcfdf04468e44 | |
parent | 865982c634dcf94e0a16176e2d18f6f98f47cb1d (diff) |
Update Taskbar Icon content description to include state description
This cl inlcudes: while user is in desktop mode, we will add state description(active, minimized) of each app icon to it's content description.
Test: Manual
Bug: 397555157
Flag: EXEMPT bugfix
Change-Id: Iaec18e7099108e8b076b76c637a41e29ed837265
-rw-r--r-- | quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java | 13 | ||||
-rw-r--r-- | res/values/strings.xml | 3 | ||||
-rw-r--r-- | src/com/android/launcher3/BubbleTextView.java | 26 |
3 files changed, 40 insertions, 2 deletions
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java index 384468c9fc..78c22d2fbf 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java @@ -83,6 +83,8 @@ import com.android.launcher3.model.data.ItemInfo; import com.android.launcher3.model.data.TaskItemInfo; import com.android.launcher3.taskbar.bubbles.BubbleBarController; import com.android.launcher3.taskbar.bubbles.BubbleControllers; +import com.android.launcher3.taskbar.customization.TaskbarAllAppsButtonContainer; +import com.android.launcher3.taskbar.customization.TaskbarDividerContainer; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.ItemInfoMatcher; import com.android.launcher3.util.LauncherBindableItemsContainer; @@ -735,10 +737,21 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar for (View iconView : getIconViews()) { if (iconView instanceof BubbleTextView btv) { btv.updateRunningState(getRunningAppState(btv)); + if (shouldUpdateIconContentDescription(btv)) { + btv.setContentDescription( + btv.getContentDescription() + " " + btv.getIconStateDescription()); + } } } } + private boolean shouldUpdateIconContentDescription(BubbleTextView btv) { + boolean isInDesktopMode = mControllers.taskbarDesktopModeController.isInDesktopMode(); + boolean isAllAppsButton = btv instanceof TaskbarAllAppsButtonContainer; + boolean isDividerButton = btv instanceof TaskbarDividerContainer; + return isInDesktopMode && !isAllAppsButton && !isDividerButton; + } + /** * @return A set of Task ids of running apps that are pinned in the taskbar. */ diff --git a/res/values/strings.xml b/res/values/strings.xml index a02516a44f..56befd679f 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -293,6 +293,9 @@ <!-- Description for a new page on homescreen[CHAR_LIMIT=none] --> <string name="workspace_new_page">New home screen page</string> + <string name="app_running_state_description">Active</string> + <string name="app_minimized_state_description">Minimized</string> + <!-- Folder accessibility --> <!-- The format string for when a folder is opened, speaks the dimensions --> <string name="folder_opened">Folder opened, <xliff:g id="width" example="5">%1$d</xliff:g> by <xliff:g id="height" example="3">%2$d</xliff:g></string> diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index bd42b2b855..730ad7858e 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -20,6 +20,9 @@ import static android.graphics.fonts.FontStyle.FONT_WEIGHT_BOLD; import static android.graphics.fonts.FontStyle.FONT_WEIGHT_NORMAL; import static android.text.Layout.Alignment.ALIGN_NORMAL; +import static com.android.launcher3.BubbleTextView.RunningAppState.RUNNING; +import static com.android.launcher3.BubbleTextView.RunningAppState.NOT_RUNNING; +import static com.android.launcher3.BubbleTextView.RunningAppState.MINIMIZED; import static com.android.launcher3.Flags.enableContrastTiles; import static com.android.launcher3.Flags.enableCursorHoverStates; import static com.android.launcher3.graphics.PreloadIconDrawable.newPendingIcon; @@ -208,6 +211,9 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, private final int mRunningAppIndicatorColor; private final int mMinimizedAppIndicatorColor; + private final String mMinimizedStateDescription; + private final String mRunningStateDescription; + /** * Various options for the running state of an app. */ @@ -240,6 +246,9 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, super(context, attrs, defStyle); mActivity = ActivityContext.lookupContext(context); FastBitmapDrawable.setFlagHoverEnabled(enableCursorHoverStates()); + mMinimizedStateDescription = getContext().getString( + R.string.app_minimized_state_description); + mRunningStateDescription = getContext().getString(R.string.app_running_state_description); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.BubbleTextView, defStyle, 0); @@ -432,6 +441,19 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, invalidate(); } + /** + * Returns state description of this icon. + */ + public String getIconStateDescription() { + if (mRunningAppState == MINIMIZED) { + return mMinimizedStateDescription; + } else if (mRunningAppState == RUNNING) { + return mRunningStateDescription; + } else { + return ""; + } + } + protected void setItemInfo(ItemInfoWithIcon itemInfo) { setTag(itemInfo); } @@ -768,13 +790,13 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, /** Draws a line under the app icon if this is representing a running app in Desktop Mode. */ protected void drawRunningAppIndicatorIfNecessary(Canvas canvas) { - if (mRunningAppState == RunningAppState.NOT_RUNNING || mDisplay != DISPLAY_TASKBAR) { + if (mRunningAppState == NOT_RUNNING || mDisplay != DISPLAY_TASKBAR) { return; } getIconBounds(mRunningAppIconBounds); Utilities.scaleRectAboutCenter(mRunningAppIconBounds, ICON_VISIBLE_AREA_FACTOR); - final boolean isMinimized = mRunningAppState == RunningAppState.MINIMIZED; + final boolean isMinimized = mRunningAppState == MINIMIZED; final int indicatorTop = mRunningAppIconBounds.bottom + mRunningAppIndicatorTopMargin; final int indicatorWidth = isMinimized ? mMinimizedAppIndicatorWidth : mRunningAppIndicatorWidth; |