mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-19 18:58:19 +00:00
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:
@@ -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:
|
||||
|
||||
@@ -136,21 +136,16 @@ public class QuickstepOnboardingPrefs {
|
||||
});
|
||||
}
|
||||
|
||||
if (!ALL_APPS_VISITED_COUNT.hasReachedMax(launcher)) {
|
||||
if (!Utilities.isRunningInTestHarness()) {
|
||||
launcher.getStateManager().addStateListener(new StateListener<LauncherState>() {
|
||||
@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));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user