diff options
author | Danesh M <daneshm90@gmail.com> | 2015-12-17 10:38:20 -0800 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2015-12-18 12:08:32 -0800 |
commit | f2b1fc1d46a5efe52e8627316cb07db213ae87a2 (patch) | |
tree | 2c2905fd57e281c60739e915be4bdcd91293f179 /src/com/android/settings/notification/SoundSettings.java | |
parent | d948c831be5baaa255a4bb8bb697f98ec586579d (diff) | |
download | packages_apps_Settings-f2b1fc1d46a5efe52e8627316cb07db213ae87a2.zip packages_apps_Settings-f2b1fc1d46a5efe52e8627316cb07db213ae87a2.tar.gz packages_apps_Settings-f2b1fc1d46a5efe52e8627316cb07db213ae87a2.tar.bz2 |
Settings : Add volume link notification
Change-Id: I06027bc4f13c8a60b19a2b7ded73ce76da4e4f02
Tablets don't need to link volumes they don't have
This feature broke the notification volume slider in settings for
devices without telephony service (tablets) and isn't applicable
anyways since they don't have ringtone volume streams.
Change-Id: Ifff10ecd35b53f5fc08a36332814fb00d20b4350
Diffstat (limited to 'src/com/android/settings/notification/SoundSettings.java')
-rw-r--r-- | src/com/android/settings/notification/SoundSettings.java | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/src/com/android/settings/notification/SoundSettings.java b/src/com/android/settings/notification/SoundSettings.java index aed746b..3957f13 100644 --- a/src/com/android/settings/notification/SoundSettings.java +++ b/src/com/android/settings/notification/SoundSettings.java @@ -92,6 +92,7 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab private static final String KEY_VIBRATE_ON_TOUCH = "vibrate_on_touch"; private static final String KEY_ZEN_ACCESS = "manage_zen_access"; private static final String KEY_ZEN_MODE = "zen_mode"; + private static final String KEY_VOLUME_LINK_NOTIFICATION = "volume_link_notification"; private static final String[] RESTRICTED_KEYS = { KEY_MEDIA_VOLUME, @@ -123,7 +124,8 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab private boolean mVoiceCapable; private Vibrator mVibrator; private AudioManager mAudioManager; - private VolumeSeekBarPreference mRingOrNotificationPreference; + private VolumeSeekBarPreference mRingPreference; + private VolumeSeekBarPreference mNotificationPreference; private TwoStatePreference mIncreasingRing; private IncreasingRingVolumePreference mIncreasingRingVolume; @@ -168,15 +170,12 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab initVolumePreference(KEY_ALARM_VOLUME, AudioManager.STREAM_ALARM, com.android.internal.R.drawable.ic_audio_alarm_mute); if (mVoiceCapable) { - mRingOrNotificationPreference = + mRingPreference = initVolumePreference(KEY_RING_VOLUME, AudioManager.STREAM_RING, com.android.internal.R.drawable.ic_audio_ring_notif_mute); - volumes.removePreference(volumes.findPreference(KEY_NOTIFICATION_VOLUME)); } else { - mRingOrNotificationPreference = - initVolumePreference(KEY_NOTIFICATION_VOLUME, AudioManager.STREAM_NOTIFICATION, - com.android.internal.R.drawable.ic_audio_ring_notif_mute); volumes.removePreference(volumes.findPreference(KEY_RING_VOLUME)); + volumes.removePreference(volumes.findPreference(KEY_VOLUME_LINK_NOTIFICATION)); } CMHardwareManager hardware = CMHardwareManager.getInstance(mContext); @@ -202,6 +201,7 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab refreshNotificationListeners(); refreshZenAccess(); lookupRingtoneNames(); + updateNotificationPreferenceState(); mSettingsObserver.register(true); mReceiver.register(true); updateRingOrNotificationPreference(); @@ -243,8 +243,24 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab return volumePref; } + private void updateNotificationPreferenceState() { + mNotificationPreference = initVolumePreference(KEY_NOTIFICATION_VOLUME, + AudioManager.STREAM_NOTIFICATION, + com.android.internal.R.drawable.ic_audio_ring_notif_mute); + + if (mVoiceCapable) { + final boolean enabled = Settings.System.getInt(getContentResolver(), + Settings.Secure.VOLUME_LINK_NOTIFICATION, 1) == 1; + + if (mNotificationPreference != null) { + boolean show = !enabled; + mNotificationPreference.setEnabled(show); + } + } + } + private void updateRingOrNotificationPreference() { - mRingOrNotificationPreference.showIcon(mSuppressor != null + mRingPreference.showIcon(mSuppressor != null ? com.android.internal.R.drawable.ic_audio_ring_notif_mute : mRingerMode == AudioManager.RINGER_MODE_VIBRATE || wasRingerModeVibrate() ? com.android.internal.R.drawable.ic_audio_ring_notif_vibrate @@ -267,11 +283,11 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab final ComponentName suppressor = NotificationManager.from(mContext).getEffectsSuppressor(); if (Objects.equals(suppressor, mSuppressor)) return; mSuppressor = suppressor; - if (mRingOrNotificationPreference != null) { + if (mRingPreference != null) { final String text = suppressor != null ? mContext.getString(com.android.internal.R.string.muted_by, getSuppressorCaption(suppressor)) : null; - mRingOrNotificationPreference.setSuppressionText(text); + mRingPreference.setSuppressionText(text); } updateRingOrNotificationPreference(); } @@ -503,6 +519,8 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_ALLOW_PRIVATE_NOTIFICATIONS); private final Uri LOCK_SCREEN_SHOW_URI = Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_SHOW_NOTIFICATIONS); + private final Uri VOLUME_LINK_NOTIFICATION_URI = + Settings.Secure.getUriFor(Settings.Secure.VOLUME_LINK_NOTIFICATION); public SettingsObserver() { super(mHandler); @@ -515,6 +533,7 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab cr.registerContentObserver(NOTIFICATION_LIGHT_PULSE_URI, false, this); cr.registerContentObserver(LOCK_SCREEN_PRIVATE_URI, false, this); cr.registerContentObserver(LOCK_SCREEN_SHOW_URI, false, this); + cr.registerContentObserver(VOLUME_LINK_NOTIFICATION_URI, false, this); } else { cr.unregisterContentObserver(this); } @@ -526,6 +545,9 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab if (VIBRATE_WHEN_RINGING_URI.equals(uri)) { updateVibrateWhenRinging(); } + if (VOLUME_LINK_NOTIFICATION_URI.equals(uri)) { + updateNotificationPreferenceState(); + } } } |