Add labels to intensity slider and flip labels

Labels are Dimmer and Brighter. As the slider value is lowered,
the dimming intensity is increased

Slider min = 100 - intensity max
Slider max = 100 - intensity min

Ex: If intensity max = 80, the slider min with be 20. If the user
moves the position to the minimum end we'll send 80 to Color DisplayManager

Test: atest ReduceBrightColorsIntensityPreferenceControllerTest,
manual
Bug: 190722076

Change-Id: Ib05ba38805b8fa1f68c144a3929027899df70abf
This commit is contained in:
Sally
2021-06-14 22:10:27 +00:00
parent 9f7564c1b6
commit d98ee531c1
4 changed files with 24 additions and 9 deletions

View File

@@ -28,6 +28,7 @@ import com.android.settings.widget.SeekBarPreference;
/** PreferenceController for feature intensity. */
public class ReduceBrightColorsIntensityPreferenceController extends SliderPreferenceController {
private static final int INVERSE_PERCENTAGE_BASE = 100;
private final ColorDisplayManager mColorDisplayManager;
public ReduceBrightColorsIntensityPreferenceController(Context context, String key) {
@@ -66,21 +67,24 @@ public class ReduceBrightColorsIntensityPreferenceController extends SliderPrefe
@Override
public int getSliderPosition() {
return mColorDisplayManager.getReduceBrightColorsStrength();
return INVERSE_PERCENTAGE_BASE - mColorDisplayManager.getReduceBrightColorsStrength();
}
@Override
public boolean setSliderPosition(int position) {
return mColorDisplayManager.setReduceBrightColorsStrength(position);
return mColorDisplayManager.setReduceBrightColorsStrength(
INVERSE_PERCENTAGE_BASE - position);
}
@Override
public int getMax() {
return ColorDisplayManager.getMaximumReduceBrightColorsStrength(mContext);
return INVERSE_PERCENTAGE_BASE
- ColorDisplayManager.getMinimumReduceBrightColorsStrength(mContext);
}
@Override
public int getMin() {
return ColorDisplayManager.getMinimumReduceBrightColorsStrength(mContext);
return INVERSE_PERCENTAGE_BASE
- ColorDisplayManager.getMaximumReduceBrightColorsStrength(mContext);
}
}