Search in sources :

Example 96 with Builder

use of android.support.v4.app.NotificationCompat.Builder in project k-9 by k9mail.

the class LockScreenNotification method createPublicNotificationWithSenderList.

private Notification createPublicNotificationWithSenderList(NotificationData notificationData) {
    Builder builder = createPublicNotification(notificationData);
    int newMessages = notificationData.getNewMessagesCount();
    if (newMessages == 1) {
        NotificationHolder holder = notificationData.getHolderForLatestNotification();
        builder.setContentText(holder.content.sender);
    } else {
        List<NotificationContent> contents = notificationData.getContentForSummaryNotification();
        String senderList = createCommaSeparatedListOfSenders(contents);
        builder.setContentText(senderList);
    }
    return builder.build();
}
Also used : Builder(android.support.v4.app.NotificationCompat.Builder)

Example 97 with Builder

use of android.support.v4.app.NotificationCompat.Builder in project k-9 by k9mail.

the class LockScreenNotification method createPublicNotificationWithNewMessagesCount.

private Notification createPublicNotificationWithNewMessagesCount(NotificationData notificationData) {
    Builder builder = createPublicNotification(notificationData);
    Account account = notificationData.getAccount();
    String accountName = controller.getAccountName(account);
    builder.setContentText(accountName);
    return builder.build();
}
Also used : Account(com.fsck.k9.Account) Builder(android.support.v4.app.NotificationCompat.Builder)

Example 98 with Builder

use of android.support.v4.app.NotificationCompat.Builder in project k-9 by k9mail.

the class WearNotifications method buildStackedNotification.

public Notification buildStackedNotification(Account account, NotificationHolder holder) {
    int notificationId = holder.notificationId;
    NotificationContent content = holder.content;
    NotificationCompat.Builder builder = createBigTextStyleNotification(account, holder, notificationId);
    PendingIntent deletePendingIntent = actionCreator.createDismissMessagePendingIntent(context, content.messageReference, holder.notificationId);
    builder.setDeleteIntent(deletePendingIntent);
    addActions(builder, account, holder);
    return builder.build();
}
Also used : Builder(android.support.v4.app.NotificationCompat.Builder) NotificationCompat(android.support.v4.app.NotificationCompat) PendingIntent(android.app.PendingIntent)

Example 99 with Builder

use of android.support.v4.app.NotificationCompat.Builder in project k-9 by k9mail.

the class SyncNotifications method showFetchingMailNotification.

public void showFetchingMailNotification(Account account, Folder folder) {
    String accountName = account.getDescription();
    String folderName = folder.getName();
    Context context = controller.getContext();
    String tickerText = context.getString(R.string.notification_bg_sync_ticker, accountName, folderName);
    String title = context.getString(R.string.notification_bg_sync_title);
    //TODO: Use format string from resources
    String text = accountName + context.getString(R.string.notification_bg_title_separator) + folderName;
    int notificationId = NotificationIds.getFetchingMailNotificationId(account);
    PendingIntent showMessageListPendingIntent = actionBuilder.createViewFolderPendingIntent(account, folderName, notificationId);
    NotificationCompat.Builder builder = controller.createNotificationBuilder().setSmallIcon(R.drawable.ic_notify_check_mail).setWhen(System.currentTimeMillis()).setOngoing(true).setTicker(tickerText).setContentTitle(title).setContentText(text).setContentIntent(showMessageListPendingIntent).setVisibility(NotificationCompat.VISIBILITY_PUBLIC).setCategory(NotificationCompat.CATEGORY_SERVICE);
    if (NOTIFICATION_LED_WHILE_SYNCING) {
        controller.configureNotification(builder, null, null, account.getNotificationSetting().getLedColor(), NOTIFICATION_LED_BLINK_FAST, true);
    }
    getNotificationManager().notify(notificationId, builder.build());
}
Also used : Context(android.content.Context) NotificationCompat(android.support.v4.app.NotificationCompat) PendingIntent(android.app.PendingIntent)

Example 100 with Builder

use of android.support.v4.app.NotificationCompat.Builder in project k-9 by k9mail.

the class BaseNotificationsTest method testCreateAndInitializeNotificationBuilder.

@Test
public void testCreateAndInitializeNotificationBuilder() throws Exception {
    Account account = createFakeAccount();
    Builder builder = notifications.createAndInitializeNotificationBuilder(account);
    verify(builder).setSmallIcon(R.drawable.notification_icon_new_mail);
    verify(builder).setColor(ACCOUNT_COLOR);
    verify(builder).setAutoCancel(true);
}
Also used : Account(com.fsck.k9.Account) Builder(android.support.v4.app.NotificationCompat.Builder) Test(org.junit.Test)

Aggregations

NotificationCompat (android.support.v4.app.NotificationCompat)105 PendingIntent (android.app.PendingIntent)86 Intent (android.content.Intent)76 NotificationManager (android.app.NotificationManager)35 Notification (android.app.Notification)29 Builder (android.support.v4.app.NotificationCompat.Builder)19 Context (android.content.Context)16 TaskStackBuilder (android.support.v4.app.TaskStackBuilder)14 Uri (android.net.Uri)11 Bundle (android.os.Bundle)10 Bitmap (android.graphics.Bitmap)9 View (android.view.View)9 RemoteViews (android.widget.RemoteViews)9 IOException (java.io.IOException)9 AlertDialog (android.app.AlertDialog)7 DialogInterface (android.content.DialogInterface)7 Paint (android.graphics.Paint)6 SpannableString (android.text.SpannableString)6 TypedValue (android.util.TypedValue)6 TextView (android.widget.TextView)6