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

Commit 432e0513 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "perform accessbility focus when the recyclerview doesn't gain focus...

Merge "perform accessbility focus when the recyclerview doesn't gain focus after fragment replacement in SettingsActivity" into ub-launcher3-master
parents ebc50f30 865dc9b3
Loading
Loading
Loading
Loading
+14 −0
Original line number Original line Diff line number Diff line
@@ -16,6 +16,8 @@


package com.android.launcher3.settings;
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.SessionCommitReceiver.ADD_ICON_PREFERENCE_KEY;
import static com.android.launcher3.states.RotationHelper.ALLOW_ROTATION_PREFERENCE_KEY;
import static com.android.launcher3.states.RotationHelper.ALLOW_ROTATION_PREFERENCE_KEY;
import static com.android.launcher3.states.RotationHelper.getAllowRotationDefaultValue;
import static com.android.launcher3.states.RotationHelper.getAllowRotationDefaultValue;
@@ -29,6 +31,7 @@ import android.os.Bundle;
import android.provider.Settings;
import android.provider.Settings;
import android.text.TextUtils;
import android.text.TextUtils;


import androidx.annotation.NonNull;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentActivity;
@@ -248,6 +251,8 @@ public class SettingsActivity extends FragmentActivity
                if (highlighter != null) {
                if (highlighter != null) {
                    getView().postDelayed(highlighter, DELAY_HIGHLIGHT_DURATION_MILLIS);
                    getView().postDelayed(highlighter, DELAY_HIGHLIGHT_DURATION_MILLIS);
                    mPreferenceHighlighted = true;
                    mPreferenceHighlighted = true;
                } else {
                    requestAccessibilityFocus(getListView());
                }
                }
            }
            }
        }
        }
@@ -268,6 +273,15 @@ public class SettingsActivity extends FragmentActivity
            return position >= 0 ? new PreferenceHighlighter(list, position) : null;
            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
        @Override
        public void onDestroy() {
        public void onDestroy() {
            if (mNotificationDotsObserver != null) {
            if (mNotificationDotsObserver != null) {