Merge "Add number type label to favorites list" into klp-dev
diff --git a/res/layout/phone_favorite_regular_row_view.xml b/res/layout/phone_favorite_regular_row_view.xml
index bf63642..c4c9c55 100644
--- a/res/layout/phone_favorite_regular_row_view.xml
+++ b/res/layout/phone_favorite_regular_row_view.xml
@@ -53,6 +53,21 @@
             android:ellipsize="marquee"
             android:textAlignment="viewStart" />
 
+        <TextView
+            android:id="@+id/contact_tile_phone_type"
+            android:layout_height="wrap_content"
+            android:layout_width="wrap_content"
+            android:layout_below="@id/contact_tile_name"
+            android:layout_toRightOf="@id/contact_tile_quick"
+            android:layout_toEndOf="@id/contact_tile_quick"
+            android:textSize="12sp"
+            android:ellipsize="marquee"
+            android:singleLine="true"
+            android:textColor="@color/dialtacts_secondary_text_color"
+            android:layout_marginLeft="8dip"
+            android:layout_marginStart="8dip"
+            android:layout_gravity="bottom" />
+
     </RelativeLayout>
 
     <LinearLayout
diff --git a/src/com/android/dialer/list/PhoneFavoriteRegularRowView.java b/src/com/android/dialer/list/PhoneFavoriteRegularRowView.java
index b4ad784..91b09d7 100644
--- a/src/com/android/dialer/list/PhoneFavoriteRegularRowView.java
+++ b/src/com/android/dialer/list/PhoneFavoriteRegularRowView.java
@@ -18,15 +18,11 @@
 import android.content.Context;
 import android.content.res.Resources;
 import android.util.AttributeSet;
-import android.view.GestureDetector;
 import android.view.View;
 
 import com.android.contacts.common.util.ViewUtil;
 import com.android.dialer.R;
 
-import com.android.dialer.list.PhoneFavoritesTileAdapter.ContactTileRow;
-
-
 public class PhoneFavoriteRegularRowView extends PhoneFavoriteTileView {
     private static final String TAG = PhoneFavoriteRegularRowView.class.getSimpleName();
     private static final boolean DEBUG = false;
diff --git a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
index 2b232e8..6969f6f 100644
--- a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
+++ b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java
@@ -106,16 +106,11 @@
     protected int mPresenceIndex;
     protected int mStatusIndex;
 
-    /**
-     * Only valid when {@link DisplayType#STREQUENT_PHONE_ONLY} is true
-     *
-     * TODO krelease: Remove entirely if not needed
-     */
     private int mPhoneNumberIndex;
     private int mPhoneNumberTypeIndex;
     private int mPhoneNumberLabelIndex;
     protected int mPinnedIndex;
-    protected int mContactIdForFrequentIndex;
+    protected int mContactIdIndex;
 
     private final int mPaddingInPixels;
 
@@ -209,7 +204,7 @@
         mPhoneNumberTypeIndex = ContactTileLoaderFactory.PHONE_NUMBER_TYPE;
         mPhoneNumberLabelIndex = ContactTileLoaderFactory.PHONE_NUMBER_LABEL;
         mPinnedIndex = ContactTileLoaderFactory.PINNED;
-        mContactIdForFrequentIndex = ContactTileLoaderFactory.CONTACT_ID_FOR_FREQUENT;
+        mContactIdIndex = ContactTileLoaderFactory.CONTACT_ID_FOR_DATA;
     }
 
     /**
@@ -274,14 +269,12 @@
             final int starred = cursor.getInt(mStarredIndex);
             final long id;
 
-            if (starred > 0) {
-                id = cursor.getLong(mIdIndex);
-            } else if (counter >= TILES_SOFT_LIMIT) {
+            // We display a maximum of TILES_SOFT_LIMIT contacts, or the total number of starred
+            // whichever is greater.
+            if (starred < 1 && counter >= TILES_SOFT_LIMIT) {
                 break;
             } else {
-                // The contact id for frequent contacts is stored in the .contact_id field rather
-                // than the _id field
-                id = cursor.getLong(mContactIdForFrequentIndex);
+                id = cursor.getLong(mContactIdIndex);
             }
 
             if (duplicates.get(id) == null) {
@@ -305,20 +298,12 @@
                     Uri.withAppendedPath(Contacts.CONTENT_LOOKUP_URI, lookupKey), id);
 
 
-            // TODO krelease: These columns are temporarily unused for now so that
-            // the contact tiles will be treated like favorites since they don't have a phone
-            // number. Depending on how the final UX goes we will either remove or enable
-            // them again.
-
-            /*
-                // Set phone number, label and status
-                final int phoneNumberType = cursor.getInt(mPhoneNumberTypeIndex);
-                final String phoneNumberCustomLabel = cursor.getString(mPhoneNumberLabelIndex);
-                contact.phoneLabel = (String) Phone.getTypeLabel(mResources, phoneNumberType,
-                        phoneNumberCustomLabel);
-                contact.phoneNumber = cursor.getString(mPhoneNumberIndex);
-                contact.status = cursor.getString(mStatusIndex);
-            */
+            // Set phone number, label and status
+            final int phoneNumberType = cursor.getInt(mPhoneNumberTypeIndex);
+            final String phoneNumberCustomLabel = cursor.getString(mPhoneNumberLabelIndex);
+            contact.phoneLabel = (String) Phone.getTypeLabel(mResources, phoneNumberType,
+                    phoneNumberCustomLabel);
+            contact.phoneNumber = cursor.getString(mPhoneNumberIndex);
 
             contact.pinned = pinned;
             mContactEntries.add(contact);