summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/com/android/dialer/calllog/CallLogAdapter.java3
-rw-r--r--src/com/android/dialer/calllog/ContactInfo.java2
-rw-r--r--src/com/android/dialer/list/RegularSearchFragment.java25
-rw-r--r--src/com/android/dialer/list/RegularSearchListAdapter.java62
-rw-r--r--src/com/android/dialer/service/CachedNumberLookupService.java15
5 files changed, 104 insertions, 3 deletions
diff --git a/src/com/android/dialer/calllog/CallLogAdapter.java b/src/com/android/dialer/calllog/CallLogAdapter.java
index da29bbd87..9ac7bea21 100644
--- a/src/com/android/dialer/calllog/CallLogAdapter.java
+++ b/src/com/android/dialer/calllog/CallLogAdapter.java
@@ -598,10 +598,9 @@ public class CallLogAdapter extends GroupingListAdapter
formattedNumber, countryIso, geocode, callTypes, date,
duration);
} else {
- // We do not pass a photo id since we do not need the high-res picture.
details = new PhoneCallDetails(number, numberPresentation,
formattedNumber, countryIso, geocode, callTypes, date,
- duration, name, ntype, label, lookupUri, null);
+ duration, name, ntype, label, lookupUri, photoUri);
}
final boolean isNew = c.getInt(CallLogQuery.IS_READ) == 0;
diff --git a/src/com/android/dialer/calllog/ContactInfo.java b/src/com/android/dialer/calllog/ContactInfo.java
index 08633f895..ac858df87 100644
--- a/src/com/android/dialer/calllog/ContactInfo.java
+++ b/src/com/android/dialer/calllog/ContactInfo.java
@@ -24,7 +24,7 @@ import com.android.contacts.common.util.UriUtils;
/**
* Information for a contact as needed by the Call Log.
*/
-public final class ContactInfo {
+public class ContactInfo {
public Uri lookupUri;
public String name;
public int type;
diff --git a/src/com/android/dialer/list/RegularSearchFragment.java b/src/com/android/dialer/list/RegularSearchFragment.java
index 47dd07532..ccbd3d0dc 100644
--- a/src/com/android/dialer/list/RegularSearchFragment.java
+++ b/src/com/android/dialer/list/RegularSearchFragment.java
@@ -15,10 +15,17 @@
*/
package com.android.dialer.list;
+import com.android.contacts.common.list.ContactEntryListAdapter;
+import com.android.dialerbind.ServiceFactory;
+import com.android.dialer.service.CachedNumberLookupService;
+
public class RegularSearchFragment extends SearchFragment {
private static final int SEARCH_DIRECTORY_RESULT_LIMIT = 5;
+ private static final CachedNumberLookupService mCachedNumberLookupService =
+ ServiceFactory.newCachedNumberLookupService();
+
public RegularSearchFragment() {
configureDirectorySearch();
}
@@ -27,4 +34,22 @@ public class RegularSearchFragment extends SearchFragment {
setDirectorySearchEnabled(true);
setDirectoryResultLimit(SEARCH_DIRECTORY_RESULT_LIMIT);
}
+
+ @Override
+ protected ContactEntryListAdapter createListAdapter() {
+ RegularSearchListAdapter adapter = new RegularSearchListAdapter(getActivity());
+ adapter.setDisplayPhotos(true);
+ adapter.setUseCallableUri(usesCallableUri());
+ return adapter;
+ }
+
+ @Override
+ protected void cacheContactInfo(int position) {
+ if (mCachedNumberLookupService != null) {
+ final RegularSearchListAdapter adapter =
+ (RegularSearchListAdapter) getAdapter();
+ mCachedNumberLookupService.addContact(getContext(),
+ adapter.getContactInfo(position));
+ }
+ }
}
diff --git a/src/com/android/dialer/list/RegularSearchListAdapter.java b/src/com/android/dialer/list/RegularSearchListAdapter.java
new file mode 100644
index 000000000..390dbb56c
--- /dev/null
+++ b/src/com/android/dialer/list/RegularSearchListAdapter.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.dialer.list;
+
+import android.content.Context;
+import android.database.Cursor;
+import android.net.Uri;
+import android.provider.ContactsContract;
+
+import com.android.contacts.common.list.DirectoryPartition;
+import com.android.contacts.common.list.PhoneNumberListAdapter;
+import com.android.dialer.service.CachedNumberLookupService.CachedContactInfo;
+
+/**
+ * List adapter to display regular search results.
+ */
+public class RegularSearchListAdapter extends PhoneNumberListAdapter {
+
+ public RegularSearchListAdapter(Context context) {
+ super(context);
+ }
+
+ public CachedContactInfo getContactInfo(int position) {
+ CachedContactInfo info = new CachedContactInfo();
+ final Cursor item = (Cursor) getItem(position);
+ if (item != null) {
+ info.name = item.getString(PhoneQuery.DISPLAY_NAME);
+ info.type = item.getInt(PhoneQuery.PHONE_TYPE);
+ info.label = item.getString(PhoneQuery.PHONE_LABEL);
+ 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);
+
+ final int partitionIndex = getPartitionForPosition(position);
+ final DirectoryPartition partition =
+ (DirectoryPartition) getPartition(partitionIndex);
+ final long directoryId = partition.getDirectoryId();
+ if (isExtendedDirectory(directoryId)) {
+ info.sourceType = CachedContactInfo.SOURCE_TYPE_EXTENDED;
+ // TODO source_id for extended directory?
+ } else {
+ info.sourceType = CachedContactInfo.SOURCE_TYPE_DIRECTORY;
+ info.sourceId = (int) directoryId;
+ }
+ }
+ return info;
+ }
+}
diff --git a/src/com/android/dialer/service/CachedNumberLookupService.java b/src/com/android/dialer/service/CachedNumberLookupService.java
index a08c28564..27bf58918 100644
--- a/src/com/android/dialer/service/CachedNumberLookupService.java
+++ b/src/com/android/dialer/service/CachedNumberLookupService.java
@@ -1,10 +1,23 @@
package com.android.dialer.service;
+import android.content.ContentValues;
import android.content.Context;
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 int sourceType;
+ public int sourceId;
+ public String lookupKey;
+ }
+
/**
* Perform a lookup using the cached number lookup service to return contact
* information stored in the cache that corresponds to the given number.
@@ -16,4 +29,6 @@ public interface CachedNumberLookupService {
* not found in the cache, and null if there was an error when querying the cache.
*/
public ContactInfo lookupCachedContactFromNumber(Context context, String number);
+
+ public void addContact(Context context, CachedContactInfo info);
}