From e529bed2594981bd11b9342c5f31a6795f620298 Mon Sep 17 00:00:00 2001 From: cketti Date: Sun, 20 Jun 2010 12:15:29 +0000 Subject: [PATCH] Added option to return to the message list after deleting a message in the message view activity. Patch provided by fiouzy (Thanks!) Fixes issue 1634 --- res/values/strings.xml | 2 ++ res/xml/global_preferences.xml | 9 +++++++-- src/com/fsck/k9/K9.java | 14 +++++++++++++- src/com/fsck/k9/activity/MessageView.java | 9 ++++++++- src/com/fsck/k9/activity/setup/Prefs.java | 6 +++++- 5 files changed, 35 insertions(+), 5 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 55f8f4513..2648a73b7 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -298,6 +298,8 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin Fixed-width fonts Use a fixed-width font when showing plain-text messages + Return to list after delete + Return to message list after message deletion Set up a new account Enter this account\'s email address: diff --git a/res/xml/global_preferences.xml b/res/xml/global_preferences.xml index 557343b13..e484588c0 100644 --- a/res/xml/global_preferences.xml +++ b/res/xml/global_preferences.xml @@ -90,12 +90,17 @@ + + + - /> diff --git a/src/com/fsck/k9/K9.java b/src/com/fsck/k9/K9.java index e522b945b..d154b6fdb 100644 --- a/src/com/fsck/k9/K9.java +++ b/src/com/fsck/k9/K9.java @@ -10,7 +10,6 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.net.Uri; -import android.os.Environment; import android.util.Log; import android.webkit.WebSettings; @@ -80,6 +79,7 @@ public class K9 extends Application private static boolean mMessageListTouchable = false; private static boolean mMessageViewFixedWidthFont = false; + private static boolean mMessageViewReturnToList = false; private static boolean mGesturesEnabled = true; private static boolean mManageBack = false; @@ -309,6 +309,7 @@ public class K9 extends Application editor.putBoolean("messageListTouchable",mMessageListTouchable); editor.putBoolean("messageViewFixedWidthFont",mMessageViewFixedWidthFont); + editor.putBoolean("messageViewReturnToList", mMessageViewReturnToList); editor.putInt("theme", theme); editor.putBoolean("useGalleryBugWorkaround", useGalleryBugWorkaround); @@ -338,6 +339,7 @@ public class K9 extends Application mMessageListTouchable = sprefs.getBoolean("messageListTouchable",false); mMessageViewFixedWidthFont = sprefs.getBoolean("messageViewFixedWidthFont", false); + mMessageViewReturnToList = sprefs.getBoolean("messageViewReturnToList", false); useGalleryBugWorkaround = sprefs.getBoolean("useGalleryBugWorkaround", K9.isGalleryBuggy()); @@ -524,6 +526,16 @@ public class K9 extends Application mMessageViewFixedWidthFont = fixed; } + public static boolean messageViewReturnToList() + { + return mMessageViewReturnToList; + } + + public static void setMessageViewReturnToList(boolean messageViewReturnToList) + { + mMessageViewReturnToList = messageViewReturnToList; + } + private static Method getMethod(Class classObject, String methodName) { try diff --git a/src/com/fsck/k9/activity/MessageView.java b/src/com/fsck/k9/activity/MessageView.java index 34e388e73..a240975eb 100644 --- a/src/com/fsck/k9/activity/MessageView.java +++ b/src/com/fsck/k9/activity/MessageView.java @@ -863,7 +863,14 @@ public class MessageView extends K9Activity implements OnClickListener { Message messageToDelete = mMessage; - showNextMessage(); + if (K9.messageViewReturnToList()) + { + finish(); + } + else + { + showNextMessage(); + } MessagingController.getInstance(getApplication()).deleteMessages( new Message[] { messageToDelete }, diff --git a/src/com/fsck/k9/activity/setup/Prefs.java b/src/com/fsck/k9/activity/setup/Prefs.java index 0efa66d1d..3e1ec9262 100644 --- a/src/com/fsck/k9/activity/setup/Prefs.java +++ b/src/com/fsck/k9/activity/setup/Prefs.java @@ -18,7 +18,6 @@ import com.fsck.k9.service.MailService; public class Prefs extends K9PreferenceActivity { - private static final String PREFERENCE_THEME = "theme"; private static final String PREFERENCE_FONT_SIZE = "font_size"; private static final String PREFERENCE_DATE_FORMAT = "dateFormat"; @@ -34,6 +33,7 @@ public class Prefs extends K9PreferenceActivity private static final String PREFERENCE_MESSAGELIST_TOUCHABLE = "messagelist_touchable"; private static final String PREFERENCE_MESSAGEVIEW_FIXEDWIDTH = "messageview_fixedwidth_font"; + private static final String PREFERENCE_MESSAGEVIEW_RETURN_TO_LIST = "messageview_return_to_list"; private static final String PREFERENCE_MEASURE_ACCOUNTS = "measure_accounts"; private static final String PREFERENCE_COUNT_SEARCH = "count_search"; @@ -51,6 +51,7 @@ public class Prefs extends K9PreferenceActivity private CheckBoxPreference mTouchable; private CheckBoxPreference mFixedWidth; + private CheckBoxPreference mReturnToList; private CheckBoxPreference mMeasureAccounts; private CheckBoxPreference mCountSearch; @@ -169,6 +170,8 @@ public class Prefs extends K9PreferenceActivity mFixedWidth = (CheckBoxPreference)findPreference(PREFERENCE_MESSAGEVIEW_FIXEDWIDTH); mFixedWidth.setChecked(K9.messageViewFixedWidthFont()); + mReturnToList = (CheckBoxPreference) findPreference(PREFERENCE_MESSAGEVIEW_RETURN_TO_LIST); + mReturnToList.setChecked(K9.messageViewReturnToList()); mMeasureAccounts = (CheckBoxPreference)findPreference(PREFERENCE_MEASURE_ACCOUNTS); mMeasureAccounts.setChecked(K9.measureAccounts()); @@ -202,6 +205,7 @@ public class Prefs extends K9PreferenceActivity K9.setMessageListTouchable(mTouchable.isChecked()); K9.setMessageViewFixedWidthFont(mFixedWidth.isChecked()); + K9.setMessageViewReturnToList(mReturnToList.isChecked()); K9.setMeasureAccounts(mMeasureAccounts.isChecked()); K9.setCountSearchMessages(mCountSearch.isChecked());