diff options
author | Jorim Jaggi <jjaggi@google.com> | 2014-05-11 23:09:22 +0200 |
---|---|---|
committer | Jorim Jaggi <jjaggi@google.com> | 2014-05-12 15:10:13 +0200 |
commit | f056e35a34a8846a1d7c7a3fd55b9d69b559a590 (patch) | |
tree | 1165f2c017ccc38124a43335a7253b1691a99bd4 /packages/SystemUI/src/com/android/systemui/settings | |
parent | 6612e3a338a92ffda807bdcac903018c7d2c13e6 (diff) | |
download | frameworks_base-f056e35a34a8846a1d7c7a3fd55b9d69b559a590.zip frameworks_base-f056e35a34a8846a1d7c7a3fd55b9d69b559a590.tar.gz frameworks_base-f056e35a34a8846a1d7c7a3fd55b9d69b559a590.tar.bz2 |
Implement intermediate brigthness control on header.
This just reuses the views from BrigthnessDialog. Later, we will move
to a model where we only have one single slider.
Change-Id: Ib8116741802b7de930331648e50ff55fc869d7af
Diffstat (limited to 'packages/SystemUI/src/com/android/systemui/settings')
3 files changed, 20 insertions, 11 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java b/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java index 327e715..1747e6e 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java +++ b/packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java @@ -119,7 +119,6 @@ public class BrightnessController implements ToggleSlider.Listener { } }; mBrightnessObserver = new BrightnessObserver(mHandler); - mBrightnessObserver.startObserving(); PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE); mMinimumBacklight = pm.getMinimumScreenBrightnessSetting(); @@ -128,13 +127,6 @@ public class BrightnessController implements ToggleSlider.Listener { mAutomaticAvailable = context.getResources().getBoolean( com.android.internal.R.bool.config_automatic_brightness_available); mPower = IPowerManager.Stub.asInterface(ServiceManager.getService("power")); - - // Update the slider and mode before attaching the listener so we don't receive the - // onChanged notifications for the initial values. - updateMode(); - updateSlider(); - - control.setOnChangedListener(this); } public void addStateChangedCallback(BrightnessStateChangeCallback cb) { @@ -150,11 +142,24 @@ public class BrightnessController implements ToggleSlider.Listener { // Do nothing } + public void registerCallbacks() { + mBrightnessObserver.startObserving(); + mUserTracker.startTracking(); + + // Update the slider and mode before attaching the listener so we don't receive the + // onChanged notifications for the initial values. + updateMode(); + updateSlider(); + + mControl.setOnChangedListener(this); + } + /** Unregister all call backs, both to and from the controller */ public void unregisterCallbacks() { mBrightnessObserver.stopObserving(); mChangeCallbacks.clear(); mUserTracker.stopTracking(); + mControl.setOnChangedListener(null); } public void onChanged(ToggleSlider view, boolean tracking, boolean automatic, int value) { diff --git a/packages/SystemUI/src/com/android/systemui/settings/BrightnessDialog.java b/packages/SystemUI/src/com/android/systemui/settings/BrightnessDialog.java index bd5e5e8..27881c4 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/BrightnessDialog.java +++ b/packages/SystemUI/src/com/android/systemui/settings/BrightnessDialog.java @@ -92,6 +92,7 @@ public class BrightnessDialog extends Dialog implements mBrightnessController = new BrightnessController(getContext(), (ImageView) findViewById(R.id.brightness_icon), (ToggleSlider) findViewById(R.id.brightness_slider)); + mBrightnessController.registerCallbacks(); dismissBrightnessDialog(mBrightnessDialogLongTimeout); mBrightnessController.addStateChangedCallback(this); } diff --git a/packages/SystemUI/src/com/android/systemui/settings/CurrentUserTracker.java b/packages/SystemUI/src/com/android/systemui/settings/CurrentUserTracker.java index 036bd4f..f8ff616 100644 --- a/packages/SystemUI/src/com/android/systemui/settings/CurrentUserTracker.java +++ b/packages/SystemUI/src/com/android/systemui/settings/CurrentUserTracker.java @@ -29,9 +29,6 @@ public abstract class CurrentUserTracker extends BroadcastReceiver { private int mCurrentUserId; public CurrentUserTracker(Context context) { - IntentFilter filter = new IntentFilter(Intent.ACTION_USER_SWITCHED); - context.registerReceiver(this, filter); - mCurrentUserId = ActivityManager.getCurrentUser(); mContext = context; } @@ -50,6 +47,12 @@ public abstract class CurrentUserTracker extends BroadcastReceiver { } } + public void startTracking() { + mCurrentUserId = ActivityManager.getCurrentUser(); + IntentFilter filter = new IntentFilter(Intent.ACTION_USER_SWITCHED); + mContext.registerReceiver(this, filter); + } + public void stopTracking() { mContext.unregisterReceiver(this); } |