diff --git a/app/src/main/java/com/github/gotify/service/WebSocketService.java b/app/src/main/java/com/github/gotify/service/WebSocketService.java index 658fc912..be739957 100644 --- a/app/src/main/java/com/github/gotify/service/WebSocketService.java +++ b/app/src/main/java/com/github/gotify/service/WebSocketService.java @@ -323,6 +323,30 @@ private void showNotification( .setColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary)) .setContentIntent(contentIntent); + String actionOpen = + Extras.getNestedValue(String.class, extras, "client::notification", "actions", "open"); + + if (actionOpen != null) { + Intent actionOpenIntent = new Intent(); + actionOpenIntent.setAction(Intent.ACTION_VIEW); + actionOpenIntent.setData(Uri.parse(actionOpen)); + PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 123, actionOpenIntent, PendingIntent.FLAG_IMMUTABLE); + b.addAction(new NotificationCompat.Action.Builder(null, "open", pendingIntent).build()); + } + + String actionShare = + Extras.getNestedValue(String.class, extras, "client::notification", "actions", "share"); + + if (actionShare != null) { + Intent sendIntent = new Intent(); + sendIntent.setAction(Intent.ACTION_SEND); + sendIntent.putExtra(Intent.EXTRA_TEXT, actionShare); + sendIntent.setType("text/plain"); + Intent shareIntent = Intent.createChooser(sendIntent, null); + PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 124, shareIntent, PendingIntent.FLAG_IMMUTABLE); + b.addAction(new NotificationCompat.Action.Builder(null, "share", pendingIntent).build()); + } + CharSequence formattedMessage = message; if (Extras.useMarkdown(extras)) { formattedMessage = markwon.toMarkdown(message); diff --git a/client/build.gradle b/client/build.gradle index 564e4d5a..363a25d8 100644 --- a/client/build.gradle +++ b/client/build.gradle @@ -100,9 +100,11 @@ ext { junit_version = "4.13" threetenbp_version = "1.4.4" json_fire_version = "1.8.4" + javax_annotation_version = "1.3.2" } dependencies { + compile "javax.annotation:javax.annotation-api:$javax_annotation_version" compile "com.squareup.retrofit2:retrofit:$retrofit_version" compile "com.squareup.retrofit2:converter-scalars:$retrofit_version" compile "com.squareup.retrofit2:converter-gson:$retrofit_version"