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 PREVIEW_PREFERENCE_KEY = "color_inversion_preview";
|
||||||
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
|
private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
|
||||||
private static final int DIALOG_ID_EDIT_SHORTCUT = 1;
|
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 static final String EXTRA_SHORTCUT_TYPE = "shortcut_type";
|
||||||
private final Handler mHandler = new Handler();
|
private final Handler mHandler = new Handler();
|
||||||
private ShortcutPreference mShortcutPreference;
|
private ShortcutPreference mShortcutPreference;
|
||||||
@@ -129,7 +127,7 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
|||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
initShortcutPreference(savedInstanceState);
|
initShortcutPreference(savedInstanceState);
|
||||||
final List<String> enableServiceFeatureKeys = new ArrayList<>(/* initialCapacity= */ 1);
|
final List<String> enableServiceFeatureKeys = new ArrayList<>(/* initialCapacity= */ 1);
|
||||||
enableServiceFeatureKeys.add(DISPLAY_INVERSION_ENABLED);
|
enableServiceFeatureKeys.add(ENABLED);
|
||||||
mSettingsContentObserver = new SettingsContentObserver(mHandler, enableServiceFeatureKeys) {
|
mSettingsContentObserver = new SettingsContentObserver(mHandler, enableServiceFeatureKeys) {
|
||||||
@Override
|
@Override
|
||||||
public void onChange(boolean selfChange, Uri uri) {
|
public void onChange(boolean selfChange, Uri uri) {
|
||||||
|
@@ -24,7 +24,9 @@ import android.content.ComponentName;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.LayoutInflater;
|
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 String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
|
||||||
private static final int DIALOG_ID_EDIT_SHORTCUT = 1;
|
private static final int DIALOG_ID_EDIT_SHORTCUT = 1;
|
||||||
private static final List<AbstractPreferenceController> sControllers = new ArrayList<>();
|
private static final List<AbstractPreferenceController> sControllers = new ArrayList<>();
|
||||||
|
private final Handler mHandler = new Handler();
|
||||||
private ShortcutPreference mShortcutPreference;
|
private ShortcutPreference mShortcutPreference;
|
||||||
|
private SettingsContentObserver mSettingsContentObserver;
|
||||||
private int mUserShortcutType = UserShortcutType.DEFAULT;
|
private int mUserShortcutType = UserShortcutType.DEFAULT;
|
||||||
private CheckBox mSoftwareTypeCheckBox;
|
private CheckBox mSoftwareTypeCheckBox;
|
||||||
private CheckBox mHardwareTypeCheckBox;
|
private CheckBox mHardwareTypeCheckBox;
|
||||||
@@ -95,6 +99,16 @@ public final class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePrefe
|
|||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
initShortcutPreference(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);
|
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
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return SettingsEnums.ACCESSIBILITY_TOGGLE_DALTONIZER;
|
return SettingsEnums.ACCESSIBILITY_TOGGLE_DALTONIZER;
|
||||||
|
Reference in New Issue
Block a user