Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions app/src/main/java/com/nextcloud/client/jobs/NotificationWork.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Loading