Loading src/com/android/dialer/calllog/CallLogAdapter.java +1 −2 Original line number Diff line number Diff line Loading @@ -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; Loading src/com/android/dialer/calllog/ContactInfo.java +1 −1 Original line number Diff line number Diff line Loading @@ -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; Loading src/com/android/dialer/list/RegularSearchFragment.java +25 −0 Original line number Diff line number Diff line Loading @@ -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(); } Loading @@ -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)); } } } src/com/android/dialer/list/RegularSearchListAdapter.java 0 → 100644 +62 −0 Original line number Diff line number Diff line /* * 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; } } src/com/android/dialer/service/CachedNumberLookupService.java +15 −0 Original line number Diff line number Diff line 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. Loading @@ -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); } Loading
src/com/android/dialer/calllog/CallLogAdapter.java +1 −2 Original line number Diff line number Diff line Loading @@ -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; Loading
src/com/android/dialer/calllog/ContactInfo.java +1 −1 Original line number Diff line number Diff line Loading @@ -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; Loading
src/com/android/dialer/list/RegularSearchFragment.java +25 −0 Original line number Diff line number Diff line Loading @@ -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(); } Loading @@ -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)); } } }
src/com/android/dialer/list/RegularSearchListAdapter.java 0 → 100644 +62 −0 Original line number Diff line number Diff line /* * 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; } }
src/com/android/dialer/service/CachedNumberLookupService.java +15 −0 Original line number Diff line number Diff line 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. Loading @@ -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); }