1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Added a setting to disable marking messages as read on viewing

This commit is contained in:
cketti 2012-03-19 04:44:41 +01:00
parent 5245191900
commit 1d28eb003d
8 changed files with 46 additions and 11 deletions

View File

@ -549,6 +549,8 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
<string name="account_settings_notification_opens_unread_summary">Searches for unread messages when Notification is opened</string> <string name="account_settings_notification_opens_unread_summary">Searches for unread messages when Notification is opened</string>
<string name="account_settings_notification_unread_count_label">Show unread count</string> <string name="account_settings_notification_unread_count_label">Show unread count</string>
<string name="account_settings_notification_unread_count_summary">Show the number of unread messages in the notification bar.</string> <string name="account_settings_notification_unread_count_summary">Show the number of unread messages in the notification bar.</string>
<string name="account_settings_mark_message_as_read_on_view_label">Mark message as read when opening</string>
<string name="account_settings_mark_message_as_read_on_view_summary">Mark a message as read when it is opened for viewing</string>
<string name="account_settings_enable_move_buttons_label">Enable refile buttons</string> <string name="account_settings_enable_move_buttons_label">Enable refile buttons</string>
<string name="account_settings_enable_move_buttons_summary">Show the Archive, Move, and Spam buttons.</string> <string name="account_settings_enable_move_buttons_summary">Show the Archive, Move, and Spam buttons.</string>

View File

@ -81,6 +81,17 @@
</PreferenceScreen> </PreferenceScreen>
<PreferenceScreen
android:title="@string/interaction_preferences">
<CheckBoxPreference
android:persistent="false"
android:key="mark_message_as_read_on_view"
android:title="@string/account_settings_mark_message_as_read_on_view_label"
android:summary="@string/account_settings_mark_message_as_read_on_view_summary" />
</PreferenceScreen>
<PreferenceScreen <PreferenceScreen
android:title="@string/account_settings_sync" android:title="@string/account_settings_sync"
android:key="incoming_prefs"> android:key="incoming_prefs">

View File

@ -149,6 +149,7 @@ public class Account implements BaseAccount {
private String mCryptoApp; private String mCryptoApp;
private boolean mCryptoAutoSignature; private boolean mCryptoAutoSignature;
private boolean mCryptoAutoEncrypt; private boolean mCryptoAutoEncrypt;
private boolean mMarkMessageAsReadOnView;
private CryptoProvider mCryptoProvider = null; private CryptoProvider mCryptoProvider = null;
@ -236,6 +237,7 @@ public class Account implements BaseAccount {
mCryptoAutoSignature = false; mCryptoAutoSignature = false;
mCryptoAutoEncrypt = false; mCryptoAutoEncrypt = false;
mEnabled = true; mEnabled = true;
mMarkMessageAsReadOnView = true;
searchableFolders = Searchable.ALL; searchableFolders = Searchable.ALL;
@ -391,6 +393,7 @@ public class Account implements BaseAccount {
mCryptoAutoSignature = prefs.getBoolean(mUuid + ".cryptoAutoSignature", false); mCryptoAutoSignature = prefs.getBoolean(mUuid + ".cryptoAutoSignature", false);
mCryptoAutoEncrypt = prefs.getBoolean(mUuid + ".cryptoAutoEncrypt", false); mCryptoAutoEncrypt = prefs.getBoolean(mUuid + ".cryptoAutoEncrypt", false);
mEnabled = prefs.getBoolean(mUuid + ".enabled", true); mEnabled = prefs.getBoolean(mUuid + ".enabled", true);
mMarkMessageAsReadOnView = prefs.getBoolean(mUuid + ".markMessageAsReadOnView", true);
} }
protected synchronized void delete(Preferences preferences) { protected synchronized void delete(Preferences preferences) {
@ -472,6 +475,7 @@ public class Account implements BaseAccount {
editor.remove(mUuid + ".enabled"); editor.remove(mUuid + ".enabled");
editor.remove(mUuid + ".enableMoveButtons"); editor.remove(mUuid + ".enableMoveButtons");
editor.remove(mUuid + ".hideMoveButtonsEnum"); editor.remove(mUuid + ".hideMoveButtonsEnum");
editor.remove(mUuid + ".markMessageAsReadOnView");
for (String type : networkTypes) { for (String type : networkTypes) {
editor.remove(mUuid + ".useCompression." + type); editor.remove(mUuid + ".useCompression." + type);
} }
@ -632,6 +636,7 @@ public class Account implements BaseAccount {
editor.putBoolean(mUuid + ".cryptoAutoSignature", mCryptoAutoSignature); editor.putBoolean(mUuid + ".cryptoAutoSignature", mCryptoAutoSignature);
editor.putBoolean(mUuid + ".cryptoAutoEncrypt", mCryptoAutoEncrypt); editor.putBoolean(mUuid + ".cryptoAutoEncrypt", mCryptoAutoEncrypt);
editor.putBoolean(mUuid + ".enabled", mEnabled); editor.putBoolean(mUuid + ".enabled", mEnabled);
editor.putBoolean(mUuid + ".markMessageAsReadOnView", mMarkMessageAsReadOnView);
editor.putBoolean(mUuid + ".vibrate", mNotificationSetting.shouldVibrate()); editor.putBoolean(mUuid + ".vibrate", mNotificationSetting.shouldVibrate());
editor.putInt(mUuid + ".vibratePattern", mNotificationSetting.getVibratePattern()); editor.putInt(mUuid + ".vibratePattern", mNotificationSetting.getVibratePattern());
@ -1500,4 +1505,12 @@ public class Account implements BaseAccount {
public synchronized void setEnabled(boolean enabled) { public synchronized void setEnabled(boolean enabled) {
mEnabled = enabled; mEnabled = enabled;
} }
public synchronized boolean isMarkMessageAsReadOnView() {
return mMarkMessageAsReadOnView;
}
public synchronized void setMarkMessageAsReadOnView(boolean value) {
mMarkMessageAsReadOnView = value;
}
} }

View File

@ -756,17 +756,16 @@ public class MessageView extends K9Activity implements OnClickListener {
mPrevious.requestFocus(); mPrevious.requestFocus();
} }
private void onMarkAsUnread() { private void onToggleRead() {
if (mMessage != null) { if (mMessage != null) {
mController.setFlag(mAccount, mMessage.getFolder().getName(), 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); mMessageView.setHeaders(mMessage, mAccount);
String subject = mMessage.getSubject(); String subject = mMessage.getSubject();
setTitle(subject); setTitle(subject);
} }
} }
private void onDownloadRemainder() { private void onDownloadRemainder() {
if (mMessage.isSet(Flag.X_DOWNLOADED_FULL)) { if (mMessage.isSet(Flag.X_DOWNLOADED_FULL)) {
return; return;
@ -833,7 +832,7 @@ public class MessageView extends K9Activity implements OnClickListener {
onSendAlternate(); onSendAlternate();
break; break;
case R.id.mark_as_unread: case R.id.mark_as_unread:
onMarkAsUnread(); onToggleRead();
break; break;
case R.id.flag: case R.id.flag:
onFlag(); onFlag();
@ -944,6 +943,12 @@ public class MessageView extends K9Activity implements OnClickListener {
additionalHeadersItem.setTitle(mMessageView.additionalHeadersVisible() ? additionalHeadersItem.setTitle(mMessageView.additionalHeadersVisible() ?
R.string.hide_full_header_action : R.string.show_full_header_action); 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); return super.onPrepareOptionsMenu(menu);
} }

View File

@ -48,6 +48,7 @@ public class AccountSettings extends K9PreferenceActivity {
private static final String PREFERENCE_SCREEN_PUSH_ADVANCED = "push_advanced"; private static final String PREFERENCE_SCREEN_PUSH_ADVANCED = "push_advanced";
private static final String PREFERENCE_DESCRIPTION = "account_description"; 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_COMPOSITION = "composition";
private static final String PREFERENCE_MANAGE_IDENTITIES = "manage_identities"; private static final String PREFERENCE_MANAGE_IDENTITIES = "manage_identities";
private static final String PREFERENCE_FREQUENCY = "account_check_frequency"; 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_APP = "crypto_app";
private static final String PREFERENCE_CRYPTO_AUTO_SIGNATURE = "crypto_auto_signature"; 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_CRYPTO_AUTO_ENCRYPT = "crypto_auto_encrypt";
private static final String PREFERENCE_LOCAL_STORAGE_PROVIDER = "local_storage_provider"; private static final String PREFERENCE_LOCAL_STORAGE_PROVIDER = "local_storage_provider";
private static final String PREFERENCE_CATEGORY_FOLDERS = "folders"; private static final String PREFERENCE_CATEGORY_FOLDERS = "folders";
private static final String PREFERENCE_ARCHIVE_FOLDER = "archive_folder"; private static final String PREFERENCE_ARCHIVE_FOLDER = "archive_folder";
private static final String PREFERENCE_DRAFTS_FOLDER = "drafts_folder"; private static final String PREFERENCE_DRAFTS_FOLDER = "drafts_folder";
@ -114,6 +113,7 @@ public class AccountSettings extends K9PreferenceActivity {
private PreferenceScreen mComposingScreen; private PreferenceScreen mComposingScreen;
private EditTextPreference mAccountDescription; private EditTextPreference mAccountDescription;
private CheckBoxPreference mMarkMessageAsReadOnView;
private ListPreference mCheckFrequency; private ListPreference mCheckFrequency;
private ListPreference mDisplayCount; private ListPreference mDisplayCount;
private ListPreference mMessageAge; private ListPreference mMessageAge;
@ -157,10 +157,7 @@ public class AccountSettings extends K9PreferenceActivity {
private ListPreference mCryptoApp; private ListPreference mCryptoApp;
private CheckBoxPreference mCryptoAutoSignature; private CheckBoxPreference mCryptoAutoSignature;
private CheckBoxPreference mCryptoAutoEncrypt; private CheckBoxPreference mCryptoAutoEncrypt;
private ListPreference mLocalStorageProvider; private ListPreference mLocalStorageProvider;
private ListPreference mArchiveFolder; private ListPreference mArchiveFolder;
private ListPreference mDraftsFolder; private ListPreference mDraftsFolder;
private ListPreference mSentFolder; 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 = (ListPreference) findPreference(PREFERENCE_MESSAGE_FORMAT);
mMessageFormat.setValue(mAccount.getMessageFormat().name()); mMessageFormat.setValue(mAccount.getMessageFormat().name());
mMessageFormat.setSummary(mMessageFormat.getEntry()); mMessageFormat.setSummary(mMessageFormat.getEntry());
@ -672,6 +672,7 @@ public class AccountSettings extends K9PreferenceActivity {
} }
mAccount.setDescription(mAccountDescription.getText()); mAccount.setDescription(mAccountDescription.getText());
mAccount.setMarkMessageAsReadOnView(mMarkMessageAsReadOnView.isChecked());
mAccount.setNotifyNewMail(mAccountNotify.isChecked()); mAccount.setNotifyNewMail(mAccountNotify.isChecked());
mAccount.setNotifySelfNewMail(mAccountNotifySelf.isChecked()); mAccount.setNotifySelfNewMail(mAccountNotifySelf.isChecked());
mAccount.setShowOngoing(mAccountNotifySync.isChecked()); mAccount.setShowOngoing(mAccountNotifySync.isChecked());

View File

@ -2846,7 +2846,7 @@ public class MessagingController implements Runnable {
|| message.getId() == 0) { || message.getId() == 0) {
throw new IllegalArgumentException("Message not found: folder=" + folder + ", uid=" + uid); 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); message.setFlag(Flag.SEEN, true);
setFlag(new Message[] { message }, Flag.SEEN, true); setFlag(new Message[] { message }, Flag.SEEN, true);
} }

View File

@ -96,6 +96,9 @@ public class AccountSettings {
s.put("localStorageProvider", Settings.versions( s.put("localStorageProvider", Settings.versions(
new V(1, new StorageProviderSetting()) new V(1, new StorageProviderSetting())
)); ));
s.put("markMessageAsReadOnView", Settings.versions(
new V(7, new BooleanSetting(true))
));
s.put("maxPushFolders", Settings.versions( s.put("maxPushFolders", Settings.versions(
new V(1, new IntegerRangeSetting(0, 100, 10)) new V(1, new IntegerRangeSetting(0, 100, 10))
)); ));

View File

@ -35,7 +35,7 @@ public class Settings {
* *
* @see SettingsExporter * @see SettingsExporter
*/ */
public static final int VERSION = 6; public static final int VERSION = 7;
public static Map<String, Object> validate(int version, Map<String, public static Map<String, Object> validate(int version, Map<String,
TreeMap<Integer, SettingsDescription>> settings, TreeMap<Integer, SettingsDescription>> settings,