Loading core/java/android/content/Intent.java +8 −0 Original line number Original line Diff line number Diff line Loading @@ -2489,6 +2489,14 @@ public class Intent implements Parcelable, Cloneable { public static final String ACTION_QUICK_CLOCK = public static final String ACTION_QUICK_CLOCK = "android.intent.action.QUICK_CLOCK"; "android.intent.action.QUICK_CLOCK"; /** * Broadcast Action: This is broadcast when a user action should request the * brightness setting dialog. * @hide */ public static final String ACTION_SHOW_BRIGHTNESS_DIALOG = "android.intent.action.SHOW_BRIGHTNESS_DIALOG"; // --------------------------------------------------------------------- // --------------------------------------------------------------------- // --------------------------------------------------------------------- // --------------------------------------------------------------------- // Standard intent categories (see addCategory()). // Standard intent categories (see addCategory()). Loading packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml +1 −1 Original line number Original line Diff line number Diff line Loading @@ -27,7 +27,7 @@ android:paddingRight="10dp" android:paddingRight="10dp" android:src="@drawable/ic_qs_brightness_auto_off" android:src="@drawable/ic_qs_brightness_auto_off" /> /> <com.android.systemui.statusbar.policy.ToggleSlider <com.android.systemui.settings.ToggleSlider android:id="@+id/brightness_slider" android:id="@+id/brightness_slider" android:layout_width="0dp" android:layout_width="0dp" android:layout_height="40dp" android:layout_height="40dp" Loading packages/SystemUI/res/layout/system_bar_settings_view.xml +1 −1 Original line number Original line Diff line number Diff line Loading @@ -100,7 +100,7 @@ style="@style/SystemBarPanelSettingsIcon" style="@style/SystemBarPanelSettingsIcon" android:src="@drawable/ic_sysbar_brightness" android:src="@drawable/ic_sysbar_brightness" /> /> <com.android.systemui.statusbar.policy.ToggleSlider <com.android.systemui.settings.ToggleSlider android:id="@+id/brightness" android:id="@+id/brightness" android:layout_width="0dp" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_height="fill_parent" Loading packages/SystemUI/src/com/android/systemui/SystemUIService.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -44,6 +44,7 @@ public class SystemUIService extends Service { 0, // system bar or status bar, filled in below. 0, // system bar or status bar, filled in below. com.android.systemui.power.PowerUI.class, com.android.systemui.power.PowerUI.class, com.android.systemui.media.RingtonePlayer.class, com.android.systemui.media.RingtonePlayer.class, com.android.systemui.settings.SettingsUI.class, }; }; /** /** Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessController.java→packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java +123 −35 Original line number Original line Diff line number Diff line /* /* * Copyright (C) 2010 The Android Open Source Project * Copyright (C) 2013 The Android Open Source Project * * * Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License. Loading @@ -14,15 +14,20 @@ * limitations under the License. * limitations under the License. */ */ package com.android.systemui.statusbar.policy; package com.android.systemui.settings; import android.content.ContentResolver; import android.content.ContentResolver; import android.content.Context; import android.content.Context; import android.content.Intent; import android.database.ContentObserver; import android.net.Uri; import android.os.AsyncTask; import android.os.AsyncTask; import android.os.Handler; import android.os.IPowerManager; import android.os.IPowerManager; import android.os.PowerManager; import android.os.PowerManager; import android.os.RemoteException; import android.os.RemoteException; import android.os.ServiceManager; import android.os.ServiceManager; import android.os.UserHandle; import android.provider.Settings; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; import android.provider.Settings.SettingNotFoundException; import android.util.Slog; import android.util.Slog; Loading @@ -30,8 +35,6 @@ import android.view.IWindowManager; import android.widget.CompoundButton; import android.widget.CompoundButton; import android.widget.ImageView; import android.widget.ImageView; import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback; import java.util.ArrayList; import java.util.ArrayList; public class BrightnessController implements ToggleSlider.Listener { public class BrightnessController implements ToggleSlider.Listener { Loading @@ -46,6 +49,8 @@ public class BrightnessController implements ToggleSlider.Listener { private final boolean mAutomaticAvailable; private final boolean mAutomaticAvailable; private final IPowerManager mPower; private final IPowerManager mPower; private final CurrentUserTracker mUserTracker; private final CurrentUserTracker mUserTracker; private final Handler mHandler; private final BrightnessObserver mBrightnessObserver; private ArrayList<BrightnessStateChangeCallback> mChangeCallbacks = private ArrayList<BrightnessStateChangeCallback> mChangeCallbacks = new ArrayList<BrightnessStateChangeCallback>(); new ArrayList<BrightnessStateChangeCallback>(); Loading @@ -54,11 +59,71 @@ public class BrightnessController implements ToggleSlider.Listener { public void onBrightnessLevelChanged(); public void onBrightnessLevelChanged(); } } /** ContentObserver to watch brightness **/ private class BrightnessObserver extends ContentObserver { private final Uri BRIGHTNESS_MODE_URI = Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS_MODE); private final Uri BRIGHTNESS_URI = Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS); public BrightnessObserver(Handler handler) { super(handler); } @Override public void onChange(boolean selfChange) { onChange(selfChange, null); } @Override public void onChange(boolean selfChange, Uri uri) { if (selfChange) return; if (BRIGHTNESS_MODE_URI.equals(uri)) { updateMode(); } else if (BRIGHTNESS_URI.equals(uri)) { updateSlider(); } else { updateMode(); updateSlider(); } for (BrightnessStateChangeCallback cb : mChangeCallbacks) { cb.onBrightnessLevelChanged(); } } public void startObserving() { final ContentResolver cr = mContext.getContentResolver(); cr.unregisterContentObserver(this); cr.registerContentObserver( BRIGHTNESS_MODE_URI, false, this, UserHandle.USER_ALL); cr.registerContentObserver( BRIGHTNESS_URI, false, this, UserHandle.USER_ALL); } public void stopObserving() { final ContentResolver cr = mContext.getContentResolver(); cr.unregisterContentObserver(this); } } public BrightnessController(Context context, ImageView icon, ToggleSlider control) { public BrightnessController(Context context, ImageView icon, ToggleSlider control) { mContext = context; mContext = context; mIcon = icon; mIcon = icon; mControl = control; mControl = control; mUserTracker = new CurrentUserTracker(mContext); mHandler = new Handler(); mUserTracker = new CurrentUserTracker(mContext) { @Override public void onUserSwitched(int newUserId) { updateMode(); updateSlider(); } }; mBrightnessObserver = new BrightnessObserver(mHandler); mBrightnessObserver.startObserving(); PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE); PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE); mMinimumBacklight = pm.getMinimumScreenBrightnessSetting(); mMinimumBacklight = pm.getMinimumScreenBrightnessSetting(); Loading @@ -68,6 +133,11 @@ public class BrightnessController implements ToggleSlider.Listener { com.android.internal.R.bool.config_automatic_brightness_available); com.android.internal.R.bool.config_automatic_brightness_available); mPower = IPowerManager.Stub.asInterface(ServiceManager.getService("power")); 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); control.setOnChangedListener(this); } } Loading @@ -75,36 +145,20 @@ public class BrightnessController implements ToggleSlider.Listener { mChangeCallbacks.add(cb); mChangeCallbacks.add(cb); } } @Override public boolean removeStateChangedCallback(BrightnessStateChangeCallback cb) { public void onInit(ToggleSlider control) { return mChangeCallbacks.remove(cb); if (mAutomaticAvailable) { int automatic; try { automatic = Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, mUserTracker.getCurrentUserId()); } catch (SettingNotFoundException snfe) { automatic = 0; } control.setChecked(automatic != 0); updateIcon(automatic != 0); } else { control.setChecked(false); updateIcon(false /*automatic*/); //control.hideToggle(); } } int value; @Override try { public void onInit(ToggleSlider control) { value = Settings.System.getIntForUser(mContext.getContentResolver(), // Do nothing Settings.System.SCREEN_BRIGHTNESS, mUserTracker.getCurrentUserId()); } catch (SettingNotFoundException ex) { value = mMaximumBacklight; } } control.setMax(mMaximumBacklight - mMinimumBacklight); /** Unregister all call backs, both to and from the controller */ control.setValue(value - mMinimumBacklight); public void unregisterCallbacks() { mBrightnessObserver.stopObserving(); mChangeCallbacks.clear(); mUserTracker.stopTracking(); } } public void onChanged(ToggleSlider view, boolean tracking, boolean automatic, int value) { public void onChanged(ToggleSlider view, boolean tracking, boolean automatic, int value) { Loading @@ -119,7 +173,7 @@ public class BrightnessController implements ToggleSlider.Listener { public void run() { public void run() { Settings.System.putIntForUser(mContext.getContentResolver(), Settings.System.putIntForUser(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, val, Settings.System.SCREEN_BRIGHTNESS, val, mUserTracker.getCurrentUserId()); UserHandle.USER_CURRENT); } } }); }); } } Loading Loading @@ -150,4 +204,38 @@ public class BrightnessController implements ToggleSlider.Listener { com.android.systemui.R.drawable.ic_qs_brightness_auto_off); com.android.systemui.R.drawable.ic_qs_brightness_auto_off); } } } } /** Fetch the brightness mode from the system settings and update the icon */ private void updateMode() { if (mAutomaticAvailable) { int automatic; try { automatic = Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, UserHandle.USER_CURRENT); } catch (SettingNotFoundException snfe) { automatic = 0; } mControl.setChecked(automatic != 0); updateIcon(automatic != 0); } else { mControl.setChecked(false); updateIcon(false /*automatic*/); } } /** Fetch the brightness from the system settings and update the slider */ private void updateSlider() { int value; try { value = Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, UserHandle.USER_CURRENT); } catch (SettingNotFoundException ex) { value = mMaximumBacklight; } mControl.setMax(mMaximumBacklight - mMinimumBacklight); mControl.setValue(value - mMinimumBacklight); } } } Loading
core/java/android/content/Intent.java +8 −0 Original line number Original line Diff line number Diff line Loading @@ -2489,6 +2489,14 @@ public class Intent implements Parcelable, Cloneable { public static final String ACTION_QUICK_CLOCK = public static final String ACTION_QUICK_CLOCK = "android.intent.action.QUICK_CLOCK"; "android.intent.action.QUICK_CLOCK"; /** * Broadcast Action: This is broadcast when a user action should request the * brightness setting dialog. * @hide */ public static final String ACTION_SHOW_BRIGHTNESS_DIALOG = "android.intent.action.SHOW_BRIGHTNESS_DIALOG"; // --------------------------------------------------------------------- // --------------------------------------------------------------------- // --------------------------------------------------------------------- // --------------------------------------------------------------------- // Standard intent categories (see addCategory()). // Standard intent categories (see addCategory()). Loading
packages/SystemUI/res/layout/quick_settings_brightness_dialog.xml +1 −1 Original line number Original line Diff line number Diff line Loading @@ -27,7 +27,7 @@ android:paddingRight="10dp" android:paddingRight="10dp" android:src="@drawable/ic_qs_brightness_auto_off" android:src="@drawable/ic_qs_brightness_auto_off" /> /> <com.android.systemui.statusbar.policy.ToggleSlider <com.android.systemui.settings.ToggleSlider android:id="@+id/brightness_slider" android:id="@+id/brightness_slider" android:layout_width="0dp" android:layout_width="0dp" android:layout_height="40dp" android:layout_height="40dp" Loading
packages/SystemUI/res/layout/system_bar_settings_view.xml +1 −1 Original line number Original line Diff line number Diff line Loading @@ -100,7 +100,7 @@ style="@style/SystemBarPanelSettingsIcon" style="@style/SystemBarPanelSettingsIcon" android:src="@drawable/ic_sysbar_brightness" android:src="@drawable/ic_sysbar_brightness" /> /> <com.android.systemui.statusbar.policy.ToggleSlider <com.android.systemui.settings.ToggleSlider android:id="@+id/brightness" android:id="@+id/brightness" android:layout_width="0dp" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_height="fill_parent" Loading
packages/SystemUI/src/com/android/systemui/SystemUIService.java +1 −0 Original line number Original line Diff line number Diff line Loading @@ -44,6 +44,7 @@ public class SystemUIService extends Service { 0, // system bar or status bar, filled in below. 0, // system bar or status bar, filled in below. com.android.systemui.power.PowerUI.class, com.android.systemui.power.PowerUI.class, com.android.systemui.media.RingtonePlayer.class, com.android.systemui.media.RingtonePlayer.class, com.android.systemui.settings.SettingsUI.class, }; }; /** /** Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessController.java→packages/SystemUI/src/com/android/systemui/settings/BrightnessController.java +123 −35 Original line number Original line Diff line number Diff line /* /* * Copyright (C) 2010 The Android Open Source Project * Copyright (C) 2013 The Android Open Source Project * * * Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License. Loading @@ -14,15 +14,20 @@ * limitations under the License. * limitations under the License. */ */ package com.android.systemui.statusbar.policy; package com.android.systemui.settings; import android.content.ContentResolver; import android.content.ContentResolver; import android.content.Context; import android.content.Context; import android.content.Intent; import android.database.ContentObserver; import android.net.Uri; import android.os.AsyncTask; import android.os.AsyncTask; import android.os.Handler; import android.os.IPowerManager; import android.os.IPowerManager; import android.os.PowerManager; import android.os.PowerManager; import android.os.RemoteException; import android.os.RemoteException; import android.os.ServiceManager; import android.os.ServiceManager; import android.os.UserHandle; import android.provider.Settings; import android.provider.Settings; import android.provider.Settings.SettingNotFoundException; import android.provider.Settings.SettingNotFoundException; import android.util.Slog; import android.util.Slog; Loading @@ -30,8 +35,6 @@ import android.view.IWindowManager; import android.widget.CompoundButton; import android.widget.CompoundButton; import android.widget.ImageView; import android.widget.ImageView; import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback; import java.util.ArrayList; import java.util.ArrayList; public class BrightnessController implements ToggleSlider.Listener { public class BrightnessController implements ToggleSlider.Listener { Loading @@ -46,6 +49,8 @@ public class BrightnessController implements ToggleSlider.Listener { private final boolean mAutomaticAvailable; private final boolean mAutomaticAvailable; private final IPowerManager mPower; private final IPowerManager mPower; private final CurrentUserTracker mUserTracker; private final CurrentUserTracker mUserTracker; private final Handler mHandler; private final BrightnessObserver mBrightnessObserver; private ArrayList<BrightnessStateChangeCallback> mChangeCallbacks = private ArrayList<BrightnessStateChangeCallback> mChangeCallbacks = new ArrayList<BrightnessStateChangeCallback>(); new ArrayList<BrightnessStateChangeCallback>(); Loading @@ -54,11 +59,71 @@ public class BrightnessController implements ToggleSlider.Listener { public void onBrightnessLevelChanged(); public void onBrightnessLevelChanged(); } } /** ContentObserver to watch brightness **/ private class BrightnessObserver extends ContentObserver { private final Uri BRIGHTNESS_MODE_URI = Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS_MODE); private final Uri BRIGHTNESS_URI = Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS); public BrightnessObserver(Handler handler) { super(handler); } @Override public void onChange(boolean selfChange) { onChange(selfChange, null); } @Override public void onChange(boolean selfChange, Uri uri) { if (selfChange) return; if (BRIGHTNESS_MODE_URI.equals(uri)) { updateMode(); } else if (BRIGHTNESS_URI.equals(uri)) { updateSlider(); } else { updateMode(); updateSlider(); } for (BrightnessStateChangeCallback cb : mChangeCallbacks) { cb.onBrightnessLevelChanged(); } } public void startObserving() { final ContentResolver cr = mContext.getContentResolver(); cr.unregisterContentObserver(this); cr.registerContentObserver( BRIGHTNESS_MODE_URI, false, this, UserHandle.USER_ALL); cr.registerContentObserver( BRIGHTNESS_URI, false, this, UserHandle.USER_ALL); } public void stopObserving() { final ContentResolver cr = mContext.getContentResolver(); cr.unregisterContentObserver(this); } } public BrightnessController(Context context, ImageView icon, ToggleSlider control) { public BrightnessController(Context context, ImageView icon, ToggleSlider control) { mContext = context; mContext = context; mIcon = icon; mIcon = icon; mControl = control; mControl = control; mUserTracker = new CurrentUserTracker(mContext); mHandler = new Handler(); mUserTracker = new CurrentUserTracker(mContext) { @Override public void onUserSwitched(int newUserId) { updateMode(); updateSlider(); } }; mBrightnessObserver = new BrightnessObserver(mHandler); mBrightnessObserver.startObserving(); PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE); PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE); mMinimumBacklight = pm.getMinimumScreenBrightnessSetting(); mMinimumBacklight = pm.getMinimumScreenBrightnessSetting(); Loading @@ -68,6 +133,11 @@ public class BrightnessController implements ToggleSlider.Listener { com.android.internal.R.bool.config_automatic_brightness_available); com.android.internal.R.bool.config_automatic_brightness_available); mPower = IPowerManager.Stub.asInterface(ServiceManager.getService("power")); 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); control.setOnChangedListener(this); } } Loading @@ -75,36 +145,20 @@ public class BrightnessController implements ToggleSlider.Listener { mChangeCallbacks.add(cb); mChangeCallbacks.add(cb); } } @Override public boolean removeStateChangedCallback(BrightnessStateChangeCallback cb) { public void onInit(ToggleSlider control) { return mChangeCallbacks.remove(cb); if (mAutomaticAvailable) { int automatic; try { automatic = Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, mUserTracker.getCurrentUserId()); } catch (SettingNotFoundException snfe) { automatic = 0; } control.setChecked(automatic != 0); updateIcon(automatic != 0); } else { control.setChecked(false); updateIcon(false /*automatic*/); //control.hideToggle(); } } int value; @Override try { public void onInit(ToggleSlider control) { value = Settings.System.getIntForUser(mContext.getContentResolver(), // Do nothing Settings.System.SCREEN_BRIGHTNESS, mUserTracker.getCurrentUserId()); } catch (SettingNotFoundException ex) { value = mMaximumBacklight; } } control.setMax(mMaximumBacklight - mMinimumBacklight); /** Unregister all call backs, both to and from the controller */ control.setValue(value - mMinimumBacklight); public void unregisterCallbacks() { mBrightnessObserver.stopObserving(); mChangeCallbacks.clear(); mUserTracker.stopTracking(); } } public void onChanged(ToggleSlider view, boolean tracking, boolean automatic, int value) { public void onChanged(ToggleSlider view, boolean tracking, boolean automatic, int value) { Loading @@ -119,7 +173,7 @@ public class BrightnessController implements ToggleSlider.Listener { public void run() { public void run() { Settings.System.putIntForUser(mContext.getContentResolver(), Settings.System.putIntForUser(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, val, Settings.System.SCREEN_BRIGHTNESS, val, mUserTracker.getCurrentUserId()); UserHandle.USER_CURRENT); } } }); }); } } Loading Loading @@ -150,4 +204,38 @@ public class BrightnessController implements ToggleSlider.Listener { com.android.systemui.R.drawable.ic_qs_brightness_auto_off); com.android.systemui.R.drawable.ic_qs_brightness_auto_off); } } } } /** Fetch the brightness mode from the system settings and update the icon */ private void updateMode() { if (mAutomaticAvailable) { int automatic; try { automatic = Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, UserHandle.USER_CURRENT); } catch (SettingNotFoundException snfe) { automatic = 0; } mControl.setChecked(automatic != 0); updateIcon(automatic != 0); } else { mControl.setChecked(false); updateIcon(false /*automatic*/); } } /** Fetch the brightness from the system settings and update the slider */ private void updateSlider() { int value; try { value = Settings.System.getIntForUser(mContext.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, UserHandle.USER_CURRENT); } catch (SettingNotFoundException ex) { value = mMaximumBacklight; } mControl.setMax(mMaximumBacklight - mMinimumBacklight); mControl.setValue(value - mMinimumBacklight); } } }