Set a pane title on the some a11y windows' root views

This allows a service to identify a window based on the title.
Configuration changes will restart the activity, losing a11y focus.
A11y focus may be retained by matching windows and unique ids. This
CL allows matching by window/pane title.

Test: manual
Bug: 175182916
Bug: 175184180
Change-Id: Iae4627795c2a35e57b651d9e7ce7527a0ddb1353
This commit is contained in:
Sally
2022-05-17 23:39:21 +00:00
committed by sallyyuen
parent bbab32409c
commit 301d621608
3 changed files with 31 additions and 0 deletions

View File

@@ -24,6 +24,7 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.View;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.IntDef; import androidx.annotation.IntDef;
@@ -104,6 +105,16 @@ public class TextReadingPreferenceFragment extends DashboardFragment {
} }
} }
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final View rootView = getActivity().getWindow().peekDecorView();
if (rootView != null) {
rootView.setAccessibilityPaneTitle(getString(
R.string.accessibility_text_reading_options_title));
}
}
@Override @Override
protected int getPreferenceScreenResId() { protected int getPreferenceScreenResId() {
return R.xml.accessibility_text_reading_options; return R.xml.accessibility_text_reading_options;

View File

@@ -44,6 +44,16 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED; private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final View rootView = getActivity().getWindow().peekDecorView();
if (rootView != null) {
rootView.setAccessibilityPaneTitle(getString(
R.string.accessibility_display_inversion_preference_title));
}
}
@Override @Override
public int getMetricsCategory() { public int getMetricsCategory() {
return SettingsEnums.ACCESSIBILITY_COLOR_INVERSION_SETTINGS; return SettingsEnums.ACCESSIBILITY_COLOR_INVERSION_SETTINGS;

View File

@@ -73,6 +73,16 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
return sControllers; return sControllers;
} }
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
final View rootView = getActivity().getWindow().peekDecorView();
if (rootView != null) {
rootView.setAccessibilityPaneTitle(getString(
R.string.accessibility_display_daltonizer_preference_title));
}
}
@Override @Override
public void onCheckedChanged(Preference preference) { public void onCheckedChanged(Preference preference) {
for (AbstractPreferenceController controller : sControllers) { for (AbstractPreferenceController controller : sControllers) {