Continuous brightness slider

Changes the brightness slider to have no visible steps
when in auto brightness mode. Also changes mirror
logic to dispatching touches instead of forwarding values.

Bug: 19516826
Change-Id: Ib0233c2dcc6807da96a71d1f5619a117ca2a73bd
This commit is contained in:
Adrian Roos
2015-06-02 13:44:46 -07:00
parent 149cae2f86
commit 27a2ce2e42
2 changed files with 12 additions and 13 deletions

View File

@@ -40,7 +40,7 @@ public class BrightnessController implements ToggleSlider.Listener {
* {@link android.provider.Settings.System#SCREEN_AUTO_BRIGHTNESS_ADJ} uses the range [-1, 1].
* Using this factor, it is converted to [0, BRIGHTNESS_ADJ_RESOLUTION] for the SeekBar.
*/
private static final float BRIGHTNESS_ADJ_RESOLUTION = 100;
private static final float BRIGHTNESS_ADJ_RESOLUTION = 2048;
private final int mMinimumBacklight;
private final int mMaximumBacklight;

View File

@@ -20,6 +20,7 @@ import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
@@ -123,6 +124,16 @@ public class ToggleSlider extends RelativeLayout {
}
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (mMirror != null) {
MotionEvent copy = ev.copy();
mMirror.dispatchTouchEvent(copy);
copy.recycle();
}
return super.dispatchTouchEvent(ev);
}
private final OnCheckedChangeListener mCheckListener = new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton toggle, boolean checked) {
@@ -146,10 +157,6 @@ public class ToggleSlider extends RelativeLayout {
mListener.onChanged(
ToggleSlider.this, mTracking, mToggle.isChecked(), progress);
}
if (mMirror != null) {
mMirror.setValue(progress);
}
}
@Override
@@ -163,10 +170,6 @@ public class ToggleSlider extends RelativeLayout {
mToggle.setChecked(false);
if (mMirror != null) {
mMirror.mSlider.setPressed(true);
}
if (mMirrorController != null) {
mMirrorController.showMirror();
mMirrorController.setLocation((View) getParent());
@@ -182,10 +185,6 @@ public class ToggleSlider extends RelativeLayout {
ToggleSlider.this, mTracking, mToggle.isChecked(), mSlider.getProgress());
}
if (mMirror != null) {
mMirror.mSlider.setPressed(false);
}
if (mMirrorController != null) {
mMirrorController.hideMirror();
}