diff --git a/src/com/fsck/k9/activity/setup/AccountSettings.java b/src/com/fsck/k9/activity/setup/AccountSettings.java index 548eb94c2..b39f9bab9 100644 --- a/src/com/fsck/k9/activity/setup/AccountSettings.java +++ b/src/com/fsck/k9/activity/setup/AccountSettings.java @@ -125,6 +125,7 @@ public class AccountSettings extends K9PreferenceActivity { private boolean mIsMoveCapable = false; private boolean mIsPushCapable = false; private boolean mIsExpungeCapable = false; + private boolean mIsSeenFlagSupported = false; private PreferenceScreen mMainScreen; private PreferenceScreen mComposingScreen; @@ -210,6 +211,7 @@ public class AccountSettings extends K9PreferenceActivity { mIsMoveCapable = store.isMoveCapable(); mIsPushCapable = store.isPushCapable(); mIsExpungeCapable = store.isExpungeCapable(); + mIsSeenFlagSupported = store.isSeenFlagSupported(); } catch (Exception e) { Log.e(K9.LOG_TAG, "Could not get remote store", e); } @@ -354,7 +356,10 @@ public class AccountSettings extends K9PreferenceActivity { }); mDeletePolicy = (ListPreference) findPreference(PREFERENCE_DELETE_POLICY); - mDeletePolicy.setValue("" + mAccount.getDeletePolicy()); + if (!mIsSeenFlagSupported) { + removeListEntry(mDeletePolicy, Integer.toString(Account.DELETE_POLICY_MARK_AS_READ)); + } + mDeletePolicy.setValue(Integer.toString(mAccount.getDeletePolicy())); mDeletePolicy.setSummary(mDeletePolicy.getEntry()); mDeletePolicy.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { @@ -716,6 +721,26 @@ public class AccountSettings extends K9PreferenceActivity { } } + private void removeListEntry(ListPreference listPreference, String remove) { + CharSequence[] entryValues = listPreference.getEntryValues(); + CharSequence[] entries = listPreference.getEntries(); + + CharSequence[] newEntryValues = new String[entryValues.length - 1]; + CharSequence[] newEntries = new String[entryValues.length - 1]; + + for (int i = 0, out = 0; i < entryValues.length; i++) { + CharSequence value = entryValues[i]; + if (!value.equals(remove)) { + newEntryValues[out] = value; + newEntries[out] = entries[i]; + out++; + } + } + + listPreference.setEntryValues(newEntryValues); + listPreference.setEntries(newEntries); + } + private void handleCryptoAppDependencies() { if ("".equals(mCryptoApp.getValue())) { mCryptoAutoSignature.setEnabled(false); diff --git a/src/com/fsck/k9/mail/Store.java b/src/com/fsck/k9/mail/Store.java index d3a67989d..426b67bfe 100644 --- a/src/com/fsck/k9/mail/Store.java +++ b/src/com/fsck/k9/mail/Store.java @@ -194,6 +194,10 @@ public abstract class Store { return false; } + public boolean isSeenFlagSupported() { + return true; + } + public void sendMessages(Message[] messages) throws MessagingException { } diff --git a/src/com/fsck/k9/mail/store/Pop3Store.java b/src/com/fsck/k9/mail/store/Pop3Store.java index b0abfe46f..53a188ee7 100644 --- a/src/com/fsck/k9/mail/store/Pop3Store.java +++ b/src/com/fsck/k9/mail/store/Pop3Store.java @@ -287,6 +287,11 @@ public class Pop3Store extends Store { folder.close(); } + @Override + public boolean isSeenFlagSupported() { + return false; + } + class Pop3Folder extends Folder { private Socket mSocket; private InputStream mIn;