use of android.app.Notification.Builder 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;
}
Aggregations