[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
This commit is contained in:
Amy Hsu
2022-09-08 00:50:38 +00:00
parent 7cfbf2e0d3
commit fc3f25c8b5
2 changed files with 14 additions and 0 deletions

View File

@@ -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);
}