Fix inconsistent shortcut strings on accessibility setting and edit dialog

Root cause: Base class provides an override function for accessibility settings shortcut preference. But, it cannot update to the edit dialog.
Solution: Refine the resilience function and base class apply into accessibility settings shortcut preference and edit dailog.

Bug: 228830417
Test: Manual testing on all accessibility page and edit dialog
Change-Id: I84bc63a39cd9cfa7e12944dff20ee6b92879008d
This commit is contained in:
menghanli
2022-04-15 08:00:36 +08:00
committed by Menghan Li
parent 3ed73b7b2d
commit 50520c2d3f
7 changed files with 18 additions and 26 deletions

View File

@@ -270,12 +270,10 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
public Dialog onCreateDialog(int dialogId) {
switch (dialogId) {
case DialogEnums.EDIT_SHORTCUT:
final CharSequence dialogTitle = getPrefContext().getString(
R.string.accessibility_shortcut_title, mPackageName);
final int dialogType = WizardManagerHelper.isAnySetupWizard(getIntent())
? DialogType.EDIT_SHORTCUT_GENERIC_SUW : DialogType.EDIT_SHORTCUT_GENERIC;
mDialog = AccessibilityDialogUtils.showEditShortcutDialog(
getPrefContext(), dialogType, dialogTitle,
getPrefContext(), dialogType, getShortcutTitle(),
this::callOnAlertDialogCheckboxClicked);
setupEditShortcutDialog(mDialog);
return mDialog;
@@ -340,9 +338,8 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
switchPreference.setTitle(title);
}
protected void updateShortcutTitle(ShortcutPreference shortcutPreference) {
final CharSequence title = getString(R.string.accessibility_shortcut_title, mPackageName);
shortcutPreference.setTitle(title);
protected CharSequence getShortcutTitle() {
return getString(R.string.accessibility_shortcut_title, mPackageName);
}
protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
@@ -515,8 +512,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
mShortcutPreference.setPersistent(false);
mShortcutPreference.setKey(getShortcutPreferenceKey());
mShortcutPreference.setOnClickCallback(this);
updateShortcutTitle(mShortcutPreference);
mShortcutPreference.setTitle(getShortcutTitle());
final PreferenceCategory generalCategory = findPreference(KEY_GENERAL_CATEGORY);
generalCategory.addPreference(mShortcutPreference);