Add platform clipboard support for attachment actions
This commit is contained in:
1 parent
9c22b2e99d
commit
64e992e8fa
7 files changed
+74
-2
No files matched your search
+26
@@ -0,0 +1,26 @@
|
|||||||
|
package cn.xiaobai.openclawapp.platform
|
||||||
|
|
||||||
|
import android.content.ClipData
|
||||||
|
import android.content.ClipboardManager
|
||||||
|
import android.content.Context
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
actual fun rememberClipboardSetter(
|
||||||
|
onResult: (String) -> Unit,
|
||||||
|
): (String) -> Unit {
|
||||||
|
val context = LocalContext.current
|
||||||
|
return remember(context, onResult) {
|
||||||
|
{ text ->
|
||||||
|
runCatching {
|
||||||
|
val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
|
clipboard.setPrimaryClip(ClipData.newPlainText("OpenClaw", text))
|
||||||
|
onResult("已复制到剪贴板:$text")
|
||||||
|
}.onFailure {
|
||||||
|
onResult(it.message ?: "复制失败")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -27,6 +27,7 @@ import cn.xiaobai.openclawapp.feature.sessions.SessionListScreen
|
|||||||
import cn.xiaobai.openclawapp.feature.settings.SettingsScreen
|
import cn.xiaobai.openclawapp.feature.settings.SettingsScreen
|
||||||
import cn.xiaobai.openclawapp.feature.status.StatusScreen
|
import cn.xiaobai.openclawapp.feature.status.StatusScreen
|
||||||
import cn.xiaobai.openclawapp.platform.rememberAttachmentPicker
|
import cn.xiaobai.openclawapp.platform.rememberAttachmentPicker
|
||||||
|
import cn.xiaobai.openclawapp.platform.rememberClipboardSetter
|
||||||
import cn.xiaobai.openclawapp.ui.OpenClawTheme
|
import cn.xiaobai.openclawapp.ui.OpenClawTheme
|
||||||
import cn.xiaobai.openclawapp.ui.StatusPill
|
import cn.xiaobai.openclawapp.ui.StatusPill
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
@@ -97,6 +98,9 @@ private fun OpenClawRoot(appState: OpenClawAppState) {
|
|||||||
appState.feedbackMessage = message
|
appState.feedbackMessage = message
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
val copyToClipboard = rememberClipboardSetter { message ->
|
||||||
|
appState.feedbackMessage = message
|
||||||
|
}
|
||||||
|
|
||||||
LaunchedEffect(appState.feedbackMessage) {
|
LaunchedEffect(appState.feedbackMessage) {
|
||||||
if (appState.feedbackMessage != null) {
|
if (appState.feedbackMessage != null) {
|
||||||
@@ -208,7 +212,7 @@ private fun OpenClawRoot(appState: OpenClawAppState) {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onCopyAttachmentName = { fileName ->
|
onCopyAttachmentName = { fileName ->
|
||||||
appState.feedbackMessage = "已复制文件名:$fileName"
|
copyToClipboard(fileName)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package cn.xiaobai.openclawapp.platform
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
expect fun rememberClipboardSetter(
|
||||||
|
onResult: (String) -> Unit = {},
|
||||||
|
): (String) -> Unit
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package cn.xiaobai.openclawapp.platform
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
actual fun rememberClipboardSetter(
|
||||||
|
onResult: (String) -> Unit,
|
||||||
|
): (String) -> Unit = remember(onResult) {
|
||||||
|
{ text -> onResult("iOS 剪贴板还没接好:$text") }
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package cn.xiaobai.openclawapp.platform
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
actual fun rememberClipboardSetter(
|
||||||
|
onResult: (String) -> Unit,
|
||||||
|
): (String) -> Unit = remember(onResult) {
|
||||||
|
{ text -> onResult("Web 剪贴板还没接好:$text") }
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
package cn.xiaobai.openclawapp.platform
|
||||||
|
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.remember
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
actual fun rememberClipboardSetter(
|
||||||
|
onResult: (String) -> Unit,
|
||||||
|
): (String) -> Unit = remember(onResult) {
|
||||||
|
{ text -> onResult("Wasm 剪贴板还没接好:$text") }
|
||||||
|
}
|
||||||
@@ -191,10 +191,11 @@ Android/iOS App
|
|||||||
|
|
||||||
目前:
|
目前:
|
||||||
|
|
||||||
- [x] 复制文件名
|
- [x] 复制文件名(Android 真剪贴板)
|
||||||
- [x] 查看附件详情
|
- [x] 查看附件详情
|
||||||
- [ ] 点击附件打开
|
- [ ] 点击附件打开
|
||||||
- [ ] 下载附件
|
- [ ] 下载附件
|
||||||
|
- [ ] iOS / Web 剪贴板
|
||||||
|
|
||||||
### 4.4 iOS / Web 文件选择器
|
### 4.4 iOS / Web 文件选择器
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user