diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4f41d06af..ad3cd20aa 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -456,6 +456,9 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
Show combined Inbox
Notify for mail I sent
Notify even for mail sent from an account identity
+ Notification opens unread messages
+ Searches for unread messages when Notification is opened
+
Scroll navigation buttons
Never
diff --git a/res/xml/account_settings_preferences.xml b/res/xml/account_settings_preferences.xml
index 7048d1860..afde7338d 100644
--- a/res/xml/account_settings_preferences.xml
+++ b/res/xml/account_settings_preferences.xml
@@ -195,6 +195,11 @@
android:title="@string/account_settings_notify_sync_label"
android:defaultValue="true"
android:summary="@string/account_settings_notify_sync_summary" />
+
diff --git a/src/com/fsck/k9/Account.java b/src/com/fsck/k9/Account.java
index 6e8a87d59..181dfa438 100644
--- a/src/com/fsck/k9/Account.java
+++ b/src/com/fsck/k9/Account.java
@@ -84,6 +84,7 @@ public class Account implements BaseAccount
private String mExpungePolicy = EXPUNGE_IMMEDIATELY;
private int mMaxPushFolders;
private int mIdleRefreshMinutes;
+ private boolean goToUnreadMessageSearch;
private Map compressionMap = new ConcurrentHashMap();
private Searchable searchableFolders;
// Tracks if we have sent a notification for this account for
@@ -133,6 +134,7 @@ public class Account implements BaseAccount
mAutoExpandFolderName = "INBOX";
mMaxPushFolders = 10;
mChipColor = 0;
+ goToUnreadMessageSearch = false;
searchableFolders = Searchable.ALL;
@@ -190,7 +192,8 @@ public class Account implements BaseAccount
mExpungePolicy = preferences.getPreferences().getString(mUuid + ".expungePolicy", EXPUNGE_IMMEDIATELY);
mMaxPushFolders = preferences.getPreferences().getInt(mUuid + ".maxPushFolders", 10);
-
+ goToUnreadMessageSearch = preferences.getPreferences().getBoolean(mUuid + ".goToUnreadMessageSearch",
+ true);
for (String type : networkTypes)
{
Boolean useCompression = preferences.getPreferences().getBoolean(mUuid + ".useCompression." + type,
@@ -354,6 +357,7 @@ public class Account implements BaseAccount
editor.remove(mUuid + ".expungePolicy");
editor.remove(mUuid + ".maxPushFolders");
editor.remove(mUuid + ".searchableFolders");
+ editor.remove(mUuid + ".goToUnreadMessageSearch");
for (String type : networkTypes)
{
editor.remove(mUuid + ".useCompression." + type);
@@ -434,6 +438,7 @@ public class Account implements BaseAccount
editor.putInt(mUuid + ".maxPushFolders", mMaxPushFolders);
editor.putString(mUuid + ".searchableFolders", searchableFolders.name());
editor.putInt(mUuid + ".chipColor", mChipColor);
+ editor.putBoolean(mUuid + ".goToUnreadMessageSearch", goToUnreadMessageSearch);
for (String type : networkTypes)
{
@@ -1152,4 +1157,14 @@ public class Account implements BaseAccount
{
mPushPollOnConnect = pushPollOnConnect;
}
+
+ public boolean goToUnreadMessageSearch()
+ {
+ return goToUnreadMessageSearch;
+ }
+
+ public void setGoToUnreadMessageSearch(boolean goToUnreadMessageSearch)
+ {
+ this.goToUnreadMessageSearch = goToUnreadMessageSearch;
+ }
}
diff --git a/src/com/fsck/k9/MessagingController.java b/src/com/fsck/k9/MessagingController.java
index e5ecb63ae..ea385bca4 100644
--- a/src/com/fsck/k9/MessagingController.java
+++ b/src/com/fsck/k9/MessagingController.java
@@ -4520,7 +4520,7 @@ public class MessagingController implements Runnable
Notification notif = new Notification(R.drawable.stat_notify_email_generic, messageNotice, System.currentTimeMillis());
notif.number = unreadMessageCount;
- Intent i = FolderList.actionHandleAccountIntent(context, account, account.getAutoExpandFolderName());
+ Intent i = FolderList.actionHandleNotification(context, account, account.getAutoExpandFolderName());
PendingIntent pi = PendingIntent.getActivity(context, 0, i, 0);
String accountNotice = context.getString(R.string.notification_new_one_account_fmt, unreadMessageCount, account.getDescription());
diff --git a/src/com/fsck/k9/activity/FolderList.java b/src/com/fsck/k9/activity/FolderList.java
index 8f0269d57..c97194a10 100644
--- a/src/com/fsck/k9/activity/FolderList.java
+++ b/src/com/fsck/k9/activity/FolderList.java
@@ -48,10 +48,7 @@ public class FolderList extends K9ListActivity
private static final String EXTRA_ACCOUNT = "account";
private static final String EXTRA_INITIAL_FOLDER = "initialFolder";
-
- //private static final String STATE_CURRENT_FOLDER = "com.fsck.k9.activity.folderlist_folder";
-
- private static final String EXTRA_CLEAR_NOTIFICATION = "clearNotification";
+ private static final String EXTRA_FROM_NOTIFICATION = "fromNotification";
private static final boolean REFRESH_REMOTE = true;
@@ -227,7 +224,7 @@ public class FolderList extends K9ListActivity
actionHandleAccount(context, account, null);
}
- public static Intent actionHandleAccountIntent(Context context, Account account, String initialFolder)
+ public static Intent actionHandleNotification(Context context, Account account, String initialFolder)
{
Intent intent = new Intent(
Intent.ACTION_VIEW,
@@ -236,7 +233,7 @@ public class FolderList extends K9ListActivity
FolderList.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.putExtra(EXTRA_ACCOUNT, account.getUuid());
- intent.putExtra(EXTRA_CLEAR_NOTIFICATION, true);
+ intent.putExtra(EXTRA_FROM_NOTIFICATION, true);
if (initialFolder != null)
{
@@ -245,11 +242,6 @@ public class FolderList extends K9ListActivity
return intent;
}
- public static Intent actionHandleAccountIntent(Context context, Account account)
- {
- return actionHandleAccountIntent(context, account, null);
- }
-
@Override
public void onCreate(Bundle savedInstanceState)
{
@@ -290,9 +282,13 @@ public class FolderList extends K9ListActivity
mAccount = Preferences.getPreferences(this).getAccount(accountUuid);
initialFolder = intent.getStringExtra(EXTRA_INITIAL_FOLDER);
- if (
- initialFolder != null
- && !K9.FOLDER_NONE.equals(initialFolder))
+ boolean fromNotification = intent.getBooleanExtra(EXTRA_FROM_NOTIFICATION, false);
+ if (fromNotification && mAccount.goToUnreadMessageSearch())
+ {
+ openUnreadSearch(this, mAccount);
+ finish();
+ }
+ else if (initialFolder != null && !K9.FOLDER_NONE.equals(initialFolder))
{
onOpenFolder(initialFolder);
finish();
@@ -1496,6 +1492,52 @@ public class FolderList extends K9ListActivity
}
-
+ private static Flag[] UNREAD_FLAG_ARRAY = { Flag.SEEN };
+
+ private void openUnreadSearch(Context context, final Account account)
+ {
+ String description = getString(R.string.search_title, mAccount.getDescription(), getString(R.string.unread_modifier));
+
+ SearchSpecification searchSpec = new SearchSpecification()
+ {
+ @Override
+ public String[] getAccountUuids()
+ {
+ return new String[] { account.getUuid() };
+ }
+
+ @Override
+ public Flag[] getForbiddenFlags()
+ {
+ return UNREAD_FLAG_ARRAY;
+ }
+
+ @Override
+ public String getQuery()
+ {
+ return "";
+ }
+
+ @Override
+ public Flag[] getRequiredFlags()
+ {
+ return null;
+ }
+
+ @Override
+ public boolean isIntegrate()
+ {
+ return false;
+ }
+
+ @Override
+ public String[] getFolderNames()
+ {
+ return null;
+ }
+
+ };
+ MessageList.actionHandle(context, description, searchSpec);
+ }
}
diff --git a/src/com/fsck/k9/activity/setup/AccountSettings.java b/src/com/fsck/k9/activity/setup/AccountSettings.java
index 2c2f62cd7..22e0f7740 100644
--- a/src/com/fsck/k9/activity/setup/AccountSettings.java
+++ b/src/com/fsck/k9/activity/setup/AccountSettings.java
@@ -49,6 +49,8 @@ public class AccountSettings extends K9PreferenceActivity
private static final String PREFERENCE_AUTO_EXPAND_FOLDER = "account_setup_auto_expand_folder";
private static final String PREFERENCE_SEARCHABLE_FOLDERS = "searchable_folders";
private static final String PREFERENCE_CHIP_COLOR = "chip_color";
+ private static final String PREFERENCE_NOTIFICATION_OPENS_UNREAD = "notification_opens_unread";
+
private Account mAccount;
@@ -73,6 +75,7 @@ public class AccountSettings extends K9PreferenceActivity
private Preference mAutoExpandFolder;
private Preference mChipColor;
private boolean mIncomingChanged = false;
+ private CheckBoxPreference mNotificationOpensUnread;
public static void actionSettings(Context context, Account account)
@@ -301,6 +304,10 @@ public class AccountSettings extends K9PreferenceActivity
mAccountVibrate = (CheckBoxPreference) findPreference(PREFERENCE_VIBRATE);
mAccountVibrate.setChecked(mAccount.isVibrate());
+
+ mNotificationOpensUnread = (CheckBoxPreference)findPreference(PREFERENCE_NOTIFICATION_OPENS_UNREAD);
+ mNotificationOpensUnread.setChecked(mAccount.goToUnreadMessageSearch());
+
mAutoExpandFolder = (Preference)findPreference(PREFERENCE_AUTO_EXPAND_FOLDER);
@@ -395,6 +402,7 @@ public class AccountSettings extends K9PreferenceActivity
mAccount.setShowOngoing(mAccountNotifySync.isChecked());
mAccount.setDisplayCount(Integer.parseInt(mDisplayCount.getValue()));
mAccount.setVibrate(mAccountVibrate.isChecked());
+ mAccount.setGoToUnreadMessageSearch(mNotificationOpensUnread.isChecked());
mAccount.setFolderTargetMode(Account.FolderMode.valueOf(mTargetMode.getValue()));
mAccount.setDeletePolicy(Integer.parseInt(mDeletePolicy.getValue()));
mAccount.setExpungePolicy(mExpungePolicy.getValue());