From fc3f25c8b52078ba29856dcaa68f782c62855c32 Mon Sep 17 00:00:00 2001 From: Amy Hsu Date: Thu, 8 Sep 2022 00:50:38 +0000 Subject: [PATCH] [RRS] Send event to AccessibilityManager when an unselect radio button is selected. Change the screen resolution will cause re-layout the screen, so the focus will back to the first view. Before we actually set the screen resolution, send an event to the AccessibilityManager and set what it should say when the user selects the unselect option. Therefore TB will say "selected" before the screen refreshes. bug: 229352892 Test: Enable/disable Talkback and check RRS app behaivor. It should read "selected" after user choose one un-selected option. Change-Id: If14ed3685f85962d4e4b1d4961216c6ca5d5f0f8 --- res/values/strings.xml | 2 ++ .../settings/display/ScreenResolutionFragment.java | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/res/values/strings.xml b/res/values/strings.xml index 9cdbad75d15..a9f6c1e2e91 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -2983,6 +2983,8 @@ 1440p QHD+ Full resolution uses more of your battery. Switching your resolution may cause some apps to restart. + + Selected Colors diff --git a/src/com/android/settings/display/ScreenResolutionFragment.java b/src/com/android/settings/display/ScreenResolutionFragment.java index 914d4be568a..7c4b3aeef03 100644 --- a/src/com/android/settings/display/ScreenResolutionFragment.java +++ b/src/com/android/settings/display/ScreenResolutionFragment.java @@ -29,6 +29,8 @@ import android.hardware.display.DisplayManager; import android.provider.Settings; import android.text.TextUtils; import android.view.Display; +import android.view.accessibility.AccessibilityEvent; +import android.view.accessibility.AccessibilityManager; import androidx.annotation.VisibleForTesting; import androidx.preference.PreferenceScreen; @@ -65,6 +67,7 @@ public class ScreenResolutionFragment extends RadioButtonPickerFragment { private IllustrationPreference mImagePreference; private DisplayObserver mDisplayObserver; + private AccessibilityManager mAccessibilityManager; @Override public void onAttach(Context context) { @@ -72,6 +75,7 @@ public class ScreenResolutionFragment extends RadioButtonPickerFragment { mDefaultDisplay = context.getSystemService(DisplayManager.class).getDisplay(Display.DEFAULT_DISPLAY); + mAccessibilityManager = context.getSystemService(AccessibilityManager.class); mResources = context.getResources(); mScreenResolutionOptions = mResources.getStringArray(R.array.config_screen_resolution_options_strings); @@ -215,6 +219,14 @@ public class ScreenResolutionFragment extends RadioButtonPickerFragment { if (!mDisplayObserver.setPendingResolutionChange(selectedWidth)) { return; } + + if (mAccessibilityManager.isEnabled()) { + AccessibilityEvent event = AccessibilityEvent.obtain(); + event.setEventType(AccessibilityEvent.TYPE_ANNOUNCEMENT); + event.getText().add(mResources.getString(R.string.screen_resolution_selected_a11y)); + mAccessibilityManager.sendAccessibilityEvent(event); + } + super.onRadioButtonClicked(selected); }