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
This commit is contained in:
Brandon Dayauon
2024-04-23 10:57:18 -07:00
parent c5fec774b2
commit deb2e2c35e
2 changed files with 14 additions and 11 deletions
@@ -28,14 +28,15 @@ import android.text.StaticLayout;
import android.text.TextPaint; import android.text.TextPaint;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
import android.view.accessibility.AccessibilityManager;
import androidx.annotation.ColorInt; import androidx.annotation.ColorInt;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import com.android.launcher3.R; import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.allapps.FloatingHeaderRow; import com.android.launcher3.allapps.FloatingHeaderRow;
import com.android.launcher3.allapps.FloatingHeaderView; import com.android.launcher3.allapps.FloatingHeaderView;
import com.android.launcher3.util.Themes;
/** /**
* A view which shows a horizontal divider * 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 mStrokeColor;
private final @ColorInt int mAllAppsLabelTextColor; private final @ColorInt int mAllAppsLabelTextColor;
private final AccessibilityManager mAccessibilityManager;
private Layout mAllAppsLabelLayout; private Layout mAllAppsLabelLayout;
private boolean mShowAllAppsLabel; private boolean mShowAllAppsLabel;
@@ -87,7 +89,8 @@ public class AppsDividerView extends View implements FloatingHeaderRow {
mAllAppsLabelTextColor = ContextCompat.getColor(context, mAllAppsLabelTextColor = ContextCompat.getColor(context,
R.color.material_color_on_surface_variant); 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) { 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. */ /** {@code true} if all apps label should be shown in place of divider. */
public void setShowAllAppsLabel(boolean showAllAppsLabel) { public void setShowAllAppsLabel(boolean showAllAppsLabel) {
if (mAccessibilityManager.isEnabled() && !Utilities.isRunningInTestHarness()) {
showAllAppsLabel = true;
}
if (showAllAppsLabel != mShowAllAppsLabel) { if (showAllAppsLabel != mShowAllAppsLabel) {
mShowAllAppsLabel = showAllAppsLabel; mShowAllAppsLabel = showAllAppsLabel;
updateDividerType(); updateDividerType();
@@ -148,6 +154,7 @@ public class AppsDividerView extends View implements FloatingHeaderRow {
mDividerType = dividerType; mDividerType = dividerType;
int topPadding; int topPadding;
int bottomPadding; int bottomPadding;
setContentDescription(null);
switch (dividerType) { switch (dividerType) {
case LINE: case LINE:
topPadding = 0; topPadding = 0;
@@ -161,6 +168,7 @@ public class AppsDividerView extends View implements FloatingHeaderRow {
bottomPadding = getResources() bottomPadding = getResources()
.getDimensionPixelSize(R.dimen.all_apps_label_bottom_padding); .getDimensionPixelSize(R.dimen.all_apps_label_bottom_padding);
mPaint.setColor(mAllAppsLabelTextColor); mPaint.setColor(mAllAppsLabelTextColor);
setContentDescription(mAllAppsLabelLayout.getText());
break; break;
case NONE: case NONE:
default: default:
@@ -136,21 +136,16 @@ public class QuickstepOnboardingPrefs {
}); });
} }
if (!ALL_APPS_VISITED_COUNT.hasReachedMax(launcher)) { if (!Utilities.isRunningInTestHarness()) {
launcher.getStateManager().addStateListener(new StateListener<LauncherState>() { launcher.getStateManager().addStateListener(new StateListener<LauncherState>() {
@Override @Override
public void onStateTransitionComplete(LauncherState finalState) { public void onStateTransitionComplete(LauncherState finalState) {
if (finalState == ALL_APPS) { if (finalState == ALL_APPS) {
ALL_APPS_VISITED_COUNT.increment(launcher); 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));
} }
}); });
} }