Remove Language and Input duplicates
Change the keys in the Language and Input screen for the gesture and tts-output settings so they can be disabled in search. Then change the preference controllers to take a key as input to avoid crashes on the other screens with these settings. Merge for: ag/2098173/ Test: make RunSettingsRoboTests Bug: 33701673 Change-Id: I8bc0776131fcac5a6edf7e8271bc53252c2fc719
This commit is contained in:
@@ -39,7 +39,7 @@
|
|||||||
android:summary="@string/summary_placeholder"/>
|
android:summary="@string/summary_placeholder"/>
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="gesture_swipe_down_fingerprint"
|
android:key="gesture_swipe_down_fingerprint_notifications"
|
||||||
android:title="@string/fingerprint_swipe_for_notifications_title"
|
android:title="@string/fingerprint_swipe_for_notifications_title"
|
||||||
android:summary="@string/fingerprint_swipe_for_notifications_summary"/>
|
android:summary="@string/fingerprint_swipe_for_notifications_summary"/>
|
||||||
|
|
||||||
|
@@ -97,12 +97,12 @@
|
|||||||
android:title="@string/lift_to_wake_title" />
|
android:title="@string/lift_to_wake_title" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="gesture_double_tap_screen"
|
android:key="gesture_double_tap_screen_display_summary"
|
||||||
android:title="@string/ambient_display_title"
|
android:title="@string/ambient_display_title"
|
||||||
android:fragment="com.android.settings.gestures.DoubleTapScreenSettings" />
|
android:fragment="com.android.settings.gestures.DoubleTapScreenSettings" />
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="gesture_pick_up"
|
android:key="gesture_pick_up_display_summary"
|
||||||
android:title="@string/ambient_display_pickup_title"
|
android:title="@string/ambient_display_pickup_title"
|
||||||
android:fragment="com.android.settings.gestures.PickupGestureSettings" />
|
android:fragment="com.android.settings.gestures.PickupGestureSettings" />
|
||||||
|
|
||||||
|
@@ -66,22 +66,22 @@
|
|||||||
android:title="@string/gesture_preference_title">
|
android:title="@string/gesture_preference_title">
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="gesture_assist"
|
android:key="gesture_assist_input_summary"
|
||||||
android:title="@string/assist_gesture_title"
|
android:title="@string/assist_gesture_title"
|
||||||
android:fragment="com.android.settings.gestures.AssistGestureSettings"/>
|
android:fragment="com.android.settings.gestures.AssistGestureSettings"/>
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="gesture_swipe_down_fingerprint"
|
android:key="gesture_swipe_down_fingerprint_input_summary"
|
||||||
android:title="@string/fingerprint_swipe_for_notifications_title"
|
android:title="@string/fingerprint_swipe_for_notifications_title"
|
||||||
android:fragment="com.android.settings.gestures.SwipeToNotificationSettings"/>
|
android:fragment="com.android.settings.gestures.SwipeToNotificationSettings"/>
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="gesture_double_tap_screen"
|
android:key="gesture_double_tap_screen_input_summary"
|
||||||
android:title="@string/ambient_display_title"
|
android:title="@string/ambient_display_title"
|
||||||
android:fragment="com.android.settings.gestures.DoubleTapScreenSettings"/>
|
android:fragment="com.android.settings.gestures.DoubleTapScreenSettings"/>
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="gesture_pick_up"
|
android:key="gesture_pick_up_input_summary"
|
||||||
android:title="@string/ambient_display_pickup_title"
|
android:title="@string/ambient_display_pickup_title"
|
||||||
android:fragment="com.android.settings.gestures.PickupGestureSettings"/>
|
android:fragment="com.android.settings.gestures.PickupGestureSettings"/>
|
||||||
|
|
||||||
@@ -91,12 +91,12 @@
|
|||||||
android:fragment="com.android.settings.gestures.CameraLiftTriggerSettings"/>
|
android:fragment="com.android.settings.gestures.CameraLiftTriggerSettings"/>
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="gesture_double_tap_power"
|
android:key="gesture_double_tap_power_input_summary"
|
||||||
android:title="@string/double_tap_power_for_camera_title"
|
android:title="@string/double_tap_power_for_camera_title"
|
||||||
android:fragment="com.android.settings.gestures.DoubleTapPowerSettings"/>
|
android:fragment="com.android.settings.gestures.DoubleTapPowerSettings"/>
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="gesture_double_twist"
|
android:key="gesture_double_twist_input_summary"
|
||||||
android:title="@string/double_twist_for_camera_mode_title"
|
android:title="@string/double_twist_for_camera_mode_title"
|
||||||
android:fragment="com.android.settings.gestures.DoubleTwistGestureSettings"/>
|
android:fragment="com.android.settings.gestures.DoubleTwistGestureSettings"/>
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
android:dialogTitle="@string/pointer_speed"/>
|
android:dialogTitle="@string/pointer_speed"/>
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="tts_settings"
|
android:key="tts_settings_summary"
|
||||||
android:title="@string/tts_settings_title"
|
android:title="@string/tts_settings_title"
|
||||||
android:fragment="com.android.settings.tts.TextToSpeechSettings"/>
|
android:fragment="com.android.settings.tts.TextToSpeechSettings"/>
|
||||||
|
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
android:fragment="com.android.settings.applications.assist.DefaultAssistPicker"/>
|
android:fragment="com.android.settings.applications.assist.DefaultAssistPicker"/>
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:key="gesture_assist"
|
android:key="gesture_assist_application"
|
||||||
android:title="@string/assist_gesture_title"
|
android:title="@string/assist_gesture_title"
|
||||||
android:fragment="com.android.settings.gestures.AssistGestureSettings"/>
|
android:fragment="com.android.settings.gestures.AssistGestureSettings"/>
|
||||||
|
|
||||||
|
@@ -57,6 +57,8 @@ public class DisplaySettings extends DashboardFragment {
|
|||||||
public static final String KEY_DISPLAY_SIZE = "screen_zoom";
|
public static final String KEY_DISPLAY_SIZE = "screen_zoom";
|
||||||
|
|
||||||
private static final String KEY_SCREEN_TIMEOUT = "screen_timeout";
|
private static final String KEY_SCREEN_TIMEOUT = "screen_timeout";
|
||||||
|
private static final String KEY_PICK_UP = "gesture_pick_up_display_summary";
|
||||||
|
private static final String KEY_DOUBLE_TAP_SCREEN = "gesture_double_tap_screen_display_summary";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
@@ -105,9 +107,10 @@ public class DisplaySettings extends DashboardFragment {
|
|||||||
controllers.add(new NightModePreferenceController(context));
|
controllers.add(new NightModePreferenceController(context));
|
||||||
controllers.add(new ScreenSaverPreferenceController(context));
|
controllers.add(new ScreenSaverPreferenceController(context));
|
||||||
controllers.add(new PickupGesturePreferenceController(
|
controllers.add(new PickupGesturePreferenceController(
|
||||||
context, lifecycle, ambientDisplayConfig, UserHandle.myUserId()));
|
context, lifecycle, ambientDisplayConfig, UserHandle.myUserId(), KEY_PICK_UP));
|
||||||
controllers.add(new DoubleTapScreenPreferenceController(
|
controllers.add(new DoubleTapScreenPreferenceController(
|
||||||
context, lifecycle, ambientDisplayConfig, UserHandle.myUserId()));
|
context, lifecycle, ambientDisplayConfig, UserHandle.myUserId(),
|
||||||
|
KEY_DOUBLE_TAP_SCREEN));
|
||||||
controllers.add(new TapToWakePreferenceController(context));
|
controllers.add(new TapToWakePreferenceController(context));
|
||||||
controllers.add(new TimeoutPreferenceController(context, KEY_SCREEN_TIMEOUT));
|
controllers.add(new TimeoutPreferenceController(context, KEY_SCREEN_TIMEOUT));
|
||||||
controllers.add(new VrDisplayPreferenceController(context));
|
controllers.add(new VrDisplayPreferenceController(context));
|
||||||
|
@@ -38,6 +38,7 @@ import java.util.List;
|
|||||||
public class ManageAssist extends DashboardFragment {
|
public class ManageAssist extends DashboardFragment {
|
||||||
|
|
||||||
private static final String TAG = "ManageAssist";
|
private static final String TAG = "ManageAssist";
|
||||||
|
private static final String KEY_ASSIST = "gesture_assist_application";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getLogTag() {
|
protected String getLogTag() {
|
||||||
@@ -71,7 +72,7 @@ public class ManageAssist extends DashboardFragment {
|
|||||||
Lifecycle lifecycle) {
|
Lifecycle lifecycle) {
|
||||||
final List<PreferenceController> controllers = new ArrayList<>();
|
final List<PreferenceController> controllers = new ArrayList<>();
|
||||||
controllers.add(new DefaultAssistPreferenceController(context));
|
controllers.add(new DefaultAssistPreferenceController(context));
|
||||||
controllers.add(new AssistGesturePreferenceController(context, lifecycle));
|
controllers.add(new AssistGesturePreferenceController(context, lifecycle, KEY_ASSIST));
|
||||||
controllers.add(new AssistContextPreferenceController(context, lifecycle));
|
controllers.add(new AssistContextPreferenceController(context, lifecycle));
|
||||||
controllers.add(new AssistScreenshotPreferenceController(context, lifecycle));
|
controllers.add(new AssistScreenshotPreferenceController(context, lifecycle));
|
||||||
controllers.add(new AssistFlashScreenPreferenceController(context, lifecycle));
|
controllers.add(new AssistFlashScreenPreferenceController(context, lifecycle));
|
||||||
@@ -94,5 +95,12 @@ public class ManageAssist extends DashboardFragment {
|
|||||||
public List<PreferenceController> getPreferenceControllers(Context context) {
|
public List<PreferenceController> getPreferenceControllers(Context context) {
|
||||||
return buildPreferenceControllers(context, null /* lifecycle */);
|
return buildPreferenceControllers(context, null /* lifecycle */);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getNonIndexableKeys(Context context) {
|
||||||
|
List<String> keys = super.getNonIndexableKeys(context);
|
||||||
|
keys.add(KEY_ASSIST);
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -35,7 +35,7 @@ public class AssistGesturePreferenceController extends GesturePreferenceControll
|
|||||||
implements OnPause, OnResume {
|
implements OnPause, OnResume {
|
||||||
|
|
||||||
private static final String PREF_KEY_VIDEO = "gesture_assist_video";
|
private static final String PREF_KEY_VIDEO = "gesture_assist_video";
|
||||||
private static final String PREF_KEY_ASSIST_GESTURE = "gesture_assist";
|
private final String mAssistGesturePrefKey;
|
||||||
|
|
||||||
private final AssistGestureFeatureProvider mFeatureProvider;
|
private final AssistGestureFeatureProvider mFeatureProvider;
|
||||||
private final SettingObserver mSettingObserver;
|
private final SettingObserver mSettingObserver;
|
||||||
@@ -44,11 +44,12 @@ public class AssistGesturePreferenceController extends GesturePreferenceControll
|
|||||||
private PreferenceScreen mScreen;
|
private PreferenceScreen mScreen;
|
||||||
private Preference mPreference;
|
private Preference mPreference;
|
||||||
|
|
||||||
public AssistGesturePreferenceController(Context context, Lifecycle lifecycle) {
|
public AssistGesturePreferenceController(Context context, Lifecycle lifecycle, String key) {
|
||||||
super(context, lifecycle);
|
super(context, lifecycle);
|
||||||
mFeatureProvider = FeatureFactory.getFactory(context).getAssistGestureFeatureProvider();
|
mFeatureProvider = FeatureFactory.getFactory(context).getAssistGestureFeatureProvider();
|
||||||
mSettingObserver = new SettingObserver();
|
mSettingObserver = new SettingObserver();
|
||||||
mWasAvailable = isAvailable();
|
mWasAvailable = isAvailable();
|
||||||
|
mAssistGesturePrefKey = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -110,7 +111,7 @@ public class AssistGesturePreferenceController extends GesturePreferenceControll
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPreferenceKey() {
|
public String getPreferenceKey() {
|
||||||
return PREF_KEY_ASSIST_GESTURE;
|
return mAssistGesturePrefKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -34,6 +34,8 @@ public class AssistGestureSettings extends DashboardFragment {
|
|||||||
|
|
||||||
private static final String TAG = "AssistGesture";
|
private static final String TAG = "AssistGesture";
|
||||||
|
|
||||||
|
private static final String KEY_ASSIST = "gesture_assist";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return MetricsProto.MetricsEvent.VIEW_UNKNOWN;
|
return MetricsProto.MetricsEvent.VIEW_UNKNOWN;
|
||||||
@@ -57,7 +59,7 @@ public class AssistGestureSettings extends DashboardFragment {
|
|||||||
private static List<PreferenceController> buildPreferenceControllers(Context context,
|
private static List<PreferenceController> buildPreferenceControllers(Context context,
|
||||||
Lifecycle lifecycle) {
|
Lifecycle lifecycle) {
|
||||||
final List<PreferenceController> controllers = new ArrayList<>();
|
final List<PreferenceController> controllers = new ArrayList<>();
|
||||||
controllers.add(new AssistGesturePreferenceController(context, lifecycle));
|
controllers.add(new AssistGesturePreferenceController(context, lifecycle, KEY_ASSIST));
|
||||||
controllers.add(new AssistGestureSensitivityPreferenceController(context, lifecycle));
|
controllers.add(new AssistGestureSensitivityPreferenceController(context, lifecycle));
|
||||||
return controllers;
|
return controllers;
|
||||||
}
|
}
|
||||||
|
@@ -20,18 +20,16 @@ import android.content.Context;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
|
|
||||||
import android.util.ArrayMap;
|
|
||||||
import com.android.settings.search2.InlineSwitchPayload;
|
|
||||||
import com.android.settings.search2.ResultPayload;
|
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
|
|
||||||
public class DoubleTapPowerPreferenceController extends GesturePreferenceController {
|
public class DoubleTapPowerPreferenceController extends GesturePreferenceController {
|
||||||
|
|
||||||
private static final String PREF_KEY_VIDEO = "gesture_double_tap_power_video";
|
private static final String PREF_KEY_VIDEO = "gesture_double_tap_power_video";
|
||||||
private static final String PREF_KEY_DOUBLE_TAP_POWER = "gesture_double_tap_power";
|
private final String mDoubleTapPowerKey;
|
||||||
|
|
||||||
public DoubleTapPowerPreferenceController(Context context, Lifecycle lifecycle) {
|
public DoubleTapPowerPreferenceController(Context context, Lifecycle lifecycle, String key) {
|
||||||
super(context, lifecycle);
|
super(context, lifecycle);
|
||||||
|
mDoubleTapPowerKey = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -47,7 +45,7 @@ public class DoubleTapPowerPreferenceController extends GesturePreferenceControl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPreferenceKey() {
|
public String getPreferenceKey() {
|
||||||
return PREF_KEY_DOUBLE_TAP_POWER;
|
return mDoubleTapPowerKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -33,6 +33,7 @@ import java.util.List;
|
|||||||
public class DoubleTapPowerSettings extends DashboardFragment {
|
public class DoubleTapPowerSettings extends DashboardFragment {
|
||||||
|
|
||||||
private static final String TAG = "DoubleTapPower";
|
private static final String TAG = "DoubleTapPower";
|
||||||
|
private static final String KEY_DOUBLE_TAP_POWER = "gesture_double_tap_power";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
@@ -57,7 +58,8 @@ public class DoubleTapPowerSettings extends DashboardFragment {
|
|||||||
private static List<PreferenceController> buildPreferenceControllers(Context context,
|
private static List<PreferenceController> buildPreferenceControllers(Context context,
|
||||||
Lifecycle lifecycle) {
|
Lifecycle lifecycle) {
|
||||||
final List<PreferenceController> controllers = new ArrayList<>();
|
final List<PreferenceController> controllers = new ArrayList<>();
|
||||||
controllers.add(new DoubleTapPowerPreferenceController(context, lifecycle));
|
controllers.add(new DoubleTapPowerPreferenceController(context, lifecycle,
|
||||||
|
KEY_DOUBLE_TAP_POWER));
|
||||||
return controllers;
|
return controllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,26 +21,24 @@ import android.content.Context;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
|
|
||||||
import android.util.ArrayMap;
|
|
||||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||||
import com.android.settings.search2.InlineSwitchPayload;
|
|
||||||
import com.android.settings.search2.ResultPayload;
|
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
|
|
||||||
public class DoubleTapScreenPreferenceController extends GesturePreferenceController {
|
public class DoubleTapScreenPreferenceController extends GesturePreferenceController {
|
||||||
|
|
||||||
private static final String PREF_KEY_VIDEO = "gesture_double_tap_screen_video";
|
private static final String PREF_KEY_VIDEO = "gesture_double_tap_screen_video";
|
||||||
private static final String PREF_KEY_DOUBLE_TAP_SCREEN = "gesture_double_tap_screen";
|
private final String mDoubleTapScreenPrefKey;
|
||||||
|
|
||||||
private final AmbientDisplayConfiguration mAmbientConfig;
|
private final AmbientDisplayConfiguration mAmbientConfig;
|
||||||
@UserIdInt
|
@UserIdInt
|
||||||
private final int mUserId;
|
private final int mUserId;
|
||||||
|
|
||||||
public DoubleTapScreenPreferenceController(Context context, Lifecycle lifecycle,
|
public DoubleTapScreenPreferenceController(Context context, Lifecycle lifecycle,
|
||||||
AmbientDisplayConfiguration config, @UserIdInt int userId) {
|
AmbientDisplayConfiguration config, @UserIdInt int userId, String key) {
|
||||||
super(context, lifecycle);
|
super(context, lifecycle);
|
||||||
mAmbientConfig = config;
|
mAmbientConfig = config;
|
||||||
mUserId = userId;
|
mUserId = userId;
|
||||||
|
mDoubleTapScreenPrefKey = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -50,7 +48,7 @@ public class DoubleTapScreenPreferenceController extends GesturePreferenceContro
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPreferenceKey() {
|
public String getPreferenceKey() {
|
||||||
return PREF_KEY_DOUBLE_TAP_SCREEN;
|
return mDoubleTapScreenPrefKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -35,6 +35,7 @@ import java.util.List;
|
|||||||
public class DoubleTapScreenSettings extends DashboardFragment {
|
public class DoubleTapScreenSettings extends DashboardFragment {
|
||||||
|
|
||||||
private static final String TAG = "DoubleTapScreen";
|
private static final String TAG = "DoubleTapScreen";
|
||||||
|
private static final String KEY_DOUBLE_TAP_SCREEN = "gesture_double_tap_screen";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
@@ -60,7 +61,8 @@ public class DoubleTapScreenSettings extends DashboardFragment {
|
|||||||
Lifecycle lifecycle) {
|
Lifecycle lifecycle) {
|
||||||
final List<PreferenceController> controllers = new ArrayList<>();
|
final List<PreferenceController> controllers = new ArrayList<>();
|
||||||
controllers.add(new DoubleTapScreenPreferenceController(context, lifecycle,
|
controllers.add(new DoubleTapScreenPreferenceController(context, lifecycle,
|
||||||
new AmbientDisplayConfiguration(context), UserHandle.myUserId()));
|
new AmbientDisplayConfiguration(context), UserHandle.myUserId(),
|
||||||
|
KEY_DOUBLE_TAP_SCREEN));
|
||||||
return controllers;
|
return controllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,6 +33,7 @@ import java.util.List;
|
|||||||
public class DoubleTwistGestureSettings extends DashboardFragment {
|
public class DoubleTwistGestureSettings extends DashboardFragment {
|
||||||
|
|
||||||
private static final String TAG = "DoubleTwistGesture";
|
private static final String TAG = "DoubleTwistGesture";
|
||||||
|
private static final String KEY_DOUBLE_TWIST = "gesture_double_twist";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
@@ -57,7 +58,7 @@ public class DoubleTwistGestureSettings extends DashboardFragment {
|
|||||||
private static List<PreferenceController> buildPreferenceControllers(Context context,
|
private static List<PreferenceController> buildPreferenceControllers(Context context,
|
||||||
Lifecycle lifecycle) {
|
Lifecycle lifecycle) {
|
||||||
final List<PreferenceController> controllers = new ArrayList<>();
|
final List<PreferenceController> controllers = new ArrayList<>();
|
||||||
controllers.add(new DoubleTwistPreferenceController(context, lifecycle));
|
controllers.add(new DoubleTwistPreferenceController(context, lifecycle, KEY_DOUBLE_TWIST));
|
||||||
return controllers;
|
return controllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -24,19 +24,17 @@ import android.provider.Settings;
|
|||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import android.util.ArrayMap;
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.search2.InlineSwitchPayload;
|
|
||||||
import com.android.settings.search2.ResultPayload;
|
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
|
|
||||||
public class DoubleTwistPreferenceController extends GesturePreferenceController {
|
public class DoubleTwistPreferenceController extends GesturePreferenceController {
|
||||||
|
|
||||||
private static final String PREF_KEY_VIDEO = "gesture_double_twist_video";
|
private static final String PREF_KEY_VIDEO = "gesture_double_twist_video";
|
||||||
private static final String PREF_KEY_DOUBLE_TWIST = "gesture_double_twist";
|
private final String mDoubleTwistPrefKey;
|
||||||
|
|
||||||
public DoubleTwistPreferenceController(Context context, Lifecycle lifecycle) {
|
public DoubleTwistPreferenceController(Context context, Lifecycle lifecycle, String key) {
|
||||||
super(context, lifecycle);
|
super(context, lifecycle);
|
||||||
|
mDoubleTwistPrefKey = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -52,7 +50,7 @@ public class DoubleTwistPreferenceController extends GesturePreferenceController
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPreferenceKey() {
|
public String getPreferenceKey() {
|
||||||
return PREF_KEY_DOUBLE_TWIST;
|
return mDoubleTwistPrefKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -21,26 +21,24 @@ import android.content.Context;
|
|||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
|
|
||||||
import android.util.ArrayMap;
|
|
||||||
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
import com.android.internal.hardware.AmbientDisplayConfiguration;
|
||||||
import com.android.settings.search2.InlineSwitchPayload;
|
|
||||||
import com.android.settings.search2.ResultPayload;
|
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
|
|
||||||
public class PickupGesturePreferenceController extends GesturePreferenceController {
|
public class PickupGesturePreferenceController extends GesturePreferenceController {
|
||||||
|
|
||||||
private static final String PREF_VIDEO_KEY = "gesture_pick_up_video";
|
private static final String PREF_VIDEO_KEY = "gesture_pick_up_video";
|
||||||
private static final String PREF_KEY_PICK_UP = "gesture_pick_up";
|
private final String mPickUpPrefKey;
|
||||||
|
|
||||||
private final AmbientDisplayConfiguration mAmbientConfig;
|
private final AmbientDisplayConfiguration mAmbientConfig;
|
||||||
@UserIdInt
|
@UserIdInt
|
||||||
private final int mUserId;
|
private final int mUserId;
|
||||||
|
|
||||||
public PickupGesturePreferenceController(Context context, Lifecycle lifecycle,
|
public PickupGesturePreferenceController(Context context, Lifecycle lifecycle,
|
||||||
AmbientDisplayConfiguration config, @UserIdInt int userId) {
|
AmbientDisplayConfiguration config, @UserIdInt int userId, String key) {
|
||||||
super(context, lifecycle);
|
super(context, lifecycle);
|
||||||
mAmbientConfig = config;
|
mAmbientConfig = config;
|
||||||
mUserId = userId;
|
mUserId = userId;
|
||||||
|
mPickUpPrefKey = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -60,7 +58,7 @@ public class PickupGesturePreferenceController extends GesturePreferenceControll
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPreferenceKey() {
|
public String getPreferenceKey() {
|
||||||
return PREF_KEY_PICK_UP;
|
return mPickUpPrefKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -35,6 +35,7 @@ import java.util.List;
|
|||||||
public class PickupGestureSettings extends DashboardFragment {
|
public class PickupGestureSettings extends DashboardFragment {
|
||||||
|
|
||||||
private static final String TAG = "PickupGestureSettings";
|
private static final String TAG = "PickupGestureSettings";
|
||||||
|
private static final String KEY_PICK_UP = "gesture_pick_up";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
@@ -60,7 +61,7 @@ public class PickupGestureSettings extends DashboardFragment {
|
|||||||
Lifecycle lifecycle) {
|
Lifecycle lifecycle) {
|
||||||
final List<PreferenceController> controllers = new ArrayList<>();
|
final List<PreferenceController> controllers = new ArrayList<>();
|
||||||
controllers.add(new PickupGesturePreferenceController(context, lifecycle,
|
controllers.add(new PickupGesturePreferenceController(context, lifecycle,
|
||||||
new AmbientDisplayConfiguration(context), UserHandle.myUserId()));
|
new AmbientDisplayConfiguration(context), UserHandle.myUserId(), KEY_PICK_UP));
|
||||||
return controllers;
|
return controllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -28,15 +28,17 @@ import com.android.settingslib.core.lifecycle.Lifecycle;
|
|||||||
public class SwipeToNotificationPreferenceController extends GesturePreferenceController {
|
public class SwipeToNotificationPreferenceController extends GesturePreferenceController {
|
||||||
|
|
||||||
private static final String PREF_KEY_VIDEO = "gesture_swipe_down_fingerprint_video";
|
private static final String PREF_KEY_VIDEO = "gesture_swipe_down_fingerprint_video";
|
||||||
private static final String PREF_KEY_SWIPE_DOWN_FINGERPRINT = "gesture_swipe_down_fingerprint";
|
private final String mSwipeDownFingerPrefKey;
|
||||||
|
|
||||||
public SwipeToNotificationPreferenceController(Context context, Lifecycle lifecycle) {
|
public SwipeToNotificationPreferenceController(Context context, Lifecycle lifecycle,
|
||||||
|
String key) {
|
||||||
super(context, lifecycle);
|
super(context, lifecycle);
|
||||||
|
mSwipeDownFingerPrefKey = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPreferenceKey() {
|
public String getPreferenceKey() {
|
||||||
return PREF_KEY_SWIPE_DOWN_FINGERPRINT;
|
return mSwipeDownFingerPrefKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -34,6 +34,8 @@ public class SwipeToNotificationSettings extends DashboardFragment {
|
|||||||
|
|
||||||
private static final String TAG = "SwipeToNotifSettings";
|
private static final String TAG = "SwipeToNotifSettings";
|
||||||
|
|
||||||
|
private static final String KEY = "gesture_swipe_down_fingerprint";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return MetricsProto.MetricsEvent.SETTINGS_GESTURE_SWIPE_TO_NOTIFICATION;
|
return MetricsProto.MetricsEvent.SETTINGS_GESTURE_SWIPE_TO_NOTIFICATION;
|
||||||
@@ -57,7 +59,7 @@ public class SwipeToNotificationSettings extends DashboardFragment {
|
|||||||
private static List<PreferenceController> buildPreferenceControllers(Context context,
|
private static List<PreferenceController> buildPreferenceControllers(Context context,
|
||||||
Lifecycle lifecycle) {
|
Lifecycle lifecycle) {
|
||||||
final List<PreferenceController> controllers = new ArrayList<>();
|
final List<PreferenceController> controllers = new ArrayList<>();
|
||||||
controllers.add(new SwipeToNotificationPreferenceController(context, lifecycle));
|
controllers.add(new SwipeToNotificationPreferenceController(context, lifecycle, KEY));
|
||||||
return controllers;
|
return controllers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -60,6 +60,13 @@ public class LanguageAndInputSettings extends DashboardFragment {
|
|||||||
|
|
||||||
private static final String TAG = "LangAndInputSettings";
|
private static final String TAG = "LangAndInputSettings";
|
||||||
|
|
||||||
|
private static final String KEY_TEXT_TO_SPEECH = "tts_settings_summary";
|
||||||
|
private static final String KEY_ASSIST = "gesture_assist_input_summary";
|
||||||
|
private static final String KEY_SWIPE_DOWN = "gesture_swipe_down_fingerprint_input_summary";
|
||||||
|
private static final String KEY_DOUBLE_TAP_POWER = "gesture_double_tap_power_input_summary";
|
||||||
|
private static final String KEY_DOUBLE_TWIST = "gesture_double_twist_input_summary";
|
||||||
|
private static final String KEY_DOUBLE_TAP_SCREEN = "gesture_double_tap_screen_input_summary";
|
||||||
|
private static final String KEY_PICK_UP = "gesture_pick_up_input_summary";
|
||||||
private static final String KEY_CAMERA_LIFT_TRIGGER = "gesture_camera_lift_trigger_summary";
|
private static final String KEY_CAMERA_LIFT_TRIGGER = "gesture_camera_lift_trigger_summary";
|
||||||
|
|
||||||
private AmbientDisplayConfiguration mAmbientDisplayConfig;
|
private AmbientDisplayConfiguration mAmbientDisplayConfig;
|
||||||
@@ -128,14 +135,16 @@ public class LanguageAndInputSettings extends DashboardFragment {
|
|||||||
|
|
||||||
controllers.add(gameControllerPreferenceController);
|
controllers.add(gameControllerPreferenceController);
|
||||||
// Gestures
|
// Gestures
|
||||||
controllers.add(new AssistGesturePreferenceController(context, lifecycle));
|
controllers.add(new AssistGesturePreferenceController(context, lifecycle, KEY_ASSIST));
|
||||||
controllers.add(new SwipeToNotificationPreferenceController(context, lifecycle));
|
controllers.add(new SwipeToNotificationPreferenceController(context, lifecycle,
|
||||||
controllers.add(new DoubleTwistPreferenceController(context, lifecycle));
|
KEY_SWIPE_DOWN));
|
||||||
controllers.add(new DoubleTapPowerPreferenceController(context, lifecycle));
|
controllers.add(new DoubleTwistPreferenceController(context, lifecycle, KEY_DOUBLE_TWIST));
|
||||||
controllers.add(new PickupGesturePreferenceController(
|
controllers.add(new DoubleTapPowerPreferenceController(context, lifecycle,
|
||||||
context, lifecycle, ambientDisplayConfiguration, UserHandle.myUserId()));
|
KEY_DOUBLE_TAP_POWER));
|
||||||
controllers.add(new DoubleTapScreenPreferenceController(
|
controllers.add(new PickupGesturePreferenceController(context, lifecycle,
|
||||||
context, lifecycle, ambientDisplayConfiguration, UserHandle.myUserId()));
|
ambientDisplayConfiguration, UserHandle.myUserId(), KEY_PICK_UP));
|
||||||
|
controllers.add(new DoubleTapScreenPreferenceController(context, lifecycle,
|
||||||
|
ambientDisplayConfiguration, UserHandle.myUserId(), KEY_DOUBLE_TAP_SCREEN));
|
||||||
controllers.add(new CameraLiftTriggerPreferenceController(context, lifecycle,
|
controllers.add(new CameraLiftTriggerPreferenceController(context, lifecycle,
|
||||||
KEY_CAMERA_LIFT_TRIGGER));
|
KEY_CAMERA_LIFT_TRIGGER));
|
||||||
controllers.add(new DefaultAutofillPreferenceController(context));
|
controllers.add(new DefaultAutofillPreferenceController(context));
|
||||||
@@ -199,5 +208,20 @@ public class LanguageAndInputSettings extends DashboardFragment {
|
|||||||
return buildPreferenceControllers(context, null,
|
return buildPreferenceControllers(context, null,
|
||||||
new AmbientDisplayConfiguration(context));
|
new AmbientDisplayConfiguration(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getNonIndexableKeys(Context context) {
|
||||||
|
List<String> keys = super.getNonIndexableKeys(context);
|
||||||
|
// Duplicates in summary and details pages.
|
||||||
|
keys.add(KEY_TEXT_TO_SPEECH);
|
||||||
|
keys.add(KEY_ASSIST);
|
||||||
|
keys.add(KEY_SWIPE_DOWN);
|
||||||
|
keys.add(KEY_DOUBLE_TAP_POWER);
|
||||||
|
keys.add(KEY_DOUBLE_TWIST);
|
||||||
|
keys.add(KEY_DOUBLE_TAP_SCREEN);
|
||||||
|
keys.add(KEY_PICK_UP);
|
||||||
|
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,8 @@ import com.android.settings.core.PreferenceController;
|
|||||||
|
|
||||||
public class TtsPreferenceController extends PreferenceController {
|
public class TtsPreferenceController extends PreferenceController {
|
||||||
|
|
||||||
private static final String KEY_TTS_SETTINGS = "tts_settings";
|
private static final String KEY_VOICE_CATEGORY = "voice_category";
|
||||||
|
private static final String KEY_TTS_SETTINGS = "tts_settings_summary";
|
||||||
|
|
||||||
private final TtsEngines mTtsEngines;
|
private final TtsEngines mTtsEngines;
|
||||||
|
|
||||||
|
@@ -35,6 +35,8 @@ import java.util.List;
|
|||||||
public class ConfigureNotificationSettings extends DashboardFragment {
|
public class ConfigureNotificationSettings extends DashboardFragment {
|
||||||
private static final String TAG = "ConfigNotiSettings";
|
private static final String TAG = "ConfigNotiSettings";
|
||||||
|
|
||||||
|
private static final String KEY_SWIPE_DOWN = "gesture_swipe_down_fingerprint_notifications";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMetricsCategory() {
|
public int getMetricsCategory() {
|
||||||
return MetricsEvent.CONFIGURE_NOTIFICATION;
|
return MetricsEvent.CONFIGURE_NOTIFICATION;
|
||||||
@@ -68,7 +70,8 @@ public class ConfigureNotificationSettings extends DashboardFragment {
|
|||||||
lifecycle.addObserver(pulseController);
|
lifecycle.addObserver(pulseController);
|
||||||
lifecycle.addObserver(lockScreenNotificationController);
|
lifecycle.addObserver(lockScreenNotificationController);
|
||||||
}
|
}
|
||||||
controllers.add(new SwipeToNotificationPreferenceController(context, lifecycle));
|
controllers.add(new SwipeToNotificationPreferenceController(context, lifecycle,
|
||||||
|
KEY_SWIPE_DOWN));
|
||||||
controllers.add(badgeController);
|
controllers.add(badgeController);
|
||||||
controllers.add(pulseController);
|
controllers.add(pulseController);
|
||||||
controllers.add(lockScreenNotificationController);
|
controllers.add(lockScreenNotificationController);
|
||||||
|
@@ -1,12 +1,6 @@
|
|||||||
dashboard_tile_placeholder
|
|
||||||
gesture_pick_up
|
|
||||||
add_users_when_locked
|
add_users_when_locked
|
||||||
additional_system_update_settings
|
additional_system_update_settings
|
||||||
gesture_assist
|
|
||||||
screen_zoom
|
screen_zoom
|
||||||
gesture_swipe_down_fingerprint
|
dashboard_tile_placeholder
|
||||||
gesture_double_twist
|
|
||||||
lock_screen_notifications
|
lock_screen_notifications
|
||||||
gesture_double_tap_power
|
|
||||||
gesture_double_tap_screen
|
|
||||||
usage_access
|
usage_access
|
@@ -0,0 +1,44 @@
|
|||||||
|
package com.android.settings;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.PowerManager;
|
||||||
|
import com.android.settings.core.PreferenceController;
|
||||||
|
import com.android.settings.testutils.XmlTestUtils;
|
||||||
|
import com.android.settings.testutils.shadow.ShadowPowerManagerWrapper;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static org.mockito.Mockito.doReturn;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
|
|
||||||
|
@RunWith(SettingsRobolectricTestRunner.class)
|
||||||
|
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||||
|
public class DisplaySettingsTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@Config(shadows = ShadowPowerManagerWrapper.class)
|
||||||
|
public void testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen() {
|
||||||
|
final Context context = RuntimeEnvironment.application;
|
||||||
|
// PowerManager wrapper = mock(PowerManager.class);
|
||||||
|
// doReturn(wrapper).when(context).getSystemService(Context.POWER_SERVICE);
|
||||||
|
final DisplaySettings fragment = new DisplaySettings();
|
||||||
|
final List<String> preferenceScreenKeys = XmlTestUtils.getKeysFromPreferenceXml(context,
|
||||||
|
fragment.getPreferenceScreenResId());
|
||||||
|
final List<String> preferenceKeys = new ArrayList<>();
|
||||||
|
|
||||||
|
for (PreferenceController controller : fragment.getPreferenceControllers(context)) {
|
||||||
|
preferenceKeys.add(controller.getPreferenceKey());
|
||||||
|
}
|
||||||
|
// Nightmode is currently hidden
|
||||||
|
preferenceKeys.remove("night_mode");
|
||||||
|
|
||||||
|
assertThat(preferenceScreenKeys).containsAllIn(preferenceKeys);
|
||||||
|
}
|
||||||
|
}
|
@@ -52,12 +52,14 @@ public class AssistGesturePreferenceControllerTest {
|
|||||||
private FakeFeatureFactory mFactory;
|
private FakeFeatureFactory mFactory;
|
||||||
private AssistGesturePreferenceController mController;
|
private AssistGesturePreferenceController mController;
|
||||||
|
|
||||||
|
private static final String KEY_ASSIST = "gesture_assist";
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
FakeFeatureFactory.setupForTest(mContext);
|
FakeFeatureFactory.setupForTest(mContext);
|
||||||
mFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
|
mFactory = (FakeFeatureFactory) FakeFeatureFactory.getFactory(mContext);
|
||||||
mController = new AssistGesturePreferenceController(mContext, null);
|
mController = new AssistGesturePreferenceController(mContext, null, KEY_ASSIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -77,7 +79,7 @@ public class AssistGesturePreferenceControllerTest {
|
|||||||
// Set the setting to be enabled.
|
// Set the setting to be enabled.
|
||||||
final Context context = ShadowApplication.getInstance().getApplicationContext();
|
final Context context = ShadowApplication.getInstance().getApplicationContext();
|
||||||
Settings.System.putInt(context.getContentResolver(), ASSIST_GESTURE_ENABLED, 1);
|
Settings.System.putInt(context.getContentResolver(), ASSIST_GESTURE_ENABLED, 1);
|
||||||
mController = new AssistGesturePreferenceController(context, null);
|
mController = new AssistGesturePreferenceController(context, null, KEY_ASSIST);
|
||||||
|
|
||||||
assertThat(mController.isSwitchPrefEnabled()).isTrue();
|
assertThat(mController.isSwitchPrefEnabled()).isTrue();
|
||||||
}
|
}
|
||||||
@@ -87,7 +89,7 @@ public class AssistGesturePreferenceControllerTest {
|
|||||||
// Set the setting to be disabled.
|
// Set the setting to be disabled.
|
||||||
final Context context = ShadowApplication.getInstance().getApplicationContext();
|
final Context context = ShadowApplication.getInstance().getApplicationContext();
|
||||||
Settings.System.putInt(context.getContentResolver(), ASSIST_GESTURE_ENABLED, 0);
|
Settings.System.putInt(context.getContentResolver(), ASSIST_GESTURE_ENABLED, 0);
|
||||||
mController = new AssistGesturePreferenceController(context, null);
|
mController = new AssistGesturePreferenceController(context, null, KEY_ASSIST);
|
||||||
|
|
||||||
assertThat(mController.isSwitchPrefEnabled()).isFalse();
|
assertThat(mController.isSwitchPrefEnabled()).isFalse();
|
||||||
}
|
}
|
||||||
|
@@ -47,11 +47,12 @@ public class DoubleTapPowerPreferenceControllerTest {
|
|||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
private PreferenceScreen mScreen;
|
private PreferenceScreen mScreen;
|
||||||
private DoubleTapPowerPreferenceController mController;
|
private DoubleTapPowerPreferenceController mController;
|
||||||
|
private static final String KEY_DOUBLE_TAP_POWER = "gesture_double_tap_power";
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mController = new DoubleTapPowerPreferenceController(mContext, null);
|
mController = new DoubleTapPowerPreferenceController(mContext, null, KEY_DOUBLE_TAP_POWER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -78,7 +79,7 @@ public class DoubleTapPowerPreferenceControllerTest {
|
|||||||
final Context context = ShadowApplication.getInstance().getApplicationContext();
|
final Context context = ShadowApplication.getInstance().getApplicationContext();
|
||||||
Settings.System.putInt(context.getContentResolver(),
|
Settings.System.putInt(context.getContentResolver(),
|
||||||
CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, 0);
|
CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, 0);
|
||||||
mController = new DoubleTapPowerPreferenceController(context, null);
|
mController = new DoubleTapPowerPreferenceController(context, null, KEY_DOUBLE_TAP_POWER);
|
||||||
|
|
||||||
assertThat(mController.isSwitchPrefEnabled()).isTrue();
|
assertThat(mController.isSwitchPrefEnabled()).isTrue();
|
||||||
}
|
}
|
||||||
@@ -89,7 +90,7 @@ public class DoubleTapPowerPreferenceControllerTest {
|
|||||||
final Context context = ShadowApplication.getInstance().getApplicationContext();
|
final Context context = ShadowApplication.getInstance().getApplicationContext();
|
||||||
Settings.System.putInt(context.getContentResolver(),
|
Settings.System.putInt(context.getContentResolver(),
|
||||||
CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, 1);
|
CAMERA_DOUBLE_TAP_POWER_GESTURE_DISABLED, 1);
|
||||||
mController = new DoubleTapPowerPreferenceController(context, null);
|
mController = new DoubleTapPowerPreferenceController(context, null, KEY_DOUBLE_TAP_POWER);
|
||||||
|
|
||||||
assertThat(mController.isSwitchPrefEnabled()).isFalse();
|
assertThat(mController.isSwitchPrefEnabled()).isFalse();
|
||||||
}
|
}
|
||||||
|
@@ -46,11 +46,13 @@ public class DoubleTapScreenPreferenceControllerTest {
|
|||||||
private AmbientDisplayConfiguration mAmbientDisplayConfiguration;
|
private AmbientDisplayConfiguration mAmbientDisplayConfiguration;
|
||||||
private DoubleTapScreenPreferenceController mController;
|
private DoubleTapScreenPreferenceController mController;
|
||||||
|
|
||||||
|
private static final String KEY_DOUBLE_TAP_SCREEN = "gesture_double_tap_screen";
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mController = new DoubleTapScreenPreferenceController(
|
mController = new DoubleTapScreenPreferenceController(
|
||||||
mContext, null, mAmbientDisplayConfiguration, 0);
|
mContext, null, mAmbientDisplayConfiguration, 0, KEY_DOUBLE_TAP_SCREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -53,11 +53,12 @@ public class DoubleTwistPreferenceControllerTest {
|
|||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
private SensorManager mSensorManager;
|
private SensorManager mSensorManager;
|
||||||
private DoubleTwistPreferenceController mController;
|
private DoubleTwistPreferenceController mController;
|
||||||
|
private static final String KEY_DOUBLE_TWIST = "gesture_double_twist";
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mController = new DoubleTwistPreferenceController(mContext, null);
|
mController = new DoubleTwistPreferenceController(mContext, null, KEY_DOUBLE_TWIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -98,7 +99,7 @@ public class DoubleTwistPreferenceControllerTest {
|
|||||||
final Context context = ShadowApplication.getInstance().getApplicationContext();
|
final Context context = ShadowApplication.getInstance().getApplicationContext();
|
||||||
Settings.System.putInt(context.getContentResolver(),
|
Settings.System.putInt(context.getContentResolver(),
|
||||||
CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, 1);
|
CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, 1);
|
||||||
mController = new DoubleTwistPreferenceController(context, null);
|
mController = new DoubleTwistPreferenceController(context, null, KEY_DOUBLE_TWIST);
|
||||||
|
|
||||||
assertThat(mController.isSwitchPrefEnabled()).isTrue();
|
assertThat(mController.isSwitchPrefEnabled()).isTrue();
|
||||||
}
|
}
|
||||||
@@ -109,7 +110,7 @@ public class DoubleTwistPreferenceControllerTest {
|
|||||||
final Context context = ShadowApplication.getInstance().getApplicationContext();
|
final Context context = ShadowApplication.getInstance().getApplicationContext();
|
||||||
Settings.System.putInt(context.getContentResolver(),
|
Settings.System.putInt(context.getContentResolver(),
|
||||||
CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, 0);
|
CAMERA_DOUBLE_TWIST_TO_FLIP_ENABLED, 0);
|
||||||
mController = new DoubleTwistPreferenceController(context, null);
|
mController = new DoubleTwistPreferenceController(context, null, KEY_DOUBLE_TWIST);
|
||||||
|
|
||||||
assertThat(mController.isSwitchPrefEnabled()).isFalse();
|
assertThat(mController.isSwitchPrefEnabled()).isFalse();
|
||||||
}
|
}
|
||||||
|
@@ -47,11 +47,13 @@ public class PIckupGesturePreferenceControllerTest {
|
|||||||
|
|
||||||
private PickupGesturePreferenceController mController;
|
private PickupGesturePreferenceController mController;
|
||||||
|
|
||||||
|
private static final String KEY_PICK_UP = "gesture_pick_up";
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mController = new PickupGesturePreferenceController(
|
mController = new PickupGesturePreferenceController(
|
||||||
mContext, null, mAmbientDisplayConfiguration, 0);
|
mContext, null, mAmbientDisplayConfiguration, 0, KEY_PICK_UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -45,11 +45,12 @@ public class SwipeToNotificationPreferenceControllerTest {
|
|||||||
private Context mContext;
|
private Context mContext;
|
||||||
|
|
||||||
private SwipeToNotificationPreferenceController mController;
|
private SwipeToNotificationPreferenceController mController;
|
||||||
|
private static final String KEY_SWIPE_DOWN = "gesture_swipe_down_fingerprint";
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mController = new SwipeToNotificationPreferenceController(mContext, null);
|
mController = new SwipeToNotificationPreferenceController(mContext, null, KEY_SWIPE_DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -75,7 +76,7 @@ public class SwipeToNotificationPreferenceControllerTest {
|
|||||||
// Set the setting to be enabled.
|
// Set the setting to be enabled.
|
||||||
final Context context = ShadowApplication.getInstance().getApplicationContext();
|
final Context context = ShadowApplication.getInstance().getApplicationContext();
|
||||||
Settings.System.putInt(context.getContentResolver(), SYSTEM_NAVIGATION_KEYS_ENABLED, 1);
|
Settings.System.putInt(context.getContentResolver(), SYSTEM_NAVIGATION_KEYS_ENABLED, 1);
|
||||||
mController = new SwipeToNotificationPreferenceController(context, null);
|
mController = new SwipeToNotificationPreferenceController(context, null, KEY_SWIPE_DOWN);
|
||||||
|
|
||||||
assertThat(mController.isSwitchPrefEnabled()).isTrue();
|
assertThat(mController.isSwitchPrefEnabled()).isTrue();
|
||||||
}
|
}
|
||||||
@@ -85,7 +86,7 @@ public class SwipeToNotificationPreferenceControllerTest {
|
|||||||
// Set the setting to be disabled.
|
// Set the setting to be disabled.
|
||||||
final Context context = ShadowApplication.getInstance().getApplicationContext();
|
final Context context = ShadowApplication.getInstance().getApplicationContext();
|
||||||
Settings.System.putInt(context.getContentResolver(), SYSTEM_NAVIGATION_KEYS_ENABLED, 0);
|
Settings.System.putInt(context.getContentResolver(), SYSTEM_NAVIGATION_KEYS_ENABLED, 0);
|
||||||
mController = new SwipeToNotificationPreferenceController(context, null);
|
mController = new SwipeToNotificationPreferenceController(context, null, KEY_SWIPE_DOWN);
|
||||||
|
|
||||||
assertThat(mController.isSwitchPrefEnabled()).isFalse();
|
assertThat(mController.isSwitchPrefEnabled()).isFalse();
|
||||||
}
|
}
|
||||||
|
@@ -18,7 +18,9 @@ package com.android.settings.language;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
import static org.mockito.Matchers.any;
|
import static org.mockito.Matchers.any;
|
||||||
|
import static org.mockito.Mockito.doReturn;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.spy;
|
||||||
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;
|
||||||
@@ -42,6 +44,9 @@ import com.android.settings.SettingsRobolectricTestRunner;
|
|||||||
import com.android.settings.TestConfig;
|
import com.android.settings.TestConfig;
|
||||||
import com.android.settings.core.PreferenceController;
|
import com.android.settings.core.PreferenceController;
|
||||||
import com.android.settings.dashboard.SummaryLoader;
|
import com.android.settings.dashboard.SummaryLoader;
|
||||||
|
import com.android.settings.fuelgauge.PowerUsageSummary;
|
||||||
|
import com.android.settings.testutils.FakeFeatureFactory;
|
||||||
|
import com.android.settings.testutils.XmlTestUtils;
|
||||||
import com.android.settings.testutils.shadow.ShadowSecureSettings;
|
import com.android.settings.testutils.shadow.ShadowSecureSettings;
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
import com.android.settingslib.core.lifecycle.LifecycleObserver;
|
||||||
@@ -52,6 +57,7 @@ import org.junit.runner.RunWith;
|
|||||||
import org.mockito.Answers;
|
import org.mockito.Answers;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import org.mockito.MockitoAnnotations;
|
import org.mockito.MockitoAnnotations;
|
||||||
|
import org.robolectric.RuntimeEnvironment;
|
||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -80,6 +86,7 @@ public class LanguageAndInputSettingsTest {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
FakeFeatureFactory.setupForTest(mContext);
|
||||||
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mock(UserManager.class));
|
when(mContext.getSystemService(Context.USER_SERVICE)).thenReturn(mock(UserManager.class));
|
||||||
when(mContext.getSystemService(Context.INPUT_SERVICE)).thenReturn(mock(InputManager.class));
|
when(mContext.getSystemService(Context.INPUT_SERVICE)).thenReturn(mock(InputManager.class));
|
||||||
when(mContext.getSystemService(Context.INPUT_SERVICE)).thenReturn(mIm);
|
when(mContext.getSystemService(Context.INPUT_SERVICE)).thenReturn(mIm);
|
||||||
@@ -145,6 +152,37 @@ public class LanguageAndInputSettingsTest {
|
|||||||
verify(loader).setSummary(provider, null);
|
verify(loader).setSummary(provider, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNonIndexableKeys_existInXmlLayout() {
|
||||||
|
final Context context = spy(RuntimeEnvironment.application);
|
||||||
|
//(InputManager) context.getSystemService(Context.INPUT_SERVICE);
|
||||||
|
InputManager manager = mock(InputManager.class);
|
||||||
|
when(manager.getInputDeviceIds()).thenReturn(new int[]{});
|
||||||
|
doReturn(manager).when(context).getSystemService(Context.INPUT_SERVICE);
|
||||||
|
final List<String> niks = LanguageAndInputSettings.SEARCH_INDEX_DATA_PROVIDER
|
||||||
|
.getNonIndexableKeys(context);
|
||||||
|
final int xmlId = (new LanguageAndInputSettings()).getPreferenceScreenResId();
|
||||||
|
|
||||||
|
final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlId);
|
||||||
|
|
||||||
|
assertThat(keys).containsAllIn(niks);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPreferenceControllers_getPreferenceKeys_existInPreferenceScreen() {
|
||||||
|
final Context context = RuntimeEnvironment.application;
|
||||||
|
final LanguageAndInputSettings fragment = new LanguageAndInputSettings();
|
||||||
|
final List<String> preferenceScreenKeys = XmlTestUtils.getKeysFromPreferenceXml(context,
|
||||||
|
fragment.getPreferenceScreenResId());
|
||||||
|
final List<String> preferenceKeys = new ArrayList<>();
|
||||||
|
|
||||||
|
for (PreferenceController controller : fragment.getPreferenceControllers(context)) {
|
||||||
|
preferenceKeys.add(controller.getPreferenceKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
assertThat(preferenceScreenKeys).containsAllIn(preferenceKeys);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test fragment to expose lifecycle and context so we can verify behavior for observables.
|
* Test fragment to expose lifecycle and context so we can verify behavior for observables.
|
||||||
*/
|
*/
|
||||||
|
@@ -108,7 +108,7 @@ public class BaseSearchIndexProviderTest {
|
|||||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
|
||||||
boolean enabled) {
|
boolean enabled) {
|
||||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||||
sir.xmlResId = R.xml.language_and_input;
|
sir.xmlResId = R.xml.data_usage;
|
||||||
return Arrays.asList(sir);
|
return Arrays.asList(sir);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,13 +121,7 @@ public class BaseSearchIndexProviderTest {
|
|||||||
final List<String> nonIndexableKeys = provider
|
final List<String> nonIndexableKeys = provider
|
||||||
.getNonIndexableKeys(RuntimeEnvironment.application);
|
.getNonIndexableKeys(RuntimeEnvironment.application);
|
||||||
|
|
||||||
assertThat(nonIndexableKeys).containsAllOf("phone_language", "spellcheckers_settings",
|
assertThat(nonIndexableKeys).containsAllOf("status_header", "limit_summary",
|
||||||
"key_user_dictionary_settings", "gesture_settings_category", "gesture_assist",
|
"restrict_background");
|
||||||
"gesture_swipe_down_fingerprint", "gesture_double_tap_power",
|
|
||||||
"gesture_double_twist", "gesture_double_tap_screen", "gesture_pick_up",
|
|
||||||
"pointer_speed", "tts_settings",
|
|
||||||
"game_controller_settings_category", "vibrate_input_devices");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2017 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.testutils.shadow;
|
||||||
|
|
||||||
|
import com.android.settings.display.PowerManagerWrapper;
|
||||||
|
import org.robolectric.annotation.Implementation;
|
||||||
|
import org.robolectric.annotation.Implements;
|
||||||
|
|
||||||
|
@Implements(PowerManagerWrapper.class)
|
||||||
|
public class ShadowPowerManagerWrapper {
|
||||||
|
|
||||||
|
@Implementation
|
||||||
|
public int getMinimumScreenBrightnessSetting() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Implementation
|
||||||
|
public int getMaximumScreenBrightnessSetting() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Implementation
|
||||||
|
public int getMinimumScreenBrightnessForVrSetting() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Implementation
|
||||||
|
public int getMaximumScreenBrightnessForVrSetting() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user