From d39cf1938a468bb1ba77538140bc2ef80d634e36 Mon Sep 17 00:00:00 2001 From: RoboErik Date: Mon, 14 Nov 2011 14:13:12 -0800 Subject: [PATCH] b/5613906 Don't show account picker for 0 or 1 account This hides the activity when dropping an email widget until we get some data back and can decide which picker to show. Change-Id: I200b035a45d079285d1b84b273ddd7ce2ffda24c --- .../activity/ShortcutPickerFragment.java | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/com/android/email/activity/ShortcutPickerFragment.java b/src/com/android/email/activity/ShortcutPickerFragment.java index 0ea851b0d..2cc41abd1 100644 --- a/src/com/android/email/activity/ShortcutPickerFragment.java +++ b/src/com/android/email/activity/ShortcutPickerFragment.java @@ -16,6 +16,13 @@ package com.android.email.activity; +import com.android.email.R; +import com.android.emailcommon.provider.Account; +import com.android.emailcommon.provider.EmailContent.AccountColumns; +import com.android.emailcommon.provider.EmailContent.MailboxColumns; +import com.android.emailcommon.provider.HostAuth; +import com.android.emailcommon.provider.Mailbox; + import android.app.Activity; import android.app.FragmentTransaction; import android.app.ListFragment; @@ -37,13 +44,6 @@ import android.widget.AdapterView.OnItemClickListener; import android.widget.ListView; import android.widget.SimpleCursorAdapter; -import com.android.email.R; -import com.android.emailcommon.provider.Account; -import com.android.emailcommon.provider.EmailContent.AccountColumns; -import com.android.emailcommon.provider.EmailContent.MailboxColumns; -import com.android.emailcommon.provider.HostAuth; -import com.android.emailcommon.provider.Mailbox; - /** * Fragment containing a list of accounts to show during shortcut creation. *

@@ -165,6 +165,7 @@ public abstract class ShortcutPickerFragment extends ListFragment /** Account picker */ public static class AccountShortcutPickerFragment extends ShortcutPickerFragment { + private volatile Boolean mLoadFinished = new Boolean(false); private final static String[] ACCOUNT_FROM_COLUMNS = new String[] { AccountColumns.DISPLAY_NAME, }; @@ -173,6 +174,9 @@ public abstract class ShortcutPickerFragment extends ListFragment public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); getActivity().setTitle(R.string.account_shortcut_picker_title); + if (!mLoadFinished) { + getActivity().setVisible(false); + } } @Override @@ -201,6 +205,8 @@ public abstract class ShortcutPickerFragment extends ListFragment return; } super.onLoadFinished(loader, data); + mLoadFinished = true; + getActivity().setVisible(true); } @Override @@ -312,6 +318,7 @@ public abstract class ShortcutPickerFragment extends ListFragment /** Selection for just the INBOX of an account */ private final static String INBOX_ONLY_SELECTION = ALL_MAILBOX_SELECTION + " AND " + MailboxColumns.TYPE + " = " + Mailbox.TYPE_INBOX; + private volatile Boolean mLoadFinished = new Boolean(false); /** The currently selected account */ private Account mAccount; /** The filter values; default to allow all mailboxes */ @@ -350,6 +357,9 @@ public abstract class ShortcutPickerFragment extends ListFragment public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); getActivity().setTitle(R.string.mailbox_shortcut_picker_title); + if (!mLoadFinished) { + getActivity().setVisible(false); + } } @Override @@ -400,6 +410,8 @@ public abstract class ShortcutPickerFragment extends ListFragment return; } super.onLoadFinished(loader, data); + mLoadFinished = true; + getActivity().setVisible(true); } @Override