use of com.android.dialer.calllog.ContactInfo in project android_packages_apps_Dialer by MoKee.
the class CallStatsQueryHandler method getContactInfoFromCallStats.
private ContactInfo getContactInfoFromCallStats(Cursor c) {
ContactInfo info = new ContactInfo();
info.lookupUri = UriUtils.parseUriOrNull(c.getString(CallStatsQuery.CACHED_LOOKUP_URI));
info.name = c.getString(CallStatsQuery.CACHED_NAME);
info.type = c.getInt(CallStatsQuery.CACHED_NUMBER_TYPE);
info.label = c.getString(CallStatsQuery.CACHED_NUMBER_LABEL);
final String matchedNumber = c.getString(CallStatsQuery.CACHED_MATCHED_NUMBER);
info.number = matchedNumber == null ? c.getString(CallStatsQuery.NUMBER) : matchedNumber;
info.normalizedNumber = c.getString(CallStatsQuery.CACHED_NORMALIZED_NUMBER);
info.formattedNumber = c.getString(CallStatsQuery.CACHED_FORMATTED_NUMBER);
info.photoId = c.getLong(CallStatsQuery.CACHED_PHOTO_ID);
// We do not cache the photo URI.
info.photoUri = null;
return info;
}
use of com.android.dialer.calllog.ContactInfo in project android_packages_apps_Dialer by MoKee.
the class ContactInfoCache method getValue.
public ContactInfo getValue(String number, String postDialString, String countryIso, ContactInfo cachedContactInfo, boolean isConf) {
String phoneNumber = number;
if (!isConf && !TextUtils.isEmpty(postDialString)) {
phoneNumber += postDialString;
}
NumberWithCountryIso numberCountryIso = new NumberWithCountryIso(phoneNumber, countryIso);
ExpirableCache.CachedValue<ContactInfo> cachedInfo = null;
if (isConf) {
cachedInfo = mCacheFor4gConfCall.getCachedValue(numberCountryIso);
} else {
cachedInfo = mCache.getCachedValue(numberCountryIso);
}
ContactInfo info = cachedInfo == null ? null : cachedInfo.getValue();
if (cachedInfo == null) {
if (isConf) {
mCacheFor4gConfCall.put(numberCountryIso, ContactInfo.EMPTY);
} else {
mCache.put(numberCountryIso, ContactInfo.EMPTY);
}
// Use the cached contact info from the call log.
info = cachedContactInfo;
// The db request should happen on a non-UI thread.
// Request the contact details immediately since they are currently missing.
enqueueRequest(number, postDialString, countryIso, cachedContactInfo, true, isConf);
// We will format the phone number when we make the background request.
} else {
if (cachedInfo.isExpired()) {
// The contact info is no longer up to date, we should request it. However, we
// do not need to request them immediately.
enqueueRequest(number, postDialString, countryIso, cachedContactInfo, false, isConf);
} else if (!callLogInfoMatches(cachedContactInfo, info)) {
// The call log information does not match the one we have, look it up again.
// We could simply update the call log directly, but that needs to be done in a
// background thread, so it is easier to simply request a new lookup, which will, as
// a side-effect, update the call log.
enqueueRequest(number, postDialString, countryIso, cachedContactInfo, false, isConf);
}
if (info == ContactInfo.EMPTY) {
// Use the cached contact info from the call log.
info = cachedContactInfo;
}
}
return info;
}
use of com.android.dialer.calllog.ContactInfo in project android_packages_apps_Dialer by MoKee.
the class ContactPhotoLoaderTest method testGetIcon_LetterTile.
public void testGetIcon_LetterTile() {
ContactInfo info = getTestContactInfo();
ContactPhotoLoader loader = new ContactPhotoLoader(mContext, info);
assertTrue(loader.getIcon() instanceof LetterTileDrawable);
}
use of com.android.dialer.calllog.ContactInfo in project android_packages_apps_Dialer by MoKee.
the class ContactPhotoLoaderTest method testGetIcon_Photo.
public void testGetIcon_Photo() {
ContactInfo info = getTestContactInfo();
info.photoUri = getResourceUri(R.drawable.phone_icon);
ContactPhotoLoader loader = new ContactPhotoLoader(mContext, info);
assertTrue(loader.getIcon() instanceof RoundedBitmapDrawable);
}
use of com.android.dialer.calllog.ContactInfo in project android_packages_apps_Dialer by MoKee.
the class GoogleForwardLookup method getEntries.
/**
* Parse JSON results and return them as an array of ContactInfo
*
* @param results The JSON results returned from the server
* @return Array of ContactInfo containing the result information
*/
private ContactInfo[] getEntries(JSONArray results) throws JSONException {
ArrayList<ContactInfo> details = new ArrayList<ContactInfo>();
JSONArray entries = results.getJSONArray(1);
for (int i = 0; i < entries.length(); i++) {
try {
JSONArray entry = entries.getJSONArray(i);
String displayName = decodeHtml(entry.getString(0));
JSONObject params = entry.getJSONObject(3);
String phoneNumber = decodeHtml(params.getString(RESULT_NUMBER));
String address = decodeHtml(params.getString(RESULT_ADDRESS));
String city = decodeHtml(params.getString(RESULT_CITY));
String profileUrl = params.optString(RESULT_WEBSITE, null);
String photoUri = params.optString(RESULT_PHOTO_URI, null);
ContactBuilder builder = new ContactBuilder(ContactBuilder.FORWARD_LOOKUP, null, phoneNumber);
builder.setName(ContactBuilder.Name.createDisplayName(displayName));
builder.addPhoneNumber(ContactBuilder.PhoneNumber.createMainNumber(phoneNumber));
builder.addWebsite(ContactBuilder.WebsiteUrl.createProfile(profileUrl));
ContactBuilder.Address a = new ContactBuilder.Address();
a.formattedAddress = address;
a.city = city;
a.type = StructuredPostal.TYPE_WORK;
builder.addAddress(a);
if (photoUri != null) {
builder.setPhotoUri(photoUri);
} else {
builder.setPhotoUri(ContactBuilder.PHOTO_URI_BUSINESS);
}
details.add(builder.build());
} catch (JSONException e) {
Log.e(TAG, "Skipping the suggestions at index " + i, e);
}
}
if (details.size() > 0) {
return details.toArray(new ContactInfo[details.size()]);
} else {
return null;
}
}
Aggregations