diff options
author | Pinyao Ting <pinyaoting@google.com> | 2019-12-05 11:00:11 -0800 |
---|---|---|
committer | Pinyao Ting <pinyaoting@google.com> | 2019-12-10 11:28:50 -0800 |
commit | 9c592e210e3f8cdc988db39ac72c3d29c13250a2 (patch) | |
tree | 03fa067a4dd377a7f2e15364d60a2028200660a7 | |
parent | 02c794578c380745341956f1441d4c12798ae13f (diff) | |
download | android_packages_apps_Trebuchet-9c592e210e3f8cdc988db39ac72c3d29c13250a2.tar.gz android_packages_apps_Trebuchet-9c592e210e3f8cdc988db39ac72c3d29c13250a2.tar.bz2 android_packages_apps_Trebuchet-9c592e210e3f8cdc988db39ac72c3d29c13250a2.zip |
perform accessbility focus when the recyclerview doesn't gain focus
after fragment replacement in SettingsActivity
Bug: 145475911
Test: Settings -> App & Notifications -> Default Apps -> Enable Talkback
-> Gear Button next to Home app -> About -> Verify Talkback reads the
first item in the page
Change-Id: I100e646ad2aba0081b48b86ec408ce8e76a80713
Merged-In: I100e646ad2aba0081b48b86ec408ce8e76a80713
(cherry picked from commit 865dc9b3b17084c73cf07868b115cc7710b7dfc1)
-rw-r--r-- | src/com/android/launcher3/settings/SettingsActivity.java | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/src/com/android/launcher3/settings/SettingsActivity.java b/src/com/android/launcher3/settings/SettingsActivity.java index 18b6094fb..8d2db78c7 100644 --- a/src/com/android/launcher3/settings/SettingsActivity.java +++ b/src/com/android/launcher3/settings/SettingsActivity.java @@ -16,6 +16,8 @@ package com.android.launcher3.settings; +import static androidx.core.view.accessibility.AccessibilityNodeInfoCompat.ACTION_ACCESSIBILITY_FOCUS; + import static com.android.launcher3.SessionCommitReceiver.ADD_ICON_PREFERENCE_KEY; import static com.android.launcher3.states.RotationHelper.ALLOW_ROTATION_PREFERENCE_KEY; import static com.android.launcher3.states.RotationHelper.getAllowRotationDefaultValue; @@ -32,14 +34,7 @@ import android.os.Bundle; import android.provider.Settings; import android.text.TextUtils; -import com.android.launcher3.LauncherFiles; -import com.android.launcher3.R; -import com.android.launcher3.Utilities; -import com.android.launcher3.config.FeatureFlags; -import com.android.launcher3.graphics.GridOptionsProvider; -import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper; -import com.android.launcher3.util.SecureSettingsObserver; - +import androidx.annotation.NonNull; import androidx.preference.Preference; import androidx.preference.PreferenceFragment; import androidx.preference.PreferenceFragment.OnPreferenceStartFragmentCallback; @@ -48,6 +43,14 @@ import androidx.preference.PreferenceGroup.PreferencePositionCallback; import androidx.preference.PreferenceScreen; import androidx.recyclerview.widget.RecyclerView; +import com.android.launcher3.LauncherFiles; +import com.android.launcher3.R; +import com.android.launcher3.Utilities; +import com.android.launcher3.config.FeatureFlags; +import com.android.launcher3.graphics.GridOptionsProvider; +import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper; +import com.android.launcher3.util.SecureSettingsObserver; + /** * Settings activity for Launcher. Currently implements the following setting: Allow rotation */ @@ -248,6 +251,8 @@ public class SettingsActivity extends Activity if (highlighter != null) { getView().postDelayed(highlighter, DELAY_HIGHLIGHT_DURATION_MILLIS); mPreferenceHighlighted = true; + } else { + requestAccessibilityFocus(getListView()); } } } @@ -268,6 +273,15 @@ public class SettingsActivity extends Activity return position >= 0 ? new PreferenceHighlighter(list, position) : null; } + private void requestAccessibilityFocus(@NonNull final RecyclerView rv) { + rv.post(() -> { + if (!rv.hasFocus() && rv.getChildCount() > 0) { + rv.getChildAt(0) + .performAccessibilityAction(ACTION_ACCESSIBILITY_FOCUS, null); + } + }); + } + @Override public void onDestroy() { if (mNotificationDotsObserver != null) { |