From 0cfb58bd75a916ac529b7df676b22af357bc1c03 Mon Sep 17 00:00:00 2001 From: Zhao Wei Liew Date: Mon, 16 Jan 2017 19:11:23 +0800 Subject: ButtonBacklight: Preview timeout once user stops dragging Change-Id: I0abebe1041b6ad42b10e7d24f76ea17046e64666 --- .../settings/cyanogenmod/ButtonBacklightBrightness.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java b/src/com/android/settings/cyanogenmod/ButtonBacklightBrightness.java index 96f6020..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. @@ -59,6 +60,8 @@ public class ButtonBacklightBrightness extends DialogPreference implements private ContentResolver mResolver; + private int mOriginalTimeout; + public ButtonBacklightBrightness(Context context, AttributeSet attrs) { super(context, attrs); @@ -105,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); @@ -140,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(); } @@ -156,6 +161,7 @@ public class ButtonBacklightBrightness extends DialogPreference implements super.onDialogClosed(positiveResult); if (!positiveResult) { + applyTimeout(mOriginalTimeout); return; } @@ -316,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 { -- cgit v1.1