From 18748499afa53216fe8ebab32d5dbf7248dfe904 Mon Sep 17 00:00:00 2001 From: Sander Bogaert Date: Mon, 16 Jul 2012 15:14:27 -0400 Subject: [PATCH] Generalize ActionBarNavigationSpinner creation. --- src/com/fsck/k9/activity/FolderList.java | 10 +++------- src/com/fsck/k9/activity/MessageList.java | 8 ++------ src/com/fsck/k9/helper/ActionBarNavigationSpinner.java | 10 ++++++++++ 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/com/fsck/k9/activity/FolderList.java b/src/com/fsck/k9/activity/FolderList.java index 60cc712c5..fe1a4cad0 100644 --- a/src/com/fsck/k9/activity/FolderList.java +++ b/src/com/fsck/k9/activity/FolderList.java @@ -106,6 +106,7 @@ public class FolderList extends K9ListActivity implements OnNavigationListener { private Context context; private MenuItem mRefreshMenuItem; private View mActionBarProgressView; + private ActionBarNavigationSpinner mNavigationSpinner; class FolderListHandler extends Handler { @@ -311,13 +312,8 @@ public class FolderList extends K9ListActivity implements OnNavigationListener { actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); - actionBar.setListNavigationCallbacks( - new ActionBarNavigationSpinner(this, - new String[] {"Inbox", "Folders", "Accounts"}, - new Long[] {ActionBarNavigationSpinner.AB_NAVIGATION_INBOX, - ActionBarNavigationSpinner.AB_NAVIGATION_FOLDERS, - ActionBarNavigationSpinner.AB_NAVIGATION_ACCOUNTS }), - this); + mNavigationSpinner = ActionBarNavigationSpinner.getDefaultSpinner(this); + actionBar.setListNavigationCallbacks(mNavigationSpinner, this); actionBar.setSelectedNavigationItem(1); } diff --git a/src/com/fsck/k9/activity/MessageList.java b/src/com/fsck/k9/activity/MessageList.java index 15cf3290e..80266555c 100644 --- a/src/com/fsck/k9/activity/MessageList.java +++ b/src/com/fsck/k9/activity/MessageList.java @@ -537,7 +537,7 @@ public class MessageList } String dispString = mAdapter.mListener.formatHeader(MessageList.this, getString(R.string.message_list_title, mAccount.getDescription(), displayName), mUnreadMessageCount, getTimeFormat()); - //setTitle(dispString); + mNavigationSpinner.setTitle(mFolderName); mNavigationSpinner.setSubTitle(mAccount.getEmail()); } else if (mQueryString != null) { @@ -907,11 +907,7 @@ public class MessageList ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); - mNavigationSpinner = new ActionBarNavigationSpinner(this, - new String[] {"Inbox", "Folders", "Accounts"}, - new Long[] {ActionBarNavigationSpinner.AB_NAVIGATION_INBOX, - ActionBarNavigationSpinner.AB_NAVIGATION_FOLDERS, - ActionBarNavigationSpinner.AB_NAVIGATION_ACCOUNTS }); + mNavigationSpinner = ActionBarNavigationSpinner.getDefaultSpinner(this); actionBar.setListNavigationCallbacks(mNavigationSpinner, this); } diff --git a/src/com/fsck/k9/helper/ActionBarNavigationSpinner.java b/src/com/fsck/k9/helper/ActionBarNavigationSpinner.java index 1f0590a0d..43114ac28 100644 --- a/src/com/fsck/k9/helper/ActionBarNavigationSpinner.java +++ b/src/com/fsck/k9/helper/ActionBarNavigationSpinner.java @@ -82,4 +82,14 @@ public class ActionBarNavigationSpinner extends ArrayAdapter implements public long getItemId(int position) { return mIds[position]; } + + public static ActionBarNavigationSpinner getDefaultSpinner(Context context) { + return new ActionBarNavigationSpinner(context, + new String[] {context.getString(R.string.special_mailbox_name_inbox), + context.getString(R.string.folder_list_display_mode_label), + context.getString(R.string.special_mailbox_name_inbox)}, + new Long[] {ActionBarNavigationSpinner.AB_NAVIGATION_INBOX, + ActionBarNavigationSpinner.AB_NAVIGATION_FOLDERS, + ActionBarNavigationSpinner.AB_NAVIGATION_ACCOUNTS }); + } }