Merge "Renaming gesture"

This commit is contained in:
Lucas Dupin
2018-09-28 22:00:56 +00:00
committed by Android (Google) Code Review
9 changed files with 53 additions and 52 deletions

View File

@@ -9585,10 +9585,10 @@
<!-- Summary text for ambient display (device) [CHAR LIMIT=NONE]--> <!-- Summary text for ambient display (device) [CHAR LIMIT=NONE]-->
<string name="ambient_display_pickup_summary" product="device">To check time, notifications, and other info, pick up your device.</string> <string name="ambient_display_pickup_summary" product="device">To check time, notifications, and other info, pick up your device.</string>
<!-- Preference and settings suggestion title text for reach gesture [CHAR LIMIT=60]--> <!-- Preference and settings suggestion title text for gesture that shows the lock screen [CHAR LIMIT=60]-->
<string name="ambient_display_reach_title">Reach gesture</string> <string name="ambient_display_wake_lock_screen_title">Wake lock screen gesture</string>
<!-- Summary text for ambient display [CHAR LIMIT=NONE]--> <!-- Summary text for ambient display [CHAR LIMIT=NONE]-->
<string name="ambient_display_reach_summary" product="default"></string> <string name="ambient_display_wake_lock_screen_summary" product="default"></string>
<!-- Title text for swiping downwards on fingerprint sensor for notifications [CHAR LIMIT=80]--> <!-- Title text for swiping downwards on fingerprint sensor for notifications [CHAR LIMIT=80]-->
<string name="fingerprint_swipe_for_notifications_title">Swipe fingerprint for notifications</string> <string name="fingerprint_swipe_for_notifications_title">Swipe fingerprint for notifications</string>

View File

@@ -28,10 +28,10 @@
settings:controller="com.android.settings.gestures.AssistGestureSettingsPreferenceController" /> settings:controller="com.android.settings.gestures.AssistGestureSettingsPreferenceController" />
<Preference <Preference
android:key="gesture_reach_summary" android:key="gesture_wake_lock_screen_summary"
android:title="@string/ambient_display_reach_title" android:title="@string/ambient_display_wake_lock_screen_title"
android:fragment="com.android.settings.gestures.ReachGestureSettings" android:fragment="com.android.settings.gestures.WakeLockScreenGestureSettings"
settings:controller="com.android.settings.gestures.ReachGesturePreferenceController" /> settings:controller="com.android.settings.gestures.WakeLockScreenGesturePreferenceController" />
<Preference <Preference
android:key="gesture_swipe_down_fingerprint_input_summary" android:key="gesture_swipe_down_fingerprint_input_summary"

View File

@@ -18,20 +18,20 @@
<PreferenceScreen <PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:key="gesture_reach_screen" android:key="gesture_wake_lock_screen_screen"
android:title="@string/ambient_display_reach_title"> android:title="@string/ambient_display_wake_lock_screen_title">
<com.android.settings.widget.VideoPreference <com.android.settings.widget.VideoPreference
android:key="gesture_reach_video" android:key="gesture_wake_lock_screen_video"
app:animation="@raw/gesture_ambient_reach" app:animation="@raw/gesture_ambient_wake_lock_screen"
app:preview="@drawable/gesture_ambient_reach" /> app:preview="@drawable/gesture_ambient_wake_lock_screen" />
<SwitchPreference <SwitchPreference
android:key="gesture_reach" android:key="gesture_wake_lock_screen"
android:title="@string/ambient_display_reach_title" android:title="@string/ambient_display_wake_lock_screen_title"
android:summary="@string/ambient_display_reach_summary" android:summary="@string/ambient_display_wake_lock_screen_summary"
app:keywords="@string/keywords_gesture" app:keywords="@string/keywords_gesture"
app:controller="com.android.settings.gestures.ReachGesturePreferenceController" app:controller="com.android.settings.gestures.WakeLockScreenGesturePreferenceController"
app:allowDividerAbove="true" /> app:allowDividerAbove="true" />
</PreferenceScreen> </PreferenceScreen>

View File

@@ -16,7 +16,7 @@
package com.android.settings.gestures; package com.android.settings.gestures;
import static android.provider.Settings.Secure.DOZE_REACH_GESTURE; import static android.provider.Settings.Secure.DOZE_WAKE_LOCK_SCREEN_GESTURE;
import android.annotation.UserIdInt; import android.annotation.UserIdInt;
import android.content.Context; import android.content.Context;
@@ -26,33 +26,34 @@ import android.text.TextUtils;
import com.android.internal.hardware.AmbientDisplayConfiguration; import com.android.internal.hardware.AmbientDisplayConfiguration;
public class ReachGesturePreferenceController extends GesturePreferenceController { public class WakeLockScreenGesturePreferenceController extends GesturePreferenceController {
private static final int ON = 1; private static final int ON = 1;
private static final int OFF = 0; private static final int OFF = 0;
private static final String PREF_KEY_VIDEO = "gesture_reach_video"; private static final String PREF_KEY_VIDEO = "gesture_wake_lock_screen_video";
private final String mReachUpPrefKey; private final String mWakeLockScreenPrefKey;
private AmbientDisplayConfiguration mAmbientConfig; private AmbientDisplayConfiguration mAmbientConfig;
@UserIdInt @UserIdInt
private final int mUserId; private final int mUserId;
public ReachGesturePreferenceController(Context context, String key) { public WakeLockScreenGesturePreferenceController(Context context, String key) {
super(context, key); super(context, key);
mUserId = UserHandle.myUserId(); mUserId = UserHandle.myUserId();
mReachUpPrefKey = key; mWakeLockScreenPrefKey = key;
} }
public ReachGesturePreferenceController setConfig(AmbientDisplayConfiguration config) { public WakeLockScreenGesturePreferenceController
setConfig(AmbientDisplayConfiguration config) {
mAmbientConfig = config; mAmbientConfig = config;
return this; return this;
} }
@Override @Override
public int getAvailabilityStatus() { public int getAvailabilityStatus() {
// No hardware support for Reach Gesture // No hardware support for this Gesture
if (!getAmbientConfig().reachGestureAvailable()) { if (!getAmbientConfig().wakeLockScreenGestureAvailable()) {
return UNSUPPORTED_ON_DEVICE; return UNSUPPORTED_ON_DEVICE;
} }
@@ -61,7 +62,7 @@ public class ReachGesturePreferenceController extends GesturePreferenceControlle
@Override @Override
public boolean isSliceable() { public boolean isSliceable() {
return TextUtils.equals(getPreferenceKey(), "gesture_reach"); return TextUtils.equals(getPreferenceKey(), "gesture_wake_lock_screen");
} }
@Override @Override
@@ -71,17 +72,17 @@ public class ReachGesturePreferenceController extends GesturePreferenceControlle
@Override @Override
public boolean isChecked() { public boolean isChecked() {
return getAmbientConfig().reachGestureEnabled(mUserId); return getAmbientConfig().wakeLockScreenGestureEnabled(mUserId);
} }
@Override @Override
public String getPreferenceKey() { public String getPreferenceKey() {
return mReachUpPrefKey; return mWakeLockScreenPrefKey;
} }
@Override @Override
public boolean setChecked(boolean isChecked) { public boolean setChecked(boolean isChecked) {
return Settings.Secure.putInt(mContext.getContentResolver(), DOZE_REACH_GESTURE, return Settings.Secure.putInt(mContext.getContentResolver(), DOZE_WAKE_LOCK_SCREEN_GESTURE,
isChecked ? ON : OFF); isChecked ? ON : OFF);
} }

View File

@@ -33,12 +33,12 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
@SearchIndexable @SearchIndexable
public class ReachGestureSettings extends DashboardFragment { public class WakeLockScreenGestureSettings extends DashboardFragment {
private static final String TAG = "ReachGestureSettings"; private static final String TAG = "WakeLockScreenGestureSettings";
public static final String PREF_KEY_SUGGESTION_COMPLETE = public static final String PREF_KEY_SUGGESTION_COMPLETE =
"pref_reach_gesture_suggestion_complete"; "pref_wake_lock_screen_gesture_suggestion_complete";
@Override @Override
public void onAttach(Context context) { public void onAttach(Context context) {
@@ -48,13 +48,13 @@ public class ReachGestureSettings extends DashboardFragment {
SharedPreferences prefs = suggestionFeatureProvider.getSharedPrefs(context); SharedPreferences prefs = suggestionFeatureProvider.getSharedPrefs(context);
prefs.edit().putBoolean(PREF_KEY_SUGGESTION_COMPLETE, true).apply(); prefs.edit().putBoolean(PREF_KEY_SUGGESTION_COMPLETE, true).apply();
use(ReachGesturePreferenceController.class) use(WakeLockScreenGesturePreferenceController.class)
.setConfig(new AmbientDisplayConfiguration(context)); .setConfig(new AmbientDisplayConfiguration(context));
} }
@Override @Override
public int getMetricsCategory() { public int getMetricsCategory() {
return MetricsProto.MetricsEvent.SETTINGS_GESTURE_REACH; return MetricsProto.MetricsEvent.SETTINGS_GESTURE_WAKE_LOCK_SCREEN;
} }
@Override @Override
@@ -64,7 +64,7 @@ public class ReachGestureSettings extends DashboardFragment {
@Override @Override
protected int getPreferenceScreenResId() { protected int getPreferenceScreenResId() {
return R.xml.reach_gesture_settings; return R.xml.wake_lock_screen_gesture_settings;
} }
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
@@ -73,7 +73,7 @@ public class ReachGestureSettings extends DashboardFragment {
public List<SearchIndexableResource> getXmlResourcesToIndex( public List<SearchIndexableResource> getXmlResourcesToIndex(
Context context, boolean enabled) { Context context, boolean enabled) {
final SearchIndexableResource sir = new SearchIndexableResource(context); final SearchIndexableResource sir = new SearchIndexableResource(context);
sir.xmlResId = R.xml.reach_gesture_settings; sir.xmlResId = R.xml.wake_lock_screen_gesture_settings;
return Arrays.asList(sir); return Arrays.asList(sir);
} }
}; };

View File

@@ -37,41 +37,41 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations; import org.mockito.MockitoAnnotations;
@RunWith(SettingsRobolectricTestRunner.class) @RunWith(SettingsRobolectricTestRunner.class)
public class ReachGesturePreferenceControllerTest { public class WakeLockScreenGesturePreferenceControllerTest {
private static final String KEY_REACH = "gesture_reach"; private static final String KEY_WAKE_LOCK_SCREEN = "gesture_wake_lock_screen";
@Mock(answer = Answers.RETURNS_DEEP_STUBS) @Mock(answer = Answers.RETURNS_DEEP_STUBS)
private Context mContext; private Context mContext;
@Mock @Mock
private AmbientDisplayConfiguration mAmbientDisplayConfiguration; private AmbientDisplayConfiguration mAmbientDisplayConfiguration;
private ReachGesturePreferenceController mController; private WakeLockScreenGesturePreferenceController mController;
@Before @Before
public void setUp() { public void setUp() {
MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this);
mController = new ReachGesturePreferenceController(mContext, KEY_REACH); mController = new WakeLockScreenGesturePreferenceController(mContext, KEY_WAKE_LOCK_SCREEN);
mController.setConfig(mAmbientDisplayConfiguration); mController.setConfig(mAmbientDisplayConfiguration);
} }
@Test @Test
public void testIsChecked_configIsSet_shouldReturnTrue() { public void testIsChecked_configIsSet_shouldReturnTrue() {
// Set the setting to be enabled. // Set the setting to be enabled.
when(mAmbientDisplayConfiguration.reachGestureEnabled(anyInt())).thenReturn(true); when(mAmbientDisplayConfiguration.wakeLockScreenGestureEnabled(anyInt())).thenReturn(true);
assertThat(mController.isChecked()).isTrue(); assertThat(mController.isChecked()).isTrue();
} }
@Test @Test
public void testIsChecked_configIsNotSet_shouldReturnFalse() { public void testIsChecked_configIsNotSet_shouldReturnFalse() {
// Set the setting to be disabled. // Set the setting to be disabled.
when(mAmbientDisplayConfiguration.reachGestureEnabled(anyInt())).thenReturn(false); when(mAmbientDisplayConfiguration.wakeLockScreenGestureEnabled(anyInt())).thenReturn(false);
assertThat(mController.isChecked()).isFalse(); assertThat(mController.isChecked()).isFalse();
} }
@Test @Test
public void getAvailabilityStatus_gestureNotSupported_UNSUPPORTED_ON_DEVICE() { public void getAvailabilityStatus_gestureNotSupported_UNSUPPORTED_ON_DEVICE() {
when(mAmbientDisplayConfiguration.reachGestureAvailable()).thenReturn(false); when(mAmbientDisplayConfiguration.wakeLockScreenGestureAvailable()).thenReturn(false);
final int availabilityStatus = mController.getAvailabilityStatus(); final int availabilityStatus = mController.getAvailabilityStatus();
assertThat(availabilityStatus).isEqualTo(UNSUPPORTED_ON_DEVICE); assertThat(availabilityStatus).isEqualTo(UNSUPPORTED_ON_DEVICE);
@@ -79,7 +79,7 @@ public class ReachGesturePreferenceControllerTest {
@Test @Test
public void getAvailabilityStatus_gestureSupported_AVAILABLE() { public void getAvailabilityStatus_gestureSupported_AVAILABLE() {
when(mAmbientDisplayConfiguration.reachGestureAvailable()).thenReturn(true); when(mAmbientDisplayConfiguration.wakeLockScreenGestureAvailable()).thenReturn(true);
final int availabilityStatus = mController.getAvailabilityStatus(); final int availabilityStatus = mController.getAvailabilityStatus();
assertThat(availabilityStatus).isEqualTo(AVAILABLE); assertThat(availabilityStatus).isEqualTo(AVAILABLE);
@@ -87,15 +87,15 @@ public class ReachGesturePreferenceControllerTest {
@Test @Test
public void isSliceableCorrectKey_returnsTrue() { public void isSliceableCorrectKey_returnsTrue() {
final ReachGesturePreferenceController controller = final WakeLockScreenGesturePreferenceController controller =
new ReachGesturePreferenceController(mContext, "gesture_reach"); new WakeLockScreenGesturePreferenceController(mContext, KEY_WAKE_LOCK_SCREEN);
assertThat(controller.isSliceable()).isTrue(); assertThat(controller.isSliceable()).isTrue();
} }
@Test @Test
public void isSliceableIncorrectKey_returnsFalse() { public void isSliceableIncorrectKey_returnsFalse() {
final ReachGesturePreferenceController controller = final WakeLockScreenGesturePreferenceController controller =
new ReachGesturePreferenceController(mContext, "bad_key"); new WakeLockScreenGesturePreferenceController(mContext, "bad_key");
assertThat(controller.isSliceable()).isFalse(); assertThat(controller.isSliceable()).isFalse();
} }
} }

View File

@@ -30,19 +30,19 @@ import org.robolectric.RuntimeEnvironment;
import java.util.List; import java.util.List;
@RunWith(SettingsRobolectricTestRunner.class) @RunWith(SettingsRobolectricTestRunner.class)
public class ReachGestureSettingsTest { public class WakeLockScreenGestureSettingsTest {
private ReachGestureSettings mSettings; private WakeLockScreenGestureSettings mSettings;
@Before @Before
public void setUp() { public void setUp() {
mSettings = new ReachGestureSettings(); mSettings = new WakeLockScreenGestureSettings();
} }
@Test @Test
public void testSearchIndexProvider_shouldIndexResource() { public void testSearchIndexProvider_shouldIndexResource() {
final List<SearchIndexableResource> indexRes = final List<SearchIndexableResource> indexRes =
ReachGestureSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex( WakeLockScreenGestureSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
RuntimeEnvironment.application, true /* enabled */); RuntimeEnvironment.application, true /* enabled */);
assertThat(indexRes).isNotNull(); assertThat(indexRes).isNotNull();