Handle incoming MAX call events
This commit is contained in:
@@ -22,8 +22,8 @@ android {
|
||||
applicationId = "xyz.kusoft.qmax"
|
||||
minSdk = 26
|
||||
targetSdk = 36
|
||||
versionCode = 58
|
||||
versionName = "1.0.1"
|
||||
versionCode = 59
|
||||
versionName = "1.0.2"
|
||||
|
||||
buildConfigField("String", "QMAX_DEFAULT_SERVER_URL", "\"https://qmax.kusoft.xyz\"")
|
||||
buildConfigField("String", "QMAX_DEFAULT_PAIRING_CODE", "\"qmax-MxRq4h2HQBEIFs6k\"")
|
||||
|
||||
@@ -3527,6 +3527,7 @@ private fun ChatRow(
|
||||
|
||||
private fun cleanChatPreview(value: String?): String? {
|
||||
return when {
|
||||
isCallMediaLabel(value) -> "\u0412\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0437\u0432\u043e\u043d\u043e\u043a"
|
||||
isGenericMediaPreview(value) -> "\u041c\u0435\u0434\u0438\u0430"
|
||||
isQuestionMarkArtifact(value) -> "\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435"
|
||||
else -> value
|
||||
@@ -4076,6 +4077,21 @@ private fun ChatScreen(vm: QMaxViewModel) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun isCallMediaLabel(value: String?): Boolean {
|
||||
val text = value?.trim().orEmpty()
|
||||
return text.equals("call", ignoreCase = true) || text.startsWith("call-", ignoreCase = true)
|
||||
}
|
||||
|
||||
private fun displayMessageText(value: String?): String? {
|
||||
return value?.takeIf { it.isNotBlank() }?.let { text ->
|
||||
if (isCallMediaLabel(text)) {
|
||||
"\u0412\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0437\u0432\u043e\u043d\u043e\u043a"
|
||||
} else {
|
||||
text
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun IncomingShareDialog(
|
||||
share: IncomingShare,
|
||||
@@ -4842,7 +4858,7 @@ private fun MessageRow(
|
||||
)
|
||||
}
|
||||
}
|
||||
message.text?.takeIf { it.isNotBlank() }?.let { text ->
|
||||
displayMessageText(message.text)?.let { text ->
|
||||
LinkifiedMessageText(
|
||||
text = text,
|
||||
modifier = Modifier.padding(horizontal = 8.dp, vertical = 6.dp)
|
||||
@@ -5104,7 +5120,7 @@ private fun replyPreviewAuthor(message: MessageDto): String {
|
||||
}
|
||||
|
||||
private fun replyPreviewBody(message: MessageDto): String {
|
||||
message.text?.takeIf { it.isNotBlank() }?.let { return it }
|
||||
displayMessageText(message.text)?.let { return it }
|
||||
val attachment = message.attachments.firstOrNull() ?: return "Message"
|
||||
return when {
|
||||
attachment.isEmojiAttachment() -> "Emoji"
|
||||
@@ -6400,7 +6416,7 @@ private fun messageSortMillis(value: String): Long {
|
||||
private fun MessageDto.matchesSearch(query: String): Boolean {
|
||||
val needle = query.trim().lowercase(Locale.ROOT)
|
||||
if (needle.isBlank()) return false
|
||||
return text?.lowercase(Locale.ROOT)?.contains(needle) == true ||
|
||||
return displayMessageText(text)?.lowercase(Locale.ROOT)?.contains(needle) == true ||
|
||||
senderName?.lowercase(Locale.ROOT)?.contains(needle) == true ||
|
||||
attachments.any { it.fileName.lowercase(Locale.ROOT).contains(needle) }
|
||||
}
|
||||
|
||||
@@ -124,12 +124,18 @@ class LocalMessageCache(context: Context) {
|
||||
|
||||
private fun cleanChat(chat: ChatDto): ChatDto {
|
||||
return when {
|
||||
isCallMediaLabel(chat.lastMessagePreview) -> chat.copy(lastMessagePreview = "\u0412\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0437\u0432\u043e\u043d\u043e\u043a")
|
||||
isGenericMediaLabel(chat.lastMessagePreview) -> chat.copy(lastMessagePreview = "\u041c\u0435\u0434\u0438\u0430")
|
||||
isQuestionMarkArtifact(chat.lastMessagePreview) -> chat.copy(lastMessagePreview = "\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435")
|
||||
else -> chat
|
||||
}
|
||||
}
|
||||
|
||||
private fun isCallMediaLabel(value: String?): Boolean {
|
||||
val text = value?.trim().orEmpty()
|
||||
return text.equals("call", ignoreCase = true) || text.startsWith("call-", ignoreCase = true)
|
||||
}
|
||||
|
||||
private fun isGenericMediaPlaceholder(message: MessageDto): Boolean {
|
||||
return message.attachments.isEmpty() && isGenericMediaLabel(message.text)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user