Move vibrate for calls setting to "Vibration & haptics" screen
Move setting to configure "Vibrate for calls" into "Vibraiton & haptics" screen. Also make this page accessible via both Accessibility and "Sound & vibration" settings pages. Bug: 185351540 Test: SoundSettingsTest manually using the settings app and checking updates Change-Id: I7e40af3f332fdff8afd1a31d54a676f7e13a6678
This commit is contained in:
@@ -5545,11 +5545,17 @@
|
|||||||
<!-- Description for the seekbar that adjust auto click time. [CHAR_LIMIT=NONE] -->
|
<!-- Description for the seekbar that adjust auto click time. [CHAR_LIMIT=NONE] -->
|
||||||
<string name="accessibility_autoclick_seekbar_desc">Auto click time</string>
|
<string name="accessibility_autoclick_seekbar_desc">Auto click time</string>
|
||||||
<!-- Title for accessibility preference screen for configuring vibrations. -->
|
<!-- Title for accessibility preference screen for configuring vibrations. -->
|
||||||
<string name="accessibility_vibration_settings_title">Vibration & haptic strength</string>
|
<string name="accessibility_vibration_settings_title">Vibration & haptics</string>
|
||||||
<!-- Title for accessibility preference for configuring notification vibrations. -->
|
<!-- Title for the category of preferences to configure device vibrations related to calls. [CHAR LIMIT=NONE] -->
|
||||||
<string name="accessibility_notification_vibration_title">Notification vibration</string>
|
<string name="accessibility_call_vibration_category_title">Calls</string>
|
||||||
|
<!-- Title for the category of preferences to configure device vibrations related to notifications and alarms. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="accessibility_notification_alarm_vibration_category_title">Notifications and alarms</string>
|
||||||
|
<!-- Title for the category of preferences to configure device vibrations triggered by user interaction with the device. [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="accessibility_interactive_haptics_category_title">Interactive haptics</string>
|
||||||
<!-- Title for accessibility preference for configuring ring vibrations. [CHAR LIMIT=NONE] -->
|
<!-- Title for accessibility preference for configuring ring vibrations. [CHAR LIMIT=NONE] -->
|
||||||
<string name="accessibility_ring_vibration_title">Ring vibration</string>
|
<string name="accessibility_ring_vibration_title">Ring vibration</string>
|
||||||
|
<!-- Title for accessibility preference for configuring notification vibrations. -->
|
||||||
|
<string name="accessibility_notification_vibration_title">Notification vibration</string>
|
||||||
<!-- Title for accessibility preference for configuring touch feedback vibrations. -->
|
<!-- Title for accessibility preference for configuring touch feedback vibrations. -->
|
||||||
<string name="accessibility_touch_vibration_title">Touch feedback</string>
|
<string name="accessibility_touch_vibration_title">Touch feedback</string>
|
||||||
<!-- Used in the accessibility service settings to control turning on/off the service entirely [CHAR LIMIT=60] -->
|
<!-- Used in the accessibility service settings to control turning on/off the service entirely [CHAR LIMIT=60] -->
|
||||||
@@ -8255,8 +8261,6 @@
|
|||||||
<string name="keywords_wifi_notify_open_networks">Wi\u2011Fi notification, wifi notification</string>
|
<string name="keywords_wifi_notify_open_networks">Wi\u2011Fi notification, wifi notification</string>
|
||||||
<!-- Search keyword for "Wi-fi data usage" settings. [CHAR_LIMIT=NONE]-->
|
<!-- Search keyword for "Wi-fi data usage" settings. [CHAR_LIMIT=NONE]-->
|
||||||
<string name="keywords_wifi_data_usage">data usage</string>
|
<string name="keywords_wifi_data_usage">data usage</string>
|
||||||
<!-- Search keyword for "Vibrate on touch" settings. [CHAR_LIMIT=NONE]-->
|
|
||||||
<string name="keywords_vibrate_on_touch">Stop vibration, tap, keyboard</string>
|
|
||||||
<!-- Search keyword for "Time format" settings. [CHAR_LIMIT=NONE]-->
|
<!-- Search keyword for "Time format" settings. [CHAR_LIMIT=NONE]-->
|
||||||
<string name="keywords_time_format">Use 24-hour format</string>
|
<string name="keywords_time_format">Use 24-hour format</string>
|
||||||
<!-- Search keyword for "Files" settings under Settings > Storage. [CHAR_LIMIT=NONE]-->
|
<!-- Search keyword for "Files" settings under Settings > Storage. [CHAR_LIMIT=NONE]-->
|
||||||
@@ -8392,11 +8396,12 @@
|
|||||||
|
|
||||||
<!-- List of synonyms for touch vibration setting (where you get a haptic response for touching things on the screen), used to match in settings search [CHAR LIMIT=NONE] -->
|
<!-- List of synonyms for touch vibration setting (where you get a haptic response for touching things on the screen), used to match in settings search [CHAR LIMIT=NONE] -->
|
||||||
<string name="keywords_touch_vibration">haptics, vibrate, screen, sensitivity</string>
|
<string name="keywords_touch_vibration">haptics, vibrate, screen, sensitivity</string>
|
||||||
|
|
||||||
<!-- List of synonyms for ring vibration setting (changes whether your phone vibrates when it rings), used to match in settings search [CHAR LIMIT=NONE] -->
|
<!-- List of synonyms for ring vibration setting (changes whether your phone vibrates when it rings), used to match in settings search [CHAR LIMIT=NONE] -->
|
||||||
<string name="keywords_ring_vibration">haptics, vibrate, phone, call, sensitivity, ring</string>
|
<string name="keywords_ring_vibration">haptics, vibrate, phone, call, sensitivity, ring</string>
|
||||||
<!-- List of synonyms for notification vibration setting (changes whether your phone vibrates when it shows a notification), used to match in settings search [CHAR LIMIT=NONE] -->
|
<!-- List of synonyms for notification vibration setting (changes whether your phone vibrates when it shows a notification), used to match in settings search [CHAR LIMIT=NONE] -->
|
||||||
<string name="keywords_notification_vibration">haptics, vibrate, sensitivity</string>
|
<string name="keywords_notification_vibration">haptics, vibrate, sensitivity</string>
|
||||||
|
<!-- List of synonyms for vibration and haptics setting, used to match in settings search [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="keywords_vibration">haptics, vibrate, vibration</string>
|
||||||
<!-- Battery Saver: Search terms for sticky battery saver preference [CHAR_LIMIT=NONE] -->
|
<!-- Battery Saver: Search terms for sticky battery saver preference [CHAR_LIMIT=NONE] -->
|
||||||
<string name="keywords_battery_saver_sticky">battery saver, sticky, persist, power saver, battery</string>
|
<string name="keywords_battery_saver_sticky">battery saver, sticky, persist, power saver, battery</string>
|
||||||
<!-- Battery Saver: Search terms for battery saver schedule preference. Feel free to add additional terms when translating if appropriate [CHAR_LIMIT=NONE] -->
|
<!-- Battery Saver: Search terms for battery saver schedule preference. Feel free to add additional terms when translating if appropriate [CHAR_LIMIT=NONE] -->
|
||||||
@@ -8508,12 +8513,6 @@
|
|||||||
<!-- Sound: Other sounds: Title for the option enabling touch sounds. [CHAR LIMIT=30] -->
|
<!-- Sound: Other sounds: Title for the option enabling touch sounds. [CHAR LIMIT=30] -->
|
||||||
<string name="touch_sounds_title">Touch sounds</string>
|
<string name="touch_sounds_title">Touch sounds</string>
|
||||||
|
|
||||||
<!-- Sound: Other sounds: Title for the option enabling haptic feedback on touch. [CHAR LIMIT=30] -->
|
|
||||||
<string name="vibrate_on_touch_title">Touch vibration</string>
|
|
||||||
|
|
||||||
<!-- Sound: Other sounds: Preference summary to the option enabling haptic feedback on touch. -->
|
|
||||||
<string name="vibrate_on_touch_summary">Haptic feedback for tap, keyboard, and more</string>
|
|
||||||
|
|
||||||
<!-- Sound: Other sounds: Title for the option enabling dock audio media. [CHAR LIMIT=50] -->
|
<!-- Sound: Other sounds: Title for the option enabling dock audio media. [CHAR LIMIT=50] -->
|
||||||
<string name="dock_audio_media_title">Dock speaker plays</string>
|
<string name="dock_audio_media_title">Dock speaker plays</string>
|
||||||
|
|
||||||
|
@@ -100,7 +100,8 @@
|
|||||||
android:icon="@drawable/ic_vibration"
|
android:icon="@drawable/ic_vibration"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:title="@string/accessibility_vibration_settings_title"
|
android:title="@string/accessibility_vibration_settings_title"
|
||||||
settings:controller="com.android.settings.accessibility.VibrationPreferenceController"/>
|
settings:controller="com.android.settings.accessibility.VibrationPreferenceController"
|
||||||
|
settings:keywords="@string/keywords_vibration"/>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
@@ -20,24 +20,49 @@
|
|||||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||||
android:title="@string/accessibility_vibration_settings_title">
|
android:title="@string/accessibility_vibration_settings_title">
|
||||||
|
|
||||||
<Preference
|
<PreferenceCategory
|
||||||
android:fragment="com.android.settings.accessibility.RingVibrationPreferenceFragment"
|
android:key="accessibility_call_vibration_category"
|
||||||
android:key="ring_vibration_preference_screen"
|
android:title="@string/accessibility_call_vibration_category_title">
|
||||||
android:title="@string/accessibility_ring_vibration_title"
|
|
||||||
settings:keywords="@string/keywords_ring_vibration"
|
|
||||||
app:controller="com.android.settings.accessibility.RingVibrationIntensityPreferenceController" />
|
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
android:fragment="com.android.settings.accessibility.NotificationVibrationPreferenceFragment"
|
android:fragment="com.android.settings.accessibility.RingVibrationPreferenceFragment"
|
||||||
android:key="notification_vibration_preference_screen"
|
android:key="ring_vibration_preference_screen"
|
||||||
android:title="@string/accessibility_notification_vibration_title"
|
android:title="@string/accessibility_ring_vibration_title"
|
||||||
settings:keywords="@string/keywords_notification_vibration"
|
settings:keywords="@string/keywords_ring_vibration"
|
||||||
app:controller="com.android.settings.accessibility.NotificationVibrationIntensityPreferenceController" />
|
app:controller="com.android.settings.accessibility.RingVibrationIntensityPreferenceController" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:fragment="com.android.settings.sound.VibrateForCallsPreferenceFragment"
|
||||||
|
android:key="vibrate_for_calls"
|
||||||
|
android:title="@string/vibrate_when_ringing_title"
|
||||||
|
settings:controller="com.android.settings.sound.VibrateForCallsPreferenceController"/>
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="accessibility_notification_alarm_vibration_category"
|
||||||
|
android:title="@string/accessibility_notification_alarm_vibration_category_title">
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:fragment="com.android.settings.accessibility.NotificationVibrationPreferenceFragment"
|
||||||
|
android:key="notification_vibration_preference_screen"
|
||||||
|
android:title="@string/accessibility_notification_vibration_title"
|
||||||
|
settings:keywords="@string/keywords_notification_vibration"
|
||||||
|
app:controller="com.android.settings.accessibility.NotificationVibrationIntensityPreferenceController" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
android:key="accessibility_interactive_haptics_category"
|
||||||
|
android:title="@string/accessibility_interactive_haptics_category_title">
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:fragment="com.android.settings.accessibility.TouchVibrationPreferenceFragment"
|
||||||
|
android:key="touch_vibration_preference_screen"
|
||||||
|
android:title="@string/accessibility_touch_vibration_title"
|
||||||
|
settings:keywords="@string/keywords_touch_vibration"
|
||||||
|
app:controller="com.android.settings.accessibility.HapticFeedbackIntensityPreferenceController" />
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
<Preference
|
|
||||||
android:fragment="com.android.settings.accessibility.TouchVibrationPreferenceFragment"
|
|
||||||
android:key="touch_vibration_preference_screen"
|
|
||||||
android:title="@string/accessibility_touch_vibration_title"
|
|
||||||
settings:keywords="@string/keywords_touch_vibration"
|
|
||||||
app:controller="com.android.settings.accessibility.HapticFeedbackIntensityPreferenceController" />
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -44,12 +44,6 @@
|
|||||||
android:key="touch_sounds"
|
android:key="touch_sounds"
|
||||||
android:title="@string/touch_sounds_title" />
|
android:title="@string/touch_sounds_title" />
|
||||||
|
|
||||||
<!-- Vibrate on touch -->
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="vibrate_on_touch"
|
|
||||||
android:title="@string/vibrate_on_touch_title"
|
|
||||||
android:summary="@string/vibrate_on_touch_summary" />
|
|
||||||
|
|
||||||
<!-- Dock speaker plays -->
|
<!-- Dock speaker plays -->
|
||||||
<DropDownPreference
|
<DropDownPreference
|
||||||
android:key="dock_audio_media"
|
android:key="dock_audio_media"
|
||||||
|
@@ -119,14 +119,14 @@
|
|||||||
settings:controller="com.android.settings.sound.MediaControlsParentPreferenceController"
|
settings:controller="com.android.settings.sound.MediaControlsParentPreferenceController"
|
||||||
settings:keywords="@string/keywords_media_controls"/>
|
settings:keywords="@string/keywords_media_controls"/>
|
||||||
|
|
||||||
<!-- Also vibrate for calls -->
|
<!-- Also vibration -->
|
||||||
<Preference
|
<Preference
|
||||||
android:fragment="com.android.settings.sound.VibrateForCallsPreferenceFragment"
|
android:fragment="com.android.settings.accessibility.VibrationSettings"
|
||||||
android:key="vibrate_for_calls"
|
android:key="vibration_and_haptics"
|
||||||
android:title="@string/vibrate_when_ringing_title"
|
android:title="@string/accessibility_vibration_settings_title"
|
||||||
android:order="-90"
|
android:order="-90"
|
||||||
settings:controller="com.android.settings.sound.VibrateForCallsPreferenceController"
|
settings:controller="com.android.settings.accessibility.VibrationPreferenceController"
|
||||||
settings:keywords="@string/keywords_vibrate_for_calls"/>
|
settings:keywords="@string/keywords_vibration"/>
|
||||||
|
|
||||||
<com.android.settingslib.PrimarySwitchPreference
|
<com.android.settingslib.PrimarySwitchPreference
|
||||||
android:key="gesture_prevent_ringing_sound"
|
android:key="gesture_prevent_ringing_sound"
|
||||||
@@ -191,14 +191,6 @@
|
|||||||
android:title="@string/touch_sounds_title"
|
android:title="@string/touch_sounds_title"
|
||||||
android:order="-30"/>
|
android:order="-30"/>
|
||||||
|
|
||||||
<!-- Vibrate on touch -->
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="vibrate_on_touch"
|
|
||||||
android:title="@string/vibrate_on_touch_title"
|
|
||||||
android:summary="@string/vibrate_on_touch_summary"
|
|
||||||
settings:keywords="@string/keywords_vibrate_on_touch"
|
|
||||||
android:order="-25"/>
|
|
||||||
|
|
||||||
<!-- Dock speaker plays -->
|
<!-- Dock speaker plays -->
|
||||||
<DropDownPreference
|
<DropDownPreference
|
||||||
android:key="dock_audio_media"
|
android:key="dock_audio_media"
|
||||||
|
@@ -256,8 +256,6 @@ public class SoundSettings extends DashboardFragment implements OnActivityResult
|
|||||||
new DockingSoundPreferenceController(context, fragment, lifecycle);
|
new DockingSoundPreferenceController(context, fragment, lifecycle);
|
||||||
final TouchSoundPreferenceController touchSoundPreferenceController =
|
final TouchSoundPreferenceController touchSoundPreferenceController =
|
||||||
new TouchSoundPreferenceController(context, fragment, lifecycle);
|
new TouchSoundPreferenceController(context, fragment, lifecycle);
|
||||||
final VibrateOnTouchPreferenceController vibrateOnTouchPreferenceController =
|
|
||||||
new VibrateOnTouchPreferenceController(context, fragment, lifecycle);
|
|
||||||
final DockAudioMediaPreferenceController dockAudioMediaPreferenceController =
|
final DockAudioMediaPreferenceController dockAudioMediaPreferenceController =
|
||||||
new DockAudioMediaPreferenceController(context, fragment, lifecycle);
|
new DockAudioMediaPreferenceController(context, fragment, lifecycle);
|
||||||
final BootSoundPreferenceController bootSoundPreferenceController =
|
final BootSoundPreferenceController bootSoundPreferenceController =
|
||||||
@@ -270,7 +268,6 @@ public class SoundSettings extends DashboardFragment implements OnActivityResult
|
|||||||
controllers.add(chargingSoundPreferenceController);
|
controllers.add(chargingSoundPreferenceController);
|
||||||
controllers.add(dockingSoundPreferenceController);
|
controllers.add(dockingSoundPreferenceController);
|
||||||
controllers.add(touchSoundPreferenceController);
|
controllers.add(touchSoundPreferenceController);
|
||||||
controllers.add(vibrateOnTouchPreferenceController);
|
|
||||||
controllers.add(dockAudioMediaPreferenceController);
|
controllers.add(dockAudioMediaPreferenceController);
|
||||||
controllers.add(bootSoundPreferenceController);
|
controllers.add(bootSoundPreferenceController);
|
||||||
controllers.add(emergencyTonePreferenceController);
|
controllers.add(emergencyTonePreferenceController);
|
||||||
@@ -281,7 +278,6 @@ public class SoundSettings extends DashboardFragment implements OnActivityResult
|
|||||||
chargingSoundPreferenceController,
|
chargingSoundPreferenceController,
|
||||||
dockingSoundPreferenceController,
|
dockingSoundPreferenceController,
|
||||||
touchSoundPreferenceController,
|
touchSoundPreferenceController,
|
||||||
vibrateOnTouchPreferenceController,
|
|
||||||
dockAudioMediaPreferenceController,
|
dockAudioMediaPreferenceController,
|
||||||
bootSoundPreferenceController,
|
bootSoundPreferenceController,
|
||||||
emergencyTonePreferenceController)));
|
emergencyTonePreferenceController)));
|
||||||
|
@@ -1,50 +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.notification;
|
|
||||||
|
|
||||||
import static com.android.settings.notification.SettingPref.TYPE_SYSTEM;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Vibrator;
|
|
||||||
import android.provider.Settings.System;
|
|
||||||
|
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
|
||||||
|
|
||||||
public class VibrateOnTouchPreferenceController extends SettingPrefController {
|
|
||||||
|
|
||||||
private static final String KEY_VIBRATE_ON_TOUCH = "vibrate_on_touch";
|
|
||||||
|
|
||||||
public VibrateOnTouchPreferenceController(Context context, SettingsPreferenceFragment parent,
|
|
||||||
Lifecycle lifecycle) {
|
|
||||||
super(context, parent, lifecycle);
|
|
||||||
mPreference = new SettingPref(
|
|
||||||
TYPE_SYSTEM, KEY_VIBRATE_ON_TOUCH, System.HAPTIC_FEEDBACK_ENABLED, 0) {
|
|
||||||
@Override
|
|
||||||
public boolean isApplicable(Context context) {
|
|
||||||
return hasHaptic(context);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean hasHaptic(Context context) {
|
|
||||||
final Vibrator vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
|
|
||||||
return vibrator != null && vibrator.hasVibrator();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -1,121 +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.notification;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
import static org.mockito.Mockito.doReturn;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Vibrator;
|
|
||||||
import android.provider.Settings.System;
|
|
||||||
|
|
||||||
import androidx.fragment.app.FragmentActivity;
|
|
||||||
import androidx.preference.PreferenceScreen;
|
|
||||||
import androidx.preference.SwitchPreference;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.mockito.Mock;
|
|
||||||
import org.mockito.MockitoAnnotations;
|
|
||||||
import org.robolectric.RobolectricTestRunner;
|
|
||||||
import org.robolectric.RuntimeEnvironment;
|
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
|
||||||
public class VibrateOnTouchPreferenceControllerTest {
|
|
||||||
|
|
||||||
@Mock
|
|
||||||
private PreferenceScreen mScreen;
|
|
||||||
@Mock
|
|
||||||
private FragmentActivity mActivity;
|
|
||||||
@Mock
|
|
||||||
private ContentResolver mContentResolver;
|
|
||||||
@Mock
|
|
||||||
private SoundSettings mSetting;
|
|
||||||
@Mock
|
|
||||||
private Context mContext;
|
|
||||||
@Mock
|
|
||||||
private Vibrator mVibrator;
|
|
||||||
|
|
||||||
private VibrateOnTouchPreferenceController mController;
|
|
||||||
private SwitchPreference mPreference;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() {
|
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
when(mActivity.getSystemService(Context.VIBRATOR_SERVICE)).thenReturn(mVibrator);
|
|
||||||
when(mContext.getSystemService(Context.VIBRATOR_SERVICE)).thenReturn(mVibrator);
|
|
||||||
when(mVibrator.hasVibrator()).thenReturn(true);
|
|
||||||
when(mSetting.getActivity()).thenReturn(mActivity);
|
|
||||||
when(mActivity.getContentResolver()).thenReturn(mContentResolver);
|
|
||||||
mPreference = new SwitchPreference(RuntimeEnvironment.application);
|
|
||||||
mController = new VibrateOnTouchPreferenceController(mContext, mSetting, null);
|
|
||||||
when(mScreen.findPreference(mController.getPreferenceKey())).thenReturn(mPreference);
|
|
||||||
doReturn(mScreen).when(mSetting).getPreferenceScreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isAvailable_hasHaptic_shouldReturnTrue() {
|
|
||||||
assertThat(mController.isAvailable()).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void isAvailable_noHaptic_shouldReturnFalse() {
|
|
||||||
when(mVibrator.hasVibrator()).thenReturn(false);
|
|
||||||
|
|
||||||
assertThat(mController.isAvailable()).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void displayPreference_hapticEnabled_shouldCheckedPreference() {
|
|
||||||
System.putInt(mContentResolver, System.HAPTIC_FEEDBACK_ENABLED, 1);
|
|
||||||
|
|
||||||
mController.displayPreference(mScreen);
|
|
||||||
|
|
||||||
assertThat(mPreference.isChecked()).isTrue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void displayPreference_hapticDisabled_shouldUncheckedPreference() {
|
|
||||||
System.putInt(mContentResolver, System.HAPTIC_FEEDBACK_ENABLED, 0);
|
|
||||||
|
|
||||||
mController.displayPreference(mScreen);
|
|
||||||
|
|
||||||
assertThat(mPreference.isChecked()).isFalse();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void onPreferenceChanged_preferenceChecked_shouldEnabledHaptic() {
|
|
||||||
mController.displayPreference(mScreen);
|
|
||||||
|
|
||||||
mPreference.getOnPreferenceChangeListener().onPreferenceChange(mPreference, true);
|
|
||||||
|
|
||||||
assertThat(System.getInt(mContentResolver, System.HAPTIC_FEEDBACK_ENABLED, 1)).isEqualTo(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void onPreferenceChanged_preferenceUnchecked_shouldDisabledHaptic() {
|
|
||||||
mController.displayPreference(mScreen);
|
|
||||||
|
|
||||||
mPreference.getOnPreferenceChangeListener().onPreferenceChange(mPreference, false);
|
|
||||||
|
|
||||||
assertThat(System.getInt(mContentResolver, System.HAPTIC_FEEDBACK_ENABLED, 1)).isEqualTo(0);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -153,14 +153,6 @@ public class SoundSettingsTest extends InstrumentationTestCase {
|
|||||||
"Touch sounds", Settings.System.SOUND_EFFECTS_ENABLED));
|
"Touch sounds", Settings.System.SOUND_EFFECTS_ENABLED));
|
||||||
}
|
}
|
||||||
|
|
||||||
@MediumTest
|
|
||||||
public void testOtherSoundsVibrateOnTap() throws Exception {
|
|
||||||
loadOtherSoundsPage();
|
|
||||||
assertTrue("Vibrate on tap not toggled",
|
|
||||||
mHelper.verifyToggleSetting(SettingsType.SYSTEM, PAGE,
|
|
||||||
"Vibrate on tap", Settings.System.HAPTIC_FEEDBACK_ENABLED));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadOtherSoundsPage() throws Exception {
|
private void loadOtherSoundsPage() throws Exception {
|
||||||
launchSoundSettings();
|
launchSoundSettings();
|
||||||
mHelper.scrollVert(false);
|
mHelper.scrollVert(false);
|
||||||
|
Reference in New Issue
Block a user