Skip to content

Commit

Permalink
Feat: Allow users to disable safe headset volume warning (2/2)
Browse files Browse the repository at this point in the history
Change-Id: I6211b7698ab299c3d77a6a57fb41c296865dce7a
Signed-off-by: Gergely Szell (sethyx) <[email protected]>
  • Loading branch information
Gergely Szell (sethyx) committed Jan 2, 2013
1 parent 5938fed commit 89a2df8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
7 changes: 6 additions & 1 deletion res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4451,7 +4451,7 @@
<string name="preview_country_title">Country</string>
<string name="preview_carrier_title">Carrier</string>

<!-- Quiet hours #CM -->
<!-- Quiet hours #CM -->
<string name="quiet_hours_title">Quiet hours</string>
<string name="quiet_hours_summary">Configure the hours the device should be quiet</string>
<string name="quiet_hours_enabled_title">Enable quiet hours</string>
Expand All @@ -4473,4 +4473,9 @@
<string name="vibration_title">Phone vibration</string>
<string name="link_volume_ringtones">Link volumes</string>
<string name="link_volume_mutes">Link mute states</string>

<!-- AOKP specific sound settings
<string name="camera_sounds">Camera sounds</string> ** TODO ** -->
<string name="safe_headset_volume_title">Safe headset volume</string>

</resources>
5 changes: 5 additions & 0 deletions res/xml/sound_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@
android:title="@string/haptic_feedback_enable_title"
android:defaultValue="true" />

<CheckBoxPreference
android:key="safe_headset_volume"
android:title="@string/safe_headset_volume_title"
android:defaultValue="true" />

<ListPreference
android:key="emergency_tone"
android:title="@string/emergency_tone_title"
Expand Down
11 changes: 11 additions & 0 deletions src/com/android/settings/SoundSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public class SoundSettings extends SettingsPreferenceFragment implements
private static final String KEY_DOCK_SOUNDS = "dock_sounds";
private static final String KEY_DOCK_AUDIO_MEDIA_ENABLED = "dock_audio_media_enabled";
private static final String KEY_QUIET_HOURS = "quiet_hours";
private static final String KEY_SAFE_HEADSET_VOLUME = "safe_headset_volume";

private static final String[] NEED_VOICE_CAPABILITY = {
KEY_RINGTONE, KEY_DTMF_TONE, KEY_CATEGORY_CALLS,
Expand All @@ -105,6 +106,7 @@ public class SoundSettings extends SettingsPreferenceFragment implements
private Preference mVibrationPreference;
private Preference mNotificationPreference;
private PreferenceScreen mQuietHours;
private CheckBoxPreference mSafeHeadsetVolume;

private Runnable mRingtoneLookupRunnable;

Expand Down Expand Up @@ -209,6 +211,11 @@ public void onCreate(Bundle savedInstanceState) {
mQuietHours.setSummary(getString(R.string.quiet_hours_summary));
}

mSafeHeadsetVolume = (CheckBoxPreference) findPreference(KEY_SAFE_HEADSET_VOLUME);
mSafeHeadsetVolume.setPersistent(false);
mSafeHeadsetVolume.setChecked(Settings.System.getBoolean(resolver,
Settings.System.MANUAL_SAFE_MEDIA_VOLUME, true));

Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
if (vibrator == null || !vibrator.hasVibrator()) {
removePreference(KEY_VIBRATE);
Expand Down Expand Up @@ -379,6 +386,10 @@ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preferen
Settings.System.putInt(getContentResolver(), Settings.System.LOCKSCREEN_SOUNDS_ENABLED,
mLockSounds.isChecked() ? 1 : 0);

} else if (preference == mSafeHeadsetVolume) {
Settings.System.putBoolean(getContentResolver(), Settings.System.MANUAL_SAFE_MEDIA_VOLUME,
mSafeHeadsetVolume.isChecked());

} else if (preference == mMusicFx) {
// let the framework fire off the intent
return false;
Expand Down

0 comments on commit 89a2df8

Please sign in to comment.