Render one-line Android invitations and retain full links for copy
This commit is contained in:
1 parent
0ce6e9e83a
commit
12e09cb0ed
2 files changed
+18
No files matched your search
@@ -15,6 +15,8 @@ import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.combinedClickable
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
@@ -41,11 +43,13 @@ import androidx.compose.foundation.gestures.awaitFirstDown
|
||||
import androidx.compose.foundation.gestures.detectTapGestures
|
||||
import androidx.compose.ui.layout.ContentScale
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.platform.LocalClipboardManager
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.platform.LocalFocusManager
|
||||
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
||||
import androidx.compose.ui.text.TextRange
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.input.TextFieldValue
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
@@ -95,6 +99,7 @@ private fun detectEmojiOnly(text: String): Int {
|
||||
private fun deliveryLabel(message: Message): String =
|
||||
if (message.deliveryStatusRes == 0) "" else stringResource(message.deliveryStatusRes)
|
||||
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun MessageBubble(message: Message, playbackState: ChatViewModel.PlaybackState = ChatViewModel.PlaybackState(),
|
||||
onPlayVoice: (String, Int) -> Unit = { _, _ -> },
|
||||
@@ -154,6 +159,18 @@ fun MessageBubble(message: Message, playbackState: ChatViewModel.PlaybackState =
|
||||
Spacer(Modifier.height(2.dp))
|
||||
|
||||
when {
|
||||
message.inviteGroupName != null -> {
|
||||
val clipboard = LocalClipboardManager.current
|
||||
Text(stringResource(R.string.group_invitation, message.inviteGroupName), fontSize = 17.sp, color = textColor)
|
||||
Text(message.text, fontSize = 17.sp, color = Color(0xFF3390EC), maxLines = 1, overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.fillMaxWidth().combinedClickable(
|
||||
onClick = { onInviteLink(message.text) },
|
||||
onLongClickLabel = stringResource(R.string.copy_link),
|
||||
onLongClick = {
|
||||
clipboard.setText(AnnotatedString(message.text))
|
||||
LogManager.addLog("DEBUG", "PM", "invitation link copied: seq=${message.id} bytes=${message.text.length}")
|
||||
}))
|
||||
}
|
||||
isVoice -> VoiceBubble(message, textColor, isActive, playbackState, onPlayVoice, onSeekVoice, onDownloadFile)
|
||||
isVideo -> VideoBubble(message, textColor, onDownloadFile, onPlayVideo)
|
||||
isImage -> ImageBubble(message, textColor, onDownloadFile, onOpenImage)
|
||||
|
||||
Reference in new issue
Block a user