Replaced custom clipboard method by the built-in
This commit is contained in:
parent
7203ee162b
commit
578f30b7c9
@ -65,17 +65,6 @@ private fun openFileJdk(filePath: String) {
|
||||
}
|
||||
}
|
||||
|
||||
fun copyInBrowser(textToCopy: String) {
|
||||
try {
|
||||
val selection = StringSelection(textToCopy)
|
||||
val clipboard: Clipboard = Toolkit.getDefaultToolkit().systemClipboard
|
||||
clipboard.setContents(selection, selection)
|
||||
} catch (ex: Exception) {
|
||||
printLog(TAG, "Failed to copy text")
|
||||
ex.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
enum class OS {
|
||||
LINUX,
|
||||
WINDOWS,
|
||||
|
@ -8,6 +8,8 @@ import androidx.compose.material.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalClipboardManager
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
@ -138,6 +140,7 @@ fun Author(
|
||||
) {
|
||||
var copied by remember(id) { mutableStateOf(false) }
|
||||
val scope = rememberCoroutineScope()
|
||||
val clipboard = LocalClipboardManager.current
|
||||
|
||||
Row(
|
||||
modifier = Modifier
|
||||
@ -173,7 +176,7 @@ fun Author(
|
||||
style = MaterialTheme.typography.body2,
|
||||
modifier = Modifier.handMouseClickable {
|
||||
scope.launch {
|
||||
copyInBrowser(id.name)
|
||||
clipboard.setText(AnnotatedString(id.name))
|
||||
copied = true
|
||||
delay(2000) // 2s
|
||||
copied = false
|
||||
|
@ -33,7 +33,7 @@ private const val TAG = "TabViewModel"
|
||||
/**
|
||||
* Contains all the information related to a tab and its subcomponents (smaller composables like the log, branches,
|
||||
* commit changes, etc.). It holds a reference to every view model because this class lives as long as the tab is open (survives
|
||||
* across full com.jetpackduba.gitnuro.app recompositions), therefore, tab's content can be recreated with these view models.
|
||||
* across full app recompositions), therefore, tab's content can be recreated with these view models.
|
||||
*/
|
||||
class TabViewModel @Inject constructor(
|
||||
val logViewModel: LogViewModel,
|
||||
|
Loading…
Reference in New Issue
Block a user