Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 27a2ce2e authored by Adrian Roos's avatar Adrian Roos
Browse files

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
parent 149cae2f
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -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;
+11 −12
Original line number Original line Diff line number Diff line
@@ -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();
            }
            }