diff --git a/res/values/strings.xml b/res/values/strings.xml index 820960b66..8d66d64ea 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -549,6 +549,8 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin Searches for unread messages when Notification is opened Show unread count Show the number of unread messages in the notification bar. + Mark message as read when opening + Mark a message as read when it is opened for viewing Enable refile buttons Show the Archive, Move, and Spam buttons. diff --git a/res/xml/account_settings_preferences.xml b/res/xml/account_settings_preferences.xml index 9fa5a11a6..683827258 100644 --- a/res/xml/account_settings_preferences.xml +++ b/res/xml/account_settings_preferences.xml @@ -81,6 +81,17 @@ + + + + + + diff --git a/src/com/fsck/k9/Account.java b/src/com/fsck/k9/Account.java index c04e89c06..98c3ddafb 100644 --- a/src/com/fsck/k9/Account.java +++ b/src/com/fsck/k9/Account.java @@ -149,6 +149,7 @@ public class Account implements BaseAccount { private String mCryptoApp; private boolean mCryptoAutoSignature; private boolean mCryptoAutoEncrypt; + private boolean mMarkMessageAsReadOnView; private CryptoProvider mCryptoProvider = null; @@ -236,6 +237,7 @@ public class Account implements BaseAccount { mCryptoAutoSignature = false; mCryptoAutoEncrypt = false; mEnabled = true; + mMarkMessageAsReadOnView = true; searchableFolders = Searchable.ALL; @@ -391,6 +393,7 @@ public class Account implements BaseAccount { mCryptoAutoSignature = prefs.getBoolean(mUuid + ".cryptoAutoSignature", false); mCryptoAutoEncrypt = prefs.getBoolean(mUuid + ".cryptoAutoEncrypt", false); mEnabled = prefs.getBoolean(mUuid + ".enabled", true); + mMarkMessageAsReadOnView = prefs.getBoolean(mUuid + ".markMessageAsReadOnView", true); } protected synchronized void delete(Preferences preferences) { @@ -472,6 +475,7 @@ public class Account implements BaseAccount { editor.remove(mUuid + ".enabled"); editor.remove(mUuid + ".enableMoveButtons"); editor.remove(mUuid + ".hideMoveButtonsEnum"); + editor.remove(mUuid + ".markMessageAsReadOnView"); for (String type : networkTypes) { editor.remove(mUuid + ".useCompression." + type); } @@ -632,6 +636,7 @@ public class Account implements BaseAccount { editor.putBoolean(mUuid + ".cryptoAutoSignature", mCryptoAutoSignature); editor.putBoolean(mUuid + ".cryptoAutoEncrypt", mCryptoAutoEncrypt); editor.putBoolean(mUuid + ".enabled", mEnabled); + editor.putBoolean(mUuid + ".markMessageAsReadOnView", mMarkMessageAsReadOnView); editor.putBoolean(mUuid + ".vibrate", mNotificationSetting.shouldVibrate()); editor.putInt(mUuid + ".vibratePattern", mNotificationSetting.getVibratePattern()); @@ -1500,4 +1505,12 @@ public class Account implements BaseAccount { public synchronized void setEnabled(boolean enabled) { mEnabled = enabled; } + + public synchronized boolean isMarkMessageAsReadOnView() { + return mMarkMessageAsReadOnView; + } + + public synchronized void setMarkMessageAsReadOnView(boolean value) { + mMarkMessageAsReadOnView = value; + } } diff --git a/src/com/fsck/k9/activity/MessageView.java b/src/com/fsck/k9/activity/MessageView.java index 1ffb9586e..87d968681 100644 --- a/src/com/fsck/k9/activity/MessageView.java +++ b/src/com/fsck/k9/activity/MessageView.java @@ -756,17 +756,16 @@ public class MessageView extends K9Activity implements OnClickListener { mPrevious.requestFocus(); } - private void onMarkAsUnread() { + private void onToggleRead() { if (mMessage != null) { mController.setFlag(mAccount, mMessage.getFolder().getName(), - new Message[] { mMessage }, Flag.SEEN, false); + new Message[] { mMessage }, Flag.SEEN, !mMessage.isSet(Flag.SEEN)); mMessageView.setHeaders(mMessage, mAccount); String subject = mMessage.getSubject(); setTitle(subject); } } - private void onDownloadRemainder() { if (mMessage.isSet(Flag.X_DOWNLOADED_FULL)) { return; @@ -833,7 +832,7 @@ public class MessageView extends K9Activity implements OnClickListener { onSendAlternate(); break; case R.id.mark_as_unread: - onMarkAsUnread(); + onToggleRead(); break; case R.id.flag: onFlag(); @@ -944,6 +943,12 @@ public class MessageView extends K9Activity implements OnClickListener { additionalHeadersItem.setTitle(mMessageView.additionalHeadersVisible() ? R.string.hide_full_header_action : R.string.show_full_header_action); } + + if (mMessage != null) { + int actionTitle = mMessage.isSet(Flag.SEEN) ? + R.string.mark_as_unread_action : R.string.mark_as_read_action; + menu.findItem(R.id.mark_as_unread).setTitle(actionTitle); + } } return super.onPrepareOptionsMenu(menu); } diff --git a/src/com/fsck/k9/activity/setup/AccountSettings.java b/src/com/fsck/k9/activity/setup/AccountSettings.java index 9ac8f7058..f38cfa20f 100644 --- a/src/com/fsck/k9/activity/setup/AccountSettings.java +++ b/src/com/fsck/k9/activity/setup/AccountSettings.java @@ -48,6 +48,7 @@ public class AccountSettings extends K9PreferenceActivity { private static final String PREFERENCE_SCREEN_PUSH_ADVANCED = "push_advanced"; private static final String PREFERENCE_DESCRIPTION = "account_description"; + private static final String PREFERENCE_MARK_MESSAGE_AS_READ_ON_VIEW = "mark_message_as_read_on_view"; private static final String PREFERENCE_COMPOSITION = "composition"; private static final String PREFERENCE_MANAGE_IDENTITIES = "manage_identities"; private static final String PREFERENCE_FREQUENCY = "account_check_frequency"; @@ -94,9 +95,7 @@ public class AccountSettings extends K9PreferenceActivity { private static final String PREFERENCE_CRYPTO_APP = "crypto_app"; private static final String PREFERENCE_CRYPTO_AUTO_SIGNATURE = "crypto_auto_signature"; private static final String PREFERENCE_CRYPTO_AUTO_ENCRYPT = "crypto_auto_encrypt"; - private static final String PREFERENCE_LOCAL_STORAGE_PROVIDER = "local_storage_provider"; - private static final String PREFERENCE_CATEGORY_FOLDERS = "folders"; private static final String PREFERENCE_ARCHIVE_FOLDER = "archive_folder"; private static final String PREFERENCE_DRAFTS_FOLDER = "drafts_folder"; @@ -114,6 +113,7 @@ public class AccountSettings extends K9PreferenceActivity { private PreferenceScreen mComposingScreen; private EditTextPreference mAccountDescription; + private CheckBoxPreference mMarkMessageAsReadOnView; private ListPreference mCheckFrequency; private ListPreference mDisplayCount; private ListPreference mMessageAge; @@ -157,10 +157,7 @@ public class AccountSettings extends K9PreferenceActivity { private ListPreference mCryptoApp; private CheckBoxPreference mCryptoAutoSignature; private CheckBoxPreference mCryptoAutoEncrypt; - private ListPreference mLocalStorageProvider; - - private ListPreference mArchiveFolder; private ListPreference mDraftsFolder; private ListPreference mSentFolder; @@ -204,6 +201,9 @@ public class AccountSettings extends K9PreferenceActivity { } }); + mMarkMessageAsReadOnView = (CheckBoxPreference) findPreference(PREFERENCE_MARK_MESSAGE_AS_READ_ON_VIEW); + mMarkMessageAsReadOnView.setChecked(mAccount.isMarkMessageAsReadOnView()); + mMessageFormat = (ListPreference) findPreference(PREFERENCE_MESSAGE_FORMAT); mMessageFormat.setValue(mAccount.getMessageFormat().name()); mMessageFormat.setSummary(mMessageFormat.getEntry()); @@ -672,6 +672,7 @@ public class AccountSettings extends K9PreferenceActivity { } mAccount.setDescription(mAccountDescription.getText()); + mAccount.setMarkMessageAsReadOnView(mMarkMessageAsReadOnView.isChecked()); mAccount.setNotifyNewMail(mAccountNotify.isChecked()); mAccount.setNotifySelfNewMail(mAccountNotifySelf.isChecked()); mAccount.setShowOngoing(mAccountNotifySync.isChecked()); diff --git a/src/com/fsck/k9/controller/MessagingController.java b/src/com/fsck/k9/controller/MessagingController.java index 290679e86..9a7065cbd 100644 --- a/src/com/fsck/k9/controller/MessagingController.java +++ b/src/com/fsck/k9/controller/MessagingController.java @@ -2846,7 +2846,7 @@ public class MessagingController implements Runnable { || message.getId() == 0) { throw new IllegalArgumentException("Message not found: folder=" + folder + ", uid=" + uid); } - if (!message.isSet(Flag.SEEN)) { + if (account.isMarkMessageAsReadOnView() && !message.isSet(Flag.SEEN)) { message.setFlag(Flag.SEEN, true); setFlag(new Message[] { message }, Flag.SEEN, true); } diff --git a/src/com/fsck/k9/preferences/AccountSettings.java b/src/com/fsck/k9/preferences/AccountSettings.java index fdc311820..f2dcf3669 100644 --- a/src/com/fsck/k9/preferences/AccountSettings.java +++ b/src/com/fsck/k9/preferences/AccountSettings.java @@ -96,6 +96,9 @@ public class AccountSettings { s.put("localStorageProvider", Settings.versions( new V(1, new StorageProviderSetting()) )); + s.put("markMessageAsReadOnView", Settings.versions( + new V(7, new BooleanSetting(true)) + )); s.put("maxPushFolders", Settings.versions( new V(1, new IntegerRangeSetting(0, 100, 10)) )); diff --git a/src/com/fsck/k9/preferences/Settings.java b/src/com/fsck/k9/preferences/Settings.java index 3b2bbb979..637d6d74d 100644 --- a/src/com/fsck/k9/preferences/Settings.java +++ b/src/com/fsck/k9/preferences/Settings.java @@ -35,7 +35,7 @@ public class Settings { * * @see SettingsExporter */ - public static final int VERSION = 6; + public static final int VERSION = 7; public static Map validate(int version, Map> settings,