Skip to content

Commit 0c63d78

Browse files
John SpurlockAndroid (Google) Code Review
authored andcommitted
Merge "Keep QS brightness slider icon in sync." into jb-mr1-dev
2 parents 8dd3aad + f5bc42d commit 0c63d78

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,7 @@ private void showBrightnessDialog() {
754754
mBrightnessDialog.setCanceledOnTouchOutside(true);
755755

756756
mBrightnessController = new BrightnessController(mContext,
757+
(ImageView) mBrightnessDialog.findViewById(R.id.brightness_icon),
757758
(ToggleSlider) mBrightnessDialog.findViewById(R.id.brightness_slider));
758759
mBrightnessController.addStateChangedCallback(mModel);
759760
mBrightnessDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {

packages/SystemUI/src/com/android/systemui/statusbar/policy/BrightnessController.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import android.util.Slog;
2929
import android.view.IWindowManager;
3030
import android.widget.CompoundButton;
31+
import android.widget.ImageView;
3132

3233
import com.android.systemui.statusbar.policy.BatteryController.BatteryStateChangeCallback;
3334

@@ -40,6 +41,7 @@ public class BrightnessController implements ToggleSlider.Listener {
4041
private final int mMaximumBacklight;
4142

4243
private final Context mContext;
44+
private final ImageView mIcon;
4345
private final ToggleSlider mControl;
4446
private final boolean mAutomaticAvailable;
4547
private final IPowerManager mPower;
@@ -52,8 +54,9 @@ public interface BrightnessStateChangeCallback {
5254
public void onBrightnessLevelChanged();
5355
}
5456

55-
public BrightnessController(Context context, ToggleSlider control) {
57+
public BrightnessController(Context context, ImageView icon, ToggleSlider control) {
5658
mContext = context;
59+
mIcon = icon;
5760
mControl = control;
5861
mUserTracker = new CurrentUserTracker(mContext);
5962

@@ -84,8 +87,10 @@ public void onInit(ToggleSlider control) {
8487
automatic = 0;
8588
}
8689
control.setChecked(automatic != 0);
90+
updateIcon(automatic != 0);
8791
} else {
8892
control.setChecked(false);
93+
updateIcon(false /*automatic*/);
8994
//control.hideToggle();
9095
}
9196

@@ -105,6 +110,7 @@ public void onInit(ToggleSlider control) {
105110
public void onChanged(ToggleSlider view, boolean tracking, boolean automatic, int value) {
106111
setMode(automatic ? Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC
107112
: Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
113+
updateIcon(automatic);
108114
if (!automatic) {
109115
final int val = value + mMinimumBacklight;
110116
setBrightness(val);
@@ -136,4 +142,12 @@ private void setBrightness(int brightness) {
136142
} catch (RemoteException ex) {
137143
}
138144
}
145+
146+
private void updateIcon(boolean automatic) {
147+
if (mIcon != null) {
148+
mIcon.setImageResource(automatic ?
149+
com.android.systemui.R.drawable.ic_qs_brightness_auto_on :
150+
com.android.systemui.R.drawable.ic_qs_brightness_auto_off);
151+
}
152+
}
139153
}

packages/SystemUI/src/com/android/systemui/statusbar/tablet/SettingsView.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public void setRotationLockControlVisibility(boolean show) {
7878
});
7979

8080
mBrightness = new BrightnessController(context,
81+
(ImageView)findViewById(R.id.brightness_icon),
8182
(ToggleSlider)findViewById(R.id.brightness));
8283
mDoNotDisturb = new DoNotDisturbController(context,
8384
(CompoundButton)findViewById(R.id.do_not_disturb_checkbox));

0 commit comments

Comments
 (0)