From 5895648eb44b3d18180888bf6f1eb5ba3caa5c97 Mon Sep 17 00:00:00 2001 From: Danesh M Date: Thu, 28 Jan 2016 10:37:44 -0800 Subject: Settings : Fix linked volume crash + inconsistent state - Ensure we fetch from Secure, not System - Don't initialize every time we toggle - Set the checkbox state from Settings value since the preference assumes a default of 0 CYNGNOS-1638 Change-Id: Ia519cef2295a6b6083b2b168f4c16df78f423cee --- .../android/settings/notification/SoundSettings.java | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/com/android/settings/notification/SoundSettings.java') diff --git a/src/com/android/settings/notification/SoundSettings.java b/src/com/android/settings/notification/SoundSettings.java index 679eb97..bc8eea4 100644 --- a/src/com/android/settings/notification/SoundSettings.java +++ b/src/com/android/settings/notification/SoundSettings.java @@ -139,7 +139,7 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab private int mLockscreenSelectedValue; private ComponentName mSuppressor; private int mRingerMode = -1; - + private SwitchPreference mVolumeLinkNotificationSwitch; private UserManager mUserManager; @Override @@ -174,6 +174,8 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab mRingPreference = initVolumePreference(KEY_RING_VOLUME, AudioManager.STREAM_RING, com.android.internal.R.drawable.ic_audio_ring_notif_mute); + mVolumeLinkNotificationSwitch = (SwitchPreference) + volumes.findPreference(KEY_VOLUME_LINK_NOTIFICATION); } else { volumes.removePreference(volumes.findPreference(KEY_RING_VOLUME)); volumes.removePreference(volumes.findPreference(KEY_VOLUME_LINK_NOTIFICATION)); @@ -248,17 +250,17 @@ public class SoundSettings extends SettingsPreferenceFragment implements Indexab } private void updateNotificationPreferenceState() { - mNotificationPreference = initVolumePreference(KEY_NOTIFICATION_VOLUME, - AudioManager.STREAM_NOTIFICATION, - com.android.internal.R.drawable.ic_audio_ring_notif_mute); + if (mNotificationPreference == null) { + 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(), + final boolean enabled = Settings.Secure.getInt(getContentResolver(), Settings.Secure.VOLUME_LINK_NOTIFICATION, 1) == 1; - - if (mNotificationPreference != null) { - boolean show = !enabled; - mNotificationPreference.setEnabled(show); + if (mVolumeLinkNotificationSwitch != null){ + mVolumeLinkNotificationSwitch.setChecked(enabled); } } } -- cgit v1.1