diff options
author | Yorke Lee <yorkelee@google.com> | 2014-04-18 14:05:01 -0700 |
---|---|---|
committer | Yorke Lee <yorkelee@google.com> | 2014-04-21 15:27:32 -0700 |
commit | efb2d9c2e32ca4ed434ff785c4b3d18c9e08db6d (patch) | |
tree | ce2311920dedaebf8abaa33f139e21502ffd4c5b /src/com/android/dialer/list/PhoneFavoriteSquareTileView.java | |
parent | 93dcef71c7ea7a99ef4067ab3dea79a263b9613b (diff) | |
download | android_packages_apps_Dialer-efb2d9c2e32ca4ed434ff785c4b3d18c9e08db6d.tar.gz android_packages_apps_Dialer-efb2d9c2e32ca4ed434ff785c4b3d18c9e08db6d.tar.bz2 android_packages_apps_Dialer-efb2d9c2e32ca4ed434ff785c4b3d18c9e08db6d.zip |
Use PhoneFavoritesTileAdapter directly in GridView
This CL moves the adapter that contains the speed dial contacts into
its own GridView that lives in PhoneFavoritesFragment. This is the
first step to splitting up PhoneFavoritesMergedAdapter into
a list of shortcuts and a grid of contacts, and also get rid of the
convoluted ContactTileRow logic within PhoneFavoritesTileAdapter, to
facilitate a future transition to RecyclerView.
* PhoneFavoritesTileAdapter now directly returns PhoneFavoriteTileViews
rather than ContactTileRows.
* Deleted a lot of unnecessary complicated logic within
PhoneFavoritesTileAdapter that had to do with ContactTileRows.
* Simplified and rewrote animation logic so that animations now perform
as expected within the GridView. In the future this may not be necessary
if RecyclerView is used.
* Rewrote layout/measurement logic for PhoneFavoriteTileView. It now
determines its height directly based on what its measured width is.
* Replaced PhoneFavoritesListView in PhoneFavoriteFragment with a
standard GridView
* Delete stale PhoneFavoriteTileAdapter tests
Notes:
Call shortcut cards are now temporarily missing due to this change
Bug: 13963734
Bug: 13933092
Bug: 13419223
Change-Id: I71e8970667589e4024d00e9af2c8b45c843c5db1
Diffstat (limited to 'src/com/android/dialer/list/PhoneFavoriteSquareTileView.java')
-rw-r--r-- | src/com/android/dialer/list/PhoneFavoriteSquareTileView.java | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/src/com/android/dialer/list/PhoneFavoriteSquareTileView.java b/src/com/android/dialer/list/PhoneFavoriteSquareTileView.java index 181d602bc..0520ab49c 100644 --- a/src/com/android/dialer/list/PhoneFavoriteSquareTileView.java +++ b/src/com/android/dialer/list/PhoneFavoriteSquareTileView.java @@ -18,7 +18,6 @@ package com.android.dialer.list; import android.content.Context; import android.provider.ContactsContract.QuickContact; -import android.text.TextUtils; import android.util.AttributeSet; import android.view.View; import android.widget.ImageButton; @@ -26,18 +25,23 @@ import android.widget.ImageButton; import com.android.contacts.common.R; import com.android.contacts.common.list.ContactEntry; -import java.util.regex.Pattern; - /** - * Displays the contact's picture overlayed with their name - * in a perfect square. It also has an additional touch target for a secondary action. + * Displays the contact's picture overlaid with their name and number type in a tile. */ public class PhoneFavoriteSquareTileView extends PhoneFavoriteTileView { private static final String TAG = PhoneFavoriteSquareTileView.class.getSimpleName(); + + private final float mHeightToWidthRatio; + private ImageButton mSecondaryButton; + private ContactEntry mContactEntry; + public PhoneFavoriteSquareTileView(Context context, AttributeSet attrs) { super(context, attrs); + + mHeightToWidthRatio = getResources().getFraction( + R.dimen.contact_tile_height_to_width_ratio, 1, 1); } @Override @@ -50,7 +54,7 @@ public class PhoneFavoriteSquareTileView extends PhoneFavoriteTileView { @Override protected int getApproximateImageSize() { // The picture is the full size of the tile (minus some padding, but we can be generous) - return mListener.getApproximateTileWidth(); + return getWidth(); } private void launchQuickContact() { @@ -69,5 +73,24 @@ public class PhoneFavoriteSquareTileView extends PhoneFavoriteTileView { } }); } + mContactEntry = entry; + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + final int width = MeasureSpec.getSize(widthMeasureSpec); + final int height = (int) (mHeightToWidthRatio * width); + final int count = getChildCount(); + for (int i = 0; i < count; i++) { + getChildAt(i).measure( + MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), + MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY) + ); + } + setMeasuredDimension(width, height); + } + + public ContactEntry getContactEntry() { + return mContactEntry; } } |