summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2013-09-03 17:48:19 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-09-03 17:48:19 +0000
commitfca0338d3d52f91c0cbcac555a8416cc75770090 (patch)
tree0cd5ecf3c8f66fbf7de962483cab0a9ab9d1c133
parent2a66648a68cb8bb88dcf3b25ebbcbae39ff77a07 (diff)
parent68a14f2ce071617743b856d14b1f7e90e0e99bcd (diff)
Merge "Show first name only for Dialer favorites" into klp-dev
-rw-r--r--src/com/android/dialer/list/PhoneFavoriteSquareTileView.java19
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];
+ }
}