From 8f38c46c5177e7f491f21cccfe5c48fb75c481be Mon Sep 17 00:00:00 2001 From: Peter_Liang Date: Sat, 12 Feb 2022 17:02:18 +0800 Subject: [PATCH 1/4] Polish and humanize the title for Text and Reading Options. Bug: 219163254 Test: manual test Change-Id: Iefa3ec8455f36338a0bf067b5ae2122afb80b64b --- res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 82bccee92b7..931de8341a0 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -5229,7 +5229,7 @@ About %1$s - Text and reading options + Display size and text Email: Plans for time machine, v2 From 61264d046db98e85de5478c97124b6d250858a4c Mon Sep 17 00:00:00 2001 From: Peter_Liang Date: Sat, 12 Feb 2022 17:36:20 +0800 Subject: [PATCH 2/4] Polish and humanize the title for the entry of Text and Reading Options in SuW. Bug: 219163254 Test: manual test Change-Id: Ic908918a1b4978dd10e42e13c619bb8d0a697467 --- AndroidManifest.xml | 2 +- res/values/strings.xml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index ce257418fc5..92dfbe51aac 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1974,7 +1974,7 @@ + android:resource="@string/accessibility_text_reading_options_suggestion_title" /> diff --git a/res/values/strings.xml b/res/values/strings.xml index 931de8341a0..36e1193e3ed 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -5230,6 +5230,8 @@ About %1$s Display size and text + + Change how text displays Email: Plans for time machine, v2 From 426e781f19ffd4e38b08c15cdc999c79ea621fd6 Mon Sep 17 00:00:00 2001 From: menghanli Date: Tue, 8 Feb 2022 14:06:24 +0800 Subject: [PATCH 3/4] Accessibility framework & Settings to support the Android accessibility intro & footer - Implements a TopIntroPreference into the Accessibility Settings base fragment. - Creates a protected API or variable to provide content to support if needed. Bug: 218407398 Test: make RunSettingsRoboTests ROBOTEST_FILTER=ToggleFeaturePreferenceFragmentTest Change-Id: Id0f7700bb8f62960951913db8bd034fce1b15a90 --- .../ToggleFeaturePreferenceFragment.java | 16 ++++++++++++++++ .../ToggleFeaturePreferenceFragmentTest.java | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java index 08e9b88878a..5ee455070db 100644 --- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java +++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java @@ -63,6 +63,7 @@ import com.android.settings.widget.SettingsMainSwitchPreference; import com.android.settingslib.accessibility.AccessibilityUtils; import com.android.settingslib.widget.IllustrationPreference; import com.android.settingslib.widget.OnMainSwitchChangeListener; +import com.android.settingslib.widget.TopIntroPreference; import com.google.android.setupcompat.util.WizardManagerHelper; @@ -92,8 +93,10 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference protected Uri mImageUri; private CharSequence mDescription; protected CharSequence mHtmlDescription; + protected CharSequence mTopIntroTitle; private static final String DRAWABLE_FOLDER = "drawable"; + protected static final String KEY_TOP_INTRO_PREFERENCE = "top_intro"; protected static final String KEY_USE_SERVICE_PREFERENCE = "use_service"; public static final String KEY_GENERAL_CATEGORY = "general_categories"; protected static final String KEY_HTML_DESCRIPTION_PREFERENCE = "html_description"; @@ -182,6 +185,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference // Need to be called as early as possible. Protected variables will be assigned here. onProcessArguments(getArguments()); + initTopIntroPreference(); initAnimatedImagePreference(); initToggleServiceSwitchPreference(); initGeneralCategory(); @@ -393,6 +397,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference /** Customizes the order by preference key. */ protected List getPreferenceOrderList() { final List lists = new ArrayList<>(); + lists.add(KEY_TOP_INTRO_PREFERENCE); lists.add(KEY_ANIMATED_IMAGE); lists.add(KEY_USE_SERVICE_PREFERENCE); lists.add(KEY_GENERAL_CATEGORY); @@ -461,6 +466,17 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference getPreferenceScreen().addPreference(illustrationPreference); } + @VisibleForTesting + void initTopIntroPreference() { + if (TextUtils.isEmpty(mTopIntroTitle)) { + return; + } + final TopIntroPreference topIntroPreference = new TopIntroPreference(getPrefContext()); + topIntroPreference.setKey(KEY_TOP_INTRO_PREFERENCE); + topIntroPreference.setTitle(mTopIntroTitle); + getPreferenceScreen().addPreference(topIntroPreference); + } + private void initToggleServiceSwitchPreference() { mToggleServiceSwitchPreference = new SettingsMainSwitchPreference(getPrefContext()); mToggleServiceSwitchPreference.setKey(KEY_USE_SERVICE_PREFERENCE); diff --git a/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java b/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java index 5ea4edc8a8d..34a2f5b3eba 100644 --- a/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java +++ b/tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java @@ -51,6 +51,7 @@ import com.android.settings.R; import com.android.settings.accessibility.AccessibilityDialogUtils.DialogType; import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType; import com.android.settings.testutils.shadow.ShadowFragment; +import com.android.settingslib.widget.TopIntroPreference; import org.junit.Before; import org.junit.Test; @@ -81,6 +82,7 @@ public class ToggleFeaturePreferenceFragmentTest { private static final String PLACEHOLDER_DIALOG_TITLE = "title"; private static final String DEFAULT_SUMMARY = "default summary"; private static final String DEFAULT_DESCRIPTION = "default description"; + private static final String DEFAULT_TOP_INTRO = "default top intro"; private static final String SOFTWARE_SHORTCUT_KEY = Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS; @@ -293,6 +295,23 @@ public class ToggleFeaturePreferenceFragmentTest { assertThat(getLatestPopupWindow().isShowing()).isTrue(); } + @Test + public void initTopIntroPreference_hasTopIntroTitle_shouldSetAsExpectedValue() { + mFragment.mTopIntroTitle = DEFAULT_TOP_INTRO; + mFragment.initTopIntroPreference(); + + TopIntroPreference topIntroPreference = + (TopIntroPreference) mFragment.getPreferenceScreen().getPreference(/* index= */ 0); + assertThat(topIntroPreference.getTitle().toString()).isEqualTo(DEFAULT_TOP_INTRO); + } + + @Test + public void initTopIntroPreference_topIntroTitleIsNull_shouldNotAdded() { + mFragment.initTopIntroPreference(); + + assertThat(mFragment.getPreferenceScreen().getPreferenceCount()).isEqualTo(0); + } + @Test public void createFooterPreference_shouldSetAsExpectedValue() { mFragment.createFooterPreference(mFragment.getPreferenceScreen(), From aa02174745dd158c836ae5060ccd15c881c5cd63 Mon Sep 17 00:00:00 2001 From: menghanli Date: Tue, 8 Feb 2022 21:56:55 +0800 Subject: [PATCH 4/4] Integrate new accessibility intro attr into settings - Accessibilty service: AccessibilityService_intro - Accesibility shortcut: AccessibilityShortcutTarget_intro Bug: 218407448 Test: manual test Change-Id: I8d8ff1bbcc999fb09aa49ffcd458a457f061f82c --- .../AccessibilityDetailsSettingsFragment.java | 3 +++ .../accessibility/AccessibilitySettings.java | 16 ++++++++++------ .../ToggleFeaturePreferenceFragment.java | 5 +++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/com/android/settings/accessibility/AccessibilityDetailsSettingsFragment.java b/src/com/android/settings/accessibility/AccessibilityDetailsSettingsFragment.java index 5fc4cd21797..2cdbb332e0f 100644 --- a/src/com/android/settings/accessibility/AccessibilityDetailsSettingsFragment.java +++ b/src/com/android/settings/accessibility/AccessibilityDetailsSettingsFragment.java @@ -234,6 +234,9 @@ public class AccessibilityDetailsSettingsFragment extends InstrumentedFragment { final String htmlDescription = info.loadHtmlDescription(getActivity().getPackageManager()); extras.putString(AccessibilitySettings.EXTRA_HTML_DESCRIPTION, htmlDescription); + final CharSequence intro = info.loadIntro(getActivity().getPackageManager()); + extras.putCharSequence(AccessibilitySettings.EXTRA_INTRO, intro); + // We will log nonA11yTool status from PolicyWarningUIController; others none. extras.putLong(AccessibilitySettings.EXTRA_TIME_FOR_LOGGING, getActivity().getIntent().getLongExtra( diff --git a/src/com/android/settings/accessibility/AccessibilitySettings.java b/src/com/android/settings/accessibility/AccessibilitySettings.java index e834640e678..6539f326734 100644 --- a/src/com/android/settings/accessibility/AccessibilitySettings.java +++ b/src/com/android/settings/accessibility/AccessibilitySettings.java @@ -94,6 +94,7 @@ public class AccessibilitySettings extends DashboardFragment { static final String EXTRA_TITLE_RES = "title_res"; static final String EXTRA_RESOLVE_INFO = "resolve_info"; static final String EXTRA_SUMMARY = "summary"; + static final String EXTRA_INTRO = "intro"; static final String EXTRA_SETTINGS_TITLE = "settings_title"; static final String EXTRA_COMPONENT_NAME = "component_name"; static final String EXTRA_SETTINGS_COMPONENT_NAME = "settings_component_name"; @@ -570,14 +571,15 @@ public class AccessibilitySettings extends DashboardFragment { final String prefKey = preference.getKey(); final int imageRes = info.getAnimatedImageRes(); + final CharSequence intro = info.loadIntro(mPm); final CharSequence description = getServiceDescription(mContext, info, serviceEnabled); final String htmlDescription = info.loadHtmlDescription(mPm); final String settingsClassName = info.getSettingsActivityName(); final String tileServiceClassName = info.getTileServiceClassName(); - putBasicExtras(preference, prefKey, title, description, imageRes, htmlDescription, - componentName); + putBasicExtras(preference, prefKey, title, intro, description, imageRes, + htmlDescription, componentName); putServiceExtras(preference, resolveInfo, serviceEnabled); putSettingsExtras(preference, packageName, settingsClassName); putTileServiceExtras(preference, packageName, tileServiceClassName); @@ -630,14 +632,15 @@ public class AccessibilitySettings extends DashboardFragment { setRestrictedPreferenceEnabled(preference, permittedServices, serviceEnabled); final String prefKey = preference.getKey(); + final CharSequence intro = info.loadIntro(mPm); final String description = info.loadDescription(mPm); final int imageRes = info.getAnimatedImageRes(); final String htmlDescription = info.loadHtmlDescription(mPm); final String settingsClassName = info.getSettingsActivityName(); final String tileServiceClassName = info.getTileServiceClassName(); - putBasicExtras(preference, prefKey, title, description, imageRes, htmlDescription, - componentName); + putBasicExtras(preference, prefKey, title, intro, description, imageRes, + htmlDescription, componentName); putSettingsExtras(preference, componentName.getPackageName(), settingsClassName); putTileServiceExtras(preference, componentName.getPackageName(), tileServiceClassName); @@ -722,11 +725,12 @@ public class AccessibilitySettings extends DashboardFragment { /** Puts the basic extras into {@link RestrictedPreference}'s getExtras(). */ private void putBasicExtras(RestrictedPreference preference, String prefKey, - CharSequence title, CharSequence summary, int imageRes, String htmlDescription, - ComponentName componentName) { + CharSequence title, CharSequence intro, CharSequence summary, int imageRes, + String htmlDescription, ComponentName componentName) { final Bundle extras = preference.getExtras(); extras.putString(EXTRA_PREFERENCE_KEY, prefKey); extras.putCharSequence(EXTRA_TITLE, title); + extras.putCharSequence(EXTRA_INTRO, intro); extras.putCharSequence(EXTRA_SUMMARY, summary); extras.putParcelable(EXTRA_COMPONENT_NAME, componentName); extras.putInt(EXTRA_ANIMATED_IMAGE_RES, imageRes); diff --git a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java index 5ee455070db..5747d0a1101 100644 --- a/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java +++ b/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragment.java @@ -392,6 +392,11 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference mHtmlDescription = arguments.getCharSequence( AccessibilitySettings.EXTRA_HTML_DESCRIPTION); } + + // Intro. + if (arguments.containsKey(AccessibilitySettings.EXTRA_INTRO)) { + mTopIntroTitle = arguments.getCharSequence(AccessibilitySettings.EXTRA_INTRO); + } } /** Customizes the order by preference key. */