From 2d53e53a471d44c3bfc20ef134b7994dd6d40dd7 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Mon, 9 Dec 2024 12:37:38 +0100 Subject: [PATCH] use input and output together for share and copy Signed-off-by: alperozturk --- .../client/assistant/extensions/TaskExtensions.kt | 9 +++++++-- .../client/assistant/model/ScreenOverlayState.kt | 8 ++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/nextcloud/client/assistant/extensions/TaskExtensions.kt b/app/src/main/java/com/nextcloud/client/assistant/extensions/TaskExtensions.kt index 1302b7a522..50544e2490 100644 --- a/app/src/main/java/com/nextcloud/client/assistant/extensions/TaskExtensions.kt +++ b/app/src/main/java/com/nextcloud/client/assistant/extensions/TaskExtensions.kt @@ -16,9 +16,14 @@ import com.owncloud.android.R import com.owncloud.android.lib.resources.assistant.model.Task import java.util.concurrent.TimeUnit -fun Task.getInput(): String? = input?.input +fun Task.getInputAndOutput(): String { + val inputText = input?.input ?: "" + val outputText = output?.output ?: "" -fun Task.getOutput(): String? = output?.output + return "$inputText\n\n$outputText" +} + +fun Task.getInput(): String? = input?.input @Suppress("MagicNumber") fun Task.getInputTitle(): String { diff --git a/app/src/main/java/com/nextcloud/client/assistant/model/ScreenOverlayState.kt b/app/src/main/java/com/nextcloud/client/assistant/model/ScreenOverlayState.kt index 6ee8ea6132..a051885e9b 100644 --- a/app/src/main/java/com/nextcloud/client/assistant/model/ScreenOverlayState.kt +++ b/app/src/main/java/com/nextcloud/client/assistant/model/ScreenOverlayState.kt @@ -9,7 +9,7 @@ package com.nextcloud.client.assistant.model import android.app.Activity import com.nextcloud.client.assistant.extensions.getInput -import com.nextcloud.client.assistant.extensions.getOutput +import com.nextcloud.client.assistant.extensions.getInputAndOutput import com.nextcloud.utils.extensions.showShareIntent import com.owncloud.android.R import com.owncloud.android.lib.resources.assistant.model.Task @@ -20,15 +20,15 @@ sealed class ScreenOverlayState { data class DeleteTask(val id: Long) : ScreenOverlayState() data class AddTask(val taskType: TaskTypeData, val input: String) : ScreenOverlayState() data class TaskActions(val task: Task) : ScreenOverlayState() { + private fun getInputAndOutput(): String = task.getInputAndOutput() private fun getInput(): String? = task.getInput() - private fun getOutput(): String? = task.getOutput() private fun getCopyToClipboardAction(activity: Activity): Triple Unit> { return Triple( R.drawable.ic_content_copy, R.string.common_copy ) { - ClipboardUtil.copyToClipboard(activity, getOutput()) + ClipboardUtil.copyToClipboard(activity, getInputAndOutput(), showToast = false) } } @@ -37,7 +37,7 @@ sealed class ScreenOverlayState { R.drawable.ic_share, R.string.common_share ) { - activity.showShareIntent(getOutput()) + activity.showShareIntent(getInputAndOutput()) } }