From deb2e2c35e93e19eaada4f35666bca8028ae06a0 Mon Sep 17 00:00:00 2001 From: Brandon Dayauon Date: Tue, 23 Apr 2024 10:57:18 -0700 Subject: [PATCH] Make all apps text focusable by accessibility. From b/330638194, the requirement is that 1. "all apps" can be focusable with talkback 2. "all apps" text is persisted when in accessibility mode. Merged-In:Ibabb92bd9d202221fdc9cfacb585755167898187 bug:330638194 Test: manual video: https://drive.google.com/file/d/1QI_F4dUijfnU2ahE2Mg6yrmRJfOVyuVJ/view?usp=sharing Flag: None Change-Id: Ibabb92bd9d202221fdc9cfacb585755167898187 --- .../launcher3/appprediction/AppsDividerView.java | 12 ++++++++++-- .../quickstep/util/QuickstepOnboardingPrefs.java | 13 ++++--------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java b/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java index 694475ae69..84c2ed252b 100644 --- a/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java +++ b/quickstep/src/com/android/launcher3/appprediction/AppsDividerView.java @@ -28,14 +28,15 @@ import android.text.StaticLayout; import android.text.TextPaint; import android.util.AttributeSet; import android.view.View; +import android.view.accessibility.AccessibilityManager; import androidx.annotation.ColorInt; import androidx.core.content.ContextCompat; import com.android.launcher3.R; +import com.android.launcher3.Utilities; import com.android.launcher3.allapps.FloatingHeaderRow; import com.android.launcher3.allapps.FloatingHeaderView; -import com.android.launcher3.util.Themes; /** * A view which shows a horizontal divider @@ -54,6 +55,7 @@ public class AppsDividerView extends View implements FloatingHeaderRow { private final @ColorInt int mStrokeColor; private final @ColorInt int mAllAppsLabelTextColor; + private final AccessibilityManager mAccessibilityManager; private Layout mAllAppsLabelLayout; private boolean mShowAllAppsLabel; @@ -87,7 +89,8 @@ public class AppsDividerView extends View implements FloatingHeaderRow { mAllAppsLabelTextColor = ContextCompat.getColor(context, R.color.material_color_on_surface_variant); - mShowAllAppsLabel = !ALL_APPS_VISITED_COUNT.hasReachedMax(context); + mAccessibilityManager = AccessibilityManager.getInstance(context); + setShowAllAppsLabel(!ALL_APPS_VISITED_COUNT.hasReachedMax(context)); } public void setup(FloatingHeaderView parent, FloatingHeaderRow[] rows, boolean tabsHidden) { @@ -99,6 +102,9 @@ public class AppsDividerView extends View implements FloatingHeaderRow { /** {@code true} if all apps label should be shown in place of divider. */ public void setShowAllAppsLabel(boolean showAllAppsLabel) { + if (mAccessibilityManager.isEnabled() && !Utilities.isRunningInTestHarness()) { + showAllAppsLabel = true; + } if (showAllAppsLabel != mShowAllAppsLabel) { mShowAllAppsLabel = showAllAppsLabel; updateDividerType(); @@ -148,6 +154,7 @@ public class AppsDividerView extends View implements FloatingHeaderRow { mDividerType = dividerType; int topPadding; int bottomPadding; + setContentDescription(null); switch (dividerType) { case LINE: topPadding = 0; @@ -161,6 +168,7 @@ public class AppsDividerView extends View implements FloatingHeaderRow { bottomPadding = getResources() .getDimensionPixelSize(R.dimen.all_apps_label_bottom_padding); mPaint.setColor(mAllAppsLabelTextColor); + setContentDescription(mAllAppsLabelLayout.getText()); break; case NONE: default: diff --git a/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java b/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java index 9df568ec76..2a27dea744 100644 --- a/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java +++ b/quickstep/src/com/android/quickstep/util/QuickstepOnboardingPrefs.java @@ -136,21 +136,16 @@ public class QuickstepOnboardingPrefs { }); } - if (!ALL_APPS_VISITED_COUNT.hasReachedMax(launcher)) { + if (!Utilities.isRunningInTestHarness()) { launcher.getStateManager().addStateListener(new StateListener() { @Override public void onStateTransitionComplete(LauncherState finalState) { if (finalState == ALL_APPS) { ALL_APPS_VISITED_COUNT.increment(launcher); - return; - } - - boolean hasReachedMaxCount = ALL_APPS_VISITED_COUNT.hasReachedMax(launcher); - launcher.getAppsView().getFloatingHeaderView().findFixedRowByType( - AppsDividerView.class).setShowAllAppsLabel(!hasReachedMaxCount); - if (hasReachedMaxCount) { - launcher.getStateManager().removeStateListener(this); } + launcher.getAppsView().getFloatingHeaderView() + .findFixedRowByType(AppsDividerView.class) + .setShowAllAppsLabel(!ALL_APPS_VISITED_COUNT.hasReachedMax(launcher)); } }); }