diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/relays/BasicRelaySetupInfoClickableRow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/relays/BasicRelaySetupInfoClickableRow.kt index 02625904e..a13218212 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/relays/BasicRelaySetupInfoClickableRow.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/relays/BasicRelaySetupInfoClickableRow.kt @@ -20,7 +20,8 @@ */ package com.vitorpamplona.amethyst.ui.actions.relays -import androidx.compose.foundation.clickable +import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer @@ -31,6 +32,8 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.remember import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.platform.LocalClipboardManager +import androidx.compose.ui.text.AnnotatedString import com.vitorpamplona.amethyst.service.Nip11CachedRetriever import com.vitorpamplona.amethyst.ui.note.RenderRelayIcon import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel @@ -41,6 +44,7 @@ import com.vitorpamplona.amethyst.ui.theme.HalfVertPadding import com.vitorpamplona.amethyst.ui.theme.ReactionRowHeightChatMaxWidth import com.vitorpamplona.amethyst.ui.theme.largeRelayIconModifier +@OptIn(ExperimentalFoundationApi::class) @Composable fun BasicRelaySetupInfoClickableRow( item: BasicRelaySetupInfo, @@ -50,7 +54,17 @@ fun BasicRelaySetupInfoClickableRow( onClick: () -> Unit, accountViewModel: AccountViewModel, ) { - Column(Modifier.fillMaxWidth().clickable(onClick = onClick)) { + val clipboardManager = LocalClipboardManager.current + Column( + Modifier + .fillMaxWidth() + .combinedClickable( + onClick = onClick, + onLongClick = { + clipboardManager.setText(AnnotatedString(item.briefInfo.url)) + }, + ), + ) { Row( verticalAlignment = Alignment.CenterVertically, modifier = HalfVertPadding, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/relays/Kind3RelayListView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/relays/Kind3RelayListView.kt index 9b1ccebde..8afe0ecc8 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/relays/Kind3RelayListView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/relays/Kind3RelayListView.kt @@ -22,7 +22,6 @@ package com.vitorpamplona.amethyst.ui.actions.relays import android.widget.Toast import androidx.compose.foundation.ExperimentalFoundationApi -import androidx.compose.foundation.clickable import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row @@ -59,8 +58,10 @@ import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalClipboardManager import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp @@ -292,6 +293,7 @@ fun LoadRelayInfo( ) } +@OptIn(ExperimentalFoundationApi::class) @Composable fun ClickableRelayItem( item: Kind3BasicRelaySetupInfo, @@ -307,7 +309,17 @@ fun ClickableRelayItem( onDelete: (Kind3BasicRelaySetupInfo) -> Unit, onClick: () -> Unit, ) { - Column(Modifier.fillMaxWidth().clickable(onClick = onClick)) { + val clipboardManager = LocalClipboardManager.current + Column( + Modifier + .fillMaxWidth() + .combinedClickable( + onClick = onClick, + onLongClick = { + clipboardManager.setText(AnnotatedString(item.briefInfo.url)) + }, + ), + ) { Row( verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(vertical = 5.dp), @@ -677,6 +689,7 @@ private fun ActiveToggles( } } +@OptIn(ExperimentalFoundationApi::class) @Composable private fun FirstLine( item: Kind3BasicRelaySetupInfo, @@ -684,11 +697,18 @@ private fun FirstLine( onDelete: (Kind3BasicRelaySetupInfo) -> Unit, modifier: Modifier, ) { + val clipboardManager = LocalClipboardManager.current Row(verticalAlignment = Alignment.CenterVertically, modifier = modifier) { Row(Modifier.weight(1f), verticalAlignment = Alignment.CenterVertically) { Text( text = item.briefInfo.displayUrl, - modifier = Modifier.clickable(onClick = onClick), + modifier = + Modifier.combinedClickable( + onClick = onClick, + onLongClick = { + clipboardManager.setText(AnnotatedString(item.briefInfo.url)) + }, + ), maxLines = 1, overflow = TextOverflow.Ellipsis, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/relays/RelayNameAndRemoveButton.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/relays/RelayNameAndRemoveButton.kt index 4d71d403f..eeba9d2d1 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/relays/RelayNameAndRemoveButton.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/relays/RelayNameAndRemoveButton.kt @@ -20,7 +20,8 @@ */ package com.vitorpamplona.amethyst.ui.actions.relays -import androidx.compose.foundation.clickable +import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size @@ -34,6 +35,8 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable 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.style.TextOverflow import androidx.compose.ui.unit.dp import com.vitorpamplona.amethyst.R @@ -41,6 +44,7 @@ import com.vitorpamplona.amethyst.ui.stringRes import com.vitorpamplona.amethyst.ui.theme.WarningColor import com.vitorpamplona.amethyst.ui.theme.allGoodColor +@OptIn(ExperimentalFoundationApi::class) @Composable fun RelayNameAndRemoveButton( item: BasicRelaySetupInfo, @@ -48,11 +52,18 @@ fun RelayNameAndRemoveButton( onDelete: (BasicRelaySetupInfo) -> Unit, modifier: Modifier, ) { + val clipboardManager = LocalClipboardManager.current Row(verticalAlignment = Alignment.CenterVertically, modifier = modifier) { Row(Modifier.weight(1f), verticalAlignment = Alignment.CenterVertically) { Text( text = item.briefInfo.displayUrl, - modifier = Modifier.clickable(onClick = onClick), + modifier = + Modifier.combinedClickable( + onClick = onClick, + onLongClick = { + clipboardManager.setText(AnnotatedString(item.briefInfo.url)) + }, + ), maxLines = 1, overflow = TextOverflow.Ellipsis, ) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/RelayListRow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/RelayListRow.kt index 6fb0691fc..fe35793bf 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/RelayListRow.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/RelayListRow.kt @@ -20,8 +20,9 @@ */ package com.vitorpamplona.amethyst.ui.note +import androidx.compose.foundation.ExperimentalFoundationApi import androidx.compose.foundation.background -import androidx.compose.foundation.clickable +import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.padding @@ -42,6 +43,8 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalClipboardManager +import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.TextStyle import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle @@ -109,6 +112,7 @@ fun ChatRelayExpandButton(onClick: () -> Unit) { } } +@OptIn(ExperimentalFoundationApi::class) @Composable fun RenderRelay( relay: RelayBriefInfoCache.RelayBriefInfo, @@ -143,11 +147,15 @@ fun RenderRelay( ) } + val clipboardManager = LocalClipboardManager.current val clickableModifier = remember(relay) { Modifier .size(Size17dp) - .clickable( + .combinedClickable( + onLongClick = { + clipboardManager.setText(AnnotatedString(relay.url)) + }, onClick = { accountViewModel.retrieveRelayDocument( relay.url,