diff options
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(); + } } } |