mirror of
https://github.com/MetaCubeX/ClashMetaForAndroid.git
synced 2024-11-16 14:52:18 +08:00
Fix: operate clipboard on main thread
This commit is contained in:
parent
b472580ca6
commit
a405372f6a
|
@ -76,11 +76,8 @@ class AccessControlActivity : BaseActivity<AccessControlDesign>() {
|
|||
val data = clipboard?.primaryClip
|
||||
|
||||
if (data != null && data.itemCount > 0) {
|
||||
val all = withContext(Dispatchers.IO) {
|
||||
val packages = data.getItemAt(0).text.split("\n").toSet()
|
||||
|
||||
design.apps.map(AppInfo::packageName).intersect(packages)
|
||||
}
|
||||
val packages = data.getItemAt(0).text.split("\n").toSet()
|
||||
val all = design.apps.map(AppInfo::packageName).intersect(packages)
|
||||
|
||||
selected.clear()
|
||||
selected.addAll(all)
|
||||
|
@ -91,14 +88,12 @@ class AccessControlActivity : BaseActivity<AccessControlDesign>() {
|
|||
AccessControlDesign.Request.Export -> {
|
||||
val clipboard = getSystemService<ClipboardManager>()
|
||||
|
||||
withContext(Dispatchers.IO) {
|
||||
val data = ClipData.newPlainText(
|
||||
"packages",
|
||||
selected.joinToString("\n")
|
||||
)
|
||||
val data = ClipData.newPlainText(
|
||||
"packages",
|
||||
selected.joinToString("\n")
|
||||
)
|
||||
|
||||
clipboard?.setPrimaryClip(data)
|
||||
}
|
||||
clipboard?.setPrimaryClip(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class LogcatDesign(
|
|||
private val binding = DesignLogcatBinding
|
||||
.inflate(context.layoutInflater, context.root, false)
|
||||
private val adapter = LogMessageAdapter(context) {
|
||||
launch(Dispatchers.IO) {
|
||||
launch {
|
||||
val data = ClipData.newPlainText("log_message", it.message)
|
||||
|
||||
context.getSystemService<ClipboardManager>()?.setPrimaryClip(data)
|
||||
|
|
Loading…
Reference in New Issue
Block a user