Hide tabs in PeopleActivity
- remove favorites tab from TabPagerAdapter
- make ViewPagerTabs gone in XML
- remove "clear frequent" option (and it's still available in Dialer)
Bug 24938588
Change-Id: Ia6397c21d3ad2ea77f57fc39114512bb60fc4ba8
diff --git a/res/drawable-hdpi/ic_star_black_128dp.png b/res/drawable-hdpi/ic_star_black_128dp.png
deleted file mode 100644
index a0cb1c1..0000000
--- a/res/drawable-hdpi/ic_star_black_128dp.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-mdpi/ic_star_black_128dp.png b/res/drawable-mdpi/ic_star_black_128dp.png
deleted file mode 100644
index 1ba2792..0000000
--- a/res/drawable-mdpi/ic_star_black_128dp.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xhdpi/ic_star_black_128dp.png b/res/drawable-xhdpi/ic_star_black_128dp.png
deleted file mode 100644
index 842ce10..0000000
--- a/res/drawable-xhdpi/ic_star_black_128dp.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_star_black_128dp.png b/res/drawable-xxhdpi/ic_star_black_128dp.png
deleted file mode 100644
index f7d0eb0..0000000
--- a/res/drawable-xxhdpi/ic_star_black_128dp.png
+++ /dev/null
Binary files differ
diff --git a/res/drawable-xxxhdpi/ic_star_black_128dp.png b/res/drawable-xxxhdpi/ic_star_black_128dp.png
deleted file mode 100644
index 49f9e8b..0000000
--- a/res/drawable-xxxhdpi/ic_star_black_128dp.png
+++ /dev/null
Binary files differ
diff --git a/res/layout/contact_tile_list.xml b/res/layout/contact_tile_list.xml
deleted file mode 100644
index 8b172d1..0000000
--- a/res/layout/contact_tile_list.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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.
--->
-
-<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingBottom="?attr/favorites_padding_bottom"
- android:background="@color/background_primary">
-
- <include layout="@layout/contact_list_card"/>
-
- <ListView
- android:id="@+id/contact_tile_list"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingTop="@dimen/contact_tile_list_padding_top"
- android:clipToPadding="false"
- android:fadingEdge="none"
- android:divider="@null"
- android:scrollbarStyle="outsideOverlay"/>
-
- <TextView
- android:id="@+id/contact_tile_list_empty"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="center_horizontal"
- android:layout_marginTop="@dimen/empty_message_top_margin"
- android:textColor="@android:color/black"
- android:drawableTop="@drawable/ic_star_black_128dp"
- android:drawablePadding="4dp"
- android:alpha="0.38"
- android:paddingTop="10dp"
- android:textAppearance="?android:attr/textAppearanceLarge"/>
-
-</FrameLayout>
diff --git a/res/layout/contact_tile_list_frequent.xml b/res/layout/contact_tile_list_frequent.xml
deleted file mode 100644
index 3707f11..0000000
--- a/res/layout/contact_tile_list_frequent.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2011 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.
--->
-
-<!--
- This is very similar to contact_tile_list.xml (there needs to be a ListView called
- contact_tile_list and an empty view called contact_tile_list_empty). However, this layout also
- contains a container view for the title of the frequently contacted list.
--->
-
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingBottom="?attr/favorites_padding_bottom"
- android:orientation="vertical">
-
- <FrameLayout
- android:id="@+id/header_container"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"/>
-
- <ListView
- android:id="@+id/contact_tile_list"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:fadingEdge="none"
- android:divider="@null" />
-
- <TextView
- android:id="@+id/contact_tile_list_empty"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="center_horizontal"
- android:layout_marginTop="@dimen/empty_message_top_margin"
- android:textColor="?android:attr/textColorSecondary"
- android:textAppearance="?android:attr/textAppearanceLarge"/>
-
-</LinearLayout>
diff --git a/res/layout/people_activity_tabs_lands.xml b/res/layout/people_activity_tabs_lands.xml
index 525ac3c..8d7b42b 100644
--- a/res/layout/people_activity_tabs_lands.xml
+++ b/res/layout/people_activity_tabs_lands.xml
@@ -23,5 +23,6 @@
android:orientation="horizontal"
android:layout_gravity="top"
android:layout_weight="0"
+ android:visibility="gone"
android:textSize="@dimen/people_activity_landscape_tabs_text_size"
style="@style/ContactsActionBarTabTextStyle" />
diff --git a/res/layout/people_activity_toolbar.xml b/res/layout/people_activity_toolbar.xml
index da1dae4..3826242 100644
--- a/res/layout/people_activity_toolbar.xml
+++ b/res/layout/people_activity_toolbar.xml
@@ -46,6 +46,7 @@
android:layout_gravity="top"
android:layout_weight="0"
android:layout_below="@id/toolbar"
+ android:visibility="gone"
style="@style/ContactsActionBarTabTextStyle" />
</LinearLayout>
\ No newline at end of file
diff --git a/res/menu/people_options.xml b/res/menu/people_options.xml
index 4c8b21d..7bcd750 100644
--- a/res/menu/people_options.xml
+++ b/res/menu/people_options.xml
@@ -30,10 +30,6 @@
android:title="@string/menu_import_export" />
<item
- android:id="@+id/menu_clear_frequents"
- android:title="@string/menu_clear_frequents" />
-
- <item
android:id="@+id/menu_blocked_numbers"
android:title="@string/menu_blocked_numbers"/>
diff --git a/res/values-land/integers.xml b/res/values-land/integers.xml
index 08e1fe3..59ac54e 100644
--- a/res/values-land/integers.xml
+++ b/res/values-land/integers.xml
@@ -14,9 +14,6 @@
limitations under the License.
-->
<resources>
- <!-- Determines the number of columns in a ContactTileRow in the favorites tab -->
- <integer name="contact_tile_column_count_in_favorites">5</integer>
-
<integer name="contact_tile_column_count">4</integer>
<!-- Number of lines the QuickContact title can have -->
diff --git a/res/values-sw600dp-land/integers.xml b/res/values-sw600dp-land/integers.xml
index 08aab2d..0d934e8 100644
--- a/res/values-sw600dp-land/integers.xml
+++ b/res/values-sw600dp-land/integers.xml
@@ -14,9 +14,6 @@
limitations under the License.
-->
<resources>
- <!-- Determines the number of columns in a ContactTileRow in the favorites tab -->
- <integer name="contact_tile_column_count_in_favorites">5</integer>
-
<integer name="contact_tile_column_count">3</integer>
<!-- Layout weight of space elements in PeopleActivity for favorites list and all
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
index 1af9d75..78bec34 100644
--- a/res/values-sw600dp/dimens.xml
+++ b/res/values-sw600dp/dimens.xml
@@ -23,7 +23,6 @@
<dimen name="list_section_height">37dip</dimen>
<dimen name="group_detail_border_padding">16dip</dimen>
<dimen name="search_view_width">400dip</dimen>
- <dimen name="contact_tile_list_padding_top">18dip</dimen>
<dimen name="contact_browser_list_item_text_size">18sp</dimen>
<dimen name="contact_browser_list_item_photo_size">50dp</dimen>
<dimen name="contact_browser_list_item_gap_between_image_and_text">25dp</dimen>
diff --git a/res/values-sw600dp/integers.xml b/res/values-sw600dp/integers.xml
index 19e2ec6..c629f7e 100644
--- a/res/values-sw600dp/integers.xml
+++ b/res/values-sw600dp/integers.xml
@@ -15,6 +15,4 @@
-->
<resources>
<integer name="contact_tile_column_count">2</integer>
- <!-- Determines the number of columns in a ContactTileRow in the favorites tab -->
- <integer name="contact_tile_column_count_in_favorites">4</integer>
</resources>
diff --git a/res/values-sw720dp-land/dimens.xml b/res/values-sw720dp-land/dimens.xml
index 9dfb96a..fac6a46 100644
--- a/res/values-sw720dp-land/dimens.xml
+++ b/res/values-sw720dp-land/dimens.xml
@@ -17,7 +17,6 @@
<dimen name="group_detail_border_padding">32dip</dimen>
<dimen name="group_editor_side_padding">64dip</dimen>
<dimen name="contact_detail_list_top_padding">32dip</dimen>
- <dimen name="contact_tile_list_padding_top">32dip</dimen>
<dimen name="list_visible_scrollbar_padding">48dip</dimen>
<dimen name="detail_contact_photo_size">256dip</dimen>
<!-- Right margin of the floating action button -->
diff --git a/res/values-sw720dp-land/integers.xml b/res/values-sw720dp-land/integers.xml
index 2ebb100..d247e46 100644
--- a/res/values-sw720dp-land/integers.xml
+++ b/res/values-sw720dp-land/integers.xml
@@ -15,6 +15,4 @@
-->
<resources>
<integer name="contact_tile_column_count">4</integer>
- <!-- Determines the number of columns in a ContactTileRow in the favorites tab -->
- <integer name="contact_tile_column_count_in_favorites">5</integer>
</resources>
diff --git a/res/values-sw720dp/integers.xml b/res/values-sw720dp/integers.xml
index ff73c62..cf6b77c 100644
--- a/res/values-sw720dp/integers.xml
+++ b/res/values-sw720dp/integers.xml
@@ -14,9 +14,6 @@
limitations under the License.
-->
<resources>
- <!-- Determines the number of columns in a ContactTileRow in the favorites tab -->
- <integer name="contact_tile_column_count_in_favorites">4</integer>
-
<integer name="contact_tile_column_count">2</integer>
<!-- Layout weight of column space elements for favorites list, all contacts list and
diff --git a/res/values/integers.xml b/res/values/integers.xml
index 86a8e26..a37488e 100644
--- a/res/values/integers.xml
+++ b/res/values/integers.xml
@@ -15,9 +15,6 @@
-->
<resources>
- <!-- Determines the number of columns in a ContactTileRow in the favorites tab -->
- <integer name="contact_tile_column_count_in_favorites">3</integer>
-
<!-- Determines the number of columns in a ContactTileRow -->
<integer name="contact_tile_column_count">2</integer>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9effe75..711caae 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -372,9 +372,6 @@
<!-- The title of "all contacts" tab. [CHAR LIMIT=14] -->
<string name="all_contacts_tab_label">All</string>
- <!-- The title of "favorites" tab. [CHAR LIMIT=14] -->
- <string name="favorites_tab_label">Favorites</string>
-
<!-- Action string for calling back a number in the call log -->
<string name="callBack">Call back</string>
diff --git a/src/com/android/contacts/activities/ActionBarAdapter.java b/src/com/android/contacts/activities/ActionBarAdapter.java
index 46bb9c9..febfa44 100644
--- a/src/com/android/contacts/activities/ActionBarAdapter.java
+++ b/src/com/android/contacts/activities/ActionBarAdapter.java
@@ -110,10 +110,9 @@
private boolean mShowHomeIcon;
public interface TabState {
- public static int FAVORITES = 0;
- public static int ALL = 1;
+ public static int ALL = 0;
- public static int COUNT = 2;
+ public static int COUNT = 1;
public static int DEFAULT = ALL;
}
diff --git a/src/com/android/contacts/activities/PeopleActivity.java b/src/com/android/contacts/activities/PeopleActivity.java
index 4467cde..e2c06dd 100644
--- a/src/com/android/contacts/activities/PeopleActivity.java
+++ b/src/com/android/contacts/activities/PeopleActivity.java
@@ -62,12 +62,10 @@
import com.android.contacts.common.activity.RequestPermissionsActivity;
import com.android.contacts.common.compat.BlockedNumberContractCompat;
import com.android.contacts.common.compat.TelecomManagerUtil;
-import com.android.contacts.common.dialog.ClearFrequentsDialog;
import com.android.contacts.common.interactions.ImportExportDialogFragment;
import com.android.contacts.common.list.ContactEntryListFragment;
import com.android.contacts.common.list.ContactListFilter;
import com.android.contacts.common.list.ContactListFilterController;
-import com.android.contacts.common.list.ContactTileAdapter.DisplayType;
import com.android.contacts.common.list.DirectoryListLoader;
import com.android.contacts.common.list.ViewPagerTabs;
import com.android.contacts.common.logging.Logger;
@@ -88,7 +86,6 @@
import com.android.contacts.interactions.ContactMultiDeletionInteraction.MultiContactDeleteListener;
import com.android.contacts.interactions.JoinContactsDialogFragment;
import com.android.contacts.interactions.JoinContactsDialogFragment.JoinContactsListener;
-import com.android.contacts.list.ContactTileListFragment;
import com.android.contacts.list.ContactsIntentResolver;
import com.android.contacts.list.ContactsRequest;
import com.android.contacts.list.ContactsUnavailableFragment;
@@ -140,9 +137,6 @@
private View mFloatingActionButtonContainer;
private boolean wasLastFabAnimationScaleIn = false;
- private ContactTileListFragment.Listener mFavoritesFragmentListener =
- new StrequentContactListFragmentListener();
-
private ContactListFilterController mContactListFilterController;
private ContactsUnavailableFragment mContactsUnavailableFragment;
@@ -155,7 +149,6 @@
* Showing a list of Contacts. Also used for showing search results in search mode.
*/
private MultiSelectContactsListFragment mAllFragment;
- private ContactTileListFragment mFavoritesFragment;
private GroupsFragment mGroupsFragment;
/** ViewPager for swipe */
@@ -319,7 +312,6 @@
final FragmentTransaction transaction = fragmentManager.beginTransaction();
mTabTitles = new String[TabState.COUNT];
- mTabTitles[TabState.FAVORITES] = getString(R.string.favorites_tab_label);
mTabTitles[TabState.ALL] = getString(R.string.all_contacts_tab_label);
mTabPager = getView(R.id.tab_pager);
mTabPagerAdapter = new TabPagerAdapter();
@@ -367,17 +359,12 @@
// However, if it's after screen rotation, the fragments have been re-created by
// the fragment manager, so first see if there're already the target fragments
// existing.
- mFavoritesFragment = (ContactTileListFragment)
- fragmentManager.findFragmentByTag(FAVORITE_TAG);
mAllFragment = (MultiSelectContactsListFragment)
fragmentManager.findFragmentByTag(ALL_TAG);
mGroupsFragment = (GroupsFragment)
fragmentManager.findFragmentByTag(GROUPS_TAG);
- if (mFavoritesFragment == null) {
- mFavoritesFragment = new ContactTileListFragment();
- transaction.add(R.id.tab_pager, mFavoritesFragment, FAVORITE_TAG);
-
+ if (mAllFragment == null) {
mAllFragment = new MultiSelectContactsListFragment();
transaction.add(R.id.tab_pager, mAllFragment, ALL_TAG);
@@ -387,8 +374,6 @@
}
}
- mFavoritesFragment.setListener(mFavoritesFragmentListener);
-
mAllFragment.setOnContactListActionListener(new ContactBrowserActionListener());
mAllFragment.setCheckBoxListListener(new CheckBoxListListener());
@@ -398,16 +383,12 @@
// Hide all fragments for now. We adjust visibility when we get onSelectedTabChanged()
// from ActionBarAdapter.
- transaction.hide(mFavoritesFragment);
transaction.hide(mAllFragment);
// Groups fragment has no UI, no need to hide it
transaction.commitAllowingStateLoss();
fragmentManager.executePendingTransactions();
- // Setting Properties after fragment is created
- mFavoritesFragment.setDisplayType(DisplayType.STREQUENT);
-
mActionBarAdapter = new ActionBarAdapter(this, this, getSupportActionBar(),
portraitViewPagerTabs, landscapeViewPagerTabs, toolbar);
mActionBarAdapter.initialize(savedState, mRequest);
@@ -514,7 +495,7 @@
case ContactsRequest.ACTION_FREQUENT:
case ContactsRequest.ACTION_STREQUENT:
case ContactsRequest.ACTION_STARRED:
- tabToOpen = TabState.FAVORITES;
+ tabToOpen = TabState.ALL;
break;
case ContactsRequest.ACTION_VIEW_CONTACT:
tabToOpen = TabState.ALL;
@@ -672,10 +653,6 @@
private void showEmptyStateForTab(int tab) {
if (mContactsUnavailableFragment != null) {
switch (getTabPositionForTextDirection(tab)) {
- case TabState.FAVORITES:
- mContactsUnavailableFragment.setTabInfo(
- R.string.listTotalAllContactsZeroStarred, TabState.FAVORITES);
- break;
case TabState.ALL:
mContactsUnavailableFragment.setTabInfo(R.string.noContacts, TabState.ALL);
break;
@@ -776,9 +753,6 @@
return 0; // Only 1 page in search mode
}
} else {
- if (object == mFavoritesFragment) {
- return getTabPositionForTextDirection(TabState.FAVORITES);
- }
if (object == mAllFragment) {
return getTabPositionForTextDirection(TabState.ALL);
}
@@ -801,9 +775,7 @@
}
return mAllFragment;
} else {
- if (position == TabState.FAVORITES) {
- return mFavoritesFragment;
- } else if (position == TabState.ALL) {
+ if (position == TabState.ALL) {
return mAllFragment;
}
}
@@ -1082,25 +1054,6 @@
}
}
- private final class StrequentContactListFragmentListener
- implements ContactTileListFragment.Listener {
- StrequentContactListFragmentListener() {}
-
- @Override
- public void onContactSelected(Uri contactUri, Rect targetRect) {
- final Intent intent = ImplicitIntentsUtil.composeQuickContactIntent(contactUri,
- QuickContactActivity.MODE_FULLY_EXPANDED);
- intent.putExtra(QuickContactActivity.EXTRA_PREVIOUS_SCREEN_TYPE, ScreenType.FAVORITES);
- ImplicitIntentsUtil.startActivityInApp(PeopleActivity.this, intent);
- }
-
- @Override
- public void onCallNumberDirectly(String phoneNumber) {
- // No need to call phone number directly from People app.
- Log.w(TAG, "unexpected invocation of onCallNumberDirectly()");
- }
- }
-
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (!areContactsAvailable()) {
@@ -1142,22 +1095,15 @@
// Get references to individual menu items in the menu
final MenuItem contactsFilterMenu = menu.findItem(R.id.menu_contacts_filter);
- final MenuItem clearFrequentsMenu = menu.findItem(R.id.menu_clear_frequents);
final boolean isSearchOrSelectionMode = mActionBarAdapter.isSearchMode()
|| mActionBarAdapter.isSelectionMode();
if (isSearchOrSelectionMode) {
contactsFilterMenu.setVisible(false);
- clearFrequentsMenu.setVisible(false);
} else {
switch (getTabPositionForTextDirection(mActionBarAdapter.getCurrentTab())) {
- case TabState.FAVORITES:
- contactsFilterMenu.setVisible(false);
- clearFrequentsMenu.setVisible(hasFrequents());
- break;
case TabState.ALL:
contactsFilterMenu.setVisible(true);
- clearFrequentsMenu.setVisible(false);
break;
}
}
@@ -1195,14 +1141,6 @@
return receivers != null && receivers.size() > 0;
}
- /**
- * Returns whether there are any frequently contacted people being displayed
- * @return
- */
- private boolean hasFrequents() {
- return mFavoritesFragment.hasFrequents();
- }
-
private void makeMenuItemVisible(Menu menu, int itemId, boolean visible) {
final MenuItem item = menu.findItem(itemId);
if (item != null) {
@@ -1248,10 +1186,6 @@
showImportExportDialogFragment();
return true;
}
- case R.id.menu_clear_frequents: {
- ClearFrequentsDialog.show(getFragmentManager());
- return true;
- }
case R.id.menu_accounts: {
final Intent intent = new Intent(Settings.ACTION_SYNC_SETTINGS);
intent.putExtra(Settings.EXTRA_AUTHORITIES, new String[] {
@@ -1305,14 +1239,8 @@
}
private void showImportExportDialogFragment(){
- final boolean isOnFavoriteTab = mTabPagerAdapter.mCurrentPrimaryItem == mFavoritesFragment;
- if (isOnFavoriteTab) {
- ImportExportDialogFragment.show(getFragmentManager(), areContactsAvailable(),
- PeopleActivity.class, ImportExportDialogFragment.EXPORT_MODE_FAVORITES);
- } else {
- ImportExportDialogFragment.show(getFragmentManager(), areContactsAvailable(),
- PeopleActivity.class, ImportExportDialogFragment.EXPORT_MODE_ALL_CONTACTS);
- }
+ ImportExportDialogFragment.show(getFragmentManager(), areContactsAvailable(),
+ PeopleActivity.class, ImportExportDialogFragment.EXPORT_MODE_ALL_CONTACTS);
}
@Override
diff --git a/src/com/android/contacts/list/ContactTileListFragment.java b/src/com/android/contacts/list/ContactTileListFragment.java
deleted file mode 100644
index 189cfd3..0000000
--- a/src/com/android/contacts/list/ContactTileListFragment.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright (C) 2011 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.list;
-
-import android.app.Activity;
-import android.app.Fragment;
-import android.app.LoaderManager;
-import android.app.LoaderManager.LoaderCallbacks;
-import android.content.CursorLoader;
-import android.content.Loader;
-import android.content.res.Resources;
-import android.database.Cursor;
-import android.graphics.Rect;
-import android.net.Uri;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.ListView;
-import android.widget.TextView;
-import com.android.contacts.R;
-import com.android.contacts.common.ContactPhotoManager;
-import com.android.contacts.common.ContactTileLoaderFactory;
-import com.android.contacts.common.list.ContactTileAdapter;
-import com.android.contacts.common.list.ContactTileAdapter.DisplayType;
-import com.android.contacts.common.list.ContactTileView;
-import com.android.contacts.common.util.ContactListViewUtils;
-import com.android.contacts.common.util.SchedulingUtils;
-
-/**
- * Fragment containing a list of starred contacts followed by a list of frequently contacted.
- *
- * TODO: Make this an abstract class so that the favorites, frequent, and group list functionality
- * can be separated out. This will make it easier to customize any of those lists if necessary
- * (i.e. adding header views to the ListViews in the fragment). This work was started
- * by creating {@link ContactTileFrequentFragment}.
- */
-public class ContactTileListFragment extends Fragment {
- private static final String TAG = ContactTileListFragment.class.getSimpleName();
-
- public interface Listener {
- void onContactSelected(Uri contactUri, Rect targetRect);
- void onCallNumberDirectly(String phoneNumber);
- }
-
- private Listener mListener;
- private ContactTileAdapter mAdapter;
- private DisplayType mDisplayType;
- private TextView mEmptyView;
- private ListView mListView;
-
- private boolean mOptionsMenuHasFrequents;
-
- @Override
- public void onAttach(Activity activity) {
- super.onAttach(activity);
-
- Resources res = getResources();
- int columnCount = res.getInteger(R.integer.contact_tile_column_count_in_favorites);
-
- mAdapter = new ContactTileAdapter(activity, mAdapterListener,
- columnCount, mDisplayType);
- mAdapter.setPhotoLoader(ContactPhotoManager.getInstance(activity));
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- return inflateAndSetupView(inflater, container, savedInstanceState,
- R.layout.contact_tile_list);
- }
-
- protected View inflateAndSetupView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState, int layoutResourceId) {
- View listLayout = inflater.inflate(layoutResourceId, container, false);
-
- mEmptyView = (TextView) listLayout.findViewById(R.id.contact_tile_list_empty);
- mListView = (ListView) listLayout.findViewById(R.id.contact_tile_list);
-
- mListView.setItemsCanFocus(true);
- mListView.setAdapter(mAdapter);
- ContactListViewUtils.applyCardPaddingToView(getResources(), mListView, listLayout);
-
- return listLayout;
- }
-
- @Override
- public void onHiddenChanged(boolean hidden) {
- super.onHiddenChanged(hidden);
- if (getActivity() != null && getView() != null && !hidden) {
- // If the padding was last applied when in a hidden state, it may have been applied
- // incorrectly. Therefore we need to reapply it.
- ContactListViewUtils.applyCardPaddingToView(getResources(), mListView, getView());
- }
- }
-
- @Override
- public void onStart() {
- super.onStart();
-
- // initialize the loader for this display type and destroy all others
- final DisplayType[] loaderTypes = mDisplayType.values();
- for (int i = 0; i < loaderTypes.length; i++) {
- if (loaderTypes[i] == mDisplayType) {
- getLoaderManager().initLoader(mDisplayType.ordinal(), null,
- mContactTileLoaderListener);
- } else {
- getLoaderManager().destroyLoader(loaderTypes[i].ordinal());
- }
- }
- }
-
- /**
- * Returns whether there are any frequents with the side effect of setting the
- * internal flag mOptionsMenuHasFrequents to the value. This should be called externally
- * by the activity that is about to prepare the options menu with the clear frequents
- * menu item.
- */
- public boolean hasFrequents() {
- mOptionsMenuHasFrequents = internalHasFrequents();
- return mOptionsMenuHasFrequents;
- }
-
- /**
- * Returns whether there are any frequents.
- */
- private boolean internalHasFrequents() {
- return mAdapter.getNumFrequents() > 0;
- }
-
- public void setColumnCount(int columnCount) {
- mAdapter.setColumnCount(columnCount);
- }
-
- public void setDisplayType(DisplayType displayType) {
- mDisplayType = displayType;
- mAdapter.setDisplayType(mDisplayType);
- }
-
- public void enableQuickContact(boolean enableQuickContact) {
- mAdapter.enableQuickContact(enableQuickContact);
- }
-
- private final LoaderManager.LoaderCallbacks<Cursor> mContactTileLoaderListener =
- new LoaderCallbacks<Cursor>() {
-
- @Override
- public CursorLoader onCreateLoader(int id, Bundle args) {
- switch (mDisplayType) {
- case STARRED_ONLY:
- return ContactTileLoaderFactory.createStarredLoader(getActivity());
- case STREQUENT:
- return ContactTileLoaderFactory.createStrequentLoader(getActivity());
- case FREQUENT_ONLY:
- return ContactTileLoaderFactory.createFrequentLoader(getActivity());
- default:
- throw new IllegalStateException(
- "Unrecognized DisplayType " + mDisplayType);
- }
- }
-
- @Override
- public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
- if (data == null || data.isClosed()) {
- Log.e(TAG, "Failed to load contacts");
- return;
- }
- mAdapter.setContactCursor(data);
- mEmptyView.setText(getEmptyStateText());
- mListView.setEmptyView(mEmptyView);
-
- // invalidate the menu options if needed
- invalidateOptionsMenuIfNeeded();
- }
-
- @Override
- public void onLoaderReset(Loader<Cursor> loader) {}
- };
-
- private boolean isOptionsMenuChanged() {
- return mOptionsMenuHasFrequents != internalHasFrequents();
- }
-
- private void invalidateOptionsMenuIfNeeded() {
- if (isOptionsMenuChanged()) {
- getActivity().invalidateOptionsMenu();
- }
- }
-
- private String getEmptyStateText() {
- String emptyText;
- switch (mDisplayType) {
- case STREQUENT:
- case STARRED_ONLY:
- emptyText = getString(R.string.listTotalAllContactsZeroStarred);
- break;
- case FREQUENT_ONLY:
- case GROUP_MEMBERS:
- emptyText = getString(R.string.noContacts);
- break;
- default:
- throw new IllegalArgumentException("Unrecognized DisplayType " + mDisplayType);
- }
- return emptyText;
- }
-
- public void setListener(Listener listener) {
- mListener = listener;
- }
-
- private ContactTileView.Listener mAdapterListener =
- new ContactTileView.Listener() {
- @Override
- public void onContactSelected(Uri contactUri, Rect targetRect) {
- if (mListener != null) {
- mListener.onContactSelected(contactUri, targetRect);
- }
- }
-
- @Override
- public void onCallNumberDirectly(String phoneNumber) {
- if (mListener != null) {
- mListener.onCallNumberDirectly(phoneNumber);
- }
- }
-
- @Override
- public int getApproximateTileWidth() {
- return getView().getWidth() / mAdapter.getColumnCount();
- }
- };
-}
diff --git a/src/com/android/contacts/list/ContactsUnavailableFragment.java b/src/com/android/contacts/list/ContactsUnavailableFragment.java
index 8cbbaa8..5c62e5c 100644
--- a/src/com/android/contacts/list/ContactsUnavailableFragment.java
+++ b/src/com/android/contacts/list/ContactsUnavailableFragment.java
@@ -172,11 +172,7 @@
mMessageView.setText(mNoContactsMsgResId);
mMessageView.setGravity(Gravity.CENTER_HORIZONTAL);
mMessageView.setVisibility(View.VISIBLE);
- if (callerTab == TabState.FAVORITES) {
- mImageView.setImageResource(R.drawable.ic_star_black_128dp);
- mProgress.setVisibility(View.GONE);
- updateButtonVisibilty(View.GONE);
- } else if (callerTab == TabState.ALL) {
+ if (callerTab == TabState.ALL) {
mImageView.setImageResource(R.drawable.ic_person_black_128dp);
updateButtonVisibilty(View.VISIBLE);
}
diff --git a/src/com/android/contacts/list/MultiSelectEntryContactListAdapter.java b/src/com/android/contacts/list/MultiSelectEntryContactListAdapter.java
index 3ba86db..b080657 100644
--- a/src/com/android/contacts/list/MultiSelectEntryContactListAdapter.java
+++ b/src/com/android/contacts/list/MultiSelectEntryContactListAdapter.java
@@ -142,6 +142,7 @@
} else {
mSelectedContactIds.remove(contactId);
}
+ notifyDataSetChanged();
if (mSelectedContactsListener != null) {
mSelectedContactsListener.onSelectedContactsChangedViaCheckBox();
}