From 8586c215c77da79e8e2b08e813442a702a3aa747 Mon Sep 17 00:00:00 2001 From: nijel8 Date: Sat, 7 Jan 2017 09:56:57 -0500 Subject: 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 --- .../cyanogenmod/ButtonBacklightBrightness.java | 24 +++++++++------------- 1 file 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() { -- cgit v1.1