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

The following examples show how to use androidx.core.app.NotificationCompat#Style . 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: NotificationBuilderImplBase.java    From FCM-for-Mojo with GNU General Public License v3.0 6 votes vote down vote up
public NotificationCompat.Style createStyle(Context context, Chat chat) {
    MessagingStyle style = new MessagingStyle(context.getString(R.string.you));
    style.setConversationTitle(chat.getName());
    style.setGroupConversation(chat.isGroup());

    for (int i = chat.getMessages().size() - NOTIFICATION_MAX_MESSAGES, count = 0; i < chat.getMessages().size() && count <= 8; i++, count++) {
        if (i < 0) {
            continue;
        }

        Message message = chat.getMessages().get(i);
        style.addMessage(message.getContent(context), message.getTimestamp(), message.getSender());
    }

    style.setSummaryText(context.getString(R.string.notification_messages, chat.getMessages().getSize()));

    return style;
}
 
Example 2
Source File: NotificationBuilderImplP.java    From FCM-for-Mojo with GNU General Public License v3.0 5 votes vote down vote up
@Override
public NotificationCompat.Style createStyle(Context context, Chat chat) {
    MessagingStyle style = new MessagingStyle(new Person.Builder()
            .setName(context.getString(R.string.you))
            .setIcon(IconCompat.createWithBitmap(UserIcon.requestIcon(context, User.getSelf().getUid(), Chat.ChatType.FRIEND)))
            .build());
    style.setConversationTitle(chat.getName());
    style.setGroupConversation(chat.isGroup());

    for (int i = chat.getMessages().size() - NOTIFICATION_MAX_MESSAGES, count = 0; i < chat.getMessages().size() && count <= 8; i++, count++) {
        if (i < 0) {
            continue;
        }

        Message message = chat.getMessages().get(i);
        User sender = message.getSenderUser();

        IconCompat icon = null;
        Bitmap bitmap = UserIcon.getIcon(context, sender.getUid(), Chat.ChatType.FRIEND);
        if (bitmap != null) {
            icon = IconCompat.createWithBitmap(bitmap);
        }

        Person person = null;
        if (message.getSenderUser() != User.getSelf()) {
            person = new Person.Builder()
                    .setKey(sender.getName())
                    .setName(sender.getName())
                    .setIcon(icon)
                    .build();
        }

        style.addMessage(message.getContent(context), message.getTimestamp(), person);
    }

    style.setSummaryText(context.getString(R.string.notification_messages, chat.getMessages().getSize()));

    return style;
}
 
Example 3
Source File: NotificationBuilder.java    From libcommon with Apache License 2.0 4 votes vote down vote up
@Override
public NotificationBuilder setStyle(final NotificationCompat.Style style) {
	super.setStyle(style);
	return this;
}
 
Example 4
Source File: MrNotification.java    From BaseProject with Apache License 2.0 2 votes vote down vote up
/**
 * Add a rich notification style to be applied at build time.
 * <br>
 * If the platform does not provide rich notification styles, this method has no effect. The
 * user will always see the normal notification style.
 *
 * @param style Object responsible for modifying the notification style.
 */
@Override
public NotificationBuilder setStyle(NotificationCompat.Style style) {
    super.setStyle(style);
    return this;
}