From fb34fdaeb60eaa20dbc825983edc17b45d879440 Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Wed, 13 Nov 2013 13:03:30 -0800 Subject: Change all contacts button to look like list item Rewrite layout of all contacts button to look like a regular contact list item. Update list default avatar background Bug: 11654293 Bug: 11668831 Change-Id: Iafa8f69e618b39eabf823cafd8153ed24ddbdfbd --- .../android/dialer/list/PhoneFavoriteFragment.java | 46 ++++++++++++++++------ 1 file changed, 34 insertions(+), 12 deletions(-) (limited to 'src/com/android/dialer') diff --git a/src/com/android/dialer/list/PhoneFavoriteFragment.java b/src/com/android/dialer/list/PhoneFavoriteFragment.java index 73703a02c..34666ee99 100644 --- a/src/com/android/dialer/list/PhoneFavoriteFragment.java +++ b/src/com/android/dialer/list/PhoneFavoriteFragment.java @@ -27,6 +27,7 @@ import android.content.Context; import android.content.CursorLoader; import android.content.Loader; import android.content.SharedPreferences; +import android.content.res.Resources; import android.database.Cursor; import android.graphics.Rect; import android.net.Uri; @@ -50,6 +51,7 @@ import com.android.contacts.common.ContactPhotoManager; import com.android.contacts.common.ContactTileLoaderFactory; import com.android.contacts.common.GeoUtil; import com.android.contacts.common.list.ContactEntry; +import com.android.contacts.common.list.ContactListItemView; import com.android.contacts.common.list.ContactTileView; import com.android.dialer.DialtactsActivity; import com.android.dialer.R; @@ -290,21 +292,12 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen mShowAllContactsInEmptyViewButton = mParentView.findViewById( R.id.show_all_contact_button_in_nofav); - mShowAllContactsInEmptyViewButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View view) { - showAllContacts(); - } - }); + prepareAllContactsButton(mShowAllContactsInEmptyViewButton); mShowAllContactsButton = inflater.inflate(R.layout.show_all_contact_button, mListView, false); - mShowAllContactsButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View view) { - showAllContacts(); - } - }); + + prepareAllContactsButton(mShowAllContactsButton); mContactTileFrame = mParentView.findViewById(R.id.contact_tile_frame); @@ -638,4 +631,33 @@ public class PhoneFavoriteFragment extends Fragment implements OnItemClickListen .apply(); fetchCalls(); } + + /** + * Returns a view that is laid out and styled to look like a regular contact, with the correct + * click behavior (to launch the all contacts activity when it is clicked). + */ + private View prepareAllContactsButton(View v) { + final ContactListItemView view = (ContactListItemView) v; + view.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + showAllContacts(); + } + }); + + view.setPhotoPosition(ContactListItemView.PhotoPosition.LEFT); + final Resources resources = getResources(); + view.setBackgroundResource(R.drawable.contact_list_item_background); + + view.setPaddingRelative( + resources.getDimensionPixelSize(R.dimen.favorites_row_start_padding), + resources.getDimensionPixelSize(R.dimen.favorites_row_end_padding), + resources.getDimensionPixelSize(R.dimen.favorites_row_top_padding), + resources.getDimensionPixelSize(R.dimen.favorites_row_bottom_padding)); + + view.setDisplayName(resources.getString(R.string.show_all_contacts_button_text)); + view.setDrawableResource(R.drawable.list_item_avatar_bg, + R.drawable.ic_menu_all_contacts_dk); + return view; + } } -- cgit v1.2.3