Add LogcatViewModel copyLogcat
This commit is contained in:
1 parent
4949528eeb
commit
60562acb80
2 files changed
+9
-7
No files matched your search
@@ -40,7 +40,6 @@ import androidx.lifecycle.lifecycleScope
|
||||
import com.v2ray.ang.R
|
||||
import com.v2ray.ang.compose.AppDivider
|
||||
import com.v2ray.ang.compose.AppTopBar
|
||||
import com.v2ray.ang.compose.LocalAppSnackbar
|
||||
import com.v2ray.ang.compose.verticalScrollbar
|
||||
import com.v2ray.ang.extension.toast
|
||||
import com.v2ray.ang.ui.base.BaseComponentActivity
|
||||
@@ -134,7 +133,6 @@ fun LogcatScreen(
|
||||
var searchQuery by remember { mutableStateOf("") }
|
||||
var showSearch by remember { mutableStateOf(false) }
|
||||
|
||||
val snackbar = LocalAppSnackbar.current
|
||||
val listState = rememberLazyListState()
|
||||
|
||||
Scaffold(
|
||||
@@ -165,11 +163,7 @@ fun LogcatScreen(
|
||||
)
|
||||
}
|
||||
}
|
||||
IconButton(onClick = {
|
||||
val all = viewModel.filteredLogs.value.joinToString("\n")
|
||||
Utils.setClipboard(context, all)
|
||||
snackbar.showInfo(context, R.string.toast_success)
|
||||
}) {
|
||||
IconButton(onClick = { viewModel.copyLogcat() }) {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_copy),
|
||||
contentDescription = stringResource(R.string.logcat_copy)
|
||||
|
||||
@@ -2,8 +2,10 @@ package com.v2ray.ang.ui.logcat
|
||||
|
||||
import android.app.Application
|
||||
import com.v2ray.ang.AppConfig
|
||||
import com.v2ray.ang.R
|
||||
import com.v2ray.ang.ui.base.BaseViewModel
|
||||
import com.v2ray.ang.util.LogUtil
|
||||
import com.v2ray.ang.util.Utils
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
@@ -38,6 +40,12 @@ class LogcatViewModel(application: Application) : BaseViewModel(application) {
|
||||
}
|
||||
}
|
||||
|
||||
fun copyLogcat() {
|
||||
val all = filteredLogs.value.joinToString("\n")
|
||||
Utils.setClipboard(app, all)
|
||||
toast(R.string.toast_success)
|
||||
}
|
||||
|
||||
fun clearLogcat() {
|
||||
try {
|
||||
val lst = LinkedHashSet<String>()
|
||||
|
||||
Reference in new issue
Block a user