2828import android .util .Slog ;
2929import android .view .IWindowManager ;
3030import android .widget .CompoundButton ;
31+ import android .widget .ImageView ;
3132
3233import 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}
0 commit comments