use of com.android.dialer.phonenumbercache.ContactInfo in project android_packages_apps_Dialer by LineageOS.
the class NumbersAdapter method updateView.
public void updateView(View view, String number, String countryIso) {
final TextView callerName = (TextView) view.findViewById(R.id.caller_name);
final TextView callerNumber = (TextView) view.findViewById(R.id.caller_number);
final QuickContactBadge quickContactBadge = (QuickContactBadge) view.findViewById(R.id.quick_contact_photo);
quickContactBadge.setOverlay(null);
if (CompatUtils.hasPrioritizedMimeType()) {
quickContactBadge.setPrioritizedMimeType(Phone.CONTENT_ITEM_TYPE);
}
ContactInfo info = mContactInfoHelper.lookupNumber(number, countryIso);
if (info == null) {
info = new ContactInfo();
info.number = number;
}
final CharSequence locationOrType = getNumberTypeOrLocation(info);
final String displayNumber = getDisplayNumber(info);
final String displayNumberStr = mBidiFormatter.unicodeWrap(displayNumber, TextDirectionHeuristics.LTR);
String nameForDefaultImage;
if (!TextUtils.isEmpty(info.name)) {
nameForDefaultImage = info.name;
callerName.setText(info.name);
callerNumber.setText(locationOrType + " " + displayNumberStr);
} else {
nameForDefaultImage = displayNumber;
callerName.setText(displayNumberStr);
if (!TextUtils.isEmpty(locationOrType)) {
callerNumber.setText(locationOrType);
callerNumber.setVisibility(View.VISIBLE);
} else {
callerNumber.setVisibility(View.GONE);
}
}
loadContactPhoto(info, nameForDefaultImage, quickContactBadge);
}
use of com.android.dialer.phonenumbercache.ContactInfo in project android_packages_apps_Dialer by LineageOS.
the class RegularSearchListAdapter method getLookupContactInfo.
public ContactInfo getLookupContactInfo(int position) {
ContactInfo info = new ContactInfo();
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);
}
return info;
}
use of com.android.dialer.phonenumbercache.ContactInfo in project android_packages_apps_Dialer by LineageOS.
the class CallerInfoUtils method buildCachedContactInfo.
/**
* Creates a new {@link CachedContactInfo} from a {@link CallerInfo}
*
* @param lookupService the {@link CachedNumberLookupService} used to build a new {@link
* CachedContactInfo}
* @param {@link CallerInfo} object
* @return a CachedContactInfo object created from this CallerInfo
* @throws NullPointerException if lookupService or ci are null
*/
public static CachedContactInfo buildCachedContactInfo(CachedNumberLookupService lookupService, CallerInfo ci) {
ContactInfo info = new ContactInfo();
info.name = ci.name;
info.type = ci.numberType;
info.label = ci.phoneLabel;
info.number = ci.phoneNumber;
info.normalizedNumber = ci.normalizedNumber;
info.photoUri = ci.contactDisplayPhotoUri;
info.userType = ci.userType;
CachedContactInfo cacheInfo = lookupService.buildCachedContactInfo(info);
cacheInfo.setLookupKey(ci.lookupKeyOrNull);
return cacheInfo;
}
use of com.android.dialer.phonenumbercache.ContactInfo in project android_packages_apps_Dialer by LineageOS.
the class MissedCallNotifier method getNotificationForCall.
private Notification getNotificationForCall(@NonNull NewCall call, @Nullable String postCallMessage) {
ContactInfo contactInfo = callLogNotificationsQueryHelper.getContactInfo(call.number, call.numberPresentation, call.countryIso);
// Create a public viewable version of the notification, suitable for display when sensitive
// notification content is hidden.
int titleResId = contactInfo.userType == ContactsUtils.USER_TYPE_WORK ? R.string.notification_missedWorkCallTitle : R.string.notification_missedCallTitle;
Notification.Builder publicBuilder = createNotificationBuilder(call).setContentTitle(context.getText(titleResId));
Notification.Builder builder = createNotificationBuilder(call);
CharSequence expandedText;
if (TextUtils.equals(contactInfo.name, contactInfo.formattedNumber) || TextUtils.equals(contactInfo.name, contactInfo.number)) {
expandedText = PhoneNumberUtilsCompat.createTtsSpannable(BidiFormatter.getInstance().unicodeWrap(contactInfo.name, TextDirectionHeuristics.LTR));
} else {
expandedText = contactInfo.name;
}
if (postCallMessage != null) {
expandedText = context.getString(R.string.post_call_notification_message, expandedText, postCallMessage);
}
ContactPhotoLoader loader = new ContactPhotoLoader(context, contactInfo);
Bitmap photoIcon = loader.loadPhotoIcon();
if (photoIcon != null) {
builder.setLargeIcon(photoIcon);
}
// Create the notification suitable for display when sensitive information is showing.
builder.setContentTitle(context.getText(titleResId)).setContentText(expandedText).setPublicVersion(publicBuilder.build());
// Add additional actions when the user isn't locked
if (UserManagerCompat.isUserUnlocked(context)) {
if (!TextUtils.isEmpty(call.number) && !TextUtils.equals(call.number, context.getString(R.string.handle_restricted))) {
builder.addAction(new Notification.Action.Builder(Icon.createWithResource(context, R.drawable.ic_phone_24dp), context.getString(R.string.notification_missedCall_call_back), createCallBackPendingIntent(call.number, call.callsUri)).build());
if (!PhoneNumberHelper.isUriNumber(call.number)) {
builder.addAction(new Notification.Action.Builder(Icon.createWithResource(context, R.drawable.quantum_ic_message_white_24), context.getString(R.string.notification_missedCall_message), createSendSmsFromNotificationPendingIntent(call.number, call.callsUri)).build());
}
}
}
Notification notification = builder.build();
configureLedOnNotification(notification);
return notification;
}
use of com.android.dialer.phonenumbercache.ContactInfo in project android_packages_apps_Dialer by LineageOS.
the class CallLogNotificationsQueryHelper method getContactInfo.
/**
* Given a number and number information (presentation and country ISO), get {@link ContactInfo}.
* If the name is empty but we have a special presentation, display that. Otherwise attempt to
* look it up in the cache. If that fails, fall back to displaying the number.
*/
public ContactInfo getContactInfo(@Nullable String number, int numberPresentation, @Nullable String countryIso) {
if (countryIso == null) {
countryIso = mCurrentCountryIso;
}
number = (number == null) ? "" : number;
ContactInfo contactInfo = new ContactInfo();
contactInfo.number = number;
contactInfo.formattedNumber = PhoneNumberUtils.formatNumber(number, countryIso);
// contactInfo.normalizedNumber is not PhoneNumberUtils.normalizeNumber. Read ContactInfo.
contactInfo.normalizedNumber = PhoneNumberUtils.formatNumberToE164(number, countryIso);
// 1. Special number representation.
contactInfo.name = PhoneNumberDisplayUtil.getDisplayName(mContext, number, numberPresentation, false).toString();
if (!TextUtils.isEmpty(contactInfo.name)) {
return contactInfo;
}
// 2. Look it up in the cache.
ContactInfo cachedContactInfo = mContactInfoHelper.lookupNumber(number, countryIso);
if (cachedContactInfo != null && !TextUtils.isEmpty(cachedContactInfo.name)) {
return cachedContactInfo;
}
if (!TextUtils.isEmpty(contactInfo.formattedNumber)) {
// 3. If we cannot lookup the contact, use the formatted number instead.
contactInfo.name = contactInfo.formattedNumber;
} else if (!TextUtils.isEmpty(number)) {
// 4. If number can't be formatted, use number.
contactInfo.name = number;
} else {
// 5. Otherwise, it's unknown number.
contactInfo.name = mContext.getResources().getString(R.string.unknown);
}
return contactInfo;
}
Aggregations