From 9a16e473abb8bb4b50c36fb18fab8614690a151b Mon Sep 17 00:00:00 2001 From: Daniel Sheng Date: Fri, 30 Jun 2017 13:14:57 -0700 Subject: [PATCH] Removed camera lift gesture settings UI. Bug: 37154489 Test: make + manual + unit tests Change-Id: Ifefa07d0e8e0de19d78303352c6f0e01dc1c52ab Merged-In: I79e70dea12a65fefcb06aca3fd1891a95d856626 --- AndroidManifest.xml | 23 --- res/drawable-nodpi/gesture_camera_lift | 0 res/raw/gesture_camera_lift.mp4 | 0 res/values/config.xml | 3 - res/values/strings.xml | 9 -- res/xml/camera_lift_trigger_settings.xml | 33 ----- res/xml/language_and_input.xml | 5 - src/com/android/settings/Settings.java | 1 - .../core/gateway/SettingsGateway.java | 2 - .../suggestions/SuggestionsChecks.java | 10 -- ...CameraLiftTriggerPreferenceController.java | 68 --------- .../gestures/CameraLiftTriggerSettings.java | 80 ----------- .../language/LanguageAndInputSettings.java | 4 - .../search/SearchIndexableResources.java | 3 - ...raLiftTriggerPreferenceControllerTest.java | 131 ------------------ .../CameraLiftTriggerSettingsTest.java | 55 -------- ...meraLiftTriggerSuggestionActivityTest.java | 66 --------- 17 files changed, 493 deletions(-) delete mode 100644 res/drawable-nodpi/gesture_camera_lift delete mode 100644 res/raw/gesture_camera_lift.mp4 delete mode 100644 res/xml/camera_lift_trigger_settings.xml delete mode 100644 src/com/android/settings/gestures/CameraLiftTriggerPreferenceController.java delete mode 100644 src/com/android/settings/gestures/CameraLiftTriggerSettings.java delete mode 100644 tests/robotests/src/com/android/settings/gestures/CameraLiftTriggerPreferenceControllerTest.java delete mode 100644 tests/robotests/src/com/android/settings/gestures/CameraLiftTriggerSettingsTest.java delete mode 100644 tests/unit/src/com/android/settings/CameraLiftTriggerSuggestionActivityTest.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 1b995663943..4ab27e62018 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -3146,29 +3146,6 @@ - - - - - - - - - - - - - - - - - false - true diff --git a/res/values/strings.xml b/res/values/strings.xml index 32e3548f6eb..902870de8f2 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -8686,15 +8686,6 @@ Swipe down on the fingerprint sensor - - Raise to open camera - - - 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. - - - Take photos when phone is asleep or locked - Assist gesture diff --git a/res/xml/camera_lift_trigger_settings.xml b/res/xml/camera_lift_trigger_settings.xml deleted file mode 100644 index d9de14f0959..00000000000 --- a/res/xml/camera_lift_trigger_settings.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - diff --git a/res/xml/language_and_input.xml b/res/xml/language_and_input.xml index 1cbeecdb514..2996c78c289 100644 --- a/res/xml/language_and_input.xml +++ b/res/xml/language_and_input.xml @@ -87,11 +87,6 @@ android:title="@string/ambient_display_pickup_title" android:fragment="com.android.settings.gestures.PickupGestureSettings" /> - - getPreferenceControllers(Context context) { - return buildPreferenceControllers(context, getLifecycle()); - } - - private static List buildPreferenceControllers(Context context, - Lifecycle lifecycle) { - final List 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 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 getPreferenceControllers(Context context) { - return buildPreferenceControllers(context, null /* lifecycle */); - } - }; -} diff --git a/src/com/android/settings/language/LanguageAndInputSettings.java b/src/com/android/settings/language/LanguageAndInputSettings.java index 70375b6c2c7..cca6cbe6c50 100644 --- a/src/com/android/settings/language/LanguageAndInputSettings.java +++ b/src/com/android/settings/language/LanguageAndInputSettings.java @@ -41,7 +41,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; } diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java index 431729f21bb..9dc34de6751 100644 --- a/src/com/android/settings/search/SearchIndexableResources.java +++ b/src/com/android/settings/search/SearchIndexableResources.java @@ -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); diff --git a/tests/robotests/src/com/android/settings/gestures/CameraLiftTriggerPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/gestures/CameraLiftTriggerPreferenceControllerTest.java deleted file mode 100644 index 94cac965b93..00000000000 --- a/tests/robotests/src/com/android/settings/gestures/CameraLiftTriggerPreferenceControllerTest.java +++ /dev/null @@ -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); - } -} diff --git a/tests/robotests/src/com/android/settings/gestures/CameraLiftTriggerSettingsTest.java b/tests/robotests/src/com/android/settings/gestures/CameraLiftTriggerSettingsTest.java deleted file mode 100644 index befdfa66145..00000000000 --- a/tests/robotests/src/com/android/settings/gestures/CameraLiftTriggerSettingsTest.java +++ /dev/null @@ -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 indexRes = - CameraLiftTriggerSettings.SEARCH_INDEX_DATA_PROVIDER.getXmlResourcesToIndex( - ShadowApplication.getInstance().getApplicationContext(), - true /* enabled */); - - assertThat(indexRes).isNotNull(); - assertThat(indexRes.get(0).xmlResId).isEqualTo(mSettings.getPreferenceScreenResId()); - } -} diff --git a/tests/unit/src/com/android/settings/CameraLiftTriggerSuggestionActivityTest.java b/tests/unit/src/com/android/settings/CameraLiftTriggerSuggestionActivityTest.java deleted file mode 100644 index cbf1db8b12c..00000000000 --- a/tests/unit/src/com/android/settings/CameraLiftTriggerSuggestionActivityTest.java +++ /dev/null @@ -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())); - } -}