summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/com/android/dialer/calllog/ContactInfoHelper.java5
-rw-r--r--src/com/android/dialer/list/RegularSearchFragment.java2
-rw-r--r--src/com/android/dialer/list/RegularSearchListAdapter.java24
-rw-r--r--src/com/android/dialer/service/CachedNumberLookupService.java22
4 files changed, 30 insertions, 23 deletions
diff --git a/src/com/android/dialer/calllog/ContactInfoHelper.java b/src/com/android/dialer/calllog/ContactInfoHelper.java
index 64484cbed..bcba9ff37 100644
--- a/src/com/android/dialer/calllog/ContactInfoHelper.java
+++ b/src/com/android/dialer/calllog/ContactInfoHelper.java
@@ -30,6 +30,7 @@ import android.text.TextUtils;
import com.android.contacts.common.util.Constants;
import com.android.contacts.common.util.UriUtils;
import com.android.dialer.service.CachedNumberLookupService;
+import com.android.dialer.service.CachedNumberLookupService.CachedContactInfo;
import com.android.dialerbind.ObjectFactory;
import org.json.JSONException;
@@ -228,7 +229,9 @@ public class ContactInfoHelper {
if (info != null && info != ContactInfo.EMPTY) {
info.formattedNumber = formatPhoneNumber(number, null, countryIso);
} else if (mCachedNumberLookupService != null) {
- info = mCachedNumberLookupService.lookupCachedContactFromNumber(mContext, number);
+ CachedContactInfo cacheInfo = mCachedNumberLookupService
+ .lookupCachedContactFromNumber(mContext, number);
+ info = cacheInfo != null ? cacheInfo.getContactInfo() : null;
}
return info;
}
diff --git a/src/com/android/dialer/list/RegularSearchFragment.java b/src/com/android/dialer/list/RegularSearchFragment.java
index 2a80b3ebd..21c8c3155 100644
--- a/src/com/android/dialer/list/RegularSearchFragment.java
+++ b/src/com/android/dialer/list/RegularSearchFragment.java
@@ -49,7 +49,7 @@ public class RegularSearchFragment extends SearchFragment {
final RegularSearchListAdapter adapter =
(RegularSearchListAdapter) getAdapter();
mCachedNumberLookupService.addContact(getContext(),
- adapter.getContactInfo(position));
+ adapter.getContactInfo(mCachedNumberLookupService, position));
}
}
}
diff --git a/src/com/android/dialer/list/RegularSearchListAdapter.java b/src/com/android/dialer/list/RegularSearchListAdapter.java
index 05af3c7ff..d0617b7dc 100644
--- a/src/com/android/dialer/list/RegularSearchListAdapter.java
+++ b/src/com/android/dialer/list/RegularSearchListAdapter.java
@@ -23,6 +23,8 @@ import android.text.TextUtils;
import com.android.contacts.common.list.DirectoryPartition;
import com.android.contacts.common.list.PhoneNumberListAdapter;
+import com.android.dialer.calllog.ContactInfo;
+import com.android.dialer.service.CachedNumberLookupService;
import com.android.dialer.service.CachedNumberLookupService.CachedContactInfo;
/**
@@ -34,8 +36,10 @@ public class RegularSearchListAdapter extends DialerPhoneNumberListAdapter {
super(context);
}
- public CachedContactInfo getContactInfo(int position) {
- CachedContactInfo info = new CachedContactInfo();
+ public CachedContactInfo getContactInfo(
+ CachedNumberLookupService lookupService, int position) {
+ ContactInfo info = new ContactInfo();
+ CachedContactInfo cacheInfo = lookupService.buildCachedContactInfo(info);
final Cursor item = (Cursor) getItem(position);
if (item != null) {
info.name = item.getString(PhoneQuery.DISPLAY_NAME);
@@ -44,19 +48,21 @@ public class RegularSearchListAdapter extends DialerPhoneNumberListAdapter {
info.number = item.getString(PhoneQuery.PHONE_NUMBER);
final String photoUriStr = item.getString(PhoneQuery.PHOTO_URI);
info.photoUri = photoUriStr == null ? null : Uri.parse(photoUriStr);
- info.lookupKey = item.getString(PhoneQuery.LOOKUP_KEY);
+
+ cacheInfo.setLookupKey(item.getString(PhoneQuery.LOOKUP_KEY));
final int partitionIndex = getPartitionForPosition(position);
final DirectoryPartition partition =
(DirectoryPartition) getPartition(partitionIndex);
final long directoryId = partition.getDirectoryId();
- info.sourceName = partition.getLabel();
- info.sourceType = isExtendedDirectory(directoryId) ?
- CachedContactInfo.SOURCE_TYPE_EXTENDED :
- CachedContactInfo.SOURCE_TYPE_DIRECTORY;
- info.sourceId = (int) directoryId;
+ final String sourceName = partition.getLabel();
+ if (isExtendedDirectory(directoryId)) {
+ cacheInfo.setExtendedSource(sourceName, directoryId);
+ } else {
+ cacheInfo.setDirectorySource(sourceName, directoryId);
+ }
}
- return info;
+ return cacheInfo;
}
@Override
diff --git a/src/com/android/dialer/service/CachedNumberLookupService.java b/src/com/android/dialer/service/CachedNumberLookupService.java
index cba158b53..62881d2fe 100644
--- a/src/com/android/dialer/service/CachedNumberLookupService.java
+++ b/src/com/android/dialer/service/CachedNumberLookupService.java
@@ -7,29 +7,27 @@ import com.android.dialer.calllog.ContactInfo;
public interface CachedNumberLookupService {
- public class CachedContactInfo extends ContactInfo {
- public static final int SOURCE_TYPE_DIRECTORY = 1;
- public static final int SOURCE_TYPE_EXTENDED = 2;
- public static final int SOURCE_TYPE_PLACES = 3;
- public static final int SOURCE_TYPE_PROFILE = 4;
-
- public String sourceName;
- public int sourceType;
- public int sourceId;
- public String lookupKey;
+ public interface CachedContactInfo {
+ public ContactInfo getContactInfo();
+
+ public void setDirectorySource(String name, long directoryId);
+ public void setExtendedSource(String name, long directoryId);
+ public void setLookupKey(String lookupKey);
}
+ public CachedContactInfo buildCachedContactInfo(ContactInfo info);
+
/**
* Perform a lookup using the cached number lookup service to return contact
* information stored in the cache that corresponds to the given number.
*
* @param context Valid context
* @param number Phone number to lookup the cache for
- * @return A {@link ContactInfo} containing the contact information if the phone
+ * @return A {@link CachedContactInfo} containing the contact information if the phone
* number is found in the cache, {@link ContactInfo#EMPTY} if the phone number was
* not found in the cache, and null if there was an error when querying the cache.
*/
- public ContactInfo lookupCachedContactFromNumber(Context context, String number);
+ public CachedContactInfo lookupCachedContactFromNumber(Context context, String number);
public void addContact(Context context, CachedContactInfo info);