diff options
author | nijel8 <nijel8@gmail.com> | 2017-01-07 09:56:57 -0500 |
---|---|---|
committer | Zhao Wei Liew <zhaoweiliew@gmail.com> | 2017-01-16 11:05:23 +0000 |
commit | 8586c215c77da79e8e2b08e813442a702a3aa747 (patch) | |
tree | 934b1fa4552ca43a6232142ca7a2f84219981192 | |
parent | 1bdefa08e856bbcac3475f42aa9bf194c9b83b27 (diff) | |
download | packages_apps_Settings-8586c215c77da79e8e2b08e813442a702a3aa747.zip packages_apps_Settings-8586c215c77da79e8e2b08e813442a702a3aa747.tar.gz packages_apps_Settings-8586c215c77da79e8e2b08e813442a702a3aa747.tar.bz2 |
Settings: Update button backlight brightness in real time
When adjusting the button backlight brightness using the seekbar,
the brightness did not update in real time, but only when the
RESET button is tapped.
With this change, the brightness is updated instantly.
Change-Id: Ib4db8b4759f2b756495dc3f9319b35cdb548d9e5
-rw-r--r-- | src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java b/src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java index 7c63f34..96f6020 100644 --- a/src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java +++ b/src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java @@ -49,8 +49,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; @@ -150,10 +148,6 @@ public class ButtonBacklightBrightness extends DialogPreference implements } } }); - - if (getDialog() != null) { - mWindow = getDialog().getWindow(); - } updateBrightnessPreview(); } @@ -280,15 +274,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() { |