diff options
-rw-r--r-- | res/values/strings.xml | 3 | ||||
-rw-r--r-- | res/xml/sound_settings.xml | 5 | ||||
-rw-r--r-- | src/com/android/settings/SoundSettings.java | 17 |
3 files changed, 22 insertions, 3 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index ea5cab4..1380386 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 @@ public class SoundSettings extends SettingsPreferenceFragment implements 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 @@ public class SoundSettings extends SettingsPreferenceFragment implements 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 @@ public class SoundSettings extends SettingsPreferenceFragment implements 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 @@ public class SoundSettings extends SettingsPreferenceFragment implements 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 @@ public class SoundSettings extends SettingsPreferenceFragment implements @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); |