private NotificationCompat.Builder buildBase(Context ctxt, String channel, int titleId) { NotificationCompat.Builder b= new NotificationCompat.Builder(ctxt, channel); b.setAutoCancel(true) .setDefaults(Notification.DEFAULT_ALL) .setContentTitle(ctxt.getString(titleId)) .setContentIntent(buildPendingIntent(ctxt, Settings.ACTION_SECURITY_SETTINGS)) .setSmallIcon(android.R.drawable.stat_sys_download_done) .addAction(android.R.drawable.ic_media_play, ctxt.getString(R.string.play), buildPendingIntent(ctxt, Settings.ACTION_SETTINGS)); return(b); }
private Notification buildForegroundNotification() { NotificationCompat.Builder b= new NotificationCompat.Builder(this, CHANNEL_WHATEVER); b.setOngoing(true) .setContentTitle(getString(R.string.msg_foreground)) .setSmallIcon(R.drawable.ic_stat_ping) .addAction(android.R.drawable.ic_media_pause, getString(R.string.msg_stop), buildStopPendingIntent()); return(b.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 void showNotification() { NotificationManager mgr= (NotificationManager)getSystemService(NOTIFICATION_SERVICE); if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.O && mgr.getNotificationChannel(CHANNEL_WHATEVER)==null) { mgr.createNotificationChannel(new NotificationChannel(CHANNEL_WHATEVER, "Whatever", NotificationManager.IMPORTANCE_DEFAULT)); } NotificationCompat.Builder b= new NotificationCompat.Builder(this, CHANNEL_WHATEVER) .setOngoing(true) .setContentTitle("Presentation!") .setSmallIcon(android.R.drawable.stat_notify_more) .addAction(android.R.drawable.ic_media_previous, getString(R.string.action_previous), buildPreviousPendingIntent()) .addAction(android.R.drawable.ic_media_next, getString(R.string.action_next), buildNextPendingIntent()) .addAction(android.R.drawable.ic_media_pause, getString(R.string.action_stop), buildStopPendingIntent()); mgr.notify(1337, b.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) .setTicker(getString(R.string.download_complete)) .setPriority(NotificationCompat.PRIORITY_DEFAULT) .setLocalOnly(true) .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) .setNumber(5) .setFullScreenIntent(buildPendingIntent(Settings.ACTION_DATE_SETTINGS), true) .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) .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) .setPriority(Notification.PRIORITY_HIGH) .addAction(android.R.drawable.ic_media_play, getString(R.string.play), buildPendingIntent(Settings.ACTION_SETTINGS)); return(b); }
void onDownloading(int progress) { if (!this.hasDeleteContent()) { this.setDelecte(buildCancelContent(mContext, mNotificationId, mUrl)); } if (!mAddedCancelAction) { mAddedCancelAction = true; mAction = new NotificationCompat.Action(R.drawable.ic_cancel_transparent_2dp, mContext.getString(android.R.string.cancel), buildCancelContent(mContext, mNotificationId, mUrl)); mBuilder.addAction(mAction); } mBuilder.setContentText(mContext.getString(R.string.agentweb_current_downloading_progress, (progress + "%"))); this.setProgress(100, progress, false); sent(); }
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 buildSummaryNotification_withoutDeleteAllAction() throws Exception { K9.setNotificationHideSubject(NotificationHideSubject.NEVER); K9.setNotificationQuickDeleteBehaviour(NotificationQuickDelete.NEVER); when(notificationData.isSingleMessageNotification()).thenReturn(false); notifications.buildSummaryNotification(account, notificationData, false); verify(builder, never()).addAction(resourceProvider.getIconDelete(), "Delete", null); }
private void addDeleteAllAction(Builder builder, NotificationData notificationData) { if (K9.getNotificationQuickDeleteBehaviour() != NotificationQuickDelete.ALWAYS) { return; } int icon = resourceProvider.getIconDelete(); String title = resourceProvider.actionDelete(); Account account = notificationData.getAccount(); int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences(); PendingIntent action = actionCreator.createDeleteAllPendingIntent(account, messageReferences, notificationId); builder.addAction(icon, title, action); }
private void addMarkAllAsReadAction(Builder builder, NotificationData notificationData) { int icon = resourceProvider.getIconMarkAsRead(); String title = resourceProvider.actionMarkAsRead(); Account account = notificationData.getAccount(); ArrayList<MessageReference> messageReferences = notificationData.getAllMessageReferences(); int notificationId = NotificationIds.getNewMailSummaryNotificationId(account); PendingIntent markAllAsReadPendingIntent = actionCreator.createMarkAllAsReadPendingIntent(account, messageReferences, notificationId); builder.addAction(icon, title, markAllAsReadPendingIntent); }
private void addDeviceDeleteAction(Builder builder, NotificationHolder holder) { if (!isDeleteActionEnabled()) { return; } int icon = resourceProvider.getIconDelete(); String title = resourceProvider.actionDelete(); NotificationContent content = holder.content; int notificationId = holder.notificationId; MessageReference messageReference = content.messageReference; PendingIntent action = actionCreator.createDeleteMessagePendingIntent(messageReference, notificationId); builder.addAction(icon, title, action); }
@Test public void buildSummaryNotification_withoutDeleteAction() throws Exception { K9.setNotificationHideSubject(NotificationHideSubject.NEVER); K9.setNotificationQuickDeleteBehaviour(NotificationQuickDelete.NEVER); when(notificationData.isSingleMessageNotification()).thenReturn(true); notifications.buildSummaryNotification(account, notificationData, false); verify(builder, never()).addAction(resourceProvider.getIconDelete(), "Delete", null); }
private void addMarkAsReadAction(Builder builder, NotificationContent content, int notificationId) { int icon = resourceProvider.getIconMarkAsRead(); String title = resourceProvider.actionMarkAsRead(); MessageReference messageReference = content.messageReference; PendingIntent action = actionCreator.createMarkMessageAsReadPendingIntent(messageReference, notificationId); builder.addAction(icon, title, action); }
private void addDeviceMarkAsReadAction(Builder builder, NotificationHolder holder) { int icon = resourceProvider.getIconMarkAsRead(); String title = resourceProvider.actionMarkAsRead(); NotificationContent content = holder.content; int notificationId = holder.notificationId; MessageReference messageReference = content.messageReference; PendingIntent action = actionCreator.createMarkMessageAsReadPendingIntent(messageReference, notificationId); builder.addAction(icon, title, action); }
private void addReplyAction(Builder builder, NotificationContent content, int notificationId) { int icon = resourceProvider.getIconReply(); String title = resourceProvider.actionReply(); MessageReference messageReference = content.messageReference; PendingIntent replyToMessagePendingIntent = actionCreator.createReplyPendingIntent(messageReference, notificationId); builder.addAction(icon, title, replyToMessagePendingIntent); }
private void addDeleteAction(Builder builder, NotificationContent content, int notificationId) { if (!isDeleteActionEnabled()) { return; } int icon = resourceProvider.getIconDelete(); String title = resourceProvider.actionDelete(); MessageReference messageReference = content.messageReference; PendingIntent action = actionCreator.createDeleteMessagePendingIntent(messageReference, notificationId); builder.addAction(icon, title, action); }
private void addDeviceReplyAction(Builder builder, NotificationHolder holder) { int icon = resourceProvider.getIconReply(); String title = resourceProvider.actionReply(); NotificationContent content = holder.content; MessageReference messageReference = content.messageReference; PendingIntent replyToMessagePendingIntent = actionCreator.createReplyPendingIntent(messageReference, holder.notificationId); builder.addAction(icon, title, replyToMessagePendingIntent); }
@Test public void addAction__shouldAddActionToNotification() { NotificationCompat.Action action = new NotificationCompat.Action.Builder(R.drawable.ic_corp_icon, "a title", null).build(); Notification notification = new NotificationCompat.Builder(RuntimeEnvironment.application) .addAction(action) .build(); assertThat(notification.actions).asList().hasSize(1); } }