diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 92884616c..4f6f217a9 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -66,7 +66,6 @@ @@ -88,7 +87,6 @@ android:label="@string/prefs_title" android:configChanges="locale" android:taskAffinity="com.fsck.k9.activity.setup.Prefs" - android:launchMode="singleTask" android:excludeFromRecents="true" > @@ -203,7 +201,6 @@ @@ -214,7 +211,6 @@ diff --git a/src/com/fsck/k9/activity/Accounts.java b/src/com/fsck/k9/activity/Accounts.java index 0bdd3dc8a..0c0b6b336 100644 --- a/src/com/fsck/k9/activity/Accounts.java +++ b/src/com/fsck/k9/activity/Accounts.java @@ -325,25 +325,14 @@ public class Accounts extends K9ListActivity implements OnItemClickListener { public static final String EXTRA_STARTUP = "startup"; - public static void actionLaunch(Context context) { - Intent intent = new Intent(context, Accounts.class); - intent.putExtra(EXTRA_STARTUP, true); - context.startActivity(intent); - } - public static void listAccounts(Context context) { Intent intent = new Intent(context, Accounts.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | + Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK); intent.putExtra(EXTRA_STARTUP, false); context.startActivity(intent); } - public static void listAccountsClearTop(Context context) { - Intent intent = new Intent(context, Accounts.class); - intent.putExtra(EXTRA_STARTUP, false); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - context.startActivity(intent); - } - @Override public void onNewIntent(Intent intent) { Uri uri = intent.getData(); @@ -1341,6 +1330,7 @@ public class Accounts extends K9ListActivity implements OnItemClickListener { private void onImport() { Intent i = new Intent(Intent.ACTION_GET_CONTENT); + i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType(MimeUtility.K9_SETTINGS_MIME_TYPE); diff --git a/src/com/fsck/k9/activity/FolderList.java b/src/com/fsck/k9/activity/FolderList.java index b408aca6f..0ae7e0b30 100644 --- a/src/com/fsck/k9/activity/FolderList.java +++ b/src/com/fsck/k9/activity/FolderList.java @@ -241,16 +241,9 @@ public class FolderList extends K9ListActivity implements OnNavigationListener { sendMail(mAccount); } - public static Intent actionHandleAccountIntent(Context context, Account account) { - return actionHandleAccountIntent(context, account, null, false); - } - - public static Intent actionHandleAccountIntent(Context context, Account account, String initialFolder) { - return actionHandleAccountIntent(context, account, initialFolder, false); - } - public static Intent actionHandleAccountIntent(Context context, Account account, String initialFolder, boolean fromShortcut) { Intent intent = new Intent(context, FolderList.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(EXTRA_ACCOUNT, account.getUuid()); if (initialFolder != null) { @@ -264,13 +257,9 @@ public class FolderList extends K9ListActivity implements OnNavigationListener { return intent; } - private static void actionHandleAccount(Context context, Account account, String initialFolder) { - Intent intent = actionHandleAccountIntent(context, account, initialFolder); - context.startActivity(intent); - } - public static void actionHandleAccount(Context context, Account account) { - actionHandleAccount(context, account, null); + Intent intent = actionHandleAccountIntent(context, account, null, false); + context.startActivity(intent); } public static Intent actionHandleNotification(Context context, Account account, String initialFolder) { @@ -279,7 +268,7 @@ public class FolderList extends K9ListActivity implements OnNavigationListener { Uri.parse("email://accounts/" + account.getAccountNumber()), context, FolderList.class); - intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(EXTRA_ACCOUNT, account.getUuid()); intent.putExtra(EXTRA_FROM_NOTIFICATION, true); @@ -418,7 +407,7 @@ public class FolderList extends K9ListActivity implements OnNavigationListener { if (!mAccount.isAvailable(this)) { Log.i(K9.LOG_TAG, "account unavaliabale, not showing folder-list but account-list"); - startActivity(new Intent(this, Accounts.class)); + Accounts.listAccounts(this); finish(); return; } @@ -434,16 +423,6 @@ public class FolderList extends K9ListActivity implements OnNavigationListener { MessagingController.getInstance(getApplication()).notifyAccountCancel(this, mAccount); } - - @Override - public void onBackPressed() { - if (K9.manageBack()) { - onAccounts(); - } else { - super.onBackPressed(); - } - } - @Override public boolean onKeyDown(int keyCode, KeyEvent event) { //Shortcuts that work no matter what is selected @@ -643,9 +622,6 @@ public class FolderList extends K9ListActivity implements OnNavigationListener { private void onOpenFolder(String folder) { MessageList.actionHandleFolder(this, mAccount, folder); - if (K9.manageBack()) { - finish(); - } } private void onCompact(Account account) { diff --git a/src/com/fsck/k9/activity/LauncherShortcuts.java b/src/com/fsck/k9/activity/LauncherShortcuts.java index 61bde33ca..415689057 100644 --- a/src/com/fsck/k9/activity/LauncherShortcuts.java +++ b/src/com/fsck/k9/activity/LauncherShortcuts.java @@ -38,7 +38,6 @@ public class LauncherShortcuts extends AccountList { true); } - shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); String description = account.getDescription(); diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index f2fbe701d..2bf60f83f 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -588,24 +588,27 @@ public class MessageList extends K9ListActivity implements OnItemClickListener, */ public static void actionHandleFolder(Context context, Bundle extras) { Intent intent = new Intent(context, MessageList.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtras(extras); intent.putExtra(EXTRA_RETURN_FROM_MESSAGE_VIEW, true); context.startActivity(intent); } public static void actionHandleFolder(Context context, Account account, String folder) { - Intent intent = actionHandleFolderIntent(context, account, folder); + Intent intent = new Intent(context, MessageList.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); + intent.putExtra(EXTRA_ACCOUNT, account.getUuid()); + + if (folder != null) { + intent.putExtra(EXTRA_FOLDER, folder); + } context.startActivity(intent); } public static Intent actionHandleFolderIntent(Context context, Account account, String folder) { Intent intent = new Intent(context, MessageList.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | + Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(EXTRA_ACCOUNT, account.getUuid()); if (folder != null) { @@ -616,6 +619,7 @@ public class MessageList extends K9ListActivity implements OnItemClickListener, public static void actionHandle(Context context, String title, String queryString, boolean integrate, Flag[] flags, Flag[] forbiddenFlags) { Intent intent = new Intent(context, MessageList.class); + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(EXTRA_QUERY, queryString); if (flags != null) { intent.putExtra(EXTRA_QUERY_FLAGS, Utility.combine(flags, ',')); @@ -625,9 +629,6 @@ public class MessageList extends K9ListActivity implements OnItemClickListener, } intent.putExtra(EXTRA_INTEGRATE, integrate); intent.putExtra(EXTRA_TITLE, title); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); context.startActivity(intent); } @@ -992,19 +993,6 @@ public class MessageList extends K9ListActivity implements OnItemClickListener, return (ActivityState) super.getLastNonConfigurationInstance(); } - @Override - public void onBackPressed() { - if (K9.manageBack()) { - if (mQueryString == null) { - onShowFolderList(); - } else { - onAccounts(); - } - } else { - super.onBackPressed(); - } - } - @Override public boolean onKeyDown(int keyCode, KeyEvent event) { // Shortcuts that work no matter what is selected diff --git a/src/com/fsck/k9/activity/MessageView.java b/src/com/fsck/k9/activity/MessageView.java index 3eebea478..cc0aece75 100644 --- a/src/com/fsck/k9/activity/MessageView.java +++ b/src/com/fsck/k9/activity/MessageView.java @@ -245,18 +245,6 @@ public class MessageView extends K9Activity implements OnClickListener { return super.onKeyUp(keyCode, event); } - @Override - public void onBackPressed() { - if (K9.manageBack()) { - if (mMessageListExtras != null) { - MessageList.actionHandleFolder(this, mMessageListExtras); - } - finish(); - } else { - super.onBackPressed(); - } - } - class MessageViewHandler extends Handler { public void progress(final boolean progress) { @@ -301,10 +289,10 @@ public class MessageView extends K9Activity implements OnClickListener { public static void actionView(Context context, MessageReference messRef, ArrayList messReferences, Bundle messageListExtras) { Intent i = new Intent(context, MessageView.class); + i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); i.putExtra(EXTRA_MESSAGE_LIST_EXTRAS, messageListExtras); i.putExtra(EXTRA_MESSAGE_REFERENCE, messRef); i.putParcelableArrayListExtra(EXTRA_MESSAGE_REFERENCES, messReferences); - i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(i); } diff --git a/src/com/fsck/k9/activity/setup/AccountSetupNames.java b/src/com/fsck/k9/activity/setup/AccountSetupNames.java index 95c8ee490..61702c52f 100644 --- a/src/com/fsck/k9/activity/setup/AccountSetupNames.java +++ b/src/com/fsck/k9/activity/setup/AccountSetupNames.java @@ -86,7 +86,7 @@ public class AccountSetupNames extends K9Activity implements OnClickListener { } mAccount.setName(mName.getText().toString()); mAccount.save(Preferences.getPreferences(this)); - Accounts.listAccountsClearTop(this); + Accounts.listAccounts(this); finish(); } diff --git a/src/com/fsck/k9/provider/UnreadWidgetProvider.java b/src/com/fsck/k9/provider/UnreadWidgetProvider.java index 616707c34..2af479d15 100644 --- a/src/com/fsck/k9/provider/UnreadWidgetProvider.java +++ b/src/com/fsck/k9/provider/UnreadWidgetProvider.java @@ -59,7 +59,8 @@ public class UnreadWidgetProvider extends AppWidgetProvider { unreadCount = stats.unreadMessageCount; accountName = account.getDescription(); if (K9.FOLDER_NONE.equals(account.getAutoExpandFolderName())) { - clickIntent = FolderList.actionHandleAccountIntent(context, account, null); + clickIntent = FolderList.actionHandleAccountIntent(context, account, null, + false); } else { clickIntent = MessageList.actionHandleFolderIntent(context, account, account.getAutoExpandFolderName());