1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-30 21:22:26 -05:00

Fix NullPointerException when saving account settings for non-IMAP accounts.

Fixes issue 2454
This commit is contained in:
cketti 2010-10-13 20:49:34 +00:00
parent 28c9dfdcce
commit 4be781a749

View File

@ -126,6 +126,10 @@ public class AccountSettings extends K9PreferenceActivity
private ListPreference mCryptoApp; private ListPreference mCryptoApp;
private CheckBoxPreference mCryptoAutoSignature; private CheckBoxPreference mCryptoAutoSignature;
boolean mIsPushCapable = false;
boolean mIsExpungeCapable = false;
public static void actionSettings(Context context, Account account) public static void actionSettings(Context context, Account account)
{ {
Intent i = new Intent(context, AccountSettings.class); Intent i = new Intent(context, AccountSettings.class);
@ -143,13 +147,11 @@ public class AccountSettings extends K9PreferenceActivity
boolean isPushCapable = false;
boolean isExpungeCapable = false;
try try
{ {
final Store store = mAccount.getRemoteStore(); final Store store = mAccount.getRemoteStore();
isPushCapable = store.isPushCapable(); mIsPushCapable = store.isPushCapable();
isExpungeCapable = store.isExpungeCapable(); mIsExpungeCapable = store.isExpungeCapable();
} }
catch (Exception e) catch (Exception e)
{ {
@ -239,7 +241,7 @@ public class AccountSettings extends K9PreferenceActivity
}); });
mPushMode = (ListPreference) findPreference(PREFERENCE_PUSH_MODE); mPushMode = (ListPreference) findPreference(PREFERENCE_PUSH_MODE);
mPushMode.setEnabled(isPushCapable); mPushMode.setEnabled(mIsPushCapable);
mPushMode.setValue(mAccount.getFolderPushMode().name()); mPushMode.setValue(mAccount.getFolderPushMode().name());
mPushMode.setSummary(mPushMode.getEntry()); mPushMode.setSummary(mPushMode.getEntry());
mPushMode.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() mPushMode.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
@ -286,7 +288,7 @@ public class AccountSettings extends K9PreferenceActivity
mExpungePolicy = (ListPreference) findPreference(PREFERENCE_EXPUNGE_POLICY); mExpungePolicy = (ListPreference) findPreference(PREFERENCE_EXPUNGE_POLICY);
mExpungePolicy.setEnabled(isExpungeCapable); mExpungePolicy.setEnabled(mIsExpungeCapable);
mExpungePolicy.setValue(mAccount.getExpungePolicy()); mExpungePolicy.setValue(mAccount.getExpungePolicy());
mExpungePolicy.setSummary(mExpungePolicy.getEntry()); mExpungePolicy.setSummary(mExpungePolicy.getEntry());
mExpungePolicy.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() mExpungePolicy.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
@ -433,7 +435,7 @@ public class AccountSettings extends K9PreferenceActivity
mPushPollOnConnect = (CheckBoxPreference) findPreference(PREFERENCE_PUSH_POLL_ON_CONNECT); mPushPollOnConnect = (CheckBoxPreference) findPreference(PREFERENCE_PUSH_POLL_ON_CONNECT);
mIdleRefreshPeriod = (ListPreference) findPreference(PREFERENCE_IDLE_REFRESH_PERIOD); mIdleRefreshPeriod = (ListPreference) findPreference(PREFERENCE_IDLE_REFRESH_PERIOD);
mMaxPushFolders = (ListPreference) findPreference(PREFERENCE_MAX_PUSH_FOLDERS); mMaxPushFolders = (ListPreference) findPreference(PREFERENCE_MAX_PUSH_FOLDERS);
if (isPushCapable) if (mIsPushCapable)
{ {
mPushPollOnConnect.setChecked(mAccount.isPushPollOnConnect()); mPushPollOnConnect.setChecked(mAccount.isPushPollOnConnect());
@ -711,9 +713,12 @@ public class AccountSettings extends K9PreferenceActivity
mAccount.setCryptoApp(mCryptoApp.getValue()); mAccount.setCryptoApp(mCryptoApp.getValue());
mAccount.setCryptoAutoSignature(mCryptoAutoSignature.isChecked()); mAccount.setCryptoAutoSignature(mCryptoAutoSignature.isChecked());
mAccount.setPushPollOnConnect(mPushPollOnConnect.isChecked()); if (mIsPushCapable)
mAccount.setIdleRefreshMinutes(Integer.parseInt(mIdleRefreshPeriod.getValue())); {
mAccount.setMaxPushFolders(Integer.parseInt(mMaxPushFolders.getValue())); mAccount.setPushPollOnConnect(mPushPollOnConnect.isChecked());
mAccount.setIdleRefreshMinutes(Integer.parseInt(mIdleRefreshPeriod.getValue()));
mAccount.setMaxPushFolders(Integer.parseInt(mMaxPushFolders.getValue()));
}
boolean needsRefresh = mAccount.setAutomaticCheckIntervalMinutes(Integer.parseInt(mCheckFrequency.getValue())); boolean needsRefresh = mAccount.setAutomaticCheckIntervalMinutes(Integer.parseInt(mCheckFrequency.getValue()));
needsRefresh |= mAccount.setFolderSyncMode(Account.FolderMode.valueOf(mSyncMode.getValue())); needsRefresh |= mAccount.setFolderSyncMode(Account.FolderMode.valueOf(mSyncMode.getValue()));