Java Code Examples for androidx.core.app.NotificationCompat#BigPictureStyle

The following examples show how to use androidx.core.app.NotificationCompat#BigPictureStyle . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NotificationManager.java    From QuickDevFramework with Apache License 2.0 5 votes vote down vote up
/**
 * set big picture style for notification
 * @param builder builder
 * @param title title
 * @param picture picture, the picture should not higher than 255dp
 * @param summaryText summary
 * */
public static NotificationCompat.Builder setBigPicture(NotificationCompat.Builder builder,
                                                String title,
                                                String summaryText,
                                                Bitmap picture) {
    NotificationCompat.BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
    bigPictureStyle.setBigContentTitle(title);
    bigPictureStyle.bigPicture(picture);
    if (!TextUtils.isEmpty(summaryText)) {
        bigPictureStyle.setSummaryText(summaryText);
    }
    builder.setStyle(bigPictureStyle);
    return builder;
}
 
Example 2
Source File: NotificationService.java    From Pix-Art-Messenger with GNU General Public License v3.0 5 votes vote down vote up
private void modifyForImage(final Builder builder, final Message message, final ArrayList<Message> messages) {
    try {
        final Bitmap bitmap = mXmppConnectionService.getFileBackend().getThumbnail(message, getPixel(288), false);
        final ArrayList<Message> tmp = new ArrayList<>();
        for (final Message msg : messages) {
            if (msg.getType() == Message.TYPE_TEXT
                    && msg.getTransferable() == null) {
                tmp.add(msg);
            }
        }
        final BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
        bigPictureStyle.bigPicture(bitmap);
        if (tmp.size() > 0) {
            CharSequence text = getMergedBodies(tmp);
            bigPictureStyle.setSummaryText(text);
            builder.setContentText(text);
            builder.setTicker(text);
        } else {
            final String description = UIHelper.getFileDescriptionString(mXmppConnectionService, message);
            builder.setContentText(description);
            builder.setTicker(description);
        }
        builder.setStyle(bigPictureStyle);
    } catch (final IOException e) {
        modifyForTextOnly(builder, messages);
    }
}
 
Example 3
Source File: NotificationUtil.java    From Hify with MIT License 4 votes vote down vote up
private void showBigNotification(String timeStamp, String user_image, Bitmap bitmap, int icon, String title, String message, PendingIntent resultPendingIntent, String notification_type) {

        int id;
        NotificationCompat.Builder mBuilder;
        NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(mContext);

        switch (notification_type){

            case "like":
                id=100;
                mBuilder = new NotificationCompat.Builder(mContext, "like_channel");
                break;
            case "comment":
                id=200;
                mBuilder = new NotificationCompat.Builder(mContext, "comments_channel");
                break;
            case "forum":
                id=(int)System.currentTimeMillis();
                mBuilder = new NotificationCompat.Builder(mContext, "forum_channel");
                break;
            case "Message":
                id=(int)System.currentTimeMillis();
                mBuilder = new NotificationCompat.Builder(mContext, "flash_message");
                break;
            default:
                id=(int)System.currentTimeMillis();
                mBuilder = new NotificationCompat.Builder(mContext, "hify_other_channel");
        }

        Notification notification;
        NotificationCompat.BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
        bigPictureStyle.setBigContentTitle(title);
        bigPictureStyle.bigPicture(bitmap);

        notification = mBuilder
                .setAutoCancel(true)
                .setContentTitle(title)
                .setTicker(title)
                .setContentIntent(resultPendingIntent)
                .setColorized(true)
                .setShowWhen(true)
                .setSound(Uri.parse("android.resource://" + mContext.getPackageName() + "/" + R.raw.hify_sound))
                .setWhen(getTimeMilliSec(timeStamp))
                .setColor(Color.parseColor("#2591FC"))
                .setStyle(bigPictureStyle) //bigPictureStyle
                .setLargeIcon(getCircularBitmap(getBitmapFromURL(user_image)))
                .setSmallIcon(icon)
                .setContentText(message)
                .build();

        notificationManagerCompat.notify(id, notification);

    }