android.support.v4.app.NotificationCompat.InboxStyle Java Examples

The following examples show how to use android.support.v4.app.NotificationCompat.InboxStyle. 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: KlyphNotification.java    From Klyph with MIT License 5 votes vote down vote up
public static void setInboxStyle(Builder builder, String title, List<String> lines)
{
	builder.setNumber(lines.size());
	InboxStyle inboxStyle = new InboxStyle();

	inboxStyle.setBigContentTitle(title);

	for (String line : lines)
	{
		inboxStyle.addLine(line);
	}

	builder.setStyle(inboxStyle);
}
 
Example #2
Source File: KlyphMessengerNotification.java    From KlyphMessenger with MIT License 5 votes vote down vote up
public static void setInboxStyle(Builder builder, String title, List<String> lines)
{
	builder.setNumber(lines.size());
	InboxStyle inboxStyle = new InboxStyle();

	inboxStyle.setBigContentTitle(title);

	for (String line : lines)
	{
		inboxStyle.addLine(line);
	}

	builder.setStyle(inboxStyle);
}
 
Example #3
Source File: NotificationHelper.java    From moVirt with Apache License 2.0 5 votes vote down vote up
public <E extends BaseEntity<?>> void showTriggersNotification(
        MovirtAccount account, List<Pair<E, Trigger>> entitiesAndTriggers, Context context, PendingIntent resultPendingIntent
) {
    Log.d(TAG, "Displaying notification " + notificationCount);
    if (entitiesAndTriggers.size() == 1) { // one entity displays in full format
        Pair<E, Trigger> entityAndTrigger = entitiesAndTriggers.get(0);
        showTriggerNotification(account, entityAndTrigger.second, entityAndTrigger.first, context, resultPendingIntent);
        return;
    }

    boolean critical = false;
    InboxStyle style = new NotificationCompat.InboxStyle();

    for (int i = 0; i < entitiesAndTriggers.size(); i++) {
        Pair<E, Trigger> pair = entitiesAndTriggers.get(i);

        if (!critical && pair.second.getNotificationType() == Trigger.NotificationType.CRITICAL) {
            critical = true;
        }

        if (i < maxDisplayedNotifications) {
            style.addLine(pair.second.getCondition().getMessage(context, pair.first));
        }
    }

    if (entitiesAndTriggers.size() > maxDisplayedNotifications) {
        style.addLine("."); // dummy line to show dots
        style.setSummaryText("+ " + (entitiesAndTriggers.size() - maxDisplayedNotifications) + " more");
    }

    Notification notification = prepareNotification(context, resultPendingIntent, System.currentTimeMillis(), getEventTitle(account, critical))
            .setStyle(style)
            .build();
    notificationManager.notify(notificationCount++, notification);
    if (critical) {
        vibrator.vibrate(vibrationDuration);
    }
}
 
Example #4
Source File: Notifications.java    From Onosendai with Apache License 2.0 5 votes vote down vote up
private static Style makePreview (final List<Tweet> tweets, final int count) {
	if (tweets == null || tweets.size() < 1) return null;

	if (tweets.size() == 1) return new NotificationCompat.BigTextStyle()
			.bigText(tweetToSpanable(tweets.iterator().next()));

	final InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
	for (final Tweet tweet : tweets) {
		inboxStyle.addLine(tweetToSpanable(tweet));
	}
	if (tweets.size() < count) {
		inboxStyle.setSummaryText(String.format("+%s more", count - tweets.size()));
	}
	return inboxStyle;
}