Settings for skip and silence gestures
Test: make RunSettingsRoboTests Bug: 118388808 Change-Id: Ic906b42476283d245b423ef8842b6818cf7893a5
This commit is contained in:
0
res/drawable-nodpi/gesture_silence
Normal file
0
res/drawable-nodpi/gesture_silence
Normal file
0
res/drawable-nodpi/gesture_skip
Normal file
0
res/drawable-nodpi/gesture_skip
Normal file
0
res/raw/gesture_silence.mp4
Normal file
0
res/raw/gesture_silence.mp4
Normal file
0
res/raw/gesture_skip.mp4
Normal file
0
res/raw/gesture_skip.mp4
Normal file
@@ -10492,4 +10492,9 @@
|
||||
<!-- String for talkback on the account avatar of the search bar. [CHAR LIMIT=NONE] -->
|
||||
<string name="search_bar_account_avatar_content_description"></string>
|
||||
|
||||
<!-- Preference title text for skip media gesture [CHAR LIMIT=60]-->
|
||||
<string name="gesture_skip_title">Skip gesture</string>
|
||||
|
||||
<!-- Preference title text for silence gesture [CHAR LIMIT=60]-->
|
||||
<string name="gesture_silence_title">Silence alerts gesture</string>
|
||||
</resources>
|
||||
|
@@ -27,6 +27,18 @@
|
||||
android:fragment="com.android.settings.gestures.AssistGestureSettings"
|
||||
settings:controller="com.android.settings.gestures.AssistGestureSettingsPreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="gesture_skip_summary"
|
||||
android:title="@string/gesture_skip_title"
|
||||
android:fragment="com.android.settings.gestures.SkipGestureSettings"
|
||||
settings:controller="com.android.settings.gestures.SkipGesturePreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="gesture_silence_summary"
|
||||
android:title="@string/gesture_silence_title"
|
||||
android:fragment="com.android.settings.gestures.SilenceGestureSettings"
|
||||
settings:controller="com.android.settings.gestures.SilenceGesturePreferenceController" />
|
||||
|
||||
<Preference
|
||||
android:key="gesture_wake_screen_input_summary"
|
||||
android:title="@string/ambient_display_wake_screen_title"
|
||||
|
26
res/xml/silence_gesture_settings.xml
Normal file
26
res/xml/silence_gesture_settings.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2019 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:key="silence_gesture"
|
||||
android:title="@string/gesture_silence_title">
|
||||
|
||||
<com.android.settings.widget.VideoPreference
|
||||
android:key="gesture_silence_video"
|
||||
app:animation="@raw/gesture_silence"
|
||||
app:preview="@drawable/gesture_silence"/>
|
||||
</PreferenceScreen>
|
26
res/xml/skip_gesture_settings.xml
Normal file
26
res/xml/skip_gesture_settings.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2019 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:key="skip_gesture"
|
||||
android:title="@string/gesture_skip_title">
|
||||
|
||||
<com.android.settings.widget.VideoPreference
|
||||
android:key="gesture_skip_video"
|
||||
app:animation="@raw/gesture_skip"
|
||||
app:preview="@drawable/gesture_skip"/>
|
||||
</PreferenceScreen>
|
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.gestures;
|
||||
|
||||
import static android.provider.Settings.Secure.SILENCE_GESTURE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
public class SilenceGesturePreferenceController extends GesturePreferenceController {
|
||||
|
||||
private static final int ON = 1;
|
||||
private static final int OFF = 0;
|
||||
|
||||
private static final String PREF_KEY_VIDEO = "gesture_silence_video";
|
||||
|
||||
public SilenceGesturePreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources()
|
||||
.getBoolean(com.android.internal.R.bool.config_silenceSensorAvailable)
|
||||
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSliceable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getVideoPrefKey() {
|
||||
return PREF_KEY_VIDEO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return Settings.Secure.getInt(mContext.getContentResolver(), SILENCE_GESTURE, ON) == ON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
return Settings.Secure.putInt(mContext.getContentResolver(), SILENCE_GESTURE,
|
||||
isChecked ? ON : OFF);
|
||||
}
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.gestures;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@SearchIndexable
|
||||
public class SilenceGestureSettings extends DashboardFragment {
|
||||
|
||||
private static final String TAG = "SilenceGestureSettings";
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.SETTINGS_GESTURE_SILENCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.silence_gesture_settings;
|
||||
}
|
||||
|
||||
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.silence_gesture_settings;
|
||||
return Arrays.asList(sir);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.gestures;
|
||||
|
||||
import static android.provider.Settings.Secure.SKIP_GESTURE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
public class SkipGesturePreferenceController extends GesturePreferenceController {
|
||||
|
||||
private static final int ON = 1;
|
||||
private static final int OFF = 0;
|
||||
|
||||
private static final String PREF_KEY_VIDEO = "gesture_silence_video";
|
||||
|
||||
public SkipGesturePreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return mContext.getResources()
|
||||
.getBoolean(com.android.internal.R.bool.config_skipSensorAvailable) ? AVAILABLE
|
||||
: UNSUPPORTED_ON_DEVICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSliceable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getVideoPrefKey() {
|
||||
return PREF_KEY_VIDEO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
return Settings.Secure.getInt(mContext.getContentResolver(), SKIP_GESTURE, ON) == ON;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setChecked(boolean isChecked) {
|
||||
return Settings.Secure.putInt(mContext.getContentResolver(), SKIP_GESTURE,
|
||||
isChecked ? ON : OFF);
|
||||
}
|
||||
}
|
63
src/com/android/settings/gestures/SkipGestureSettings.java
Normal file
63
src/com/android/settings/gestures/SkipGestureSettings.java
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.gestures;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@SearchIndexable
|
||||
public class SkipGestureSettings extends DashboardFragment {
|
||||
|
||||
private static final String TAG = "SkipGestureSettings";
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return SettingsEnums.SETTINGS_GESTURE_SKIP;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getPreferenceScreenResId() {
|
||||
return R.xml.skip_gesture_settings;
|
||||
}
|
||||
|
||||
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.skip_gesture_settings;
|
||||
return Arrays.asList(sir);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.gestures;
|
||||
|
||||
import static android.provider.Settings.Secure.SILENCE_GESTURE;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.provider.Settings;
|
||||
|
||||
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.RobolectricTestRunner;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class SilenceGesturePreferenceControllerTest {
|
||||
|
||||
private static final String KEY_SILENCE = "gesture_silence";
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private Resources mResources;
|
||||
|
||||
private SilenceGesturePreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
when(mContext.getResources()).thenReturn(mResources);
|
||||
mController = new SilenceGesturePreferenceController(mContext, KEY_SILENCE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_gestureNotSupported_UNSUPPORTED_ON_DEVICE() {
|
||||
when(mResources.getBoolean(
|
||||
com.android.internal.R.bool.config_silenceSensorAvailable))
|
||||
.thenReturn(false);
|
||||
final int availabilityStatus = mController.getAvailabilityStatus();
|
||||
|
||||
assertThat(availabilityStatus).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_gestureSupported_AVAILABLE() {
|
||||
when(mResources.getBoolean(
|
||||
com.android.internal.R.bool.config_silenceSensorAvailable)).thenReturn(true);
|
||||
final int availabilityStatus = mController.getAvailabilityStatus();
|
||||
|
||||
assertThat(availabilityStatus).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSliceableCorrectKey_returnsTrue() {
|
||||
assertThat(mController.isSliceable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isChecked_testTrue() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), SILENCE_GESTURE, 1);
|
||||
assertThat(mController.isChecked()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isChecked_testFalse() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), SILENCE_GESTURE, 0);
|
||||
assertThat(mController.isChecked()).isFalse();
|
||||
}
|
||||
}
|
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.gestures;
|
||||
|
||||
import static android.provider.Settings.Secure.SKIP_GESTURE;
|
||||
|
||||
import static com.android.settings.core.BasePreferenceController.AVAILABLE;
|
||||
import static com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.provider.Settings;
|
||||
|
||||
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.RobolectricTestRunner;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class SkipGesturePreferenceControllerTest {
|
||||
|
||||
private static final String KEY_SKIP = "gesture_skip";
|
||||
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private Resources mResources;
|
||||
|
||||
private SkipGesturePreferenceController mController;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
when(mContext.getResources()).thenReturn(mResources);
|
||||
mController = new SkipGesturePreferenceController(mContext, KEY_SKIP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_gestureNotSupported_UNSUPPORTED_ON_DEVICE() {
|
||||
when(mResources.getBoolean(
|
||||
com.android.internal.R.bool.config_skipSensorAvailable))
|
||||
.thenReturn(false);
|
||||
final int availabilityStatus = mController.getAvailabilityStatus();
|
||||
|
||||
assertThat(availabilityStatus).isEqualTo(UNSUPPORTED_ON_DEVICE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAvailabilityStatus_gestureSupported_AVAILABLE() {
|
||||
when(mResources.getBoolean(
|
||||
com.android.internal.R.bool.config_skipSensorAvailable)).thenReturn(true);
|
||||
final int availabilityStatus = mController.getAvailabilityStatus();
|
||||
|
||||
assertThat(availabilityStatus).isEqualTo(AVAILABLE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isSliceableCorrectKey_returnsTrue() {
|
||||
assertThat(mController.isSliceable()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isChecked_testTrue() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), SKIP_GESTURE, 1);
|
||||
assertThat(mController.isChecked()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isChecked_testFalse() {
|
||||
Settings.Secure.putInt(mContext.getContentResolver(), SKIP_GESTURE, 0);
|
||||
assertThat(mController.isChecked()).isFalse();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user