@@ -1022,13 +1022,15 @@ class ChatActivity :
10221022 binding.offline.root.visibility = View .GONE
10231023 binding.messagesListView.visibility = View .VISIBLE
10241024
1025-
10261025 lifecycleScope.launch {
10271026 repeatOnLifecycle(Lifecycle .State .STARTED ) {
10281027 chatViewModel.observeMessages()
10291028 .collect { messages ->
1030- Log .d(" newchat" , " messages.size when colleting in ChatActivity:" + messages
1031- .size)
1029+ Log .d(
1030+ " newchat" ,
1031+ " messages.size when colleting in ChatActivity:" + messages
1032+ .size
1033+ )
10321034
10331035 val transformedMessages = messages
10341036 .let (::handleSystemMessages)
@@ -1060,7 +1062,6 @@ class ChatActivity :
10601062 }
10611063 }
10621064 }
1063-
10641065 }
10651066 else -> {}
10661067 }
@@ -1345,160 +1346,6 @@ class ChatActivity :
13451346 }
13461347 }
13471348
1348- @Composable
1349- private fun PinnedMessageView (message : ChatMessage ) {
1350- message.incoming = true
1351-
1352- val pinnedBy = stringResource(R .string.pinned_by)
1353-
1354- message.actorDisplayName = remember(message.pinnedActorDisplayName) {
1355- " ${message.actorDisplayName} \n $pinnedBy ${message.pinnedActorDisplayName} "
1356- }
1357- val scrollState = rememberScrollState()
1358-
1359- val outgoingBubbleColor = remember {
1360- val colorInt = viewThemeUtils.talk
1361- .getOutgoingMessageBubbleColor(context, message.isDeleted, false )
1362-
1363- Color (colorInt)
1364- }
1365-
1366- val incomingBubbleColor = remember {
1367- val colorInt = resources
1368- .getColor(R .color.bg_message_list_incoming_bubble, null )
1369-
1370- Color (colorInt)
1371- }
1372-
1373- val canPin = remember {
1374- message.isOneToOneConversation ||
1375- ConversationUtils .isParticipantOwnerOrModerator(currentConversation!! )
1376- }
1377-
1378- Column (
1379- verticalArrangement = Arrangement .spacedBy((- 16 ).dp),
1380- modifier = Modifier
1381- ) {
1382- Box (
1383- modifier = Modifier
1384- .shadow(4 .dp, shape = RoundedCornerShape (16 .dp))
1385- .background(incomingBubbleColor, RoundedCornerShape (16 .dp))
1386- .padding(16 .dp)
1387- .heightIn(max = 100 .dp)
1388- .verticalScroll(scrollState)
1389- .clickable {
1390- scrollToMessageWithIdWithOffset(message.id)
1391- }
1392-
1393- ) {
1394- ComposeChatAdapter ().GetComposableForMessage (message)
1395- }
1396-
1397- var expanded by remember { mutableStateOf(false ) }
1398-
1399- val pinnedText = remember(message.pinnedUntil) {
1400- val pinnedUntilStr = context.getString(R .string.pinned_until)
1401- val untilUnpin = context.getString(R .string.until_unpin)
1402-
1403- message.pinnedUntil?.let {
1404- val format = if (DateFormat .is24HourFormat(context)) {
1405- " MMM dd yyyy, HH:mm"
1406- } else {
1407- " MMM dd yyyy, hh:mm a"
1408- }
1409-
1410- val localDateTime = Instant .ofEpochSecond(it)
1411- .atZone(ZoneId .systemDefault())
1412- .toLocalDateTime()
1413-
1414- val timeString = localDateTime.format(DateTimeFormatter .ofPattern(format))
1415-
1416- " $pinnedUntilStr $timeString "
1417- } ? : untilUnpin
1418- }
1419-
1420- Box (
1421- modifier = Modifier
1422- .offset(16 .dp, 0 .dp)
1423- .background(outgoingBubbleColor, RoundedCornerShape (16 .dp))
1424- ) {
1425- IconButton (onClick = { expanded = true }) {
1426- Icon (
1427- imageVector = Icons .Default .Menu , // Or use a Pin icon here
1428- contentDescription = " Pinned Message Options"
1429- )
1430- }
1431-
1432- DropdownMenu (
1433- expanded = expanded,
1434- onDismissRequest = { expanded = false },
1435- modifier = Modifier .background(outgoingBubbleColor)
1436- ) {
1437- DropdownMenuItem (
1438- text = {
1439- Text (
1440- text = pinnedText,
1441- style = MaterialTheme .typography.bodySmall,
1442- color = MaterialTheme .colorScheme.onSurfaceVariant
1443- )
1444- },
1445- onClick = { /* No-op or toggle expansion */ },
1446- enabled = false // Visually distinct as information, not action
1447- )
1448-
1449- Divider ()
1450-
1451- DropdownMenuItem (
1452- text = { Text (" Go to message" ) },
1453- leadingIcon = {
1454- Icon (
1455- painter = painterResource(R .drawable.baseline_chat_bubble_outline_24),
1456- contentDescription = null ,
1457- modifier = Modifier .size(24 .dp)
1458- )
1459- },
1460- onClick = {
1461- expanded = false
1462- scrollToMessageWithIdWithOffset(message.id)
1463- }
1464- )
1465-
1466- DropdownMenuItem (
1467- text = { Text (" Dismiss" ) },
1468- leadingIcon = {
1469- Icon (
1470- painter = painterResource(R .drawable.ic_eye_off),
1471- contentDescription = null ,
1472- modifier = Modifier .size(24 .dp)
1473- )
1474- },
1475- onClick = {
1476- expanded = false
1477- hidePinnedMessage(message)
1478- }
1479- )
1480-
1481- if (canPin) {
1482- DropdownMenuItem (
1483- text = { Text (" Unpin" ) },
1484- leadingIcon = {
1485- Icon (
1486- painter = painterResource(R .drawable.keep_off_24px),
1487- contentDescription = null ,
1488- modifier = Modifier .size(24 .dp)
1489- )
1490- },
1491- onClick = {
1492- expanded = false
1493- unPinMessage(message)
1494- }
1495- )
1496- }
1497- }
1498- }
1499- }
1500- }
1501-
15021349 private fun removeUnreadMessagesMarker () {
15031350 removeMessageById(UNREAD_MESSAGES_MARKER_ID .toString())
15041351 }
@@ -3359,7 +3206,7 @@ class ChatActivity :
33593206 }
33603207 }
33613208
3362- private fun determinePreviousMessageIds (chatMessageList : List <ChatMessage >) : List <ChatMessage > {
3209+ private fun determinePreviousMessageIds (chatMessageList : List <ChatMessage >): List <ChatMessage > {
33633210 var previousMessageId = NO_PREVIOUS_MESSAGE_ID
33643211 for (i in chatMessageList.indices.reversed()) {
33653212 val chatMessage = chatMessageList[i]
@@ -3932,7 +3779,6 @@ class ChatActivity :
39323779 (message2.lastEditTimestamp == 0L || message1.lastEditTimestamp == 0L )
39333780 }
39343781
3935-
39363782 for (i in chatMessageList.indices) {
39373783 if (chatMessageList.size > i + 1 ) {
39383784 chatMessageList[i].isGrouped = groupMessages(chatMessageList[i], chatMessageList[i + 1 ])
0 commit comments