Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9c592e21 authored by Pinyao Ting's avatar Pinyao Ting
Browse files

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 865dc9b3)
parent 02c79457
Loading
Loading
Loading
Loading
+22 −8
Original line number Diff line number Diff line
@@ -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) {