Merge "Use Gesture nav settings activity instead of dialog" into rvc-dev am: 42a906d874
Change-Id: I033b74fba64e39993173c995e95696ed725db642
This commit is contained in:
@@ -1,67 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!--
|
|
||||||
~ Copyright (C) 2019 The Android Open Source Project
|
|
||||||
~
|
|
||||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
~ you may not use this file except in compliance with the License.
|
|
||||||
~ You may obtain a copy of the License at
|
|
||||||
~
|
|
||||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
~
|
|
||||||
~ Unless required by applicable law or agreed to in writing, software
|
|
||||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
~ See the License for the specific language governing permissions and
|
|
||||||
~ limitations under the License
|
|
||||||
-->
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="12dp">
|
|
||||||
|
|
||||||
<SeekBar
|
|
||||||
android:id="@+id/back_sensitivity_seekbar"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:min="0"
|
|
||||||
android:max="3"
|
|
||||||
style="@android:style/Widget.Material.SeekBar.Discrete"
|
|
||||||
android:theme="@*android:style/ThemeOverlay.DeviceDefault.Accent" />
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_marginTop="2dp"
|
|
||||||
android:layout_marginBottom="8dp">
|
|
||||||
|
|
||||||
<TextView android:id="@+id/low_tick"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_marginBottom="2dp"
|
|
||||||
android:layout_marginStart="12dp"
|
|
||||||
android:gravity="start"
|
|
||||||
android:text="@string/low_label"
|
|
||||||
android:textAppearance="?android:attr/textAppearance"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:ellipsize="marquee" />
|
|
||||||
|
|
||||||
<TextView android:id="@+id/high_tick"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:layout_marginBottom="2dp"
|
|
||||||
android:layout_marginEnd="12dp"
|
|
||||||
android:gravity="end"
|
|
||||||
android:text="@string/high_label"
|
|
||||||
android:textAppearance="?android:attr/textAppearance"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:ellipsize="marquee" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
</LinearLayout>
|
|
@@ -1,80 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2019 The Android Open Source Project
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.android.settings.gestures;
|
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
|
||||||
import android.app.Dialog;
|
|
||||||
import android.app.settings.SettingsEnums;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.om.IOverlayManager;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.ServiceManager;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.SeekBar;
|
|
||||||
|
|
||||||
import com.android.settings.R;
|
|
||||||
import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Dialog to set the back gesture's sensitivity in Gesture navigation mode.
|
|
||||||
*/
|
|
||||||
public class GestureNavigationBackSensitivityDialog extends InstrumentedDialogFragment {
|
|
||||||
private static final String TAG = "GestureNavigationBackSensitivityDialog";
|
|
||||||
private static final String KEY_BACK_SENSITIVITY = "back_sensitivity";
|
|
||||||
|
|
||||||
public static void show(SystemNavigationGestureSettings parent, int sensitivity) {
|
|
||||||
if (!parent.isAdded()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final GestureNavigationBackSensitivityDialog dialog =
|
|
||||||
new GestureNavigationBackSensitivityDialog();
|
|
||||||
final Bundle bundle = new Bundle();
|
|
||||||
bundle.putInt(KEY_BACK_SENSITIVITY, sensitivity);
|
|
||||||
dialog.setArguments(bundle);
|
|
||||||
dialog.setTargetFragment(parent, 0);
|
|
||||||
dialog.show(parent.getFragmentManager(), TAG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMetricsCategory() {
|
|
||||||
return SettingsEnums.SETTINGS_GESTURE_NAV_BACK_SENSITIVITY_DLG;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
|
||||||
final View view = getActivity().getLayoutInflater().inflate(
|
|
||||||
R.layout.dialog_back_gesture_sensitivity, null);
|
|
||||||
final SeekBar seekBar = view.findViewById(R.id.back_sensitivity_seekbar);
|
|
||||||
seekBar.setProgress(getArguments().getInt(KEY_BACK_SENSITIVITY));
|
|
||||||
return new AlertDialog.Builder(getContext())
|
|
||||||
.setTitle(R.string.back_sensitivity_dialog_title)
|
|
||||||
.setMessage(R.string.back_sensitivity_dialog_message)
|
|
||||||
.setView(view)
|
|
||||||
.setPositiveButton(R.string.okay, (dialog, which) -> {
|
|
||||||
int sensitivity = seekBar.getProgress();
|
|
||||||
getArguments().putInt(KEY_BACK_SENSITIVITY, sensitivity);
|
|
||||||
SystemNavigationGestureSettings.setBackSensitivity(getActivity(),
|
|
||||||
getOverlayManager(), sensitivity);
|
|
||||||
})
|
|
||||||
.create();
|
|
||||||
}
|
|
||||||
|
|
||||||
private IOverlayManager getOverlayManager() {
|
|
||||||
return IOverlayManager.Stub.asInterface(ServiceManager.getService(Context.OVERLAY_SERVICE));
|
|
||||||
}
|
|
||||||
}
|
|
@@ -65,11 +65,6 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i
|
|||||||
|
|
||||||
private static final String TAG = "SystemNavigationGesture";
|
private static final String TAG = "SystemNavigationGesture";
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
static final String SHARED_PREFERENCES_NAME = "system_navigation_settings_preferences";
|
|
||||||
@VisibleForTesting
|
|
||||||
static final String PREFS_BACK_SENSITIVITY_KEY = "system_navigation_back_sensitivity";
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static final String KEY_SYSTEM_NAV_3BUTTONS = "system_nav_3buttons";
|
static final String KEY_SYSTEM_NAV_3BUTTONS = "system_nav_3buttons";
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@@ -80,25 +75,6 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i
|
|||||||
public static final String PREF_KEY_SUGGESTION_COMPLETE =
|
public static final String PREF_KEY_SUGGESTION_COMPLETE =
|
||||||
"pref_system_navigation_suggestion_complete";
|
"pref_system_navigation_suggestion_complete";
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
static final String NAV_BAR_MODE_GESTURAL_OVERLAY_NARROW_BACK
|
|
||||||
= "com.android.internal.systemui.navbar.gestural_narrow_back";
|
|
||||||
@VisibleForTesting
|
|
||||||
static final String NAV_BAR_MODE_GESTURAL_OVERLAY_WIDE_BACK
|
|
||||||
= "com.android.internal.systemui.navbar.gestural_wide_back";
|
|
||||||
@VisibleForTesting
|
|
||||||
static final String NAV_BAR_MODE_GESTURAL_OVERLAY_EXTRA_WIDE_BACK
|
|
||||||
= "com.android.internal.systemui.navbar.gestural_extra_wide_back";
|
|
||||||
@VisibleForTesting
|
|
||||||
static final String[] BACK_GESTURE_INSET_OVERLAYS = {
|
|
||||||
NAV_BAR_MODE_GESTURAL_OVERLAY_NARROW_BACK,
|
|
||||||
NAV_BAR_MODE_GESTURAL_OVERLAY,
|
|
||||||
NAV_BAR_MODE_GESTURAL_OVERLAY_WIDE_BACK,
|
|
||||||
NAV_BAR_MODE_GESTURAL_OVERLAY_EXTRA_WIDE_BACK
|
|
||||||
};
|
|
||||||
@VisibleForTesting
|
|
||||||
static int BACK_GESTURE_INSET_DEFAULT_OVERLAY = 1;
|
|
||||||
|
|
||||||
private IOverlayManager mOverlayManager;
|
private IOverlayManager mOverlayManager;
|
||||||
|
|
||||||
private VideoPreference mVideoPreference;
|
private VideoPreference mVideoPreference;
|
||||||
@@ -122,6 +98,8 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i
|
|||||||
mVideoPreference.setHeight( /* Illustration height in dp */
|
mVideoPreference.setHeight( /* Illustration height in dp */
|
||||||
getResources().getDimension(R.dimen.system_navigation_illustration_height)
|
getResources().getDimension(R.dimen.system_navigation_illustration_height)
|
||||||
/ getResources().getDisplayMetrics().density);
|
/ getResources().getDisplayMetrics().density);
|
||||||
|
|
||||||
|
migrateOverlaySensitivityToSettings(context, mOverlayManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -164,8 +142,8 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i
|
|||||||
RadioButtonPreferenceWithExtraWidget p = (RadioButtonPreferenceWithExtraWidget) pref;
|
RadioButtonPreferenceWithExtraWidget p = (RadioButtonPreferenceWithExtraWidget) pref;
|
||||||
if (info.getKey() == KEY_SYSTEM_NAV_GESTURAL) {
|
if (info.getKey() == KEY_SYSTEM_NAV_GESTURAL) {
|
||||||
p.setExtraWidgetVisibility(EXTRA_WIDGET_VISIBILITY_SETTING);
|
p.setExtraWidgetVisibility(EXTRA_WIDGET_VISIBILITY_SETTING);
|
||||||
p.setExtraWidgetOnClickListener((v) -> GestureNavigationBackSensitivityDialog
|
p.setExtraWidgetOnClickListener((v) -> startActivity(new Intent(
|
||||||
.show(this, getBackSensitivity(getContext(), mOverlayManager)));
|
GestureNavigationSettingsFragment.GESTURE_NAVIGATION_SETTINGS)));
|
||||||
} else {
|
} else {
|
||||||
p.setExtraWidgetVisibility(EXTRA_WIDGET_VISIBILITY_GONE);
|
p.setExtraWidgetVisibility(EXTRA_WIDGET_VISIBILITY_GONE);
|
||||||
}
|
}
|
||||||
@@ -213,8 +191,7 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean setDefaultKey(String key) {
|
protected boolean setDefaultKey(String key) {
|
||||||
final Context c = getContext();
|
setCurrentSystemNavigationMode(mOverlayManager, key);
|
||||||
setCurrentSystemNavigationMode(c, mOverlayManager, key);
|
|
||||||
setIllustrationVideo(mVideoPreference, key);
|
setIllustrationVideo(mVideoPreference, key);
|
||||||
if (TextUtils.equals(KEY_SYSTEM_NAV_GESTURAL, key) && (
|
if (TextUtils.equals(KEY_SYSTEM_NAV_GESTURAL, key) && (
|
||||||
isAnyServiceSupportAccessibilityButton() || isNavBarMagnificationEnabled())) {
|
isAnyServiceSupportAccessibilityButton() || isNavBarMagnificationEnabled())) {
|
||||||
@@ -225,36 +202,26 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
static void migrateOverlaySensitivityToSettings(Context context,
|
||||||
static void setBackSensitivity(Context context, IOverlayManager overlayManager,
|
IOverlayManager overlayManager) {
|
||||||
int sensitivity) {
|
if (!SystemNavigationPreferenceController.isGestureNavigationEnabled(context)) {
|
||||||
if (sensitivity < 0 || sensitivity >= BACK_GESTURE_INSET_OVERLAYS.length) {
|
return;
|
||||||
throw new IllegalArgumentException("Sensitivity out of range.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the sensitivity level, to be able to restore when user returns to Gesture Nav mode
|
|
||||||
context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE).edit()
|
|
||||||
.putInt(PREFS_BACK_SENSITIVITY_KEY, sensitivity).apply();
|
|
||||||
if (getCurrentSystemNavigationMode(context) == KEY_SYSTEM_NAV_GESTURAL) {
|
|
||||||
setNavBarInteractionMode(overlayManager, BACK_GESTURE_INSET_OVERLAYS[sensitivity]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
static int getBackSensitivity(Context context, IOverlayManager overlayManager) {
|
|
||||||
for (int i = 0; i < BACK_GESTURE_INSET_OVERLAYS.length; i++) {
|
|
||||||
OverlayInfo info = null;
|
OverlayInfo info = null;
|
||||||
try {
|
try {
|
||||||
info = overlayManager.getOverlayInfo(BACK_GESTURE_INSET_OVERLAYS[i], USER_CURRENT);
|
info = overlayManager.getOverlayInfo(NAV_BAR_MODE_GESTURAL_OVERLAY, USER_CURRENT);
|
||||||
} catch (RemoteException e) { /* Do nothing */ }
|
} catch (RemoteException e) { /* Do nothing */ }
|
||||||
if (info != null && info.isEnabled()) {
|
if (info != null && !info.isEnabled()) {
|
||||||
return i;
|
// Enable the default gesture nav overlay. Back sensitivity for left and right are
|
||||||
|
// stored as separate settings values, and other gesture nav overlays are deprecated.
|
||||||
|
setCurrentSystemNavigationMode(overlayManager, KEY_SYSTEM_NAV_GESTURAL);
|
||||||
|
Settings.Secure.putFloat(context.getContentResolver(),
|
||||||
|
Settings.Secure.BACK_GESTURE_INSET_SCALE_LEFT, 1.0f);
|
||||||
|
Settings.Secure.putFloat(context.getContentResolver(),
|
||||||
|
Settings.Secure.BACK_GESTURE_INSET_SCALE_RIGHT, 1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If Gesture nav is not selected, read the value from shared preferences.
|
|
||||||
return context.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE)
|
|
||||||
.getInt(PREFS_BACK_SENSITIVITY_KEY, BACK_GESTURE_INSET_DEFAULT_OVERLAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static String getCurrentSystemNavigationMode(Context context) {
|
static String getCurrentSystemNavigationMode(Context context) {
|
||||||
@@ -268,24 +235,20 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i
|
|||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static void setCurrentSystemNavigationMode(Context context, IOverlayManager overlayManager,
|
static void setCurrentSystemNavigationMode(IOverlayManager overlayManager, String key) {
|
||||||
String key) {
|
String overlayPackage = NAV_BAR_MODE_GESTURAL_OVERLAY;
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case KEY_SYSTEM_NAV_GESTURAL:
|
case KEY_SYSTEM_NAV_GESTURAL:
|
||||||
int sensitivity = getBackSensitivity(context, overlayManager);
|
overlayPackage = NAV_BAR_MODE_GESTURAL_OVERLAY;
|
||||||
setNavBarInteractionMode(overlayManager, BACK_GESTURE_INSET_OVERLAYS[sensitivity]);
|
|
||||||
break;
|
break;
|
||||||
case KEY_SYSTEM_NAV_2BUTTONS:
|
case KEY_SYSTEM_NAV_2BUTTONS:
|
||||||
setNavBarInteractionMode(overlayManager, NAV_BAR_MODE_2BUTTON_OVERLAY);
|
overlayPackage = NAV_BAR_MODE_2BUTTON_OVERLAY;
|
||||||
break;
|
break;
|
||||||
case KEY_SYSTEM_NAV_3BUTTONS:
|
case KEY_SYSTEM_NAV_3BUTTONS:
|
||||||
setNavBarInteractionMode(overlayManager, NAV_BAR_MODE_3BUTTON_OVERLAY);
|
overlayPackage = NAV_BAR_MODE_3BUTTON_OVERLAY;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private static void setNavBarInteractionMode(IOverlayManager overlayManager,
|
|
||||||
String overlayPackage) {
|
|
||||||
try {
|
try {
|
||||||
overlayManager.setEnabledExclusiveInCategory(overlayPackage, USER_CURRENT);
|
overlayManager.setEnabledExclusiveInCategory(overlayPackage, USER_CURRENT);
|
||||||
} catch (RemoteException e) {
|
} catch (RemoteException e) {
|
||||||
|
@@ -24,14 +24,9 @@ import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON_OVE
|
|||||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
|
||||||
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY;
|
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL_OVERLAY;
|
||||||
|
|
||||||
import static com.android.settings.gestures.SystemNavigationGestureSettings.BACK_GESTURE_INSET_DEFAULT_OVERLAY;
|
|
||||||
import static com.android.settings.gestures.SystemNavigationGestureSettings.BACK_GESTURE_INSET_OVERLAYS;
|
|
||||||
import static com.android.settings.gestures.SystemNavigationGestureSettings.KEY_SYSTEM_NAV_2BUTTONS;
|
import static com.android.settings.gestures.SystemNavigationGestureSettings.KEY_SYSTEM_NAV_2BUTTONS;
|
||||||
import static com.android.settings.gestures.SystemNavigationGestureSettings.KEY_SYSTEM_NAV_3BUTTONS;
|
import static com.android.settings.gestures.SystemNavigationGestureSettings.KEY_SYSTEM_NAV_3BUTTONS;
|
||||||
import static com.android.settings.gestures.SystemNavigationGestureSettings.KEY_SYSTEM_NAV_GESTURAL;
|
import static com.android.settings.gestures.SystemNavigationGestureSettings.KEY_SYSTEM_NAV_GESTURAL;
|
||||||
import static com.android.settings.gestures.SystemNavigationGestureSettings.NAV_BAR_MODE_GESTURAL_OVERLAY_EXTRA_WIDE_BACK;
|
|
||||||
import static com.android.settings.gestures.SystemNavigationGestureSettings.NAV_BAR_MODE_GESTURAL_OVERLAY_NARROW_BACK;
|
|
||||||
import static com.android.settings.gestures.SystemNavigationGestureSettings.NAV_BAR_MODE_GESTURAL_OVERLAY_WIDE_BACK;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
@@ -39,7 +34,6 @@ import static junit.framework.Assert.assertEquals;
|
|||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.Mockito.never;
|
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -116,96 +110,16 @@ public class SystemNavigationGestureSettingsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetCurrentSystemNavigationMode() throws Exception {
|
public void testSetCurrentSystemNavigationMode() throws Exception {
|
||||||
mSettings.setBackSensitivity(mContext, mOverlayManager, 0);
|
mSettings.setCurrentSystemNavigationMode(mOverlayManager, KEY_SYSTEM_NAV_GESTURAL);
|
||||||
mSettings.setCurrentSystemNavigationMode(mContext, mOverlayManager,
|
|
||||||
KEY_SYSTEM_NAV_GESTURAL);
|
|
||||||
verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
|
|
||||||
NAV_BAR_MODE_GESTURAL_OVERLAY_NARROW_BACK, USER_CURRENT);
|
|
||||||
|
|
||||||
mSettings.setBackSensitivity(mContext, mOverlayManager, 1);
|
|
||||||
mSettings.setCurrentSystemNavigationMode(mContext, mOverlayManager,
|
|
||||||
KEY_SYSTEM_NAV_GESTURAL);
|
|
||||||
verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
|
verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
|
||||||
NAV_BAR_MODE_GESTURAL_OVERLAY, USER_CURRENT);
|
NAV_BAR_MODE_GESTURAL_OVERLAY, USER_CURRENT);
|
||||||
|
|
||||||
mSettings.setBackSensitivity(mContext, mOverlayManager, 2);
|
mSettings.setCurrentSystemNavigationMode(mOverlayManager, KEY_SYSTEM_NAV_2BUTTONS);
|
||||||
mSettings.setCurrentSystemNavigationMode(mContext, mOverlayManager,
|
|
||||||
KEY_SYSTEM_NAV_GESTURAL);
|
|
||||||
verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
|
|
||||||
NAV_BAR_MODE_GESTURAL_OVERLAY_WIDE_BACK, USER_CURRENT);
|
|
||||||
|
|
||||||
mSettings.setBackSensitivity(mContext, mOverlayManager, 3);
|
|
||||||
mSettings.setCurrentSystemNavigationMode(mContext, mOverlayManager,
|
|
||||||
KEY_SYSTEM_NAV_GESTURAL);
|
|
||||||
verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
|
|
||||||
NAV_BAR_MODE_GESTURAL_OVERLAY_EXTRA_WIDE_BACK, USER_CURRENT);
|
|
||||||
|
|
||||||
mSettings.setCurrentSystemNavigationMode(mContext, mOverlayManager,
|
|
||||||
KEY_SYSTEM_NAV_2BUTTONS);
|
|
||||||
verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
|
verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
|
||||||
NAV_BAR_MODE_2BUTTON_OVERLAY, USER_CURRENT);
|
NAV_BAR_MODE_2BUTTON_OVERLAY, USER_CURRENT);
|
||||||
|
|
||||||
mSettings.setCurrentSystemNavigationMode(mContext, mOverlayManager,
|
mSettings.setCurrentSystemNavigationMode(mOverlayManager, KEY_SYSTEM_NAV_3BUTTONS);
|
||||||
KEY_SYSTEM_NAV_3BUTTONS);
|
|
||||||
verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
|
verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
|
||||||
NAV_BAR_MODE_3BUTTON_OVERLAY, USER_CURRENT);
|
NAV_BAR_MODE_3BUTTON_OVERLAY, USER_CURRENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testSetCurrentSystemNavigationMode_backSensitivityValuePersists() throws Exception {
|
|
||||||
SettingsShadowResources.overrideResource(
|
|
||||||
R.integer.config_navBarInteractionMode, NAV_BAR_MODE_3BUTTON);
|
|
||||||
|
|
||||||
mSettings.setBackSensitivity(mContext, mOverlayManager, 2);
|
|
||||||
mSettings.setCurrentSystemNavigationMode(mContext, mOverlayManager,
|
|
||||||
KEY_SYSTEM_NAV_3BUTTONS);
|
|
||||||
verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
|
|
||||||
NAV_BAR_MODE_3BUTTON_OVERLAY, USER_CURRENT);
|
|
||||||
|
|
||||||
// Return to Gesture navigation, without setting the sensitivity value.
|
|
||||||
mSettings.setCurrentSystemNavigationMode(mContext, mOverlayManager,
|
|
||||||
KEY_SYSTEM_NAV_GESTURAL);
|
|
||||||
verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
|
|
||||||
NAV_BAR_MODE_GESTURAL_OVERLAY_WIDE_BACK, USER_CURRENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetBackSensitivity_default() {
|
|
||||||
assertEquals(BACK_GESTURE_INSET_DEFAULT_OVERLAY,
|
|
||||||
mSettings.getBackSensitivity(mContext, mOverlayManager));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBackSensitivitySetterAndGetter_currentNavModeNotGestural() throws Exception {
|
|
||||||
SettingsShadowResources.overrideResource(
|
|
||||||
R.integer.config_navBarInteractionMode, NAV_BAR_MODE_3BUTTON);
|
|
||||||
|
|
||||||
mSettings.setBackSensitivity(mContext, mOverlayManager, 3);
|
|
||||||
assertEquals(3, mSettings.getBackSensitivity(mContext, mOverlayManager));
|
|
||||||
mSettings.setBackSensitivity(mContext, mOverlayManager, 2);
|
|
||||||
assertEquals(2, mSettings.getBackSensitivity(mContext, mOverlayManager));
|
|
||||||
|
|
||||||
verify(mOverlayManager, never()).setEnabledExclusiveInCategory(any(), anyInt());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testBackSensitivitySetterAndGetter_currentNavModeIsGestural() throws Exception {
|
|
||||||
SettingsShadowResources.overrideResource(
|
|
||||||
R.integer.config_navBarInteractionMode, NAV_BAR_MODE_GESTURAL);
|
|
||||||
|
|
||||||
when(mOverlayManager.getOverlayInfo(BACK_GESTURE_INSET_OVERLAYS[3], USER_CURRENT))
|
|
||||||
.thenReturn(mOverlayInfoEnabled);
|
|
||||||
mSettings.setBackSensitivity(mContext, mOverlayManager, 3);
|
|
||||||
assertEquals(3, mSettings.getBackSensitivity(mContext, mOverlayManager));
|
|
||||||
|
|
||||||
when(mOverlayManager.getOverlayInfo(BACK_GESTURE_INSET_OVERLAYS[2], USER_CURRENT))
|
|
||||||
.thenReturn(mOverlayInfoEnabled);
|
|
||||||
mSettings.setBackSensitivity(mContext, mOverlayManager, 2);
|
|
||||||
assertEquals(2, mSettings.getBackSensitivity(mContext, mOverlayManager));
|
|
||||||
|
|
||||||
verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
|
|
||||||
NAV_BAR_MODE_GESTURAL_OVERLAY_WIDE_BACK, USER_CURRENT);
|
|
||||||
verify(mOverlayManager, times(1)).setEnabledExclusiveInCategory(
|
|
||||||
NAV_BAR_MODE_GESTURAL_OVERLAY_EXTRA_WIDE_BACK, USER_CURRENT);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user