summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/searchfragment/cp2/SearchContactViewHolder.java
diff options
context:
space:
mode:
authorcalderwoodra <calderwoodra@google.com>2017-10-17 15:54:45 -0700
committerEric Erfanian <erfanian@google.com>2017-10-17 20:10:38 -0700
commitfe7e9e1d5a083bfe376df0d54bcf632f60012dcf (patch)
tree903650b336b90175f9d9dad64dc36c21848cd65b /java/com/android/dialer/searchfragment/cp2/SearchContactViewHolder.java
parente1c4dc99304e117325bc8c92731c2c64f2c79400 (diff)
Contacts are now searchable by company name.
This change coalesces Cp2 contacts into a new cursor so that they can be associated with the Company name. The following logs can help explain how the data is organizes in the original cursor: display Name (A Pixel), lookupKey (3535i7a9673fc89b77de3), mimeType (vnd.android.cursor.item/name), data1 (A Pixel) display Name (A Pixel), lookupKey (3535i7a9673fc89b77de3), mimeType (vnd.android.cursor.item/note), data1 () display Name (A Pixel), lookupKey (3535i7a9673fc89b77de3), mimeType (vnd.android.cursor.item/group_membership), data1 (1) display Name (A Pixel), lookupKey (3535i7a9673fc89b77de3), mimeType (vnd.android.cursor.item/phone_v2), data1 (+1 650-200-7932) display Name (A Pixel), lookupKey (3535i7a9673fc89b77de3), mimeType (vnd.android.cursor.item/phone_v2), data1 (+1 540-555-6666) display Name (A Pixel), lookupKey (3535i7a9673fc89b77de3), mimeType (vnd.android.cursor.item/organization), data1 (Walmart) This is an example of what is returned for a single contact. We can easily associate contact rows together using the lookup key and determine which rows have relevant data by checking the mime type. I use the data here to coalesce the contacts together into one row for easy parsing in ContactFilterCursor. Rows with mime type phone_v2 contain contact information (for example, this contact has 2 phone numbers). Rows with mime type organization contain contact's company information (for example, this contact works at Walmart). Bug: 67675742,64894607,67848713 Test: existing + SCCT.filter_companyName PiperOrigin-RevId: 172528797 Change-Id: I5c9f66ff0c27276869295eff97bb0216f92995be
Diffstat (limited to 'java/com/android/dialer/searchfragment/cp2/SearchContactViewHolder.java')
-rw-r--r--java/com/android/dialer/searchfragment/cp2/SearchContactViewHolder.java25
1 files changed, 12 insertions, 13 deletions
diff --git a/java/com/android/dialer/searchfragment/cp2/SearchContactViewHolder.java b/java/com/android/dialer/searchfragment/cp2/SearchContactViewHolder.java
index b162a5e52..c09396c72 100644
--- a/java/com/android/dialer/searchfragment/cp2/SearchContactViewHolder.java
+++ b/java/com/android/dialer/searchfragment/cp2/SearchContactViewHolder.java
@@ -96,7 +96,7 @@ public final class SearchContactViewHolder extends ViewHolder implements OnClick
dialerContact = getDialerContact(context, cursor);
position = cursor.getPosition();
number = cursor.getString(Projections.PHONE_NUMBER);
- String name = cursor.getString(Projections.PHONE_DISPLAY_NAME);
+ String name = cursor.getString(Projections.DISPLAY_NAME);
String label = getLabel(context.getResources(), cursor);
String secondaryInfo =
TextUtils.isEmpty(label)
@@ -111,12 +111,12 @@ public final class SearchContactViewHolder extends ViewHolder implements OnClick
if (shouldShowPhoto(cursor)) {
nameOrNumberView.setVisibility(View.VISIBLE);
photo.setVisibility(View.VISIBLE);
- String photoUri = cursor.getString(Projections.PHONE_PHOTO_URI);
+ String photoUri = cursor.getString(Projections.PHOTO_URI);
ContactPhotoManager.getInstance(context)
.loadDialerThumbnailOrPhoto(
photo,
getContactUri(cursor),
- cursor.getLong(Projections.PHONE_PHOTO_ID),
+ cursor.getLong(Projections.PHOTO_ID),
photoUri == null ? null : Uri.parse(photoUri),
name,
LetterTileDrawable.TYPE_DEFAULT);
@@ -129,11 +129,11 @@ public final class SearchContactViewHolder extends ViewHolder implements OnClick
// Show the contact photo next to only the first number if a contact has multiple numbers
private boolean shouldShowPhoto(SearchCursor cursor) {
int currentPosition = cursor.getPosition();
- String currentLookupKey = cursor.getString(Projections.PHONE_LOOKUP_KEY);
+ String currentLookupKey = cursor.getString(Projections.LOOKUP_KEY);
cursor.moveToPosition(currentPosition - 1);
if (!cursor.isHeader() && !cursor.isBeforeFirst()) {
- String previousLookupKey = cursor.getString(Projections.PHONE_LOOKUP_KEY);
+ String previousLookupKey = cursor.getString(Projections.LOOKUP_KEY);
cursor.moveToPosition(currentPosition);
return !currentLookupKey.equals(previousLookupKey);
}
@@ -142,8 +142,8 @@ public final class SearchContactViewHolder extends ViewHolder implements OnClick
}
private static Uri getContactUri(Cursor cursor) {
- long contactId = cursor.getLong(Projections.PHONE_ID);
- String lookupKey = cursor.getString(Projections.PHONE_LOOKUP_KEY);
+ long contactId = cursor.getLong(Projections.ID);
+ String lookupKey = cursor.getString(Projections.LOOKUP_KEY);
return Contacts.getLookupUri(contactId, lookupKey);
}
@@ -188,7 +188,7 @@ public final class SearchContactViewHolder extends ViewHolder implements OnClick
private static @CallToAction int getCallToAction(
Context context, SearchCursor cursor, String query) {
- int carrierPresence = cursor.getInt(Projections.PHONE_CARRIER_PRESENCE);
+ int carrierPresence = cursor.getInt(Projections.CARRIER_PRESENCE);
String number = cursor.getString(Projections.PHONE_NUMBER);
if ((carrierPresence & Phone.CARRIER_PRESENCE_VT_CAPABLE) == 1) {
return CallToAction.VIDEO_CALL;
@@ -262,16 +262,15 @@ public final class SearchContactViewHolder extends ViewHolder implements OnClick
private static DialerContact getDialerContact(Context context, Cursor cursor) {
DialerContact.Builder contact = DialerContact.newBuilder();
- String displayName = cursor.getString(Projections.PHONE_DISPLAY_NAME);
+ String displayName = cursor.getString(Projections.DISPLAY_NAME);
String number = cursor.getString(Projections.PHONE_NUMBER);
Uri contactUri =
Contacts.getLookupUri(
- cursor.getLong(Projections.PHONE_CONTACT_ID),
- cursor.getString(Projections.PHONE_LOOKUP_KEY));
+ cursor.getLong(Projections.CONTACT_ID), cursor.getString(Projections.LOOKUP_KEY));
contact
.setNumber(number)
- .setPhotoId(cursor.getLong(Projections.PHONE_PHOTO_ID))
+ .setPhotoId(cursor.getLong(Projections.PHOTO_ID))
.setContactType(LetterTileDrawable.TYPE_DEFAULT)
.setNameOrNumber(displayName)
.setNumberLabel(
@@ -281,7 +280,7 @@ public final class SearchContactViewHolder extends ViewHolder implements OnClick
cursor.getString(Projections.PHONE_LABEL))
.toString());
- String photoUri = cursor.getString(Projections.PHONE_PHOTO_URI);
+ String photoUri = cursor.getString(Projections.PHOTO_URI);
if (photoUri != null) {
contact.setPhotoUri(photoUri);
}