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

Commit 1b6bdf93 authored by Mehdi Alizadeh's avatar Mehdi Alizadeh Committed by Android (Google) Code Review
Browse files

Merge "Rename methods to reflect the correct names of nav modes"

parents d7da4436 3ea61b66
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -258,9 +258,9 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i

    @VisibleForTesting
    static String getCurrentSystemNavigationMode(Context context) {
        if (SystemNavigationPreferenceController.isEdgeToEdgeEnabled(context)) {
        if (SystemNavigationPreferenceController.isGestureNavigationEnabled(context)) {
            return KEY_SYSTEM_NAV_GESTURAL;
        } else if (SystemNavigationPreferenceController.isSwipeUpEnabled(context)) {
        } else if (SystemNavigationPreferenceController.is2ButtonNavigationEnabled(context)) {
            return KEY_SYSTEM_NAV_2BUTTONS;
        } else {
            return KEY_SYSTEM_NAV_3BUTTONS;
+4 −7
Original line number Diff line number Diff line
@@ -43,9 +43,9 @@ public class SystemNavigationPreferenceController extends BasePreferenceControll

    @Override
    public CharSequence getSummary() {
        if (isEdgeToEdgeEnabled(mContext)) {
        if (isGestureNavigationEnabled(mContext)) {
            return mContext.getText(R.string.edge_to_edge_navigation_title);
        } else if (isSwipeUpEnabled(mContext)) {
        } else if (is2ButtonNavigationEnabled(mContext)) {
            return mContext.getText(R.string.swipe_up_to_switch_apps_title);
        } else {
            return mContext.getText(R.string.legacy_navigation_title);
@@ -86,15 +86,12 @@ public class SystemNavigationPreferenceController extends BasePreferenceControll
        }
    }

    static boolean isSwipeUpEnabled(Context context) {
        if (isEdgeToEdgeEnabled(context)) {
            return false;
        }
    static boolean is2ButtonNavigationEnabled(Context context) {
        return NAV_BAR_MODE_2BUTTON == context.getResources().getInteger(
                com.android.internal.R.integer.config_navBarInteractionMode);
    }

    static boolean isEdgeToEdgeEnabled(Context context) {
    static boolean isGestureNavigationEnabled(Context context) {
        return NAV_BAR_MODE_GESTURAL == context.getResources().getInteger(
                com.android.internal.R.integer.config_navBarInteractionMode);
    }
+12 −6
Original line number Diff line number Diff line
@@ -137,30 +137,36 @@ public class SystemNavigationPreferenceControllerTest {
    public void testIsSwipeUpEnabled() {
        SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
                NAV_BAR_MODE_2BUTTON);
        assertThat(SystemNavigationPreferenceController.isSwipeUpEnabled(mContext)).isTrue();
        assertThat(SystemNavigationPreferenceController.is2ButtonNavigationEnabled(
                mContext)).isTrue();

        SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
                NAV_BAR_MODE_3BUTTON);
        assertThat(SystemNavigationPreferenceController.isSwipeUpEnabled(mContext)).isFalse();
        assertThat(SystemNavigationPreferenceController.is2ButtonNavigationEnabled(
                mContext)).isFalse();

        SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
                NAV_BAR_MODE_GESTURAL);
        assertThat(SystemNavigationPreferenceController.isSwipeUpEnabled(mContext)).isFalse();
        assertThat(SystemNavigationPreferenceController.is2ButtonNavigationEnabled(
                mContext)).isFalse();
    }

    @Test
    public void testIsEdgeToEdgeEnabled() {
        SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
                NAV_BAR_MODE_GESTURAL);
        assertThat(SystemNavigationPreferenceController.isEdgeToEdgeEnabled(mContext)).isTrue();
        assertThat(SystemNavigationPreferenceController.isGestureNavigationEnabled(
                mContext)).isTrue();

        SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
                NAV_BAR_MODE_3BUTTON);
        assertThat(SystemNavigationPreferenceController.isEdgeToEdgeEnabled(mContext)).isFalse();
        assertThat(SystemNavigationPreferenceController.isGestureNavigationEnabled(
                mContext)).isFalse();

        SettingsShadowResources.overrideResource(R.integer.config_navBarInteractionMode,
                NAV_BAR_MODE_2BUTTON);
        assertThat(SystemNavigationPreferenceController.isEdgeToEdgeEnabled(mContext)).isFalse();
        assertThat(SystemNavigationPreferenceController.isGestureNavigationEnabled(
                mContext)).isFalse();
    }

    @Test