Introduce new "vibrate when ringing"
We once removed "vibrate and ring" option with
I7168ed140266a7c754fb3d7209cf12e73041c306, while we still need
vibration setting which only affects Phone app.
This depends on I850d27629a75615647883fdaa2933f337c4824d1
See also I3a4ed2bd5e4bde05dfb97c7bb20b9284d1c6f13f for Phone app
side change.
Bug: 6036529
Change-Id: Idb0453e187f8025565d6744cd774613531e7cb8b
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 92a3a9d..8c53822 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1591,6 +1591,9 @@
<string name="volume_notification_description">Notifications</string>
<!-- Volume description for alarm volume -->
<string name="volume_alarm_description">Alarms</string>
+ <!-- Sound settings screen, setting option name checkbox. About vibration setting
+ during incoming calls. [CHAR LIMIT=30] -->
+ <string name="vibrate_when_ringing_title">Vibrate when ringing</string>
<!-- Dock settings title, top level -->
<string name="dock_settings">Dock</string>
diff --git a/res/xml/sound_settings.xml b/res/xml/sound_settings.xml
index d7c692f..e9c9a61 100644
--- a/res/xml/sound_settings.xml
+++ b/res/xml/sound_settings.xml
@@ -58,6 +58,11 @@
android:persistent="false"
android:ringtoneType="notification" />
+ <CheckBoxPreference
+ android:key="vibrate_when_ringing"
+ android:title="@string/vibrate_when_ringing_title"
+ android:persistent="false" />
+
<PreferenceCategory
android:title="@string/sound_category_feedback_title"/>
diff --git a/src/com/android/settings/SoundSettings.java b/src/com/android/settings/SoundSettings.java
index 59e40df..4b9d975 100644
--- a/src/com/android/settings/SoundSettings.java
+++ b/src/com/android/settings/SoundSettings.java
@@ -56,7 +56,7 @@
private static final int FALLBACK_EMERGENCY_TONE_VALUE = 0;
private static final String KEY_SILENT_MODE = "silent_mode";
- private static final String KEY_VIBRATE = "vibrate_on_ring";
+ private static final String KEY_VIBRATE = "vibrate_when_ringing";
private static final String KEY_RING_VOLUME = "ring_volume";
private static final String KEY_MUSICFX = "musicfx";
private static final String KEY_DTMF_TONE = "dtmf_tone";
@@ -81,6 +81,7 @@
private static final int MSG_UPDATE_RINGTONE_SUMMARY = 1;
private static final int MSG_UPDATE_NOTIFICATION_SUMMARY = 2;
+ private CheckBoxPreference mVibrateWhenRinging;
private ListPreference mSilentMode;
private CheckBoxPreference mDtmfTone;
private CheckBoxPreference mSoundEffects;
@@ -141,6 +142,11 @@
mSilentMode.setOnPreferenceChangeListener(this);
}
+ mVibrateWhenRinging = (CheckBoxPreference) findPreference(KEY_VIBRATE);
+ mVibrateWhenRinging.setPersistent(false);
+ mVibrateWhenRinging.setChecked(Settings.System.getInt(resolver,
+ Settings.System.VIBRATE_WHEN_RINGING, 0) != 0);
+
mDtmfTone = (CheckBoxPreference) findPreference(KEY_DTMF_TONE);
mDtmfTone.setPersistent(false);
mDtmfTone.setChecked(Settings.System.getInt(resolver,
@@ -161,7 +167,9 @@
mRingtonePreference = findPreference(KEY_RINGTONE);
mNotificationPreference = findPreference(KEY_NOTIFICATION_SOUND);
- if (!((Vibrator) getSystemService(Context.VIBRATOR_SERVICE)).hasVibrator()) {
+ Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
+ if (vibrator == null || !vibrator.hasVibrator()) {
+ getPreferenceScreen().removePreference(mVibrateWhenRinging);
getPreferenceScreen().removePreference(mHapticFeedback);
}
@@ -294,7 +302,10 @@
@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
- if (preference == mDtmfTone) {
+ if (preference == mVibrateWhenRinging) {
+ Settings.System.putInt(getContentResolver(), Settings.System.VIBRATE_WHEN_RINGING,
+ mVibrateWhenRinging.isChecked() ? 1 : 0);
+ } else if (preference == mDtmfTone) {
Settings.System.putInt(getContentResolver(), Settings.System.DTMF_TONE_WHEN_DIALING,
mDtmfTone.isChecked() ? 1 : 0);