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

Commit 0b79c923 authored by danielwbhuang's avatar danielwbhuang
Browse files

[Fixed] Reverse scrolling setting is reversed

If useTouchpadNaturalScrolling is false, "Reverse scrolling" should be on.

[The API value]
useTouchpadNaturalScrolling: false

[The expected UX behavior]
Reverse scrolling: on
fingers upward, scroll up, content moves down

The description of "useTouchpadNaturalScrolling":
Returns true if moving two fingers upwards on the touchpad should scroll down, which is known as natural scrolling.

The description of "Reverse scrolling":
Content moves up when you scroll down.

Bug: 280047007
Test: manual and passed atest TrackpadReverseScrollingPreferenceControllerTest
Change-Id: Ia5e30fa14b599ddcffae99005114f10412ccad3c
parent 2b44fc26
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -30,12 +30,12 @@ public class TrackpadReverseScrollingPreferenceController extends TogglePreferen


    @Override
    @Override
    public boolean isChecked() {
    public boolean isChecked() {
        return InputSettings.useTouchpadNaturalScrolling(mContext);
        return !InputSettings.useTouchpadNaturalScrolling(mContext);
    }
    }


    @Override
    @Override
    public boolean setChecked(boolean isChecked) {
    public boolean setChecked(boolean isChecked) {
        InputSettings.setTouchpadNaturalScrolling(mContext, isChecked);
        InputSettings.setTouchpadNaturalScrolling(mContext, !isChecked);
        return true;
        return true;
    }
    }


+8 −8
Original line number Original line Diff line number Diff line
@@ -61,7 +61,7 @@ public class TrackpadReverseScrollingPreferenceControllerTest {
    }
    }


    @Test
    @Test
    public void setChecked_true_shouldReturn1() {
    public void setChecked_true_shouldReturn0() {
        mController.setChecked(true);
        mController.setChecked(true);


        int result = Settings.System.getIntForUser(
        int result = Settings.System.getIntForUser(
@@ -70,11 +70,11 @@ public class TrackpadReverseScrollingPreferenceControllerTest {
                0,
                0,
                UserHandle.USER_CURRENT);
                UserHandle.USER_CURRENT);


        assertThat(result).isEqualTo(1);
        assertThat(result).isEqualTo(0);
    }
    }


    @Test
    @Test
    public void setChecked_false_shouldReturn0() {
    public void setChecked_false_shouldReturn1() {
        mController.setChecked(false);
        mController.setChecked(false);


        int result = Settings.System.getIntForUser(
        int result = Settings.System.getIntForUser(
@@ -83,11 +83,11 @@ public class TrackpadReverseScrollingPreferenceControllerTest {
                0,
                0,
                UserHandle.USER_CURRENT);
                UserHandle.USER_CURRENT);


        assertThat(result).isEqualTo(0);
        assertThat(result).isEqualTo(1);
    }
    }


    @Test
    @Test
    public void isChecked_providerPutInt1_returnTrue() {
    public void isChecked_providerPutInt1_returnFalse() {
        Settings.System.putIntForUser(
        Settings.System.putIntForUser(
                mContext.getContentResolver(),
                mContext.getContentResolver(),
                SETTING_KEY,
                SETTING_KEY,
@@ -96,11 +96,11 @@ public class TrackpadReverseScrollingPreferenceControllerTest {


        boolean result = mController.isChecked();
        boolean result = mController.isChecked();


        assertThat(result).isTrue();
        assertThat(result).isFalse();
    }
    }


    @Test
    @Test
    public void isChecked_providerPutInt0_returnFalse() {
    public void isChecked_providerPutInt0_returnTrue() {
        Settings.System.putIntForUser(
        Settings.System.putIntForUser(
                mContext.getContentResolver(),
                mContext.getContentResolver(),
                SETTING_KEY,
                SETTING_KEY,
@@ -109,6 +109,6 @@ public class TrackpadReverseScrollingPreferenceControllerTest {


        boolean result = mController.isChecked();
        boolean result = mController.isChecked();


        assertThat(result).isFalse();
        assertThat(result).isTrue();
    }
    }
}
}