am 27a2ce2e: Continuous brightness slider

* commit '27a2ce2e425f0a291344bd1d41fbbaf8afa14f0e':
  Continuous brightness slider
This commit is contained in:
Adrian Roos
2015-06-03 18:20:50 +00:00
committed by Android Git Automerger
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]. * {@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. * 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 mMinimumBacklight;
private final int mMaximumBacklight; private final int mMaximumBacklight;

View File

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