private void updateNotificationForStatus(Context context, MsfRpcdService.Status status) { NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context, context.getString(R.string.csploitChannelId)) .setSmallIcon(R.drawable.exploit_msf) .setContentTitle(context.getString(R.string.msf_status)) .setProgress(0, 0, status.inProgress()) .setContentText(context.getString(status.getText())) .setColor(ContextCompat.getColor(context, status.getColor())) .setChannelId(context.getString(R.string.csploitChannelId)); NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(MSF_NOTIFICATION, mBuilder.build()); } }
.setContentText(getString(R.string.connecting)) .setSmallIcon(android.R.drawable.stat_sys_download) .setProgress(100, 0, true) .setChannelId(getBaseContext().getString(R.string.csploitChannelId)); mNotificationManager.notify(NOTIFICATION_ID,mBuilder.build()); mBuilder.setProgress(100, percentage, false) .setContentInfo(percentage + "%") .setChannelId(getBaseContext().getString(R.string.csploitChannelId));
/** * if mContentIntent is null delete our notification, * else assign it to the notification onClick */ private void finishNotification() { if(mContentIntent==null){ Logger.debug("deleting notifications"); mNotificationManager.cancel(NOTIFICATION_ID); } else { Logger.debug("assign '"+mContentIntent.toString()+"'to notification"); mBuilder.setContentIntent(PendingIntent.getActivity(this, CLICK_CODE, mContentIntent, 0)) .setProgress(0,0,false) .setAutoCancel(true) .setDeleteIntent(PendingIntent.getActivity(this, 0, new Intent(), 0)) .setChannelId(getBaseContext().getString(R.string.csploitChannelId)); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); } if(mReceiver!=null) unregisterReceiver(mReceiver); mReceiver = null; mBuilder = null; mNotificationManager = null; }
NotificationUpdateCallback(Context context, Device device, ArrayList<NetworkPacket> toSend) { this.toSend = toSend; this.device = device; this.res = context.getResources(); String title; if (toSend.size() > 1) { title = res.getString(R.string.outgoing_files_title, device.getName()); } else { title = res.getString(R.string.outgoing_file_title, device.getName()); } notificationManager = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); builder = new NotificationCompat.Builder(context, NotificationHelper.Channels.FILETRANSFER) .setSmallIcon(android.R.drawable.stat_sys_upload) .setAutoCancel(true) .setOngoing(true) .setProgress(100, 0, false) .setContentTitle(title) .setTicker(title); notificationId = (int) System.currentTimeMillis(); numFiles = toSend.size(); }
@Override protected void onProgressUpdate(Integer... progress) { super.onProgressUpdate(progress); if (fineProgress > last_perc) { last_perc = fineProgress; double ttDownloaded = round(last_perc * onePercent); // if we get here, length is known, now set indeterminate to false // Notification mBuilder.setProgress(100, progress[0], false) .setContentTitle("Downloading Kali Chroot: " + last_perc + "%") .setContentText("So far " + ttDownloaded + " MB of " + humanSize + " MB downloaded."); mNotifyManager.notify(1, mBuilder.build()); // Dialog mProgressDialog.setIndeterminate(false); mProgressDialog.setProgress(progress[0]); mProgressDialog.setTitle("Downloading Chroot."); } }
@Override protected void onCancelled() { isRunning = false; // mProgressDialog.setTitle("Chroot download Aborted."); mBuilder.setContentTitle("Chroot download Aborted.") .setContentText("Download canceled by the user.") .setSmallIcon(R.drawable.ic_action_perm_device_information) // Removes the progress bar .setProgress(0, 0, false); mNotifyManager.notify(1, mBuilder.build()); statusLog("Download canceled by the user, removing temp file..."); deleteFile(zipFilePath); checkForExistingChroot(); mNotifyManager.cancel(1); }
public void setProgress(int progress, String progressMessage) { builder.setProgress( 100, progress, false); builder.setContentText(progressMessage); }
@Override public NotificationBuilder setProgress(final int max, final int progress, final boolean indeterminate) { super.setProgress(max, progress, indeterminate); return this; }
@Override public void onProgressChanged(int progress) { builder.setProgress(100 * numFiles, (100 * sentFiles) + progress, false); NotificationHelper.notifyCompat(notificationManager, notificationId, builder.build()); }
private void updateNotification() { if ((mSumImageDownloads - (mRemainingArtists + mRemainingAlbums)) % 10 == 0) { mBuilder.setProgress(mSumImageDownloads, mSumImageDownloads - (mRemainingArtists + mRemainingAlbums), false); mBuilder.setStyle(new NotificationCompat.BigTextStyle() .bigText(getString(R.string.downloader_notification_remaining_images) + ' ' + String.valueOf(mSumImageDownloads - (mRemainingArtists + mRemainingAlbums)) + '/' + String.valueOf(mSumImageDownloads))); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); } }
private void updateNotification() { // Updates the notification but only every 10 elements to reduce load on the notification view if (mScannedFiles % 10 == 0 && !mAbort) { mBuilder.setProgress(mFilesToScan, mScannedFiles, false); mBuilder.setStyle(new NotificationCompat.BigTextStyle() .bigText(getString(R.string.mediascanner_notification_text, mScannedFiles, mFilesToScan))); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); } }
public ShareNotification(Device device) { this.device = device; notificationId = (int) System.currentTimeMillis(); notificationManager = (NotificationManager) device.getContext().getSystemService(Context.NOTIFICATION_SERVICE); builder = new NotificationCompat.Builder(device.getContext(), NotificationHelper.Channels.FILETRANSFER) .setSmallIcon(android.R.drawable.stat_sys_download) .setAutoCancel(true) .setOngoing(true) .setProgress(100, 0, true); }
.setContentInfo("") .setSmallIcon(android.R.drawable.ic_popup_sync) .setProgress(100, 0, false) .setChannelId(getBaseContext().getString(R.string.csploitChannelId)); mNotificationManager.notify(NOTIFICATION_ID,mBuilder.build()); mBuilder.setProgress(100, percentage, false) .setContentInfo(percentage + "%") .setChannelId(getBaseContext().getString(R.string.csploitChannelId)); .setProgress(100, 100, true) .setChannelId(getBaseContext().getString(R.string.csploitChannelId)); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
.setSmallIcon(android.R.drawable.ic_popup_sync) .setContentText("") .setProgress(100, 0, false) .setChannelId(getBaseContext().getString(R.string.csploitChannelId)); mNotificationManager.notify(NOTIFICATION_ID,mBuilder.build()); mBuilder.setProgress(100, percentage, false) .setContentInfo(percentage + "%") .setChannelId(getBaseContext().getString(R.string.csploitChannelId)); .setContentTitle(getString(R.string.update_available)) .setContentText(getString(R.string.click_here_to_upgrade)) .setProgress(0, 0, false) // remove progress bar .setAutoCancel(true); exitForError=false;
.setContentText("") .setContentInfo("") .setProgress(100, 0, true) .setChannelId(getBaseContext().getString(R.string.csploitChannelId)); mNotificationManager.notify(NOTIFICATION_ID,mBuilder.build()); percentage = (short) (((double) counter.getBytesRead() / total) * 100); if (percentage != old_percentage) { mBuilder.setProgress(100, percentage, false) .setContentInfo(percentage + "%") .setChannelId(getBaseContext().getString(R.string.csploitChannelId));
.setProgress(100, 0, true);
.setContentInfo("") .setSmallIcon(android.R.drawable.stat_sys_download) .setProgress(100, 0, true) .setChannelId(getBaseContext().getString(R.string.csploitChannelId)); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
/** * Informs the {@link UploadService} that the task has made some progress. You should call this * method from your task whenever you have successfully transferred some bytes to the server. * * @param uploadInfo upload information and statistics */ private void updateNotificationProgress(UploadInfo uploadInfo) { if (params.notificationConfig == null || params.notificationConfig.getProgress().message == null) return; UploadNotificationStatusConfig statusConfig = params.notificationConfig.getProgress(); NotificationCompat.Builder notification = new NotificationCompat.Builder(service, params.notificationConfig.getNotificationChannelId()) .setWhen(notificationCreationTimeMillis) .setContentTitle(Placeholders.replace(statusConfig.title, uploadInfo)) .setContentText(Placeholders.replace(statusConfig.message, uploadInfo)) .setContentIntent(statusConfig.getClickIntent(service)) .setSmallIcon(statusConfig.iconResourceID) .setLargeIcon(statusConfig.largeIcon) .setColor(statusConfig.iconColorResourceID) .setGroup(UploadService.NAMESPACE) .setProgress((int) uploadInfo.getTotalBytes(), (int) uploadInfo.getUploadedBytes(), false) .setOngoing(true); statusConfig.addActionsToNotificationBuilder(notification); Notification builtNotification = notification.build(); if (service.holdForegroundNotification(params.id, builtNotification)) { notificationManager.cancel(notificationId); } else { notificationManager.notify(notificationId, builtNotification); } }
/** * If the upload task is initialized with a notification configuration, this handles its * creation. * * @param uploadInfo upload information and statistics */ private void createNotification(UploadInfo uploadInfo) { if (params.notificationConfig == null || params.notificationConfig.getProgress().message == null) return; UploadNotificationStatusConfig statusConfig = params.notificationConfig.getProgress(); notificationCreationTimeMillis = System.currentTimeMillis(); NotificationCompat.Builder notification = new NotificationCompat.Builder(service, params.notificationConfig.getNotificationChannelId()) .setWhen(notificationCreationTimeMillis) .setContentTitle(Placeholders.replace(statusConfig.title, uploadInfo)) .setContentText(Placeholders.replace(statusConfig.message, uploadInfo)) .setContentIntent(statusConfig.getClickIntent(service)) .setSmallIcon(statusConfig.iconResourceID) .setLargeIcon(statusConfig.largeIcon) .setColor(statusConfig.iconColorResourceID) .setGroup(UploadService.NAMESPACE) .setProgress(100, 0, true) .setOngoing(true); statusConfig.addActionsToNotificationBuilder(notification); Notification builtNotification = notification.build(); if (service.holdForegroundNotification(params.id, builtNotification)) { notificationManager.cancel(notificationId); } else { notificationManager.notify(notificationId, builtNotification); } }
private void updateNotification(UploadInfo uploadInfo, UploadNotificationStatusConfig statusConfig) { if (params.notificationConfig == null) return; notificationManager.cancel(notificationId); if (statusConfig.message == null) return; if (!statusConfig.autoClear) { NotificationCompat.Builder notification = new NotificationCompat.Builder(service, params.notificationConfig.getNotificationChannelId()) .setContentTitle(Placeholders.replace(statusConfig.title, uploadInfo)) .setContentText(Placeholders.replace(statusConfig.message, uploadInfo)) .setContentIntent(statusConfig.getClickIntent(service)) .setAutoCancel(statusConfig.clearOnAction) .setSmallIcon(statusConfig.iconResourceID) .setLargeIcon(statusConfig.largeIcon) .setColor(statusConfig.iconColorResourceID) .setGroup(UploadService.NAMESPACE) .setProgress(0, 0, false) .setOngoing(false); statusConfig.addActionsToNotificationBuilder(notification); setRingtone(notification); // this is needed because the main notification used to show progress is ongoing // and a new one has to be created to allow the user to dismiss it uploadInfo.setNotificationID(notificationId + 1); notificationManager.notify(notificationId + 1, notification.build()); } }