NotificationCompat.Action prevAction = new NotificationCompat.Action.Builder(R.drawable.ic_skip_previous_48dp, "Previous", prevPendingIntent).build(); playPauseIcon = R.drawable.ic_play_arrow_48dp; NotificationCompat.Action playPauseAction = new NotificationCompat.Action.Builder(playPauseIcon, "PlayPause", playPauseIntent).build(); NotificationCompat.Action nextAction = new NotificationCompat.Action.Builder(R.drawable.ic_skip_next_48dp, "Next", nextPendingIntent).build();
@TargetApi(Build.VERSION_CODES.N) private static void createInlineReply( Context ctx, NotificationCompat.Builder builder, NotificationEntity entity) { RemoteInput remoteInput = new RemoteInput.Builder(Constants.EXTRA_COMMENT) .setLabel(ctx.getString(R.string.change_details_review_hint)) .setAllowFreeFormInput(true) .build(); NotificationCompat.Action action = new NotificationCompat.Action.Builder( R.drawable.ic_send, ctx.getString(R.string.action_reply), getReplyPendingIntent(ctx, entity)) .addRemoteInput(remoteInput) .setAllowGeneratedReplies(false) .build(); builder.addAction(action); }
iPlay.putExtra(MprisMediaNotificationReceiver.EXTRA_MPRIS_PLAYER, notificationPlayer.getPlayer()); PendingIntent piPlay = PendingIntent.getBroadcast(service, 0, iPlay, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action.Builder aPlay = new NotificationCompat.Action.Builder( R.drawable.ic_play_white, service.getString(R.string.mpris_play), piPlay); iPause.putExtra(MprisMediaNotificationReceiver.EXTRA_MPRIS_PLAYER, notificationPlayer.getPlayer()); PendingIntent piPause = PendingIntent.getBroadcast(service, 0, iPause, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action.Builder aPause = new NotificationCompat.Action.Builder( R.drawable.ic_pause_white, service.getString(R.string.mpris_pause), piPause); iPrevious.putExtra(MprisMediaNotificationReceiver.EXTRA_MPRIS_PLAYER, notificationPlayer.getPlayer()); PendingIntent piPrevious = PendingIntent.getBroadcast(service, 0, iPrevious, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action.Builder aPrevious = new NotificationCompat.Action.Builder( R.drawable.ic_previous_white, service.getString(R.string.mpris_previous), piPrevious); iNext.putExtra(MprisMediaNotificationReceiver.EXTRA_MPRIS_PLAYER, notificationPlayer.getPlayer()); PendingIntent piNext = PendingIntent.getBroadcast(service, 0, iNext, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action.Builder aNext = new NotificationCompat.Action.Builder( R.drawable.ic_next_white, service.getString(R.string.mpris_next), piNext); long playbackActions = 0; if (notificationPlayer.isGoPreviousAllowed()) { notification.addAction(aPrevious.build()); playbackActions |= PlaybackStateCompat.ACTION_SKIP_TO_PREVIOUS; ++numActions; notification.addAction(aPause.build()); playbackActions |= PlaybackStateCompat.ACTION_PAUSE; ++numActions;
new NotificationCompat.Action.Builder( R.drawable.ic_reply_white_18dp, replyLabel, replyActionPendingIntent) .addRemoteInput(remoteInput) .setShowsUserInterface(false) .setAllowGeneratedReplies(true) .setSemanticAction(Action.SEMANTIC_ACTION_REPLY) .build();
new NotificationCompat.Action.Builder( R.drawable.ic_reply_white_18dp, replyLabel, replyActionPendingIntent) .addRemoteInput(remoteInput) .setShowsUserInterface(false) .setAllowGeneratedReplies(true) .setSemanticAction(Action.SEMANTIC_ACTION_REPLY) .build();
new NotificationCompat.Action.Builder( R.drawable.ic_reply_white_18dp, replyLabel, replyActionPendingIntent) .addRemoteInput(remoteInput) .build();
new NotificationCompat.Action.Builder( R.drawable.ic_alarm_white_48dp, "Snooze", snoozePendingIntent) .build(); new NotificationCompat.Action.Builder( R.drawable.ic_cancel_white_48dp, "Dismiss", dismissPendingIntent) .build();
new NotificationCompat.Action.Builder( R.drawable.ic_alarm_white_48dp, "Snooze", snoozePendingIntent) .build(); new NotificationCompat.Action.Builder( R.drawable.ic_cancel_white_48dp, "Dismiss", dismissPendingIntent) .build(); NotificationCompat.Action mainAction = new NotificationCompat.Action.Builder( R.drawable.ic_launcher, "Open", mainPendingIntent) .build();
new NotificationCompat.Action.Builder( R.drawable.ic_reply_white_18dp, replyLabel, replyActionPendingIntent) .addRemoteInput(remoteInput) .extend(inlineActionForWear2) .build();
new NotificationCompat.Action.Builder( R.drawable.ic_alarm_white_48dp, "Snooze", snoozePendingIntent) .build(); new NotificationCompat.Action.Builder( R.drawable.ic_cancel_white_48dp, "Dismiss", dismissPendingIntent) .build(); NotificationCompat.Action mainAction = new NotificationCompat.Action.Builder( R.drawable.ic_launcher, "Open", mainPendingIntent) .build();
new NotificationCompat.Action.Builder( R.drawable.ic_reply_white_18dp, replyLabel, replyActionPendingIntent) .addRemoteInput(remoteInput) .setShowsUserInterface(false) .setAllowGeneratedReplies(true) .setSemanticAction(Action.SEMANTIC_ACTION_REPLY) .extend(inlineActionForWear2) .build();
new NotificationCompat.Action.Builder( R.drawable.ic_reply_white_18dp, replyLabel, replyActionPendingIntent) .addRemoteInput(remoteInput) .setShowsUserInterface(false) .setAllowGeneratedReplies(true) .setSemanticAction(Action.SEMANTIC_ACTION_REPLY) .extend(inlineActionForWear2) .build();
new NotificationCompat.Action.Builder( R.drawable.ic_reply_white_18dp, replyLabel, replyActionPendingIntent) .addRemoteInput(remoteInput) .extend(inlineActionForWear2) .build();
new NotificationCompat.Action.Builder( R.drawable.ic_alarm_white_48dp, "Snooze", snoozePendingIntent) .build(); new NotificationCompat.Action.Builder( R.drawable.ic_cancel_white_48dp, "Dismiss", dismissPendingIntent) .build();
new NotificationCompat.Action.Builder( R.drawable.ic_reply_white_18dp, replyLabel, replyActionPendingIntent) .addRemoteInput(remoteInput) .build();
int replyIcon = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? R.drawable.ic_reply : R.drawable.ic_notification_reply; NotificationCompat.Action replyAction = new NotificationCompat.Action.Builder( replyIcon, context.getString(R.string.action_reply), replyIntent) .addRemoteInput(new RemoteInput.Builder(NotificationActionReceiver.KEY_REPLY_TEXT) .setLabel(context.getString(R.string.action_reply)) .build()) .build(); notification .setContentTitle(title)
PendingIntent sharePendingIntent = PendingIntent.getActivity(device.getContext(), (int) System.currentTimeMillis(), shareIntent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action.Builder shareAction = new NotificationCompat.Action.Builder( R.drawable.ic_share_white, device.getContext().getString(R.string.share), sharePendingIntent); builder.addAction(shareAction.build());
NotificationCompat.Action cancelAction = new NotificationCompat.Action.Builder(R.drawable.ic_close_24dp, getString(R.string.dialog_action_cancel), nextPendingIntent).build();
private void runAsForeground() { if (mBroadcastReceiver == null) { mBroadcastReceiver = new ActionReceiver(); // Create a filter to only handle certain actions IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ACTION_CANCEL_BULKDOWNLOAD); registerReceiver(mBroadcastReceiver, intentFilter); } mBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID) .setContentTitle(getString(R.string.downloader_notification_title)) .setStyle(new NotificationCompat.BigTextStyle() .bigText(getString(R.string.downloader_notification_remaining_images) + ' ' + String.valueOf(mSumImageDownloads - (mRemainingArtists + mRemainingAlbums)) + '/' + String.valueOf(mSumImageDownloads))) .setProgress(mSumImageDownloads, mSumImageDownloads - (mRemainingArtists + mRemainingAlbums), false) .setSmallIcon(R.drawable.odyssey_notification); openChannel(); mBuilder.setOngoing(true); // Cancel action Intent nextIntent = new Intent(BulkDownloadService.ACTION_CANCEL_BULKDOWNLOAD); PendingIntent nextPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 1, nextIntent, PendingIntent.FLAG_UPDATE_CURRENT); androidx.core.app.NotificationCompat.Action cancelAction = new androidx.core.app.NotificationCompat.Action.Builder(R.drawable.ic_close_24dp, getString(R.string.dialog_action_cancel), nextPendingIntent).build(); mBuilder.addAction(cancelAction); Notification notification = mBuilder.build(); startForeground(NOTIFICATION_ID, notification); mNotificationManager.notify(NOTIFICATION_ID, notification); }
private NotificationCompat.Action makeFuncButtonAction() { Intent funcButtonIntent = new Intent(getApplicationContext(), NotificationReceiver.class); int type = pref.getInt(getString(R.string.pref_key_foreground_notify_func_button), SettingsManager.Default.funcButton(getApplicationContext())); int icon = 0; String text = null; if (type == Integer.parseInt(getString(R.string.pref_function_button_pause_value))) { funcButtonIntent.setAction(NotificationReceiver.NOTIFY_ACTION_PAUSE_RESUME); boolean isPause = isPauseButton.get(); icon = (isPause ? R.drawable.ic_pause_white_24dp : R.drawable.ic_play_arrow_white_24dp); text = (isPause ? getString(R.string.pause_torrent) : getString(R.string.resume_torrent)); } else if (type == Integer.parseInt(getString(R.string.pref_function_button_add_value))) { funcButtonIntent.setAction(NotificationReceiver.NOTIFY_ACTION_ADD_TORRENT); icon = R.drawable.ic_add_white_36dp; text = getString(R.string.add); } PendingIntent funcButtonPendingIntent = PendingIntent.getBroadcast( getApplicationContext(), 0, funcButtonIntent, PendingIntent.FLAG_UPDATE_CURRENT); return new NotificationCompat.Action.Builder(icon, text, funcButtonPendingIntent).build(); }