summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java')
-rw-r--r--src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java b/src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java
index 7c63f34..ab3ee3f 100644
--- a/src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java
+++ b/src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2013 The CyanogenMod Project
+ * 2017 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -49,8 +50,6 @@ public class ButtonBacklightBrightness extends DialogPreference implements
public static final String KEY_BUTTON_BACKLIGHT = "pre_navbar_button_backlight";
- private Window mWindow;
-
private BrightnessControl mButtonBrightness;
private BrightnessControl mKeyboardBrightness;
private BrightnessControl mActiveControl;
@@ -61,6 +60,8 @@ public class ButtonBacklightBrightness extends DialogPreference implements
private ContentResolver mResolver;
+ private int mOriginalTimeout;
+
public ButtonBacklightBrightness(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -107,7 +108,8 @@ public class ButtonBacklightBrightness extends DialogPreference implements
mTimeoutValue = (TextView) view.findViewById(R.id.timeout_value);
mTimeoutBar.setMax(30);
mTimeoutBar.setOnSeekBarChangeListener(this);
- mTimeoutBar.setProgress(getTimeout());
+ mOriginalTimeout = getTimeout();
+ mTimeoutBar.setProgress(mOriginalTimeout);
handleTimeoutUpdate(mTimeoutBar.getProgress());
ViewGroup buttonContainer = (ViewGroup) view.findViewById(R.id.button_container);
@@ -142,6 +144,7 @@ public class ButtonBacklightBrightness extends DialogPreference implements
@Override
public void onClick(View v) {
mTimeoutBar.setProgress(DEFAULT_BUTTON_TIMEOUT);
+ applyTimeout(DEFAULT_BUTTON_TIMEOUT);
if (mButtonBrightness != null) {
mButtonBrightness.reset();
}
@@ -150,10 +153,6 @@ public class ButtonBacklightBrightness extends DialogPreference implements
}
}
});
-
- if (getDialog() != null) {
- mWindow = getDialog().getWindow();
- }
updateBrightnessPreview();
}
@@ -162,6 +161,7 @@ public class ButtonBacklightBrightness extends DialogPreference implements
super.onDialogClosed(positiveResult);
if (!positiveResult) {
+ applyTimeout(mOriginalTimeout);
return;
}
@@ -280,15 +280,17 @@ public class ButtonBacklightBrightness extends DialogPreference implements
}
private void updateBrightnessPreview() {
- if (mWindow != null) {
- LayoutParams params = mWindow.getAttributes();
- if (mActiveControl != null) {
- params.buttonBrightness = (float) mActiveControl.getBrightness(false) / 255.0f;
- } else {
- params.buttonBrightness = -1;
- }
- mWindow.setAttributes(params);
+ if (getDialog() == null || getDialog().getWindow() == null) {
+ return;
}
+ Window window = getDialog().getWindow();
+ LayoutParams params = window.getAttributes();
+ if (mActiveControl != null) {
+ params.buttonBrightness = (float) mActiveControl.getBrightness(false) / 255.0f;
+ } else {
+ params.buttonBrightness = -1;
+ }
+ window.setAttributes(params);
}
private void updateTimeoutEnabledState() {
@@ -320,7 +322,7 @@ public class ButtonBacklightBrightness extends DialogPreference implements
@Override
public void onStopTrackingTouch(SeekBar seekBar) {
- // Do nothing here
+ applyTimeout(seekBar.getProgress());
}
private static class SavedState extends BaseSavedState {