1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-12-26 01:28:50 -05:00

Changed the way we use the activity stack

- removed launchMode attributes for all activities
- only use one activity task
- got rid of "managed back button" behavior
This commit is contained in:
cketti 2012-09-07 02:39:57 +02:00
parent 8daea241af
commit d8e9c48177
8 changed files with 23 additions and 85 deletions

View File

@ -66,7 +66,6 @@
<activity
android:name="com.fsck.k9.activity.Accounts"
android:launchMode="singleTask"
android:configChanges="locale"
android:uiOptions="splitActionBarWhenNarrow"
android:label="@string/app_name">
@ -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"
>
</activity>
@ -203,7 +201,6 @@
</activity>
<activity
android:name="com.fsck.k9.activity.FolderList"
android:launchMode="singleTask"
android:configChanges="locale"
android:uiOptions="splitActionBarWhenNarrow"
>
@ -214,7 +211,6 @@
</activity>
<activity
android:name="com.fsck.k9.activity.MessageList"
android:launchMode="singleTask"
android:configChanges="locale"
android:uiOptions="splitActionBarWhenNarrow"
>

View File

@ -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);

View File

@ -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) {

View File

@ -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();

View File

@ -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

View File

@ -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<MessageReference> 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);
}

View File

@ -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();
}

View File

@ -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());