From 8516829b181ef4ade82e3628a7ce20eb457e3de6 Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Thu, 25 Jun 2026 07:57:04 +0200 Subject: [PATCH] Handle WEB on notification (for testing) Signed-off-by: tobiasKaminsky --- .../nextcloud/client/jobs/NotificationWork.kt | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/nextcloud/client/jobs/NotificationWork.kt b/app/src/main/java/com/nextcloud/client/jobs/NotificationWork.kt index 928fe29e08ad..05bb6877472e 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/NotificationWork.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/NotificationWork.kt @@ -23,6 +23,7 @@ import android.util.Base64 import androidx.core.app.ActivityCompat import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat +import androidx.core.net.toUri import androidx.work.Worker import androidx.work.WorkerParameters import com.google.gson.Gson @@ -314,7 +315,7 @@ class NotificationWork constructor( val actionType = intent.getStringExtra(KEY_NOTIFICATION_ACTION_TYPE) val actionLink = intent.getStringExtra(KEY_NOTIFICATION_ACTION_LINK) val success: Boolean = if (!actionType.isNullOrEmpty() && !actionLink.isNullOrEmpty()) { - val resultCode = executeAction(actionType, actionLink, client) + val resultCode = executeAction(actionType, actionLink, client, context) resultCode == HttpStatus.SC_OK || resultCode == HttpStatus.SC_ACCEPTED } else { DeleteNotificationRemoteOperation(numericNotificationId) @@ -341,9 +342,21 @@ class NotificationWork constructor( } @Suppress("ReturnCount") // legacy code - private fun executeAction(actionType: String, actionLink: String, client: OwnCloudClient): Int { - val method: HttpMethod - method = when (actionType) { + private fun executeAction( + actionType: String, + actionLink: String, + client: OwnCloudClient, + context: Context + ): Int { + if (actionType == "WEB") { + val browserIntent = Intent(Intent.ACTION_VIEW, actionLink.toUri()).apply { + addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + } + context.startActivity(browserIntent) + return HttpStatus.SC_OK + } + + val method: HttpMethod = when (actionType) { "GET" -> GetMethod(actionLink) "POST" -> Utf8PostMethod(actionLink) "DELETE" -> DeleteMethod(actionLink)