Color correction improvement (4/n)
Integrate with the multiple shortcut selections and change the behavior as below: - Register a setting content observer to monitor the service on/off status to update switch toggle UI. Bug: 145968068 Test: make RunSettingsRoboTests2 Change-Id: Ib195aab720d965a7a3047070999783fe9525bfd9
This commit is contained in:
@@ -60,8 +60,6 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
||||
private static final String PREVIEW_PREFERENCE_KEY = "color_inversion_preview";
|
||||
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
|
||||
private static final int DIALOG_ID_EDIT_SHORTCUT = 1;
|
||||
private static final String DISPLAY_INVERSION_ENABLED =
|
||||
Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED;
|
||||
private static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
|
||||
private final Handler mHandler = new Handler();
|
||||
private ShortcutPreference mShortcutPreference;
|
||||
@@ -129,7 +127,7 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
||||
Bundle savedInstanceState) {
|
||||
initShortcutPreference(savedInstanceState);
|
||||
final List<String> enableServiceFeatureKeys = new ArrayList<>(/* initialCapacity= */ 1);
|
||||
enableServiceFeatureKeys.add(DISPLAY_INVERSION_ENABLED);
|
||||
enableServiceFeatureKeys.add(ENABLED);
|
||||
mSettingsContentObserver = new SettingsContentObserver(mHandler, enableServiceFeatureKeys) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange, Uri uri) {
|
||||
|
@@ -24,7 +24,9 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.Resources;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -64,7 +66,9 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
||||
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
|
||||
private static final int DIALOG_ID_EDIT_SHORTCUT = 1;
|
||||
private static final List<AbstractPreferenceController> sControllers = new ArrayList<>();
|
||||
private final Handler mHandler = new Handler();
|
||||
private ShortcutPreference mShortcutPreference;
|
||||
private SettingsContentObserver mSettingsContentObserver;
|
||||
private int mUserShortcutType = UserShortcutType.DEFAULT;
|
||||
private CheckBox mSoftwareTypeCheckBox;
|
||||
private CheckBox mHardwareTypeCheckBox;
|
||||
@@ -95,6 +99,16 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
initShortcutPreference(savedInstanceState);
|
||||
final List<String> enableServiceFeatureKeys = new ArrayList<>(/* initialCapacity= */ 1);
|
||||
enableServiceFeatureKeys.add(ENABLED);
|
||||
mSettingsContentObserver = new SettingsContentObserver(mHandler, enableServiceFeatureKeys) {
|
||||
@Override
|
||||
public void onChange(boolean selfChange, Uri uri) {
|
||||
mSwitchBar.setCheckedInternal(
|
||||
Settings.Secure.getInt(getContentResolver(), ENABLED, State.OFF)
|
||||
== State.ON);
|
||||
}
|
||||
};
|
||||
return super.onCreateView(inflater, container, savedInstanceState);
|
||||
}
|
||||
|
||||
@@ -253,6 +267,18 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
mSettingsContentObserver.register(getContentResolver());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
mSettingsContentObserver.unregister(getContentResolver());
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.ACCESSIBILITY_TOGGLE_DALTONIZER;
|
||||
|
Reference in New Issue
Block a user