Fix & clean up intent handling

- Make sure an account shortcut really opens the account by
  adding the FLAG_ACTIVITY_CLEAR_TOP flag to shortcuts

  * Shortcuts have to be re-created for this fix to take effect.

- Remove Welcome.createOpenCombinedInbox/OutboxIntent, which don't work
  with the new combined view.

  * createOpenCombinedInboxIntent() is not used already
  * createOpenCombinedOutboxIntent() is used, but is not final UI, so
    removing it is okay.

- Fix MessageListXL.actionOpenMailbox -- now it really uses the passed
  mailbox ID.

Bug 3144066

Change-Id: I2ee3f84c62a135351c10266c7ca6d5178c3a0ca2
This commit is contained in:
Makoto Onuki 2010-11-02 17:38:29 -07:00
parent 278cb8e3d5
commit 7126e5ae53
3 changed files with 11 additions and 26 deletions

View File

@ -235,8 +235,11 @@ public class NotificationController {
*/
public void showWarningNotification(int id, String tickerText, String notificationText,
Intent intent) {
PendingIntent pendingIntent =
PendingIntent.getActivity(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent pendingIntent = null;
if (intent != null) {
pendingIntent = PendingIntent.getActivity(mContext, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT);
}
Notification n = new Notification(android.R.drawable.stat_notify_error, tickerText,
System.currentTimeMillis());
n.setLatestEventInfo(mContext, tickerText, notificationText, pendingIntent);
@ -252,8 +255,7 @@ public class NotificationController {
showWarningNotification(NOTIFICATION_ID_ATTACHMENT_WARNING,
mContext.getString(R.string.forward_download_failed_ticker),
mContext.getString(R.string.forward_download_failed_notification,
att.mFileName),
Welcome.createOpenCombinedOutboxIntent(mContext));
att.mFileName), null);
}
/**

View File

@ -92,7 +92,8 @@ public class MessageListXL extends Activity implements
* Launch and open a mailbox.
*
* @param accountId must not be -1.
* @param mailboxId must not be -1.
* @param mailboxId must not be -1. Magic mailboxes IDs (such as
* {@link Mailbox#QUERY_ALL_INBOXES}) don't work.
*/
public static void actionOpenMailbox(Activity fromActivity, long accountId, long mailboxId) {
Intent i = new Intent(fromActivity, MessageListXL.class);
@ -100,7 +101,7 @@ public class MessageListXL extends Activity implements
throw new InvalidParameterException();
}
i.putExtra(EXTRA_ACCOUNT_ID, accountId);
i.putExtra(EXTRA_MAILBOX_ID, Mailbox.QUERY_ALL_INBOXES);
i.putExtra(EXTRA_MAILBOX_ID, mailboxId);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
fromActivity.startActivity(i);
}
@ -138,8 +139,7 @@ public class MessageListXL extends Activity implements
final long accountId = i.getLongExtra(EXTRA_ACCOUNT_ID, -1);
final long mailboxId = i.getLongExtra(EXTRA_MAILBOX_ID, -1);
if (Email.DEBUG) {
Log.d(Email.LOG_TAG,
String.format("Welcome: %d %d", accountId, mailboxId));
Log.d(Email.LOG_TAG, String.format("initFromIntent: %d %d", accountId, mailboxId));
}
if (accountId != -1) {

View File

@ -103,30 +103,13 @@ public class Welcome extends Activity {
*/
public static Intent createOpenAccountInboxIntent(Context context, long accountId) {
Intent i = new Intent(context, Welcome.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
if (accountId != -1) {
i.putExtra(EXTRA_ACCOUNT_ID, accountId);
}
return i;
}
/**
* Create an Intent to open "Combined Outbox".
*/
public static Intent createOpenCombinedInboxIntent(Context context) {
Intent i = new Intent(context, Welcome.class);
i.putExtra(EXTRA_MAILBOX_ID, Mailbox.QUERY_ALL_INBOXES);
return i;
}
/**
* Create an Intent to open "Combined Inbox".
*/
public static Intent createOpenCombinedOutboxIntent(Context context) {
Intent i = new Intent(context, Welcome.class);
i.putExtra(EXTRA_MAILBOX_ID, Mailbox.QUERY_ALL_OUTBOX);
return i;
}
/**
* Open account's inbox.
*/