Rename methods to reflect the correct names of nav modes

Bug: 146004827
Test: make RunSettingsRoboTests ROBOTEST_FILTER=SystemNavigationGestureSettingsTest
Test: make RunSettingsRoboTests ROBOTEST_FILTER=SystemNavigationPreferenceControllerTest

Change-Id: I00602c41aed5e675b8e0d3df7a3b3b318e6ec903
This commit is contained in:
Mehdi Alizadeh
2019-12-13 15:37:18 -08:00
parent d907169965
commit 3ea61b66af
3 changed files with 18 additions and 15 deletions

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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