Skip to content

Commit

Permalink
Add a toggle to enable Brightness slider buttons [1/2]
Browse files Browse the repository at this point in the history
  • Loading branch information
PMS22 committed Apr 23, 2018
1 parent 971622e commit a273d0a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
7 changes: 7 additions & 0 deletions core/java/android/provider/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -4600,6 +4600,13 @@ public boolean validate(String value) {
*/
public static final String CUSTOM_CARRIER_LABEL = "custom_carrier_label";

/**
* Whether to show the two buttons besides the brightness slider
* Enabled by default
* @hide
*/
public static final String SHOW_BRIGHTNESS_BUTTONS = "show_brightness_buttons";

/**
* Settings to backup. This is here so that it's in the same place as the settings
* keys and easy to update.
Expand Down
16 changes: 13 additions & 3 deletions packages/SystemUI/src/com/android/systemui/qs/QSPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public class QSPanel extends LinearLayout implements Tunable, Callback, Brightne
protected final Context mContext;
protected final ArrayList<TileRecord> mRecords = new ArrayList<TileRecord>();
protected final View mBrightnessView;
protected final ImageView mBrightnessIcon;
protected final ImageView mBrightnessIcon, mMinBrightness , mMaxBrightness;
private final H mHandler = new H();
private final View mPageIndicator;
private final MetricsLogger mMetricsLogger = Dependency.get(MetricsLogger.class);
Expand Down Expand Up @@ -130,7 +130,7 @@ public QSPanel(final Context context, AttributeSet attrs) {
mBrightnessIcon,
mBrightnessView.findViewById(R.id.brightness_slider));

ImageView mMinBrightness = mBrightnessView.findViewById(R.id.brightness_left);
mMinBrightness =(ImageView) mBrightnessView.findViewById(R.id.brightness_left);
mMinBrightness.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down Expand Up @@ -163,7 +163,7 @@ public boolean onLongClick(View v) {
}
});

ImageView mMaxBrightness = mBrightnessView.findViewById(R.id.brightness_right);
mMaxBrightness = (ImageView) mBrightnessView.findViewById(R.id.brightness_right);
mMaxBrightness.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down Expand Up @@ -311,6 +311,15 @@ private void setBrightnessIcon() {
updateResources();
}

private void showButtons() {
boolean showButtonsEnabled = Settings.System.getIntForUser(
mContext.getContentResolver(), Settings.System.SHOW_BRIGHTNESS_BUTTONS,
1, UserHandle.USER_CURRENT) == 1;
mMinBrightness.setVisibility(showButtonsEnabled ? View.VISIBLE : View.GONE);
mMaxBrightness.setVisibility(showButtonsEnabled ? View.VISIBLE : View.GONE);
updateResources();
}

public void setBrightnessMirror(BrightnessMirrorController c) {
if (mBrightnessMirrorController != null) {
mBrightnessMirrorController.removeCallback(this);
Expand Down Expand Up @@ -429,6 +438,7 @@ public void setListening(boolean listening) {
}
}
setBrightnessIcon();
showButtons();
}

public void refreshAllTiles() {
Expand Down

0 comments on commit a273d0a

Please sign in to comment.