mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-27 11:42:16 -05:00
Fixes Issue 1561
The user can elect to have opening a Notification open a account-specific search for unread messages.
This commit is contained in:
parent
8b92bc3836
commit
1502660826
@ -456,6 +456,9 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
|
||||
<string name="account_settings_show_combined_label">Show combined Inbox</string>
|
||||
<string name="account_settings_notify_self_label">Notify for mail I sent</string>
|
||||
<string name="account_settings_notify_self_summary">Notify even for mail sent from an account identity</string>
|
||||
<string name="account_settings_notification_opens_unread_label">Notification opens unread messages</string>
|
||||
<string name="account_settings_notification_opens_unread_summary">Searches for unread messages when Notification is opened</string>
|
||||
|
||||
|
||||
<string name="account_settings_hide_buttons_label">Scroll navigation buttons</string>
|
||||
<string name="account_settings_hide_buttons_never">Never</string>
|
||||
|
@ -195,6 +195,11 @@
|
||||
android:title="@string/account_settings_notify_sync_label"
|
||||
android:defaultValue="true"
|
||||
android:summary="@string/account_settings_notify_sync_summary" />
|
||||
<CheckBoxPreference
|
||||
android:key="notification_opens_unread"
|
||||
android:title="@string/account_settings_notification_opens_unread_label"
|
||||
android:defaultValue="true"
|
||||
android:summary="@string/account_settings_notification_opens_unread_summary" />
|
||||
|
||||
</PreferenceCategory>
|
||||
|
||||
|
@ -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<String, Boolean> compressionMap = new ConcurrentHashMap<String, Boolean>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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)
|
||||
@ -302,6 +305,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);
|
||||
|
||||
mAutoExpandFolder.setSummary(translateFolder(mAccount.getAutoExpandFolderName()));
|
||||
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user