Disable notification prefs until folder prefs are loaded.

Bug: 8485354
Change-Id: Id56c2634a16274e9340ad6ecb96661ee8a489d49
This commit is contained in:
Yu Ping Hu 2013-03-27 17:04:27 -07:00
parent b1792d725a
commit c534638b7a
2 changed files with 10 additions and 5 deletions

View File

@ -89,7 +89,9 @@
</PreferenceCategory>
<!-- This category is enabled after the folder preferences are loaded -->
<PreferenceCategory
android:enabled="false"
android:key="account_notifications"
android:title="@string/account_settings_notifications">

View File

@ -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);