mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2024-12-17 17:20:21 +01:00
changes
This commit is contained in:
@@ -105,8 +105,12 @@ class MainActivity: FragmentActivity() {
|
||||
AppLock.laFailed.value = true
|
||||
}
|
||||
if (!onBackPressedDispatcher.hasEnabledCallbacks()) {
|
||||
val sharedContent = chatModel.sharedContent.value
|
||||
if (sharedContent is SharedContent.Forward) {
|
||||
chatModel.chatId.value = sharedContent.fromChatInfo.id
|
||||
}
|
||||
// Drop shared content
|
||||
SimplexApp.context.chatModel.sharedContent.value = null
|
||||
chatModel.sharedContent.value = null
|
||||
if (canFinishActivity) {
|
||||
finish()
|
||||
}
|
||||
|
||||
+7
-14
@@ -20,7 +20,6 @@ import androidx.compose.ui.text.AnnotatedString
|
||||
import dev.icerock.moko.resources.compose.painterResource
|
||||
import dev.icerock.moko.resources.compose.stringResource
|
||||
import androidx.compose.ui.text.font.FontStyle
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
@@ -30,8 +29,7 @@ import chat.simplex.common.views.chat.item.ItemAction
|
||||
import chat.simplex.common.views.chat.item.MarkdownText
|
||||
import chat.simplex.common.views.helpers.*
|
||||
import chat.simplex.common.ui.theme.*
|
||||
import chat.simplex.common.views.chatlist.openDirectChat
|
||||
import chat.simplex.common.views.chatlist.openGroupChat
|
||||
import chat.simplex.common.views.chatlist.*
|
||||
import chat.simplex.res.MR
|
||||
import dev.icerock.moko.resources.ImageResource
|
||||
|
||||
@@ -43,7 +41,7 @@ sealed class CIInfoTab {
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ChatItemInfoView(chatModel: ChatModel, ci: ChatItem, ciInfo: ChatItemInfo, devTools: Boolean) {
|
||||
fun ChatItemInfoView(chatRh: Long?, ci: ChatItem, ciInfo: ChatItemInfo, devTools: Boolean) {
|
||||
val sent = ci.chatDir.sent
|
||||
val appColors = CurrentColors.collectAsState().value.appColors
|
||||
val uriHandler = LocalUriHandler.current
|
||||
@@ -164,14 +162,13 @@ fun ChatItemInfoView(chatModel: ChatModel, ci: ChatItem, ciInfo: ChatItemInfo, d
|
||||
@Composable
|
||||
fun ForwardedFromSender(forwardedFromItem: AChatItem) {
|
||||
@Composable
|
||||
fun ChatPreviewTitleText(text: String, color: Color, fontStyle: FontStyle = FontStyle.Normal) {
|
||||
fun ChatPreviewTitleText(text: String, fontStyle: FontStyle = FontStyle.Normal) {
|
||||
Text(
|
||||
text,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
style = MaterialTheme.typography.h3,
|
||||
fontStyle = fontStyle,
|
||||
color = color
|
||||
fontStyle = fontStyle
|
||||
)
|
||||
}
|
||||
|
||||
@@ -184,11 +181,11 @@ fun ChatItemInfoView(chatModel: ChatModel, ci: ChatItem, ciInfo: ChatItemInfo, d
|
||||
) {
|
||||
Column {
|
||||
if (forwardedFromItem.chatItem.chatDir.sent) {
|
||||
ChatPreviewTitleText(text = stringResource(MR.strings.sender_you_pronoun), color = MaterialTheme.colors.primary, fontStyle = FontStyle.Italic)
|
||||
ChatPreviewTitleText(text = stringResource(MR.strings.sender_you_pronoun), fontStyle = FontStyle.Italic)
|
||||
Spacer(Modifier.height(DEFAULT_PADDING_HALF))
|
||||
Text(forwardedFromItem.chatInfo.chatViewName, maxLines = 1, style = MaterialTheme.typography.body1.copy(color = if (isInDarkTheme()) MessagePreviewDark else MessagePreviewLight, lineHeight = 22.sp))
|
||||
} else if (forwardedFromItem.chatItem.chatDir is CIDirection.GroupRcv) {
|
||||
ChatPreviewTitleText(text = forwardedFromItem.chatItem.chatDir.groupMember.chatViewName, color = MaterialTheme.colors.primary)
|
||||
ChatPreviewTitleText(text = forwardedFromItem.chatItem.chatDir.groupMember.chatViewName)
|
||||
Spacer(Modifier.height(DEFAULT_PADDING_HALF))
|
||||
Text(forwardedFromItem.chatInfo.chatViewName, maxLines = 1, style = MaterialTheme.typography.body1.copy(color = if (isInDarkTheme()) MessagePreviewDark else MessagePreviewLight, lineHeight = 22.sp))
|
||||
} else {
|
||||
@@ -205,11 +202,7 @@ fun ChatItemInfoView(chatModel: ChatModel, ci: ChatItem, ciInfo: ChatItemInfo, d
|
||||
SectionItemView(
|
||||
click = {
|
||||
withBGApi {
|
||||
if (forwardedFromItem.chatInfo is ChatInfo.Direct) {
|
||||
openDirectChat(chatModel.remoteHostId(), forwardedFromItem.chatInfo.apiId, chatModel)
|
||||
} else {
|
||||
openGroupChat(chatModel.remoteHostId(), forwardedFromItem.chatInfo.apiId, chatModel)
|
||||
}
|
||||
openChat(chatRh, forwardedFromItem.chatInfo, chatModel)
|
||||
}
|
||||
ModalManager.end.closeModals()
|
||||
},
|
||||
|
||||
+1
-1
@@ -408,7 +408,7 @@ fun ChatView(chatId: String, chatModel: ChatModel, onComposed: suspend (chatId:
|
||||
clipboard.shareText(itemInfoShareText(chatModel, cItem, ciInfo, chatModel.controller.appPrefs.developerTools.get()))
|
||||
}
|
||||
}) { close ->
|
||||
ChatItemInfoView(chatModel, cItem, ciInfo, devTools = chatModel.controller.appPrefs.developerTools.get())
|
||||
ChatItemInfoView(chatRh, cItem, ciInfo, devTools = chatModel.controller.appPrefs.developerTools.get())
|
||||
KeyChangeEffect(chatModel.chatId.value) {
|
||||
close()
|
||||
}
|
||||
|
||||
+1
-1
@@ -418,7 +418,7 @@ fun ComposeView(
|
||||
itemId = forwardedItem.id
|
||||
)
|
||||
if (chatItem != null) {
|
||||
chatModel.addChatItem(chat.remoteHostId, chat.chatInfo, chatItem)
|
||||
chatModel.addChatItem(rhId, chat.chatInfo, chatItem)
|
||||
return chatItem
|
||||
}
|
||||
return null
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ fun ContextItemView(
|
||||
|
||||
@Composable
|
||||
fun ContextMsgPreview(lines: Int) {
|
||||
Row {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Attachment()
|
||||
Spacer(Modifier.width(4.dp))
|
||||
MessageText(lines)
|
||||
|
||||
+15
-7
@@ -13,9 +13,8 @@ import dev.icerock.moko.resources.compose.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import chat.simplex.common.SettingsViewState
|
||||
import chat.simplex.common.model.*
|
||||
import chat.simplex.common.views.helpers.*
|
||||
import chat.simplex.common.model.Chat
|
||||
import chat.simplex.common.model.ChatModel
|
||||
import chat.simplex.common.platform.*
|
||||
import chat.simplex.res.MR
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
@@ -82,7 +81,14 @@ private fun ShareListToolbar(chatModel: ChatModel, userPickerState: MutableState
|
||||
userPickerState.value = AnimatedViewState.VISIBLE
|
||||
}
|
||||
}
|
||||
else -> NavigationButtonBack(onButtonClicked = { chatModel.sharedContent.value = null })
|
||||
else -> NavigationButtonBack(onButtonClicked = {
|
||||
val sharedContent = chatModel.sharedContent.value
|
||||
if (sharedContent is SharedContent.Forward) {
|
||||
chatModel.chatId.value = sharedContent.fromChatInfo.id
|
||||
}
|
||||
// Drop shared content
|
||||
chatModel.sharedContent.value = null
|
||||
})
|
||||
}
|
||||
}
|
||||
if (chatModel.chats.size >= 8) {
|
||||
@@ -136,12 +142,14 @@ private fun ShareListToolbar(chatModel: ChatModel, userPickerState: MutableState
|
||||
|
||||
@Composable
|
||||
private fun ShareList(chatModel: ChatModel, search: String) {
|
||||
val filter: (Chat) -> Boolean = { chat: Chat ->
|
||||
chat.chatInfo.chatViewName.lowercase().contains(search.lowercase())
|
||||
}
|
||||
val chats by remember(search) {
|
||||
derivedStateOf {
|
||||
if (search.isEmpty()) chatModel.chats.toList().filter { it.chatInfo.ready } else chatModel.chats.toList().filter { it.chatInfo.ready }.filter(filter)
|
||||
val sorted = chatModel.chats.toList().sortedByDescending { it.chatInfo is ChatInfo.Local }
|
||||
if (search.isEmpty()) {
|
||||
sorted.filter { it.chatInfo.ready }
|
||||
} else {
|
||||
sorted.filter { it.chatInfo.ready && it.chatInfo.chatViewName.lowercase().contains(search.lowercase()) }
|
||||
}
|
||||
}
|
||||
}
|
||||
LazyColumnWithScrollBar(
|
||||
|
||||
Reference in New Issue
Block a user