static Notification buildNotification(Context ctxt) { NotificationCompat.Builder b=new NotificationCompat.Builder(ctxt) .setOngoing(true) .setContentTitle(ctxt.getString(R.string.notif_title)) .setContentText(ctxt.getString(R.string.notif_text)) .setSmallIcon(android.R.drawable.stat_sys_warning); return(b.build()); }
public void raiseContent(View view) { Notification n=new NotificationCompat.Builder(MainActivity.this, CHANNEL_CONTENT) .setContentTitle(getString(R.string.notif_content_title)) .setContentText(getString(R.string.notify_content_text)) .setSmallIcon(android.R.drawable.stat_sys_warning) .build(); mgr.notify(NOTIF_ID_CONTENT, n); }
private Notification buildForegroundNotification(String filename) { NotificationCompat.Builder b= new NotificationCompat.Builder(this, CHANNEL_WHATEVER); b.setOngoing(true) .setContentTitle(getString(R.string.downloading)) .setContentText(filename) .setSmallIcon(android.R.drawable.stat_sys_download); return(b.build()); } }
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(); }
private NotificationCompat.Builder buildNormal() { NotificationCompat.Builder b= new NotificationCompat.Builder(this, CHANNEL_WHATEVER); b.setAutoCancel(true) .setDefaults(Notification.DEFAULT_ALL) .setContentTitle(getString(R.string.download_complete)) .setContentText(getString(R.string.fun)) .setContentIntent(buildPendingIntent(Settings.ACTION_SECURITY_SETTINGS)) .setSmallIcon(android.R.drawable.stat_sys_download_done) .addAction(android.R.drawable.ic_media_play, getString(R.string.play), buildPendingIntent(Settings.ACTION_SETTINGS)); return(b); }
private NotificationCompat.Builder buildNormal() { NotificationCompat.Builder b= new NotificationCompat.Builder(this, CHANNEL_WHATEVER); b.setAutoCancel(true) .setDefaults(Notification.DEFAULT_ALL) .setContentTitle(getString(R.string.download_complete)) .setContentText(getString(R.string.fun)) .setContentIntent(buildPendingIntent(Settings.ACTION_SECURITY_SETTINGS)) .setSmallIcon(android.R.drawable.stat_sys_download_done) .addAction(android.R.drawable.ic_media_play, getString(R.string.play), buildPendingIntent(Settings.ACTION_SETTINGS)); return(b); }
@Test public void testGetFetchingMailNotificationId() throws Exception { Folder folder = createFakeFolder(); int notificationId = NotificationIds.getFetchingMailNotificationId(account); syncNotifications.showFetchingMailNotification(account, folder); verify(notificationManager).notify(notificationId, notification); verify(builder).setSmallIcon(resourceProvider.getIconCheckingMail()); verify(builder).setTicker("Checking mail: " + ACCOUNT_NAME + ":" + FOLDER_NAME); verify(builder).setContentTitle("Checking mail"); verify(builder).setContentText(ACCOUNT_NAME + ":" + FOLDER_NAME); verify(builder).setContentIntent(contentIntent); verify(builder).setVisibility(NotificationCompat.VISIBILITY_PUBLIC); }
private NotificationCompat.Builder createSimpleSummaryNotification(Account account, int unreadMessageCount) { String accountName = notificationHelper.getAccountName(account); CharSequence newMailText = resourceProvider.newMailTitle(); String unreadMessageCountText = resourceProvider.newMailUnreadMessageCount(unreadMessageCount, accountName); int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent contentIntent = actionCreator.createViewFolderListPendingIntent(account, notificationId); return createAndInitializeNotificationBuilder(account) .setNumber(unreadMessageCount) .setTicker(newMailText) .setContentTitle(unreadMessageCountText) .setContentText(newMailText) .setContentIntent(contentIntent); }
private NotificationCompat.Builder buildNormal() { NotificationCompat.Builder b= new NotificationCompat.Builder(this, CHANNEL_WHATEVER); b.setAutoCancel(true) .setDefaults(Notification.DEFAULT_ALL) .setContentTitle(getString(R.string.download_complete)) .setContentText(getString(R.string.fun)) .setContentIntent(buildPendingIntent(Settings.ACTION_SECURITY_SETTINGS)) .setSmallIcon(android.R.drawable.stat_sys_download_done) .setGroup(GROUP_SAMPLE) .setGroupSummary(true); return(b); }
private void assertCertificateErrorNotificationContents() { verify(builder).setSmallIcon(resourceProvider.getIconWarning()); verify(builder).setTicker("Certificate error for " + ACCOUNT_NAME); verify(builder).setContentTitle("Certificate error for " + ACCOUNT_NAME); verify(builder).setContentText("Check your server settings"); verify(builder).setContentIntent(contentIntent); verify(builder).setVisibility(NotificationCompat.VISIBILITY_PUBLIC); }
@Test public void configureLockScreenNotification_MESSAGE_COUNT() throws Exception { K9.setLockScreenNotificationVisibility(LockScreenNotificationVisibility.MESSAGE_COUNT); when(notificationData.getNewMessagesCount()).thenReturn(NEW_MESSAGE_COUNT); when(notificationData.getUnreadMessageCount()).thenReturn(UNREAD_MESSAGE_COUNT); lockScreenNotification.configureLockScreenNotification(builder, notificationData); verify(publicBuilder).setSmallIcon(resourceProvider.getIconNewMail()); verify(publicBuilder).setNumber(UNREAD_MESSAGE_COUNT); verify(publicBuilder).setContentTitle(NEW_MESSAGE_COUNT + " new messages"); verify(publicBuilder).setContentText(ACCOUNT_NAME); verify(builder).setPublicVersion(publicBuilder.build()); }
@Test public void testShowSendingNotification() throws Exception { int notificationId = NotificationIds.getFetchingMailNotificationId(account); syncNotifications.showSendingNotification(account); verify(notificationManager).notify(notificationId, notification); verify(builder).setSmallIcon(resourceProvider.getIconSendingMail()); verify(builder).setTicker("Sending mail: " + ACCOUNT_NAME); verify(builder).setContentTitle("Sending mail"); verify(builder).setContentText(ACCOUNT_NAME); verify(builder).setContentIntent(contentIntent); verify(builder).setVisibility(NotificationCompat.VISIBILITY_PUBLIC); }
@Test public void testShowSendFailedNotification() throws Exception { Exception exception = new Exception(); sendFailedNotifications.showSendFailedNotification(account, exception); verify(notificationManager).notify(notificationId, notification); verify(builder).setSmallIcon(resourceProvider.getIconWarning()); verify(builder).setTicker("Failed to send some messages"); verify(builder).setContentTitle("Failed to send some messages"); verify(builder).setContentText("Exception"); verify(builder).setContentIntent(contentIntent); verify(builder).setVisibility(NotificationCompat.VISIBILITY_PUBLIC); }
private Notification createPublicNotificationWithNewMessagesCount(NotificationData notificationData) { Builder builder = createPublicNotification(notificationData); Account account = notificationData.getAccount(); String accountName = notificationHelper.getAccountName(account); builder.setContentText(accountName); return builder.build(); }
private void assertAuthenticationErrorNotificationContents() { verify(builder).setSmallIcon(resourceProvider.getIconWarning()); verify(builder).setTicker("Authentication failed"); verify(builder).setContentTitle("Authentication failed"); verify(builder).setContentText("Authentication failed for " + ACCOUNT_NAME + ". Update your server settings."); verify(builder).setContentIntent(contentIntent); verify(builder).setVisibility(NotificationCompat.VISIBILITY_PUBLIC); }
private NotificationCompat.Builder buildForeground( String filename) { NotificationCompat.Builder b= new NotificationCompat.Builder(this, CHANNEL_WHATEVER); b.setContentTitle(getString(R.string.downloading)) .setContentText(filename) .setSmallIcon(android.R.drawable.stat_sys_download) .setOnlyAlertOnce(true) .setOngoing(true); return(b); } }
public void raiseCoins(View view) { Notification n=new NotificationCompat.Builder(MainActivity.this, CHANNEL_COINS) .setContentTitle(getString(R.string.notif_coins_title)) .setContentText(getString(R.string.notif_coins_text)) .setSmallIcon(android.R.drawable.stat_sys_warning) .setTimeoutAfter(5000) .build(); mgr.notify(NOTIF_ID_COINS, n); }
private NotificationCompat.Builder createNotification() { return new NotificationCompat.Builder(this, getString(R.string.notification_channel_id)) .setOngoing(true) .setSmallIcon(R.drawable.ic_newpipe_triangle_white) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setContentTitle(getString(R.string.preferred_player_fetcher_notification_title)) .setContentText(getString(R.string.preferred_player_fetcher_notification_message)); } }
public void raiseBattle(View view) { Notification n=new NotificationCompat.Builder(MainActivity.this, CHANNEL_BATTLE) .setContentTitle(getString(R.string.notif_battle_title)) .setContentText(getString(R.string.notif_battle_text)) .setSmallIcon(android.R.drawable.stat_sys_warning) .setBadgeIconType(Notification.BADGE_ICON_SMALL) .setColor(Color.RED) .setColorized(true) .build(); mgr.notify(NOTIF_ID_BATTLE, n); }
protected void updateNotification(String text) { notificationBuilder.setProgress(maxProgress.get(), currentProgress.get(), maxProgress.get() == -1); final String progressText = currentProgress + "/" + maxProgress; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { if (!TextUtils.isEmpty(text)) text = text + " (" + progressText + ")"; } else { notificationBuilder.setContentInfo(progressText); } if (!TextUtils.isEmpty(text)) notificationBuilder.setContentText(text); notificationManager.notify(getNotificationId(), notificationBuilder.build()); }