Refactor SettingsContentObserver and add it to follow typing feature.
Refactor SettingsContentObserver and rename it to AccessibilitySettingsContentObserver. Besides, we register it to observe follow typing feature preference value. The reasons behind refactor: 1. We change callback signature due to the consistency for register it by preference key, not by Uri. 2. We refactor the default preference key to a seperate method. Since the default value is related to accessibility, we rename it with accessibility prefix. 3. We can register different callback for difference collections of preference keys. Default preference keys: They existed in the previous constructor. 1. Settings.Secure.ACCESSIBILITY_ENABLED 2. Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES Bug: 194668976 Test: make RunSettingsRoboTests ROBOTEST_FILTER= AccessibilitySettingsTest AccessibilitySettingsContentObserverTest AccessibilityShortcutPreferenceFragmentTest MagnificationFollowTypingPreferenceControllerTest ToggleFeaturePreferenceFragmentTest ToggleScreenMagnificationPreferenceFragmentTest Change-Id: Iafd27e044ebe2536ae7ae55c1c80af54f7f0f822
This commit is contained in:
@@ -25,7 +25,6 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.icu.text.CaseMap;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.provider.Settings;
|
||||
@@ -64,7 +63,7 @@ public abstract class AccessibilityShortcutPreferenceFragment extends DashboardF
|
||||
protected ShortcutPreference mShortcutPreference;
|
||||
private AccessibilityManager.TouchExplorationStateChangeListener
|
||||
mTouchExplorationStateChangeListener;
|
||||
private SettingsContentObserver mSettingsContentObserver;
|
||||
private AccessibilitySettingsContentObserver mSettingsContentObserver;
|
||||
private CheckBox mSoftwareTypeCheckBox;
|
||||
private CheckBox mHardwareTypeCheckBox;
|
||||
|
||||
@@ -98,13 +97,11 @@ public abstract class AccessibilityShortcutPreferenceFragment extends DashboardF
|
||||
final List<String> shortcutFeatureKeys = new ArrayList<>();
|
||||
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS);
|
||||
shortcutFeatureKeys.add(Settings.Secure.ACCESSIBILITY_SHORTCUT_TARGET_SERVICE);
|
||||
mSettingsContentObserver = new SettingsContentObserver(new Handler(), shortcutFeatureKeys) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange, Uri uri) {
|
||||
updateShortcutPreferenceData();
|
||||
updateShortcutPreference();
|
||||
}
|
||||
};
|
||||
mSettingsContentObserver = new AccessibilitySettingsContentObserver(new Handler());
|
||||
mSettingsContentObserver.registerKeysToObserverCallback(shortcutFeatureKeys, key -> {
|
||||
updateShortcutPreferenceData();
|
||||
updateShortcutPreference();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user