summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java18
-rw-r--r--src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java23
2 files changed, 19 insertions, 22 deletions
diff --git a/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java b/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java
index 0593aa0256..a3cff3da3d 100644
--- a/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java
+++ b/src/com/android/settings/display/AmbientDisplayAlwaysOnPreferenceController.java
@@ -43,10 +43,7 @@ public class AmbientDisplayAlwaysOnPreferenceController extends TogglePreference
@Override
public int getAvailabilityStatus() {
- if (mConfig == null) {
- mConfig = new AmbientDisplayConfiguration(mContext);
- }
- return isAvailable(mConfig) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
+ return isAvailable(getConfig()) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
}
@Override
@@ -56,7 +53,7 @@ public class AmbientDisplayAlwaysOnPreferenceController extends TogglePreference
@Override
public boolean isChecked() {
- return mConfig.alwaysOnEnabled(MY_USER);
+ return getConfig().alwaysOnEnabled(MY_USER);
}
@Override
@@ -82,15 +79,14 @@ public class AmbientDisplayAlwaysOnPreferenceController extends TogglePreference
return this;
}
- public static boolean isAlwaysOnEnabled(AmbientDisplayConfiguration config) {
- return config.alwaysOnEnabled(MY_USER);
- }
-
public static boolean isAvailable(AmbientDisplayConfiguration config) {
return config.alwaysOnAvailableForUser(MY_USER);
}
- public static boolean accessibilityInversionEnabled(AmbientDisplayConfiguration config) {
- return config.accessibilityInversionEnabled(MY_USER);
+ private AmbientDisplayConfiguration getConfig() {
+ if (mConfig == null) {
+ mConfig = new AmbientDisplayConfiguration(mContext);
+ }
+ return mConfig;
}
}
diff --git a/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java b/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
index 4795229102..04bdedccce 100644
--- a/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
+++ b/src/com/android/settings/gestures/DoubleTapScreenPreferenceController.java
@@ -35,7 +35,6 @@ public class DoubleTapScreenPreferenceController extends GesturePreferenceContro
private final int OFF = 0;
private static final String PREF_KEY_VIDEO = "gesture_double_tap_screen_video";
- private final String mDoubleTapScreenPrefKey;
private final String SECURE_KEY = DOZE_PULSE_ON_DOUBLE_TAP;
@@ -46,7 +45,6 @@ public class DoubleTapScreenPreferenceController extends GesturePreferenceContro
public DoubleTapScreenPreferenceController(Context context, String key) {
super(context, key);
mUserId = UserHandle.myUserId();
- mDoubleTapScreenPrefKey = key;
}
public DoubleTapScreenPreferenceController setConfig(AmbientDisplayConfiguration config) {
@@ -67,17 +65,13 @@ public class DoubleTapScreenPreferenceController extends GesturePreferenceContro
@Override
public int getAvailabilityStatus() {
- if (mAmbientConfig == null) {
- mAmbientConfig = new AmbientDisplayConfiguration(mContext);
- }
-
// No hardware support for Double Tap
- if (!mAmbientConfig.doubleTapSensorAvailable()) {
+ if (!getAmbientConfig().doubleTapSensorAvailable()) {
return UNSUPPORTED_ON_DEVICE;
}
// Can't change Double Tap when AOD is enabled.
- if (!mAmbientConfig.ambientDisplayAvailable()) {
+ if (!getAmbientConfig().ambientDisplayAvailable()) {
return DISABLED_DEPENDENT_SETTING;
}
@@ -102,11 +96,18 @@ public class DoubleTapScreenPreferenceController extends GesturePreferenceContro
@Override
public boolean isChecked() {
- return mAmbientConfig.pulseOnDoubleTapEnabled(mUserId);
+ return getAmbientConfig().pulseOnDoubleTapEnabled(mUserId);
}
@Override
protected boolean canHandleClicks() {
- return !mAmbientConfig.alwaysOnEnabled(mUserId);
+ return !getAmbientConfig().alwaysOnEnabled(mUserId);
+ }
+
+ private AmbientDisplayConfiguration getAmbientConfig() {
+ if (mAmbientConfig == null) {
+ mAmbientConfig = new AmbientDisplayConfiguration(mContext);
+ }
+ return mAmbientConfig;
}
-} \ No newline at end of file
+}