From 79fab5ae623ea75ba526e2673fe6749066b177e4 Mon Sep 17 00:00:00 2001 From: Jorge Lugo Date: Thu, 21 Jul 2011 14:46:57 -0700 Subject: [PATCH] Improved shortcut name Shortcut name is now the name of folder when it's a non-inbox folder; otherwise it's the account name. Previously was always account name. Bug: 4903490 Change-Id: I15b4024d28db6a48464e423db887bdca99132423 --- src/com/android/email/activity/ShortcutPicker.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/com/android/email/activity/ShortcutPicker.java b/src/com/android/email/activity/ShortcutPicker.java index 3282a7a95..94d6f05bb 100644 --- a/src/com/android/email/activity/ShortcutPicker.java +++ b/src/com/android/email/activity/ShortcutPicker.java @@ -31,6 +31,7 @@ import com.android.email.activity.ShortcutPickerFragment.PickerCallback; import com.android.emailcommon.Logging; import com.android.emailcommon.provider.Account; import com.android.emailcommon.provider.EmailContent.Message; +import com.android.emailcommon.provider.Mailbox; /** * This class implements a launcher shortcut for directly accessing a single account. @@ -87,7 +88,14 @@ public class ShortcutPicker extends Activity implements OnClickListener, PickerC @Override public void onSelected(Account account, long mailboxId) { - setupShortcut(account, mailboxId); + String shortcutName; + if (Account.isNormalAccount(account.mId) && + (Mailbox.getMailboxType(this, mailboxId) != Mailbox.TYPE_INBOX)) { + shortcutName = Mailbox.getDisplayName(this, mailboxId); + } else { + shortcutName = account.getDisplayName(); + } + setupShortcut(account, mailboxId, shortcutName); finish(); } @@ -124,7 +132,7 @@ public class ShortcutPicker extends Activity implements OnClickListener, PickerC * with an appropriate Uri for your content, but any Intent will work here as long as it * triggers the desired action within your Activity. */ - private void setupShortcut(Account account, long mailboxId) { + private void setupShortcut(Account account, long mailboxId, String shortcutName) { Activity myActivity = this; // First, set up the shortcut intent. final Intent shortcutIntent; @@ -145,7 +153,7 @@ public class ShortcutPicker extends Activity implements OnClickListener, PickerC // Then, set up the container intent (the response to the caller) Intent intent = new Intent(); intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); - intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, account.getDisplayName()); + intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, shortcutName); Parcelable iconResource = Intent.ShortcutIconResource.fromContext(myActivity, R.mipmap.ic_launcher_email); intent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, iconResource);