From 7305cf5c8e8332e720da758d3a81267cf8bb7d4b Mon Sep 17 00:00:00 2001 From: Todd Kennedy Date: Tue, 7 Jun 2011 17:12:34 -0700 Subject: [PATCH] update account spinner properly Fixes two issues: 1. if a recent folder was selected from the spinner, the user could not re-select it (even if they navigated to another mailbox using the mailbox list) unless they manually selected another element in the spinner 2. the recent item "show all folders" did not set the associated account position, so, when selecting that item, the spinner was not showing the correct view. Change-Id: I469f9f28aebd36a348534def28a4c476c0df366d --- src/com/android/email/activity/AccountSelectorAdapter.java | 4 ++-- src/com/android/email/activity/ActionBarController.java | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/com/android/email/activity/AccountSelectorAdapter.java b/src/com/android/email/activity/AccountSelectorAdapter.java index 96b77b986..53546d665 100644 --- a/src/com/android/email/activity/AccountSelectorAdapter.java +++ b/src/com/android/email/activity/AccountSelectorAdapter.java @@ -210,7 +210,7 @@ public class AccountSelectorAdapter extends CursorAdapter { return c.moveToPosition(position) ? getAccountUnreadCount(c) : 0; } - private int getAccountPosition(int position) { + int getAccountPosition(int position) { final Cursor c = getCursor(); return c.moveToPosition(position) ? getAccountPosition(c) : UNKNOWN_POSITION; } @@ -358,7 +358,7 @@ public class AccountSelectorAdapter extends CursorAdapter { String name = mContext.getString( R.string.mailbox_list_account_selector_show_all_folders); addRow(matrixCursor, ROW_TYPE_MAILBOX, Mailbox.NO_MAILBOX, name, null, 0, - UNKNOWN_POSITION); + accountPosition); } } diff --git a/src/com/android/email/activity/ActionBarController.java b/src/com/android/email/activity/ActionBarController.java index 5173de372..2d95ea444 100644 --- a/src/com/android/email/activity/ActionBarController.java +++ b/src/com/android/email/activity/ActionBarController.java @@ -238,6 +238,12 @@ public class ActionBarController { mCallback.onAccountSelected(itemId); } else if (!mAccountsSelectorAdapter.isAccountItem(itemPosition)) { mCallback.onMailboxSelected(itemId); + // We need to update the selection, otherwise the user is unable to select the + // recent folder a second time w/o first selecting another item in the spinner + int selectedPosition = mAccountsSelectorAdapter.getAccountPosition(itemPosition); + if (selectedPosition != AccountSelectorAdapter.UNKNOWN_POSITION) { + mActionBar.setSelectedNavigationItem(selectedPosition); + } } return true; }