diff options
author | mindyp <mindyp@google.com> | 2012-09-05 09:27:08 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2012-09-05 11:13:50 -0700 |
commit | 6fb1b62b9e8e480892cb1575c8219dfd4c4e1eee (patch) | |
tree | e158ac649fc8d87ad9978c385b434f32bdd9f7da | |
parent | 601ab03706b6674c4154ca313080b6549bdb562f (diff) | |
download | android_packages_apps_UnifiedEmail-6fb1b62b9e8e480892cb1575c8219dfd4c4e1eee.tar.gz android_packages_apps_UnifiedEmail-6fb1b62b9e8e480892cb1575c8219dfd4c4e1eee.tar.bz2 android_packages_apps_UnifiedEmail-6fb1b62b9e8e480892cb1575c8219dfd4c4e1eee.zip |
Use old spinner
The framework has too many issues with us using the spinner the way
we want to for navigation by default
Just patching in our old custom version for now
Change-Id: Ibf84b43ac03e5bdb30b65993ef9fd9f1bed33fa1
-rw-r--r-- | res/layout/account_switch_spinner_item.xml | 7 | ||||
-rw-r--r-- | res/layout/actionbar_view.xml | 6 | ||||
-rw-r--r-- | res/layout/search_actionbar_view.xml | 6 | ||||
-rw-r--r-- | res/values-sw600dp-port/dimen.xml | 1 | ||||
-rw-r--r-- | res/values-sw600dp-port/styles.xml | 3 | ||||
-rw-r--r-- | res/values-sw600dp/dimen.xml | 2 | ||||
-rw-r--r-- | res/values-sw600dp/styles.xml | 3 | ||||
-rw-r--r-- | res/values-sw720dp-port/dimen.xml | 2 | ||||
-rw-r--r-- | res/values/styles.xml | 4 | ||||
-rw-r--r-- | src/com/android/mail/AccountSpinnerAdapter.java | 9 | ||||
-rw-r--r-- | src/com/android/mail/ui/MailActionBarView.java | 85 | ||||
-rw-r--r-- | src/com/android/mail/ui/SearchMailActionBarView.java | 2 |
12 files changed, 75 insertions, 55 deletions
diff --git a/res/layout/account_switch_spinner_item.xml b/res/layout/account_switch_spinner_item.xml index 1185524ac..47a56487b 100644 --- a/res/layout/account_switch_spinner_item.xml +++ b/res/layout/account_switch_spinner_item.xml @@ -20,10 +20,9 @@ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_parent" - android:layout_width="match_parent" android:paddingLeft="0dip" - android:paddingRight="0dip" - android:layout_marginLeft="0dip"> + android:layout_marginLeft="0dip" + style="@style/AccountSwitchSpinnerItem"> <LinearLayout android:layout_height="match_parent" @@ -57,7 +56,5 @@ android:id="@+id/account_unread" android:layout_toRightOf="@id/account_spinner" android:layout_marginLeft="4dp" - android:layout_marginRight="0dp" - android:paddingRight="0dp" style="@style/UnreadCountActionBar"/> </RelativeLayout> diff --git a/res/layout/actionbar_view.xml b/res/layout/actionbar_view.xml index 5c0913292..862c864b2 100644 --- a/res/layout/actionbar_view.xml +++ b/res/layout/actionbar_view.xml @@ -25,6 +25,12 @@ android:layout_height="match_parent" android:orientation="horizontal" > + <Spinner + android:id="@+id/account_spinner" + android:layout_height="match_parent" + android:layout_width="wrap_content" + style="@style/PlainSpinnerDropdown"/> + <include layout="@layout/actionbar_folder" /> <include layout="@layout/actionbar_subject" /> diff --git a/res/layout/search_actionbar_view.xml b/res/layout/search_actionbar_view.xml index aee5cd7cb..b341c26d8 100644 --- a/res/layout/search_actionbar_view.xml +++ b/res/layout/search_actionbar_view.xml @@ -26,6 +26,12 @@ android:layout_height="match_parent" android:orientation="horizontal" > + <Spinner + android:id="@+id/account_spinner" + android:layout_height="match_parent" + android:layout_width="match_parent" + style="@style/PlainSpinnerDropdown"/> + <include layout="@layout/actionbar_folder" /> <include layout="@layout/actionbar_subject" /> diff --git a/res/values-sw600dp-port/dimen.xml b/res/values-sw600dp-port/dimen.xml index ea66f63a8..718db8ce6 100644 --- a/res/values-sw600dp-port/dimen.xml +++ b/res/values-sw600dp-port/dimen.xml @@ -20,4 +20,5 @@ <dimen name="compose_area_left_padding">80dip</dimen> <dimen name="compose_area_right_padding">80dip</dimen> <dimen name="search_view_width">400dip</dimen> + <dimen name="spinner_frame_width">170dp</dimen> </resources> diff --git a/res/values-sw600dp-port/styles.xml b/res/values-sw600dp-port/styles.xml index 338b028f7..dfb3ab88c 100644 --- a/res/values-sw600dp-port/styles.xml +++ b/res/values-sw600dp-port/styles.xml @@ -20,4 +20,7 @@ <item name="android:layout_marginLeft">12dp</item> <item name="android:layout_width">wrap_content</item> </style> + <style name="AccountSwitchSpinnerItem"> + <item name="android:layout_width">match_parent</item> + </style> </resources> diff --git a/res/values-sw600dp/dimen.xml b/res/values-sw600dp/dimen.xml index e4edad53b..3f7580842 100644 --- a/res/values-sw600dp/dimen.xml +++ b/res/values-sw600dp/dimen.xml @@ -24,7 +24,7 @@ <dimen name="max_total_folder_width_wide">128dip</dimen> <dimen name="wide_subject_margin_right">28dip</dimen> <dimen name="subject_width">238dip</dimen> - <dimen name="spinner_frame_width">180dp</dimen> + <dimen name="spinner_frame_width">196dp</dimen> <dimen name="conversation_view_margin_side">32dp</dimen> <dimen name="conversation_header_side_padding">0dip</dimen> <dimen name="conversation_header_vertical_padding">12dip</dimen> diff --git a/res/values-sw600dp/styles.xml b/res/values-sw600dp/styles.xml index 8c530e735..5bfd38418 100644 --- a/res/values-sw600dp/styles.xml +++ b/res/values-sw600dp/styles.xml @@ -16,6 +16,9 @@ limitations under the License. --> <resources> + <style name="AccountSwitchSpinnerItem"> + <item name="android:layout_width">308dp</item> + </style> <style name="PersonalIndicatorStyle"> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> diff --git a/res/values-sw720dp-port/dimen.xml b/res/values-sw720dp-port/dimen.xml index db038f99e..43e005563 100644 --- a/res/values-sw720dp-port/dimen.xml +++ b/res/values-sw720dp-port/dimen.xml @@ -16,5 +16,5 @@ limitations under the License. --> <resources> - <dimen name="spinner_frame_width">200dip</dimen> + <dimen name="spinner_frame_width">172dip</dimen> </resources>
\ No newline at end of file diff --git a/res/values/styles.xml b/res/values/styles.xml index 59fce9fb1..77c5ee2a4 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -179,6 +179,10 @@ <style name="AccountSpinnerAnchorTextSecondary" parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Subtitle"> </style> + <style name="AccountSwitchSpinnerItem"> + <item name="android:layout_width">match_parent</item> + </style> + <!-- Browse list item styles --> <style name="PersonalIndicatorStyle"> <item name="android:layout_width">wrap_content</item> diff --git a/src/com/android/mail/AccountSpinnerAdapter.java b/src/com/android/mail/AccountSpinnerAdapter.java index 7e512beb5..155df3dfe 100644 --- a/src/com/android/mail/AccountSpinnerAdapter.java +++ b/src/com/android/mail/AccountSpinnerAdapter.java @@ -113,7 +113,7 @@ public class AccountSpinnerAdapter extends BaseAdapter { final int pos = Account.findPosition(mAllAccounts, newAccount.uri); LogUtils.d(LOG_TAG, "setCurrentAccount: mCurrentAccountPos = %d", pos); if (pos >= 0) { - requestRecentFoldersAndRedraw(); + requestRecentFolders(); } notifyDataSetChanged(); } @@ -122,7 +122,7 @@ public class AccountSpinnerAdapter extends BaseAdapter { private final RecentFolderObserver mRecentFolderObserver = new RecentFolderObserver() { @Override public void onChanged() { - requestRecentFoldersAndRedraw(); + requestRecentFolders(); } }; @@ -264,7 +264,7 @@ public class AccountSpinnerAdapter extends BaseAdapter { public boolean setCurrentFolder(Folder folder) { if (folder != null && folder != mCurrentFolder) { mCurrentFolder = folder; - requestRecentFoldersAndRedraw(); + requestRecentFolders(); return true; } return false; @@ -501,10 +501,9 @@ public class AccountSpinnerAdapter extends BaseAdapter { * Cause a refresh of the recent folders for the current folder and redraw the spinner with * the new information. */ - public void requestRecentFoldersAndRedraw() { + public void requestRecentFolders() { final Uri uri = mCurrentFolder == null ? null : mCurrentFolder.uri; mRecentFolderList = mRecentFolders.getRecentFolderList(uri); - notifyDataSetChanged(); } /** diff --git a/src/com/android/mail/ui/MailActionBarView.java b/src/com/android/mail/ui/MailActionBarView.java index 284da7d6d..e66c47ecd 100644 --- a/src/com/android/mail/ui/MailActionBarView.java +++ b/src/com/android/mail/ui/MailActionBarView.java @@ -31,8 +31,12 @@ import android.util.AttributeSet; import android.view.Menu; import android.view.MenuItem; import android.view.View; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.AdapterView.OnItemSelectedListener; import android.widget.LinearLayout; import android.widget.SearchView; +import android.widget.Spinner; import android.widget.TextView; import android.widget.SearchView.OnQueryTextListener; import android.widget.SearchView.OnSuggestionListener; @@ -56,9 +60,9 @@ import com.android.mail.utils.Utils; * This also happens to be the custom view we supply to ActionBar. * */ -public class MailActionBarView extends LinearLayout implements OnNavigationListener, - ViewMode.ModeChangeListener, OnQueryTextListener, OnSuggestionListener, - MenuItem.OnActionExpandListener, SubjectDisplayChanger { +public class MailActionBarView extends LinearLayout implements ViewMode.ModeChangeListener, + OnQueryTextListener, OnSuggestionListener, MenuItem.OnActionExpandListener, + SubjectDisplayChanger, OnItemSelectedListener { protected ActionBar mActionBar; protected ControllableActivity mActivity; protected ActivityController mController; @@ -69,7 +73,8 @@ public class MailActionBarView extends LinearLayout implements OnNavigationListe private int mMode = ViewMode.UNKNOWN; private MenuItem mSearch; - private AccountSpinnerAdapter mSpinner; + private AccountSpinnerAdapter mSpinnerAdapter; + private Spinner mSpinner; /** * The account currently being shown */ @@ -232,7 +237,10 @@ public class MailActionBarView extends LinearLayout implements OnNavigationListe mController.registerFolderObserver(mFolderObserver); // We don't want to include the "Show all folders" menu item on tablet devices final boolean showAllFolders = !Utils.useTabletUI(getContext()); - mSpinner = new AccountSpinnerAdapter(activity, getContext(), showAllFolders); + mSpinnerAdapter = new AccountSpinnerAdapter(activity, getContext(), showAllFolders); + mSpinner = (Spinner) findViewById(R.id.account_spinner); + mSpinner.setAdapter(mSpinnerAdapter); + mSpinner.setOnItemSelectedListener(this); mAccount = mAccountObserver.initialize(activity.getAccountController()); } @@ -240,7 +248,7 @@ public class MailActionBarView extends LinearLayout implements OnNavigationListe * Attach the action bar to the view. */ public void attach() { - mActionBar.setListNavigationCallbacks(mSpinner, this); + // Do nothing. } /** @@ -249,20 +257,7 @@ public class MailActionBarView extends LinearLayout implements OnNavigationListe */ public void setAccounts(Account[] accounts) { final Account currentAccount = mController.getCurrentAccount(); - mSpinner.setAccountArray(accounts); - } - - /** - * Sets the selected navigation position in the spinner to the position given here. - * @param position - */ - private void setSelectedPosition(int position) { - // Only change the position if we are in the correct mode. - if (mActionBar.getNavigationMode() != ActionBar.NAVIGATION_MODE_LIST) { - return; - } - LogUtils.d(LOG_TAG, "ActionBarView.setSelectedNavigationItem(%d)", position); - mActionBar.setSelectedNavigationItem(position); + mSpinnerAdapter.setAccountArray(accounts); } /** @@ -272,14 +267,18 @@ public class MailActionBarView extends LinearLayout implements OnNavigationListe public void setFolder(Folder folder) { setRefreshInProgress(false); mFolder = folder; - mSpinner.setCurrentFolder(folder); mActivity.invalidateOptionsMenu(); } @Override - public boolean onNavigationItemSelected(int position, long id) { + public void onNothingSelected(AdapterView<?> parent) { + // Do nothing. + } + + @Override + public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { LogUtils.d(LOG_TAG, "onNavigationItemSelected(%d, %d) called", position, id); - final int type = mSpinner.getType(position); + final int type = mSpinnerAdapter.getType(position); switch (type) { case AccountSpinnerAdapter.TYPE_DEAD_HEADER: // Automatic selections @@ -287,7 +286,7 @@ public class MailActionBarView extends LinearLayout implements OnNavigationListe break; case AccountSpinnerAdapter.TYPE_ACCOUNT: // Get the capabilities associated with this account. - final Account account = (Account) mSpinner.getItem(position); + final Account account = (Account) mSpinnerAdapter.getItem(position); LogUtils.d(LOG_TAG, "onNavigationItemSelected: Selecting account: %s", account.name); if (mAccount.uri.equals(account.uri)) { @@ -299,7 +298,7 @@ public class MailActionBarView extends LinearLayout implements OnNavigationListe } break; case AccountSpinnerAdapter.TYPE_FOLDER: - final Object folder = mSpinner.getItem(position); + final Object folder = mSpinnerAdapter.getItem(position); assert (folder instanceof Folder); LogUtils.d(LOG_TAG, "onNavigationItemSelected: Selecting folder: %s", ((Folder)folder).name); @@ -309,10 +308,6 @@ public class MailActionBarView extends LinearLayout implements OnNavigationListe mController.showFolderList(); break; } - // Change the currently selected item to an element which is a spacer: valid - // but not useful. This allows us to receive subsequent taps on all menu items. - setSelectedPosition(mSpinner.getSpacerPosition()); - return false; } public void onDestroy() { @@ -320,7 +315,7 @@ public class MailActionBarView extends LinearLayout implements OnNavigationListe mController.unregisterFolderObserver(mFolderObserver); mFolderObserver = null; } - mSpinner.destroy(); + mSpinnerAdapter.destroy(); mAccountObserver.unregisterAndDestroy(); } @@ -333,9 +328,9 @@ public class MailActionBarView extends LinearLayout implements OnNavigationListe // Check if we are either on a phone, or in Conversation mode on tablet. For these, the // recent folders is enabled. if (!mIsOnTablet || mMode == ViewMode.CONVERSATION) { - mSpinner.enableRecentFolders(); + mSpinnerAdapter.enableRecentFolders(); } else { - mSpinner.disableRecentFolders(); + mSpinnerAdapter.disableRecentFolders(); } boolean showFolderView = false; @@ -424,21 +419,27 @@ public class MailActionBarView extends LinearLayout implements OnNavigationListe * Put the ActionBar in List navigation mode. This starts the spinner up if it is missing. */ private void showNavList() { - mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); - // Don't show title, and don't show custom views. - final int mask = ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM; - final int enabled = 0; - mActionBar.setDisplayOptions(enabled, mask); + mSpinner.setVisibility(View.VISIBLE); + mFolderView.setVisibility(View.GONE); + mFolderAccountName.setVisibility(View.GONE); } /** * Set the actionbar mode to standard mode: no list navigation. */ protected void setStandardMode() { - mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); - // Show a custom view, and use a logo. - final int mask = ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME; - mActionBar.setDisplayOptions(mask, mask); + mSpinner.setVisibility(View.GONE); + mFolderView.setVisibility(View.VISIBLE); + mFolderAccountName.setVisibility(View.VISIBLE); + } + + /** + * Set the actionbar mode to empty: no title, no custom content. + */ + protected void setEmptyMode() { + mSpinner.setVisibility(View.GONE); + mFolderView.setVisibility(View.GONE); + mFolderAccountName.setVisibility(View.GONE); } public void removeBackButton() { @@ -557,7 +558,7 @@ public class MailActionBarView extends LinearLayout implements OnNavigationListe * Notify that the folder has changed. */ public void onFolderUpdated(Folder folder) { - mSpinner.onFolderUpdated(folder); + mSpinnerAdapter.onFolderUpdated(folder); int status = folder.syncStatus; if (folder.isSyncInProgress()) { onRefreshStarted(); diff --git a/src/com/android/mail/ui/SearchMailActionBarView.java b/src/com/android/mail/ui/SearchMailActionBarView.java index 127f5a483..c218403bd 100644 --- a/src/com/android/mail/ui/SearchMailActionBarView.java +++ b/src/com/android/mail/ui/SearchMailActionBarView.java @@ -54,7 +54,7 @@ public class SearchMailActionBarView extends MailActionBarView { case ViewMode.SEARCH_RESULTS_LIST: case ViewMode.SEARCH_RESULTS_CONVERSATION: mActionBar.setDisplayHomeAsUpEnabled(true); - setStandardMode(); + setEmptyMode(); if (!showConversationSubject()) { setPopulatedSearchView(); } |