Search in sources :

Example 16 with Builder

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;
}
Also used : Bitmap(android.graphics.Bitmap) Builder(android.app.Notification.Builder) ContactPhotoLoader(com.android.dialer.app.contactinfo.ContactPhotoLoader) CallIntentBuilder(com.android.dialer.callintent.CallIntentBuilder) Builder(android.app.Notification.Builder) ContactInfo(com.android.dialer.phonenumbercache.ContactInfo) Notification(android.app.Notification) StatusBarNotification(android.service.notification.StatusBarNotification)

Aggregations

Builder (android.app.Notification.Builder)16 Notification (android.app.Notification)10 PendingIntent (android.app.PendingIntent)6 Intent (android.content.Intent)6 StatusBarNotification (android.service.notification.StatusBarNotification)5 RemoteViews (android.widget.RemoteViews)5 SuppressLint (android.annotation.SuppressLint)1 SharedPreferences (android.content.SharedPreferences)1 Bitmap (android.graphics.Bitmap)1 ContactPhotoLoader (com.android.dialer.app.contactinfo.ContactPhotoLoader)1 CallIntentBuilder (com.android.dialer.callintent.CallIntentBuilder)1 ContactInfo (com.android.dialer.phonenumbercache.ContactInfo)1 ChatMsg (com.lingtuan.firefly.vo.ChatMsg)1 Date (java.util.Date)1