summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristine Chen <christinech@google.com>2013-09-24 17:42:32 -0700
committerChristine Chen <christinech@google.com>2013-09-26 11:05:26 -0700
commit4fdf594962b3928c6497b471dbb1ee7be56e18ef (patch)
treec289bc21ef4e0a8a79f61294554cb2e7d78845fd /src
parentad4a5f1f6ded88bcf4e91f1819550619a8a99d19 (diff)
Add no favorite card to the Dialer
Bug: 10862541 Change-Id: I7299d38dcc63fa2a37e61949ebfcc794c3471c70
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/list/PhoneFavoriteFragment.java74
-rw-r--r--src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java14
-rw-r--r--src/com/android/dialer/list/PhoneFavoritesTileAdapter.java23
3 files changed, 74 insertions, 37 deletions
diff --git a/src/com/android/dialer/list/PhoneFavoriteFragment.java b/src/com/android/dialer/list/PhoneFavoriteFragment.java
index 32ec71c26..aa81858f3 100644
--- a/src/com/android/dialer/list/PhoneFavoriteFragment.java
+++ b/src/com/android/dialer/list/PhoneFavoriteFragment.java
@@ -17,7 +17,9 @@ package com.android.dialer.list;
import android.animation.Animator;
import android.animation.AnimatorSet;
+import android.animation.ArgbEvaluator;
import android.animation.ObjectAnimator;
+import android.animation.ValueAnimator;
import android.app.Activity;
import android.app.Fragment;
import android.app.LoaderManager;
@@ -26,7 +28,6 @@ import android.content.CursorLoader;
import android.content.Loader;
import android.content.SharedPreferences;
import android.database.Cursor;
-import android.database.MatrixCursor;
import android.graphics.Rect;
import android.net.Uri;
import android.os.Bundle;
@@ -42,7 +43,6 @@ import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ImageView;
import android.widget.ListView;
-import android.widget.TextView;
import com.android.contacts.common.ContactPhotoManager;
import com.android.contacts.common.ContactTileLoaderFactory;
@@ -128,6 +128,7 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
if (DEBUG) Log.d(TAG, "ContactTileLoaderListener#onLoadFinished");
mContactTileAdapter.setContactCursor(data);
+ setEmptyViewVisibility(mContactTileAdapter.getCount() == 0);
}
@Override
@@ -179,9 +180,12 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
private CallLogAdapter mCallLogAdapter;
private CallLogQueryHandler mCallLogQueryHandler;
+ private View mParentView;
+
private PhoneFavoriteListView mListView;
private View mShowAllContactsButton;
+ private View mShowAllContactsInEmptyViewButton;
private final HashMap<Long, Integer> mItemIdTopMap = new HashMap<Long, Integer>();
private final HashMap<Long, Integer> mItemIdLeftMap = new HashMap<Long, Integer>();
@@ -253,10 +257,9 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- final View listLayout = inflater.inflate(
- R.layout.phone_favorites_fragment, container, false);
+ mParentView = inflater.inflate(R.layout.phone_favorites_fragment, container, false);
- mListView = (PhoneFavoriteListView) listLayout.findViewById(R.id.contact_tile_list);
+ mListView = (PhoneFavoriteListView) mParentView.findViewById(R.id.contact_tile_list);
mListView.setItemsCanFocus(true);
mListView.setOnItemClickListener(this);
mListView.setVerticalScrollBarEnabled(false);
@@ -266,10 +269,19 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
mListView.setOnDragDropListener(mContactTileAdapter);
final ImageView dragShadowOverlay =
- (ImageView) listLayout.findViewById(R.id.contact_tile_drag_shadow_overlay);
+ (ImageView) mParentView.findViewById(R.id.contact_tile_drag_shadow_overlay);
mListView.setDragShadowOverlay(dragShadowOverlay);
- mEmptyView = inflater.inflate(R.layout.phone_no_favorites, mListView, false);
+ mEmptyView = mParentView.findViewById(R.id.phone_no_favorites_view);
+
+ mShowAllContactsInEmptyViewButton = mParentView.findViewById(
+ R.id.show_all_contact_button_in_nofav);
+ mShowAllContactsInEmptyViewButton.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ showAllContacts();
+ }
+ });
mShowAllContactsButton = inflater.inflate(R.layout.show_all_contact_button, mListView,
false);
@@ -280,7 +292,6 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
}
});
- mContactTileAdapter.setEmptyView(mEmptyView);
mAdapter = new PhoneFavoriteMergedAdapter(getActivity(), this, mContactTileAdapter,
mCallLogAdapter, mShowAllContactsButton);
@@ -290,7 +301,7 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
mListView.setFastScrollEnabled(false);
mListView.setFastScrollAlwaysVisible(false);
- return listLayout;
+ return mParentView;
}
public boolean hasFrequents() {
@@ -298,6 +309,51 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen
return mContactTileAdapter.getNumFrequents() > 0;
}
+ /* package */ void setEmptyViewVisibility(final boolean visible) {
+ final int previousVisibility = mEmptyView.getVisibility();
+ final int newVisibility = visible ? View.VISIBLE : View.GONE;
+
+ if (previousVisibility != newVisibility) {
+ Integer colorFrom = visible ?
+ getResources().getColor(R.color.background_dialer_light) :
+ getResources().getColor(R.color.nofavorite_background_color);
+ Integer colorTo = visible ?
+ getResources().getColor(R.color.nofavorite_background_color) :
+ getResources().getColor(R.color.background_dialer_light);
+ ValueAnimator colorAnimation = ValueAnimator.ofObject(new ArgbEvaluator(),
+ colorFrom, colorTo);
+ colorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ @Override
+ public void onAnimationUpdate(ValueAnimator animator) {
+ mParentView.setBackgroundColor((Integer)animator.getAnimatedValue());
+ }
+ });
+ colorAnimation.addListener(new Animator.AnimatorListener() {
+ @Override
+ public void onAnimationStart(Animator animator) {
+ if (!visible) {
+ mEmptyView.setVisibility(View.GONE);
+ }
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animator) {
+ if (visible) {
+ mEmptyView.setVisibility(View.VISIBLE);
+ }
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animator) {}
+
+ @Override
+ public void onAnimationRepeat(Animator animator) {}
+ });
+
+ colorAnimation.start();
+ }
+ }
+
@Override
public void onStart() {
super.onStart();
diff --git a/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java b/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java
index cf2aeeee9..334743774 100644
--- a/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java
+++ b/src/com/android/dialer/list/PhoneFavoriteMergedAdapter.java
@@ -116,14 +116,12 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter {
}
@Override
- public boolean isEmpty() {
- // This adapter will always contain at least the all contacts button
- return false;
- }
-
- @Override
public int getCount() {
- return mContactTileAdapter.getCount() + mCallLogAdapter.getCount() + 1;
+ if (mContactTileAdapter.getCount() > 0) {
+ return mContactTileAdapter.getCount() + mCallLogAdapter.getCount() + 1;
+ } else {
+ return mCallLogAdapter.getCount();
+ }
}
@Override
@@ -198,7 +196,7 @@ public class PhoneFavoriteMergedAdapter extends BaseAdapter {
public View getView(int position, View convertView, ViewGroup parent) {
final int callLogAdapterCount = mCallLogAdapter.getCount();
- if (position == getCount() - 1) {
+ if ((position == getCount() - 1) && (mContactTileAdapter.getCount() > 0)) {
return mShowAllContactsButton;
}
diff --git a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
index 882d3c633..939a1eac3 100644
--- a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
+++ b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
@@ -73,8 +73,6 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
private Context mContext;
private Resources mResources;
- private View mEmptyView;
-
/** Contact data stored in cache. This is used to populate the associated view. */
protected ArrayList<ContactEntry> mContactEntries = null;
/** Back up of the temporarily removed Contact during dragging. */
@@ -362,15 +360,10 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
return mNumFrequents;
}
- private boolean isEmptyView(int position) {
- return position == 0 && (mContactEntries == null || mContactEntries.isEmpty());
- }
-
@Override
public int getCount() {
if (mContactEntries == null || mContactEntries.isEmpty()) {
- // empty view
- return 1;
+ return 0;
}
int total = mContactEntries.size();
@@ -493,7 +486,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
@Override
public boolean isEnabled(int position) {
- return !isEmptyView(position);
+ return getCount() > 0;
}
@Override
@@ -512,10 +505,6 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
int itemViewType = getItemViewType(position);
- if (itemViewType == ViewTypes.EMPTY) {
- return mEmptyView;
- }
-
ContactTileRow contactTileRowView = (ContactTileRow) convertView;
ArrayList<ContactEntry> contactList = getItem(position);
@@ -547,7 +536,6 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
@Override
public int getItemViewType(int position) {
- if (isEmptyView(position)) return ViewTypes.EMPTY;
if (position < getRowCount(getMaxContactsInTiles())) {
return ViewTypes.TOP;
} else {
@@ -1164,10 +1152,9 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
}
protected static class ViewTypes {
- public static final int COUNT = 3;
public static final int FREQUENT = 0;
public static final int TOP = 1;
- public static final int EMPTY = 2;
+ public static final int COUNT = 2;
}
@Override
@@ -1216,8 +1203,4 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements
setInDragging(false);
handleDrop();
}
-
- public void setEmptyView(View emptyView) {
- mEmptyView = emptyView;
- }
}