Clean up un-used ContactListEmptyView.

The code path to ContactListEmptyView is not used.  Prefactor to moving
ContactEntryListFragment.

Also removed isSyncActive() from ContactEntryListFragment since that will
help with un-bundling in the future.

Bug: 6993891
Change-Id: I5fa5270067530f672e18886c070d1abbb60a2542
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 4a84751..832750b 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -246,12 +246,6 @@
     <!-- The text displayed when the groups list is empty and no accounts are set on the device while displaying all groups [CHAR LIMIT=NONE] -->
     <string name="noAccounts">To create groups you need an account.</string>
 
-    <!-- The text displayed when the contacts list is empty while displaying results after searching contacts -->
-    <string name="noMatchingContacts">No matching contacts found.</string>
-
-    <!-- The text displayed when the contacts list is empty while displaying only contacts that have phone numbers -->
-    <string name="noContactsWithPhoneNumbers">No contacts with phone numbers.</string>
-
     <!-- The text displayed when there are no members in the group while displaying the group detail page [CHAR LIMIT=40] -->
     <string name="emptyGroup">No people in this group.</string>
 
@@ -386,75 +380,6 @@
     <!-- Dialog title displayed when loading a phone number from the SIM card for speed dial -->
     <string name="simContacts_title">SIM card contacts</string>
 
-    <!-- Displayed full screen when the user want to create a shortcut, but there is no contacts, and contact syncing is enabled -->
-    <string name="noContactsHelpTextWithSyncForCreateShortcut">"You don't have any contacts to display. (If you just added an account, it can take a few minutes to sync contacts.)"</string>
-
-    <!-- Displayed full screen when the user want to create a shortcut, but there is no contacts -->
-    <string name="noContactsHelpTextForCreateShortcut">"You don't have any contacts to display."</string>
-
-    <!-- Displayed full screen when the user has no contacts and they are displaying the My Contacts group, and contact syncing is disabled.  [CHAR LIMIT=NONE] -->
-    <string name="noContactsHelpText" product="tablet">"You don't have any contacts to display.\n\nTo add contacts, touch <font fgcolor="#ffffffff"><b>Menu</b></font>, then touch:\n
-        \n<li><font fgcolor="#ffffffff"><b>Accounts</b></font> to add or set up an account with contacts you can sync to the tablet\n</li>
-        \n<li><font fgcolor="#ffffffff"><b>New contact</b></font> to create a new contact from scratch\n</li>
-        \n<li><font fgcolor="#ffffffff"><b>Import/export</b></font> to import contacts from your SIM or SD card\n</li>"
-    </string>
-    <!-- Displayed full screen when the user has no contacts and they are displaying the My Contacts group, and contact syncing is disabled.  [CHAR LIMIT=NONE] -->
-    <string name="noContactsHelpText" product="default">"You don't have any contacts to display.\n\nTo add contacts, touch <font fgcolor="#ffffffff"><b>Menu</b></font>, then touch:\n
-        \n<li><font fgcolor="#ffffffff"><b>Accounts</b></font> to add or set up an account with contacts you can sync to the phone\n</li>
-        \n<li><font fgcolor="#ffffffff"><b>New contact</b></font> to create a new contact from scratch\n</li>
-        \n<li><font fgcolor="#ffffffff"><b>Import/Export</b></font> to import contacts from your SIM or SD card\n</li>"
-    </string>
-
-    <!-- Displayed full screen when the user has no contacts and they are displaying the My Contacts group, and contact syncing is enabled.  [CHAR LIMIT=NONE] -->
-    <string name="noContactsHelpTextWithSync" product="tablet">"You don't have any contacts to display. (If you just added an account, it can take a few minutes to sync contacts.)\n\nTo add contacts, touch <font fgcolor="#ffffffff"><b>Menu</b></font>, then touch:\n
-        \n<li><font fgcolor="#ffffffff"><b>Accounts</b></font> to add or set up an account with contacts you can sync to the tablet\n</li>
-        \n<li><font fgcolor="#ffffffff"><b>Display options</b></font> to change which contacts are visible\n</li>
-        \n<li><font fgcolor="#ffffffff"><b>New contact</b></font> to create a new contact from scratch\n</li>
-        \n<li><font fgcolor="#ffffffff"><b>Import/Export</b></font> to import contacts from your SIM or SD card\n</li>"
-    </string>
-    <!-- Displayed full screen when the user has no contacts and they are displaying the My Contacts group, and contact syncing is enabled.  [CHAR LIMIT=NONE] -->
-    <string name="noContactsHelpTextWithSync" product="default">"You don't have any contacts to display. (If you just added an account, it can take a few minutes to sync contacts.)\n\nTo add contacts, touch <font fgcolor="#ffffffff"><b>Menu</b></font>, then touch:\n
-        \n<li><font fgcolor="#ffffffff"><b>Accounts</b></font> to add or set up an account with contacts you can sync to the phone\n</li>
-        \n<li><font fgcolor="#ffffffff"><b>Display options</b></font> to change which contacts are visible\n</li>
-        \n<li><font fgcolor="#ffffffff"><b>New contact</b></font> to create a new contact from scratch\n</li>
-        \n<li><font fgcolor="#ffffffff"><b>Import/Export</b></font> to import contacts from your SIM or SD card\n</li>"
-    </string>
-
-    <!-- Displayed full screen when the user has no contacts and they are displaying the My Contacts group, and contact syncing is disabled, and there is no sim card (cdma).  [CHAR LIMIT=NONE]-->
-    <string name="noContactsNoSimHelpText" product="tablet">"You don't have any contacts to display.\n\nTo add contacts, touch <font fgcolor="#ffffffff"><b>Menu</b></font>, then touch:\n
-        \n<li><font fgcolor="#ffffffff"><b>Accounts</b></font> to add or set up an account with contacts you can sync to the tablet\n</li>
-        \n<li><font fgcolor="#ffffffff"><b>New contact</b></font> to create a new contact from scratch\n</li>
-        \n<li><font fgcolor="#ffffffff"><b>Import/Export</b></font> to import contacts from your SD card\n</li>"
-    </string>
-    <!-- Displayed full screen when the user has no contacts and they are displaying the My Contacts group, and contact syncing is disabled, and there is no sim card (cdma).  [CHAR LIMIT=NONE]-->
-    <string name="noContactsNoSimHelpText" product="default">"You don't have any contacts to display.\n\nTo add contacts, touch <font fgcolor="#ffffffff"><b>Menu</b></font>, then touch:\n
-        \n<li><font fgcolor="#ffffffff"><b>Accounts</b></font> to add or set up an account with contacts you can sync to the phone\n</li>
-        \n<li><font fgcolor="#ffffffff"><b>New contact</b></font> to create a new contact from scratch\n</li>
-        \n<li><font fgcolor="#ffffffff"><b>Import/Export</b></font> to import contacts from your SD card\n</li>"
-    </string>
-
-    <!-- Displayed full screen when the user has no contacts and they are displaying the My Contacts group, and contact syncing is enabled, and there is no sim card (cdma).  [CHAR LIMIT=NONE] -->
-    <string name="noContactsNoSimHelpTextWithSync" product="tablet">"You don't have any contacts to display. (If you just added an account, it can take a few minutes to sync contacts.)\n\nTo add contacts, touch <font fgcolor="#ffffffff"><b>Menu</b></font>, then touch:\n
-        \n<li><font fgcolor="#ffffffff"><b>Accounts</b></font> to add or set up an account with contacts you can sync to the tablet\n</li>
-        \n<li><font fgcolor="#ffffffff"><b>Display options</b></font> to change which contacts are visible\n</li>
-        \n<li><font fgcolor="#ffffffff"><b>New contact</b></font> to create a new contact from scratch\n</li>
-        \n<li><font fgcolor="#ffffffff"><b>Import/Export</b></font> to import contacts from your SD card\n</li>"
-    </string>
-    <!-- Displayed full screen when the user has no contacts and they are displaying the My Contacts group, and contact syncing is enabled, and there is no sim card (cdma).  [CHAR LIMIT=NONE] -->
-    <string name="noContactsNoSimHelpTextWithSync" product="default">"You don't have any contacts to display. (If you just added an account, it can take a few minutes to sync contacts.)\n\nTo add contacts, touch <font fgcolor="#ffffffff"><b>Menu</b></font>, then touch:\n
-        \n<li><font fgcolor="#ffffffff"><b>Accounts</b></font> to add or set up an account with contacts you can sync to the phone\n</li>
-        \n<li><font fgcolor="#ffffffff"><b>Display options</b></font> to change which contacts are visible\n</li>
-        \n<li><font fgcolor="#ffffffff"><b>New contact</b></font> to create a new contact from scratch\n</li>
-        \n<li><font fgcolor="#ffffffff"><b>Import/Export</b></font> to import contacts from your SD card\n</li>"
-    </string>
-
-    <!-- Displayed full screen when the user has no favorites and they are displaying the favorites tab. [CHAR LIMIT=NONE] -->
-    <string name="noFavoritesHelpText">"You don't have any favorites.\n\nTo add a contact to your list of favorites:\n
-        <li>Touch the <b>Contacts</b> tab\n</li>
-        \n<li>Touch the contact you want to add to your favorites\n</li>
-        \n<li>Touch the star next to the contact\'s name\n</li>"
-    </string>
-
     <!-- Item label: jump to the in-call DTMF dialpad.
          (Part of a list of options shown in the dialer when another call
          is already in progress.) -->
@@ -1029,9 +954,6 @@
     <!-- Label to clear all selection in multiple picker -->
     <string name="menu_select_none">"Unselect all"</string>
 
-    <!-- The text displayed when the contacts list is empty while displaying only selected contacts in multiple picker -->
-    <string name="no_contacts_selected">"No contacts selected."</string>
-
     <!-- The add field button shown in the editor under each editable Raw Contact [CHAR LIMIT=30] -->
     <string name="add_field">Add another field</string>
 
diff --git a/src/com/android/contacts/ContactListEmptyView.java b/src/com/android/contacts/ContactListEmptyView.java
deleted file mode 100644
index 40d5152..0000000
--- a/src/com/android/contacts/ContactListEmptyView.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.contacts;
-
-import android.accounts.Account;
-import android.accounts.AccountManager;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.content.IContentService;
-import android.os.RemoteException;
-import android.provider.ContactsContract;
-import android.telephony.TelephonyManager;
-import android.util.AttributeSet;
-import android.util.Log;
-import android.widget.ScrollView;
-import android.widget.TextView;
-
-/**
- * Displays a message when there is nothing to display in a contact list.
- */
-public class ContactListEmptyView extends ScrollView {
-
-    private static final String TAG = "ContactListEmptyView";
-
-    public ContactListEmptyView(Context context, AttributeSet attrs) {
-        super(context, attrs);
-    }
-
-    public void hide() {
-        TextView empty = (TextView) findViewById(R.id.emptyText);
-        empty.setVisibility(GONE);
-    }
-
-    public void show(boolean searchMode, boolean displayOnlyPhones,
-            boolean isFavoritesMode, boolean isQueryMode, boolean isShortcutAction,
-            boolean isMultipleSelectionEnabled, boolean showSelectedOnly) {
-        if (searchMode) {
-            return;
-        }
-
-        TextView empty = (TextView) findViewById(R.id.emptyText);
-        Context context = getContext();
-        if (displayOnlyPhones) {
-            empty.setText(context.getText(R.string.noContactsWithPhoneNumbers));
-        } else if (isFavoritesMode) {
-            empty.setText(context.getText(R.string.noFavoritesHelpText));
-        } else if (isQueryMode) {
-            empty.setText(context.getText(R.string.noMatchingContacts));
-        } if (isMultipleSelectionEnabled) {
-            if (showSelectedOnly) {
-                empty.setText(context.getText(R.string.no_contacts_selected));
-            } else {
-                empty.setText(context.getText(R.string.noContactsWithPhoneNumbers));
-            }
-        } else {
-            TelephonyManager telephonyManager =
-                    (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
-            boolean hasSim = telephonyManager.hasIccCard();
-            if (isSyncActive()) {
-                if (isShortcutAction) {
-                    // Help text is the same no matter whether there is SIM or not.
-                    empty.setText(
-                            context.getText(R.string.noContactsHelpTextWithSyncForCreateShortcut));
-                } else if (hasSim) {
-                    empty.setText(context.getText(R.string.noContactsHelpTextWithSync));
-                } else {
-                    empty.setText(context.getText(R.string.noContactsNoSimHelpTextWithSync));
-                }
-            } else {
-                if (isShortcutAction) {
-                    // Help text is the same no matter whether there is SIM or not.
-                    empty.setText(context.getText(R.string.noContactsHelpTextForCreateShortcut));
-                } else if (hasSim) {
-                    empty.setText(context.getText(R.string.noContactsHelpText));
-                } else {
-                    empty.setText(context.getText(R.string.noContactsNoSimHelpText));
-                }
-            }
-        }
-        empty.setVisibility(VISIBLE);
-    }
-
-    private boolean isSyncActive() {
-        Account[] accounts = AccountManager.get(getContext()).getAccounts();
-        if (accounts != null && accounts.length > 0) {
-            IContentService contentService = ContentResolver.getContentService();
-            for (Account account : accounts) {
-                try {
-                    if (contentService.isSyncActive(account, ContactsContract.AUTHORITY)) {
-                        return true;
-                    }
-                } catch (RemoteException e) {
-                    Log.e(TAG, "Could not get the sync status");
-                }
-            }
-        }
-        return false;
-    }
-}
diff --git a/src/com/android/contacts/list/ContactBrowseListFragment.java b/src/com/android/contacts/list/ContactBrowseListFragment.java
index 45cee6b..64c4c3d 100644
--- a/src/com/android/contacts/list/ContactBrowseListFragment.java
+++ b/src/com/android/contacts/list/ContactBrowseListFragment.java
@@ -35,12 +35,11 @@
 import android.util.Log;
 
 import com.android.common.widget.CompositeCursorAdapter.Partition;
-import com.android.contacts.R;
+import com.android.contacts.common.list.AutoScrollListView;
 import com.android.contacts.common.list.ContactListAdapter;
 import com.android.contacts.common.list.ContactListFilter;
 import com.android.contacts.common.list.DirectoryPartition;
 import com.android.contacts.util.ContactLoaderUtils;
-import com.android.contacts.common.list.AutoScrollListView;
 
 import java.util.List;
 
@@ -276,25 +275,6 @@
         checkSelection();
     }
 
-    @Override
-    protected void prepareEmptyView() {
-        if (isSearchMode()) {
-            return;
-        } else if (isSyncActive()) {
-            if (hasIccCard()) {
-                setEmptyText(R.string.noContactsHelpTextWithSync);
-            } else {
-                setEmptyText(R.string.noContactsNoSimHelpTextWithSync);
-            }
-        } else {
-            if (hasIccCard()) {
-                setEmptyText(R.string.noContactsHelpText);
-            } else {
-                setEmptyText(R.string.noContactsNoSimHelpText);
-            }
-        }
-    }
-
     public Uri getSelectedContactUri() {
         return mSelectedContactUri;
     }
diff --git a/src/com/android/contacts/list/ContactEntryListFragment.java b/src/com/android/contacts/list/ContactEntryListFragment.java
index 7971905..e867b4d 100644
--- a/src/com/android/contacts/list/ContactEntryListFragment.java
+++ b/src/com/android/contacts/list/ContactEntryListFragment.java
@@ -16,16 +16,12 @@
 
 package com.android.contacts.list;
 
-import android.accounts.Account;
-import android.accounts.AccountManager;
 import android.app.Activity;
 import android.app.Fragment;
 import android.app.LoaderManager;
 import android.app.LoaderManager.LoaderCallbacks;
-import android.content.ContentResolver;
 import android.content.Context;
 import android.content.CursorLoader;
-import android.content.IContentService;
 import android.content.Intent;
 import android.content.Loader;
 import android.database.Cursor;
@@ -33,12 +29,8 @@
 import android.os.Handler;
 import android.os.Message;
 import android.os.Parcelable;
-import android.os.RemoteException;
-import android.provider.ContactsContract;
 import android.provider.ContactsContract.Directory;
-import android.telephony.TelephonyManager;
 import android.text.TextUtils;
-import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.MotionEvent;
 import android.view.View;
@@ -51,10 +43,8 @@
 import android.widget.AdapterView;
 import android.widget.AdapterView.OnItemClickListener;
 import android.widget.ListView;
-import android.widget.TextView;
 
 import com.android.common.widget.CompositeCursorAdapter.Partition;
-import com.android.contacts.ContactListEmptyView;
 import com.android.contacts.R;
 import com.android.contacts.common.ContactPhotoManager;
 import com.android.contacts.common.list.ContactEntryListAdapter;
@@ -128,7 +118,6 @@
     private int mDirectoryResultLimit = DEFAULT_DIRECTORY_RESULT_LIMIT;
 
     private ContactPhotoManager mPhotoManager;
-    private ContactListEmptyView mEmptyView;
     private ContactsPreferences mContactsPrefs;
 
     private boolean mForceLoad;
@@ -229,10 +218,6 @@
         return mListView;
     }
 
-    public ContactListEmptyView getEmptyView() {
-        return mEmptyView;
-    }
-
     @Override
     public void onSaveInstanceState(Bundle outState) {
         super.onSaveInstanceState(outState);
@@ -475,13 +460,6 @@
     }
 
     /**
-     * Configures the empty view. It is called when we are about to populate
-     * the list with an empty cursor.
-     */
-    protected void prepareEmptyView() {
-    }
-
-    /**
      * Shows the count of entries included in the list. The default
      * implementation does nothing.
      */
@@ -739,9 +717,6 @@
         View emptyView = mView.findViewById(android.R.id.empty);
         if (emptyView != null) {
             mListView.setEmptyView(emptyView);
-            if (emptyView instanceof ContactListEmptyView) {
-                mEmptyView = (ContactListEmptyView)emptyView;
-            }
         }
 
         mListView.setOnItemClickListener(this);
@@ -851,14 +826,6 @@
     }
 
     /**
-     * Dismisses the search UI along with the keyboard if the filter text is empty.
-     */
-    public void onClose() {
-        hideSoftKeyboard();
-        finish();
-    }
-
-    /**
      * Restore the list state after the adapter is populated.
      */
     protected void completeRestoreInstanceState() {
@@ -868,36 +835,6 @@
         }
     }
 
-    protected void setEmptyText(int resourceId) {
-        TextView empty = (TextView) getEmptyView().findViewById(R.id.emptyText);
-        empty.setText(mContext.getText(resourceId));
-        empty.setVisibility(View.VISIBLE);
-    }
-
-    // TODO redesign into an async task or loader
-    protected boolean isSyncActive() {
-        Account[] accounts = AccountManager.get(mContext).getAccounts();
-        if (accounts != null && accounts.length > 0) {
-            IContentService contentService = ContentResolver.getContentService();
-            for (Account account : accounts) {
-                try {
-                    if (contentService.isSyncActive(account, ContactsContract.AUTHORITY)) {
-                        return true;
-                    }
-                } catch (RemoteException e) {
-                    Log.e(TAG, "Could not get the sync status");
-                }
-            }
-        }
-        return false;
-    }
-
-    protected boolean hasIccCard() {
-        TelephonyManager telephonyManager =
-                (TelephonyManager)mContext.getSystemService(Context.TELEPHONY_SERVICE);
-        return telephonyManager.hasIccCard();
-    }
-
     public void setDarkTheme(boolean value) {
         mDarkTheme = value;
         if (mAdapter != null) mAdapter.setDarkTheme(value);
diff --git a/src/com/android/contacts/list/ContactPickerFragment.java b/src/com/android/contacts/list/ContactPickerFragment.java
index 2de71be..acc142e 100644
--- a/src/com/android/contacts/list/ContactPickerFragment.java
+++ b/src/com/android/contacts/list/ContactPickerFragment.java
@@ -75,10 +75,6 @@
         mEditMode = flag;
     }
 
-    public boolean isShortcutRequested() {
-        return mShortcutRequested;
-    }
-
     public void setShortcutRequested(boolean flag) {
         mShortcutRequested = flag;
     }
@@ -185,31 +181,6 @@
     }
 
     @Override
-    protected void prepareEmptyView() {
-        if (isSearchMode()) {
-            return;
-        } else if (isSyncActive()) {
-            if (mShortcutRequested) {
-                // Help text is the same no matter whether there is SIM or not.
-                setEmptyText(R.string.noContactsHelpTextWithSyncForCreateShortcut);
-            } else if (hasIccCard()) {
-                setEmptyText(R.string.noContactsHelpTextWithSync);
-            } else {
-                setEmptyText(R.string.noContactsNoSimHelpTextWithSync);
-            }
-        } else {
-            if (mShortcutRequested) {
-                // Help text is the same no matter whether there is SIM or not.
-                setEmptyText(R.string.noContactsHelpTextWithSyncForCreateShortcut);
-            } else if (hasIccCard()) {
-                setEmptyText(R.string.noContactsHelpText);
-            } else {
-                setEmptyText(R.string.noContactsNoSimHelpText);
-            }
-        }
-    }
-
-    @Override
     public void onShortcutIntentCreated(Uri uri, Intent shortcutIntent) {
         mListener.onShortcutIntentCreated(shortcutIntent);
     }