diff options
-rw-r--r-- | src/com/android/dialer/list/PhoneFavoriteSquareTileView.java | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/com/android/dialer/list/PhoneFavoriteSquareTileView.java b/src/com/android/dialer/list/PhoneFavoriteSquareTileView.java index 17f2b8a6c..e2548a3bf 100644 --- a/src/com/android/dialer/list/PhoneFavoriteSquareTileView.java +++ b/src/com/android/dialer/list/PhoneFavoriteSquareTileView.java @@ -17,16 +17,15 @@ package com.android.dialer.list; import android.content.Context; -import android.content.Intent; import android.provider.ContactsContract.QuickContact; +import android.text.TextUtils; import android.util.AttributeSet; -import android.view.GestureDetector; import android.view.View; import android.widget.ImageButton; import com.android.contacts.common.R; -import com.android.dialer.list.PhoneFavoriteDragAndDropListeners.PhoneFavoriteDragListener; -import com.android.dialer.list.PhoneFavoritesTileAdapter.ContactTileRow; + +import java.util.regex.Pattern; /** * Displays the contact's picture overlayed with their name @@ -36,6 +35,10 @@ public class PhoneFavoriteSquareTileView extends PhoneFavoriteTileView { private static final String TAG = PhoneFavoriteSquareTileView.class.getSimpleName(); private ImageButton mSecondaryButton; + // TODO: Use a more expansive name token separator if needed. For now it should be fine to + // not split by dashes, underscore etc. + private static final Pattern NAME_TOKEN_SEPARATOR_PATTERN = Pattern.compile("\\s+"); + public PhoneFavoriteSquareTileView(Context context, AttributeSet attrs) { super(context, attrs); } @@ -63,4 +66,12 @@ public class PhoneFavoriteSquareTileView extends PhoneFavoriteTileView { QuickContact.showQuickContact(getContext(), PhoneFavoriteSquareTileView.this, getLookupUri(), QuickContact.MODE_LARGE, null); } + + @Override + protected String getNameForView(String name) { + if (TextUtils.isEmpty(name)) return name; + final String[] tokens = NAME_TOKEN_SEPARATOR_PATTERN.split(name, 2); + if (tokens.length < 1) return name; + return tokens[0]; + } } |