Fix incorrect UI after triple-tap is disabled

The preference summary is not changed after
users disable the triple tap shortcut by the confirm
dialog. It is due to the fact that the fragment doesn't
observe the settings value change.

To fix it, we add the settings key to observe the change.

Bug: 208755360
Test: manual test
Change-Id: Ie5b7fc5e67c5491b53485af0d3d68d1789aeace4
This commit is contained in:
ryanlwlin
2021-12-02 20:51:21 +08:00
committed by Ryan Lin
parent 395ea90b83
commit a992b611bf
2 changed files with 15 additions and 3 deletions

View File

@@ -143,9 +143,7 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
setPreferenceScreen(preferenceScreen);
}
final List<String> shortcutFeatureKeys = new ArrayList<>();
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS);
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE);
final List<String> shortcutFeatureKeys = getFeatureSettingsKeys();
mSettingsContentObserver = new SettingsContentObserver(new Handler(), shortcutFeatureKeys) {
@Override
public void onChange(boolean selfChange, Uri uri) {
@@ -155,6 +153,13 @@ public abstract class ToggleFeaturePreferenceFragment extends SettingsPreference
};
}
protected List<String> getFeatureSettingsKeys() {
final List<String> shortcutFeatureKeys = new ArrayList<>();
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS);
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE);
return shortcutFeatureKeys;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

View File

@@ -275,6 +275,13 @@ public class ToggleScreenMagnificationPreferenceFragment extends
return context.getText(resId);
}
@Override
protected List<String> getFeatureSettingsKeys() {
final List<String> shortcutKeys = super.getFeatureSettingsKeys();
shortcutKeys.add(Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED);
return shortcutKeys;
}
@Override
protected CharSequence getShortcutTypeSummary(Context context) {
if (!mShortcutPreference.isChecked()) {