Removed camera lift gesture settings UI.
Bug: 37154489 Test: make + manual + unit tests Change-Id: I79e70dea12a65fefcb06aca3fd1891a95d856626
This commit is contained in:
@@ -3189,29 +3189,6 @@
|
||||
|
||||
|
||||
<!-- Activities for moves/gestures suggestions -->
|
||||
<activity
|
||||
android:name=".Settings$CameraLiftTriggerSuggestionActivity"
|
||||
android:label="@string/camera_lift_trigger_title"
|
||||
android:icon="@drawable/ic_suggestion_gesture"
|
||||
android:enabled="@bool/config_cameraLiftTriggerAvailable">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="com.android.settings.suggested.category.GESTURE" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="com.android.settings.suggested.category.FIRST_IMPRESSION" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="com.android.settings.dismiss"
|
||||
android:value="4,8,30" />
|
||||
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||
android:value="com.android.settings.gestures.CameraLiftTriggerSettings"/>
|
||||
<meta-data android:name="com.android.settings.title"
|
||||
android:resource="@string/camera_lift_trigger_title" />
|
||||
<meta-data android:name="com.android.settings.summary"
|
||||
android:resource="@string/camera_lift_trigger_suggestion_summary" />
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".Settings$DoubleTapPowerSuggestionActivity"
|
||||
android:label="@string/double_tap_power_for_camera_title"
|
||||
|
@@ -102,9 +102,6 @@
|
||||
-->
|
||||
</string-array>
|
||||
|
||||
<!-- Whether or not the camera lift trigger is available in the moves menu. -->
|
||||
<bool name="config_cameraLiftTriggerAvailable">false</bool>
|
||||
|
||||
<!-- Whether or not we should tint the icon color on setting pages. -->
|
||||
<bool name="config_tintSettingIcon">true</bool>
|
||||
|
||||
|
@@ -8688,15 +8688,6 @@
|
||||
<!-- Summary for settings suggestion for fingerprint swipe for notifications [CHAR LIMIT=60] -->
|
||||
<string name="fingerprint_swipe_for_notifications_suggestion_summary">Swipe down on the fingerprint sensor</string>
|
||||
|
||||
<!-- Title and settings suggestion title text for opening camera when lifting the phone to a photo-taking position [CHAR LIMIT=60]-->
|
||||
<string name="camera_lift_trigger_title">Raise to open camera</string>
|
||||
|
||||
<!-- Summary text for opening camera when lifting the phone to a photo-taking position [CHAR LIMIT=none]-->
|
||||
<string name="camera_lift_trigger_summary">To open the camera automatically, lift up your phone into a photo-taking position (landscape or portrait). Works when your phone is asleep or locked.</string>
|
||||
|
||||
<!-- Settings suggestion summary text for opening camera when lifting the phone to a photo-taking position [CHAR LIMIT=60]-->
|
||||
<string name="camera_lift_trigger_suggestion_summary">Take photos when phone is asleep or locked</string>
|
||||
|
||||
<!-- Title text for the assist gesture [CHAR LIMIT=60]-->
|
||||
<string name="assist_gesture_title">Assist gesture</string>
|
||||
|
||||
|
@@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
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.
|
||||
-->
|
||||
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:title="@string/camera_lift_trigger_title">
|
||||
|
||||
<com.android.settings.widget.VideoPreference
|
||||
android:key="gesture_camera_lift_trigger_video"
|
||||
app:animation="@raw/gesture_camera_lift"
|
||||
app:preview="@drawable/gesture_camera_lift"/>
|
||||
|
||||
<SwitchPreference
|
||||
android:key="gesture_camera_lift_trigger"
|
||||
android:title="@string/camera_lift_trigger_title"
|
||||
android:summary="@string/camera_lift_trigger_summary"
|
||||
app:keywords="@string/keywords_gesture"/>
|
||||
|
||||
</PreferenceScreen>
|
@@ -87,11 +87,6 @@
|
||||
android:title="@string/ambient_display_pickup_title"
|
||||
android:fragment="com.android.settings.gestures.PickupGestureSettings" />
|
||||
|
||||
<Preference
|
||||
android:key="gesture_camera_lift_trigger_summary"
|
||||
android:title="@string/camera_lift_trigger_title"
|
||||
android:fragment="com.android.settings.gestures.CameraLiftTriggerSettings" />
|
||||
|
||||
<Preference
|
||||
android:key="gesture_double_tap_power_input_summary"
|
||||
android:title="@string/double_tap_power_for_camera_title"
|
||||
|
@@ -149,7 +149,6 @@ public class Settings extends SettingsActivity {
|
||||
/* empty */
|
||||
}
|
||||
public static class ScreenLockSuggestionActivity extends ChooseLockGeneric { /* empty */ }
|
||||
public static class CameraLiftTriggerSuggestionActivity extends SettingsActivity { /* empty */ }
|
||||
public static class DoubleTapPowerSuggestionActivity extends SettingsActivity { /* empty */ }
|
||||
public static class DoubleTwistSuggestionActivity extends SettingsActivity { /* empty */ }
|
||||
public static class AmbientDisplaySuggestionActivity extends SettingsActivity { /* empty */ }
|
||||
|
@@ -81,7 +81,6 @@ import com.android.settings.fuelgauge.AdvancedPowerUsageDetail;
|
||||
import com.android.settings.fuelgauge.BatterySaverSettings;
|
||||
import com.android.settings.fuelgauge.PowerUsageSummary;
|
||||
import com.android.settings.gestures.AssistGestureSettings;
|
||||
import com.android.settings.gestures.CameraLiftTriggerSettings;
|
||||
import com.android.settings.gestures.DoubleTapPowerSettings;
|
||||
import com.android.settings.gestures.DoubleTapScreenSettings;
|
||||
import com.android.settings.gestures.DoubleTwistGestureSettings;
|
||||
@@ -182,7 +181,6 @@ public class SettingsGateway {
|
||||
AccountSyncSettings.class.getName(),
|
||||
AssistGestureSettings.class.getName(),
|
||||
SwipeToNotificationSettings.class.getName(),
|
||||
CameraLiftTriggerSettings.class.getName(),
|
||||
DoubleTapPowerSettings.class.getName(),
|
||||
DoubleTapScreenSettings.class.getName(),
|
||||
PickupGestureSettings.class.getName(),
|
||||
|
@@ -28,7 +28,6 @@ import android.provider.Settings;
|
||||
import android.support.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.ims.ImsManager;
|
||||
import com.android.settings.Settings.CameraLiftTriggerSuggestionActivity;
|
||||
import com.android.settings.Settings.FingerprintEnrollSuggestionActivity;
|
||||
import com.android.settings.Settings.ScreenLockSuggestionActivity;
|
||||
import com.android.settings.Settings.WifiCallingSuggestionActivity;
|
||||
@@ -75,8 +74,6 @@ public class SuggestionsChecks {
|
||||
return true;
|
||||
}
|
||||
return manager.hasEnrolledFingerprints();
|
||||
} else if (className.equals(CameraLiftTriggerSuggestionActivity.class.getName())) {
|
||||
return isCameraLiftTriggerEnabled();
|
||||
}
|
||||
|
||||
final SuggestionFeatureProvider provider =
|
||||
@@ -127,11 +124,4 @@ public class SuggestionsChecks {
|
||||
mContext.getUserId());
|
||||
return (dpmFlags & DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT) == 0;
|
||||
}
|
||||
|
||||
private boolean isCameraLiftTriggerEnabled() {
|
||||
final int triggerEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.CAMERA_LIFT_TRIGGER_ENABLED,
|
||||
Settings.Secure.CAMERA_LIFT_TRIGGER_ENABLED_DEFAULT);
|
||||
return triggerEnabled == 1;
|
||||
}
|
||||
}
|
||||
|
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
* 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.gestures;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
public class CameraLiftTriggerPreferenceController extends GesturePreferenceController {
|
||||
|
||||
private static final String PREF_KEY_VIDEO = "gesture_camera_lift_trigger_video";
|
||||
|
||||
private final String mCameraLiftTriggerKey;
|
||||
|
||||
public CameraLiftTriggerPreferenceController(Context context, Lifecycle lifecycle, String key) {
|
||||
super(context, lifecycle);
|
||||
mCameraLiftTriggerKey = key;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return mContext.getResources().getBoolean(
|
||||
R.bool.config_cameraLiftTriggerAvailable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getVideoPrefKey() {
|
||||
return PREF_KEY_VIDEO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPreferenceKey() {
|
||||
return mCameraLiftTriggerKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
boolean enabled = (boolean) newValue;
|
||||
Settings.Secure.putInt(mContext.getContentResolver(),
|
||||
Settings.Secure.CAMERA_LIFT_TRIGGER_ENABLED, enabled ? 1 : 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isSwitchPrefEnabled() {
|
||||
final int triggerEnabled = Settings.Secure.getInt(mContext.getContentResolver(),
|
||||
Settings.Secure.CAMERA_LIFT_TRIGGER_ENABLED,
|
||||
Settings.Secure.CAMERA_LIFT_TRIGGER_ENABLED_DEFAULT);
|
||||
return triggerEnabled == 1;
|
||||
}
|
||||
}
|
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* 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.gestures;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CameraLiftTriggerSettings extends DashboardFragment {
|
||||
|
||||
private static final String TAG = "CameraLiftTrigger";
|
||||
private static final String KEY = "gesture_camera_lift_trigger";
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.SETTINGS_GESTURE_CAMERA_LIFT_TRIGGER;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.camera_lift_trigger_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
|
||||
return buildPreferenceControllers(context, getLifecycle());
|
||||
}
|
||||
|
||||
private static List<AbstractPreferenceController> buildPreferenceControllers(Context context,
|
||||
Lifecycle lifecycle) {
|
||||
final List<AbstractPreferenceController> controllers = new ArrayList<>();
|
||||
controllers.add(new CameraLiftTriggerPreferenceController(context, lifecycle, KEY));
|
||||
return controllers;
|
||||
}
|
||||
|
||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
||||
Context context, boolean enabled) {
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.camera_lift_trigger_settings;
|
||||
return Arrays.asList(sir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AbstractPreferenceController> getPreferenceControllers(Context context) {
|
||||
return buildPreferenceControllers(context, null /* lifecycle */);
|
||||
}
|
||||
};
|
||||
}
|
@@ -40,7 +40,6 @@ import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.dashboard.SummaryLoader;
|
||||
import com.android.settings.gestures.AssistGestureFeatureProvider;
|
||||
import com.android.settings.gestures.AssistGesturePreferenceController;
|
||||
import com.android.settings.gestures.CameraLiftTriggerPreferenceController;
|
||||
import com.android.settings.gestures.DoubleTapPowerPreferenceController;
|
||||
import com.android.settings.gestures.DoubleTapScreenPreferenceController;
|
||||
import com.android.settings.gestures.DoubleTwistPreferenceController;
|
||||
@@ -70,7 +69,6 @@ public class LanguageAndInputSettings extends DashboardFragment {
|
||||
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 AmbientDisplayConfiguration mAmbientDisplayConfig;
|
||||
|
||||
@@ -149,8 +147,6 @@ public class LanguageAndInputSettings extends DashboardFragment {
|
||||
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,
|
||||
KEY_CAMERA_LIFT_TRIGGER));
|
||||
controllers.add(new DefaultAutofillPreferenceController(context));
|
||||
return controllers;
|
||||
}
|
||||
|
@@ -56,7 +56,6 @@ import com.android.settings.fuelgauge.BatterySaverSettings;
|
||||
import com.android.settings.fuelgauge.PowerUsageAdvanced;
|
||||
import com.android.settings.fuelgauge.PowerUsageSummary;
|
||||
import com.android.settings.gestures.AssistGestureSettings;
|
||||
import com.android.settings.gestures.CameraLiftTriggerSettings;
|
||||
import com.android.settings.gestures.DoubleTapPowerSettings;
|
||||
import com.android.settings.gestures.DoubleTapScreenSettings;
|
||||
import com.android.settings.gestures.DoubleTwistGestureSettings;
|
||||
@@ -147,8 +146,6 @@ public final class SearchIndexableResources {
|
||||
addIndex(DoubleTwistGestureSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_gestures);
|
||||
addIndex(SwipeToNotificationSettings.class, NO_DATA_RES_ID,
|
||||
R.drawable.ic_settings_gestures);
|
||||
addIndex(CameraLiftTriggerSettings.class, NO_DATA_RES_ID,
|
||||
R.drawable.ic_settings_gestures);
|
||||
addIndex(LanguageAndInputSettings.class, NO_DATA_RES_ID, R.drawable.ic_settings_language);
|
||||
addIndex(LocationSettings.class, R.xml.location_settings, R.drawable.ic_settings_location);
|
||||
addIndex(ScanningSettings.class, R.xml.location_scanning, R.drawable.ic_settings_location);
|
||||
|
@@ -1,131 +0,0 @@
|
||||
/*
|
||||
* 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.gestures;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.support.v7.preference.PreferenceScreen;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
|
||||
import com.android.settings.R;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Answers;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import static android.provider.Settings.Secure.CAMERA_LIFT_TRIGGER_ENABLED;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class CameraLiftTriggerPreferenceControllerTest {
|
||||
|
||||
private static final String KEY_CAMERA_LIFT_TRIGGER = "gesture_camera_lift_trigger";
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Context mContext;
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private PreferenceScreen mScreen;
|
||||
private CameraLiftTriggerPreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mController = new CameraLiftTriggerPreferenceController(mContext, null,
|
||||
KEY_CAMERA_LIFT_TRIGGER);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_configIsTrue_shouldReturnTrue() {
|
||||
when(mContext.getResources().
|
||||
getBoolean(R.bool.config_cameraLiftTriggerAvailable))
|
||||
.thenReturn(true);
|
||||
|
||||
assertThat(mController.isAvailable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isAvailable_configIsTrue_shouldReturnFalse() {
|
||||
when(mContext.getResources().
|
||||
getBoolean(R.bool.config_cameraLiftTriggerAvailable))
|
||||
.thenReturn(false);
|
||||
|
||||
assertThat(mController.isAvailable()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwitchEnabled_defaultConfig_shouldReturnTrue() {
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
mController = new CameraLiftTriggerPreferenceController(context, null,
|
||||
KEY_CAMERA_LIFT_TRIGGER);
|
||||
|
||||
assertThat(mController.isSwitchPrefEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwitchEnabled_configIsNotSet_shouldReturnFalse() {
|
||||
// Set the setting to be enabled.
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
Settings.System.putInt(context.getContentResolver(),
|
||||
CAMERA_LIFT_TRIGGER_ENABLED, 0);
|
||||
mController = new CameraLiftTriggerPreferenceController(context, null,
|
||||
KEY_CAMERA_LIFT_TRIGGER);
|
||||
|
||||
assertThat(mController.isSwitchPrefEnabled()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwitchEnabled_configIsSet_shouldReturnTrue() {
|
||||
// Set the setting to be disabled.
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
Settings.System.putInt(context.getContentResolver(),
|
||||
CAMERA_LIFT_TRIGGER_ENABLED, 1);
|
||||
mController = new CameraLiftTriggerPreferenceController(context, null,
|
||||
KEY_CAMERA_LIFT_TRIGGER);
|
||||
|
||||
assertThat(mController.isSwitchPrefEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEnablePreference_shouldSetSetting() {
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
mController = new CameraLiftTriggerPreferenceController(context, null,
|
||||
KEY_CAMERA_LIFT_TRIGGER);
|
||||
mController.onPreferenceChange(null, true);
|
||||
|
||||
assertThat(Settings.Secure.getInt(context.getContentResolver(),
|
||||
CAMERA_LIFT_TRIGGER_ENABLED, 0)).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDisablePreference_shouldClearSetting() {
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
mController = new CameraLiftTriggerPreferenceController(context, null,
|
||||
KEY_CAMERA_LIFT_TRIGGER);
|
||||
mController.onPreferenceChange(null, false);
|
||||
|
||||
assertThat(Settings.Secure.getInt(context.getContentResolver(),
|
||||
CAMERA_LIFT_TRIGGER_ENABLED, 1)).isEqualTo(0);
|
||||
}
|
||||
}
|
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* 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.gestures;
|
||||
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.TestConfig;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION)
|
||||
public class CameraLiftTriggerSettingsTest {
|
||||
|
||||
private CameraLiftTriggerSettings mSettings;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
mSettings = new CameraLiftTriggerSettings();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchIndexProvider_shouldIndexResource() {
|
||||
final List<SearchIndexableResource> indexRes =
|
||||
CameraLiftTriggerSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex(
|
||||
ShadowApplication.getInstance().getApplicationContext(),
|
||||
true /* enabled */);
|
||||
|
||||
assertThat(indexRes).isNotNull();
|
||||
assertThat(indexRes.get(0).xmlResId).isEqualTo(mSettings.getPreferenceScreenResId());
|
||||
}
|
||||
}
|
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
import static android.support.test.espresso.Espresso.onView;
|
||||
import static android.support.test.espresso.assertion.ViewAssertions.matches;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
||||
import static android.support.test.espresso.matcher.ViewMatchers.hasSibling;
|
||||
import static org.hamcrest.Matchers.allOf;
|
||||
|
||||
import android.app.Instrumentation;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.filters.SmallTest;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public class CameraLiftTriggerSuggestionActivityTest {
|
||||
private Instrumentation mInstrumentation;
|
||||
private Context mTargetContext;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
mInstrumentation = InstrumentationRegistry.getInstrumentation();
|
||||
mTargetContext = mInstrumentation.getTargetContext();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void launchCameraLiftTriggerSuggestion_shouldNotCrash() {
|
||||
final Intent cameraTriggerSuggestionIntent = new Intent(mTargetContext,
|
||||
Settings.CameraLiftTriggerSuggestionActivity.class);
|
||||
final boolean cameraLiftTriggerEnabled = mTargetContext.getResources()
|
||||
.getBoolean(R.bool.config_cameraLiftTriggerAvailable);
|
||||
|
||||
if (!cameraLiftTriggerEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mInstrumentation.startActivitySync(cameraTriggerSuggestionIntent);
|
||||
|
||||
onView(allOf(withText(R.string.camera_lift_trigger_title),
|
||||
hasSibling(withText(R.string.camera_lift_trigger_summary))))
|
||||
.check(matches(isDisplayed()));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user