From c534638b7aeb1f4bd65852bbcff6b2c78f21d566 Mon Sep 17 00:00:00 2001 From: Yu Ping Hu Date: Wed, 27 Mar 2013 17:04:27 -0700 Subject: [PATCH] Disable notification prefs until folder prefs are loaded. Bug: 8485354 Change-Id: Id56c2634a16274e9340ad6ecb96661ee8a489d49 --- res/xml/account_settings_preferences.xml | 2 ++ .../activity/setup/AccountSettingsFragment.java | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/res/xml/account_settings_preferences.xml b/res/xml/account_settings_preferences.xml index 04fa921bb..672260340 100755 --- a/res/xml/account_settings_preferences.xml +++ b/res/xml/account_settings_preferences.xml @@ -89,7 +89,9 @@ + diff --git a/src/com/android/email/activity/setup/AccountSettingsFragment.java b/src/com/android/email/activity/setup/AccountSettingsFragment.java index 920032eee..535633bb6 100644 --- a/src/com/android/email/activity/setup/AccountSettingsFragment.java +++ b/src/com/android/email/activity/setup/AccountSettingsFragment.java @@ -116,6 +116,7 @@ public class AccountSettingsFragment extends EmailPreferenceFragment private CheckBoxPreference mInboxNotify; private CheckBoxPreference mInboxVibrate; private Preference mInboxRingtone; + private PreferenceCategory mNotificationsCategory; private CheckBoxPreference mSyncContacts; private CheckBoxPreference mSyncCalendar; private CheckBoxPreference mSyncEmail; @@ -563,11 +564,12 @@ public class AccountSettingsFragment extends EmailPreferenceFragment public void run() { mInboxNotify.setChecked( mInboxFolderPreferences.areNotificationsEnabled()); - mInboxVibrate.setChecked( mInboxFolderPreferences.isNotificationVibrateEnabled()); - setRingtoneSummary(); + // Notification preferences must be disabled until after + // mInboxFolderPreferences is available, so enable them here. + mNotificationsCategory.setEnabled(true); } }); } @@ -699,6 +701,9 @@ public class AccountSettingsFragment extends EmailPreferenceFragment } }); + mNotificationsCategory = + (PreferenceCategory) findPreference(PREFERENCE_CATEGORY_NOTIFICATIONS); + // Set the vibrator value, or hide it on devices w/o a vibrator mInboxVibrate = (CheckBoxPreference) findPreference( FolderPreferences.PreferenceKeys.NOTIFICATION_VIBRATE); @@ -710,9 +715,7 @@ public class AccountSettingsFragment extends EmailPreferenceFragment mInboxVibrate.setOnPreferenceChangeListener(this); } else { // No vibrator present. Remove the preference altogether. - PreferenceCategory notificationsCategory = (PreferenceCategory) - findPreference(PREFERENCE_CATEGORY_NOTIFICATIONS); - notificationsCategory.removePreference(mInboxVibrate); + mNotificationsCategory.removePreference(mInboxVibrate); } final Preference retryAccount = findPreference(PREFERENCE_POLICIES_RETRY_ACCOUNT);