Skip to content

Commit a0b161d

Browse files
committed
Notification sound-to-vibration conversion toggle
Allows to change the new feature of AOSP 4.2, where all notification are changed to vibrations on vibrate mode. Instead, allow the old behaviour to silence sound notifications and to only play vibrations if desired. Alle credits go to AOKP, I just ported it. PatchSet daproy#2: First go swapping boolean to int PatchSet daproy#3+daproy#4: Some more fixes Change-Id: Icc10956cfc7a9fe8a6e12e7f47aaf063e24c7291
1 parent 7500d95 commit a0b161d

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

res/values/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4456,6 +4456,10 @@
44564456
<string name="start_time_title">Start</string>
44574457
<string name="end_time_title">End</string>
44584458

4459+
<!-- convert sound to vibration toggle -->
4460+
<string name="notification_convert_sound_to_vibration_title">Notification conversion</string>
4461+
<string name="notification_convert_sound_to_vibration_summary">Sounds to vibrations during vibrate mode</string>
4462+
44594463
<!-- Hostname setting -->
44604464
<string name="device_hostname">Device hostname</string>
44614465

res/xml/sound_settings_rom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
android:persistent="false"
3333
android:streamType="ring" />
3434

35+
<CheckBoxPreference
36+
android:key="notification_convert_sound_to_vibration"
37+
android:title="@string/notification_convert_sound_to_vibration_title"
38+
android:summary="@string/notification_convert_sound_to_vibration_summary"
39+
android:defaultValue="true" />
40+
3541
<CheckBoxPreference
3642
android:key="safe_headset_restore"
3743
android:title="@string/safe_headset_restore_title"

src/com/android/settings/slim/SoundSettings.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,15 @@ public class SoundSettings extends SettingsPreferenceFragment implements
4545
private static final String KEY_VOLUME_OVERLAY = "volume_overlay";
4646
private static final String KEY_SAFE_HEADSET_RESTORE = "safe_headset_restore";
4747
private static final String KEY_VOLBTN_MUSIC_CTRL = "volbtn_music_controls";
48+
private static final String KEY_CONVERT_SOUND_TO_VIBRATE = "notification_convert_sound_to_vibration";
4849

4950

5051
private final Configuration mCurConfig = new Configuration();
5152

5253
private ListPreference mVolumeOverlay;
5354
private CheckBoxPreference mSafeHeadsetRestore;
5455
private CheckBoxPreference mVolBtnMusicCtrl;
56+
private CheckBoxPreference mConvertSoundToVibration;
5557

5658
@Override
5759
public void onCreate(Bundle savedInstanceState) {
@@ -77,6 +79,11 @@ public void onCreate(Bundle savedInstanceState) {
7779
mVolBtnMusicCtrl.setChecked(Settings.System.getInt(resolver,
7880
Settings.System.VOLBTN_MUSIC_CONTROLS, 1) != 0);
7981

82+
mConvertSoundToVibration = (CheckBoxPreference) findPreference(KEY_CONVERT_SOUND_TO_VIBRATE);
83+
mConvertSoundToVibration.setPersistent(false);
84+
mConvertSoundToVibration.setChecked(Settings.System.getInt(resolver,
85+
Settings.System.NOTIFICATION_CONVERT_SOUND_TO_VIBRATION, 1) == 1);
86+
8087

8188
}
8289

@@ -108,6 +115,10 @@ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preferen
108115
Settings.System.putInt(getContentResolver(), Settings.System.VOLBTN_MUSIC_CONTROLS,
109116
mVolBtnMusicCtrl.isChecked() ? 1 : 0);
110117

118+
} else if (preference == mConvertSoundToVibration) {
119+
Settings.System.putInt(getContentResolver(), Settings.System.NOTIFICATION_CONVERT_SOUND_TO_VIBRATION,
120+
mConvertSoundToVibration.isChecked() ? 1 : 0);
121+
111122
} else {
112123
// If we didn't handle it, let preferences handle it.
113124
return super.onPreferenceTreeClick(preferenceScreen, preference);

0 commit comments

Comments
 (0)