forked from upstream-mirrors/quik
Merge upstream Quik 4.3.7 and preserve Matrix bridge initialization
This commit is contained in:
@@ -1,4 +1,32 @@
|
||||
[
|
||||
{
|
||||
"versionCode": 2239,
|
||||
"versionName": "4.3.7",
|
||||
"fixed": [
|
||||
"## What's Changed",
|
||||
"* Create a proper dark theme for gallery, which will fix app themes",
|
||||
"* Delete app/build/outputs/apk/debug/app-debug.apk",
|
||||
"* fix(main): Don't animate layout changes",
|
||||
"* fix(main): Get scheduled messages from view model",
|
||||
"* Refactor and simplify the navigator",
|
||||
"* compose: Fix sendAsGroup switch resetting while typing on new conversation",
|
||||
"* Translations update from Hosted Weblate",
|
||||
"* Translations update from Hosted Weblate",
|
||||
"* Add DeepWiki badge",
|
||||
"* fix(readme): Update star history chart link",
|
||||
"* refactor(compose): Use registerForActivityResult for picking content",
|
||||
"* fix(compose): Properly handle attachments when forwarding",
|
||||
"* feat(notif): Open FAQ URL from worker notification",
|
||||
"* Fix ANR in emoji reaction parsing and do some refactoring in related code",
|
||||
"* fix(ci): Explicitly define permissions for auto update mms configs",
|
||||
"* CI updates",
|
||||
"* Update MMS configs",
|
||||
"* Revert \"Prevent notifications from alerting on update\"",
|
||||
"* Translations update from Hosted Weblate",
|
||||
"* Translations update from Hosted Weblate",
|
||||
"* Fix emoji sync crashing if a regex is empty"
|
||||
]
|
||||
},
|
||||
{
|
||||
"versionCode": 2238,
|
||||
"versionName": "4.3.6",
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
{
|
||||
"emoji_reaction_ios_generic_added": "^(?s)Реакция (.+?) към “(.+?)”$",
|
||||
"emoji_reaction_ios_generic_removed": "^(?s)Премахнато (.+?) от “(.+?)”$",
|
||||
"emoji_reaction_ios_heart_added": "^(?s)Харесано “(.+?)”$"
|
||||
"emoji_reaction_ios_heart_added": "^(?s)Харесано “(.+?)”$",
|
||||
"emoji_reaction_ios_exclamation_removed": "",
|
||||
"emoji_reaction_ios_question_mark_removed": "",
|
||||
"emoji_reaction_ios_exclamation_added": "",
|
||||
"emoji_reaction_ios_dislike_removed": "",
|
||||
"emoji_reaction_ios_question_mark_added": "",
|
||||
"emoji_reaction_ios_dislike_added": "",
|
||||
"emoji_reaction_ios_laugh_added": "",
|
||||
"emoji_reaction_ios_laugh_removed": "",
|
||||
"emoji_reaction_ios_heart_removed": "",
|
||||
"emoji_reaction_ios_like_added": "",
|
||||
"emoji_reaction_ios_like_removed": ""
|
||||
}
|
||||
|
||||
@@ -1 +1,16 @@
|
||||
{}
|
||||
{
|
||||
"emoji_reaction_ios_exclamation_removed": "",
|
||||
"emoji_reaction_ios_question_mark_removed": "",
|
||||
"emoji_reaction_ios_exclamation_added": "",
|
||||
"emoji_reaction_ios_dislike_removed": "",
|
||||
"emoji_reaction_ios_question_mark_added": "",
|
||||
"emoji_reaction_ios_dislike_added": "",
|
||||
"emoji_reaction_ios_laugh_added": "",
|
||||
"emoji_reaction_ios_heart_added": "",
|
||||
"emoji_reaction_ios_laugh_removed": "",
|
||||
"emoji_reaction_ios_heart_removed": "",
|
||||
"emoji_reaction_ios_like_added": "",
|
||||
"emoji_reaction_ios_generic_removed": "",
|
||||
"emoji_reaction_ios_generic_added": "",
|
||||
"emoji_reaction_ios_like_removed": ""
|
||||
}
|
||||
|
||||
@@ -1 +1,16 @@
|
||||
{}
|
||||
{
|
||||
"emoji_reaction_ios_exclamation_removed": "",
|
||||
"emoji_reaction_ios_question_mark_removed": "",
|
||||
"emoji_reaction_ios_exclamation_added": "",
|
||||
"emoji_reaction_ios_dislike_removed": "",
|
||||
"emoji_reaction_ios_question_mark_added": "",
|
||||
"emoji_reaction_ios_dislike_added": "",
|
||||
"emoji_reaction_ios_laugh_added": "",
|
||||
"emoji_reaction_ios_heart_added": "",
|
||||
"emoji_reaction_ios_laugh_removed": "",
|
||||
"emoji_reaction_ios_heart_removed": "",
|
||||
"emoji_reaction_ios_like_added": "",
|
||||
"emoji_reaction_ios_generic_removed": "",
|
||||
"emoji_reaction_ios_generic_added": "",
|
||||
"emoji_reaction_ios_like_removed": ""
|
||||
}
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
{
|
||||
"emoji_reaction_ios_like_added": "^(?s)Le Gusta “(.+?)”$",
|
||||
"emoji_reaction_ios_heart_added": "^(?s)Le encanta “(.+?)”$"
|
||||
"emoji_reaction_ios_heart_added": "^(?s)Le encanta “(.+?)”$",
|
||||
"emoji_reaction_ios_exclamation_removed": "",
|
||||
"emoji_reaction_ios_question_mark_removed": "",
|
||||
"emoji_reaction_ios_exclamation_added": "",
|
||||
"emoji_reaction_ios_dislike_removed": "",
|
||||
"emoji_reaction_ios_question_mark_added": "",
|
||||
"emoji_reaction_ios_dislike_added": "",
|
||||
"emoji_reaction_ios_laugh_added": "",
|
||||
"emoji_reaction_ios_laugh_removed": "",
|
||||
"emoji_reaction_ios_heart_removed": "",
|
||||
"emoji_reaction_ios_generic_removed": "",
|
||||
"emoji_reaction_ios_generic_added": "",
|
||||
"emoji_reaction_ios_like_removed": ""
|
||||
}
|
||||
|
||||
@@ -1 +1,16 @@
|
||||
{}
|
||||
{
|
||||
"emoji_reaction_ios_exclamation_removed": "",
|
||||
"emoji_reaction_ios_question_mark_removed": "",
|
||||
"emoji_reaction_ios_exclamation_added": "",
|
||||
"emoji_reaction_ios_dislike_removed": "",
|
||||
"emoji_reaction_ios_question_mark_added": "",
|
||||
"emoji_reaction_ios_dislike_added": "",
|
||||
"emoji_reaction_ios_laugh_added": "",
|
||||
"emoji_reaction_ios_heart_added": "",
|
||||
"emoji_reaction_ios_laugh_removed": "",
|
||||
"emoji_reaction_ios_heart_removed": "",
|
||||
"emoji_reaction_ios_like_added": "",
|
||||
"emoji_reaction_ios_generic_removed": "",
|
||||
"emoji_reaction_ios_generic_added": "",
|
||||
"emoji_reaction_ios_like_removed": ""
|
||||
}
|
||||
|
||||
@@ -1 +1,16 @@
|
||||
{}
|
||||
{
|
||||
"emoji_reaction_ios_exclamation_removed": "",
|
||||
"emoji_reaction_ios_question_mark_removed": "",
|
||||
"emoji_reaction_ios_exclamation_added": "",
|
||||
"emoji_reaction_ios_dislike_removed": "",
|
||||
"emoji_reaction_ios_question_mark_added": "",
|
||||
"emoji_reaction_ios_dislike_added": "",
|
||||
"emoji_reaction_ios_laugh_added": "",
|
||||
"emoji_reaction_ios_heart_added": "",
|
||||
"emoji_reaction_ios_laugh_removed": "",
|
||||
"emoji_reaction_ios_heart_removed": "",
|
||||
"emoji_reaction_ios_like_added": "",
|
||||
"emoji_reaction_ios_generic_removed": "",
|
||||
"emoji_reaction_ios_generic_added": "",
|
||||
"emoji_reaction_ios_like_removed": ""
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"emoji_reaction_ios_generic_added": "^(?s)Reagerte med (.+?) på “(.+?)”$",
|
||||
"emoji_reaction_ios_generic_removed": "^(?s)Fjernet (.+?) fra “(.+?)”$",
|
||||
"emoji_reaction_ios_heart_added": "^(?s)Satte et hjerte ved “(.+?)”$",
|
||||
"emoji_reaction_ios_heart_removed": "^(?s)Fjernet et hjerte fra “(.+?)”$",
|
||||
"emoji_reaction_ios_like_added": "^(?s)Likte “(.+?)”$",
|
||||
"emoji_reaction_ios_like_removed": "^(?s)Liker ikke lenger “(.+?)”$",
|
||||
"emoji_reaction_ios_dislike_added": "^(?s)Mislikte “(.+?)”$",
|
||||
"emoji_reaction_ios_dislike_removed": "^(?s)Misliker ikke lenger “(.+?)”$",
|
||||
"emoji_reaction_ios_laugh_added": "^(?s)Lo av “(.+?)”$",
|
||||
"emoji_reaction_ios_laugh_removed": "^(?s)Fjernet latter fra “(.+?)”$",
|
||||
"emoji_reaction_ios_exclamation_added": "^(?s)Satte utropstegn ved “(.+?)”$",
|
||||
"emoji_reaction_ios_exclamation_removed": "^(?s)Fjernet et utropstegn fra “(.+?)”$",
|
||||
"emoji_reaction_ios_question_mark_added": "^(?s)Satte spørsmålstegn ved “(.+?)”$",
|
||||
"emoji_reaction_ios_question_mark_removed": "^(?s)Fjernet et spørsmålstegn fra “(.+?)”$"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"emoji_reaction_ios_exclamation_removed": "",
|
||||
"emoji_reaction_ios_question_mark_removed": "",
|
||||
"emoji_reaction_ios_exclamation_added": "",
|
||||
"emoji_reaction_ios_dislike_removed": "",
|
||||
"emoji_reaction_ios_question_mark_added": "",
|
||||
"emoji_reaction_ios_dislike_added": "",
|
||||
"emoji_reaction_ios_laugh_added": "",
|
||||
"emoji_reaction_ios_heart_added": "",
|
||||
"emoji_reaction_ios_laugh_removed": "",
|
||||
"emoji_reaction_ios_heart_removed": "",
|
||||
"emoji_reaction_ios_like_added": "",
|
||||
"emoji_reaction_ios_generic_removed": "",
|
||||
"emoji_reaction_ios_generic_added": "",
|
||||
"emoji_reaction_ios_like_removed": ""
|
||||
}
|
||||
@@ -34,20 +34,33 @@ class EmojiReactionRepositoryImpl @Inject constructor(
|
||||
private val keyManager: KeyManager,
|
||||
private val moshi: Moshi,
|
||||
) : EmojiReactionRepository {
|
||||
companion object {
|
||||
/**
|
||||
* How many recent messages a text-matched reaction scans before giving up.
|
||||
* It is highly unlikely that someone would react to a text over 500 messages away
|
||||
* so we can set this limit.
|
||||
*/
|
||||
private const val MAX_TEXT_MATCH_CANDIDATES = 500L
|
||||
|
||||
/** Give a bit of slack for messages potentially being in the wrong order */
|
||||
private const val MESSAGE_DATE_TOLERANCE_MS = 60_000L
|
||||
private const val MESSAGE_TRUNCATION_DELIMITER = "\u2026"
|
||||
private const val GOOGLE_MESSAGE_REACTION_REGEX =
|
||||
"(?s)^\u200a[^\u200b\u200a]*\u200b([^\u200b]*)\u200b[^\u200b\u200a]*\u200a(.*)\u200a[^\u200b\u200a]*\u200a\\Z"
|
||||
private const val GOOGLE_MESSAGE_REACTION_REMOVAL_REGEX =
|
||||
"(?s)^\u200a[^\u200c\u200a]*\u200c([^\u200c]*)\u200c[^\u200c\u200a]*\u200a(.*)\u200a[^\u200c\u200a]*\u200a\\Z"
|
||||
}
|
||||
|
||||
// We use an ordered map to make sure we can test tapback regexes before generic ones
|
||||
private val reactionPatterns: LinkedHashMap<Regex, (MatchResult) -> ParsedEmojiReaction?> = linkedMapOf(
|
||||
Regex( // Google Messages
|
||||
"(?s)^\u200a[^\u200b\u200a]*\u200b([^\u200b]*)\u200b[^\u200b\u200a]*\u200a(.*)\u200a[^\u200b\u200a]*\u200a\\Z"
|
||||
) to { match ->
|
||||
Regex(GOOGLE_MESSAGE_REACTION_REGEX) to { match ->
|
||||
ParsedEmojiReaction(
|
||||
match.groupValues[1], match.groupValues[2]
|
||||
)
|
||||
}
|
||||
)
|
||||
private val removalPatterns: LinkedHashMap<Regex, (MatchResult) -> ParsedEmojiReaction?> = linkedMapOf(
|
||||
Regex( // Google Messages
|
||||
"(?s)^\u200a[^\u200c\u200a]*\u200c([^\u200c]*)\u200c[^\u200c\u200a]*\u200a(.*)\u200a[^\u200c\u200a]*\u200a\\Z"
|
||||
) to { match ->
|
||||
Regex(GOOGLE_MESSAGE_REACTION_REMOVAL_REGEX) to { match ->
|
||||
ParsedEmojiReaction(
|
||||
match.groupValues[1], match.groupValues[2], isRemoval = true
|
||||
)
|
||||
@@ -81,24 +94,29 @@ class EmojiReactionRepositoryImpl @Inject constructor(
|
||||
Triple("‼️", strings.iosExclamationAdded, strings.iosExclamationRemoved),
|
||||
Triple("❓", strings.iosQuestionMarkAdded, strings.iosQuestionMarkRemoved)
|
||||
).forEach { (emoji, added, removed) ->
|
||||
added?.let {
|
||||
added?.takeIf { it.isNotBlank() }
|
||||
?.let {
|
||||
reactionPatterns[Regex(it)] =
|
||||
{ match -> ParsedEmojiReaction(emoji, match.groupValues[1]) }
|
||||
}
|
||||
removed?.let {
|
||||
removed?.takeIf { it.isNotBlank() }
|
||||
?.let {
|
||||
removalPatterns[Regex(it)] =
|
||||
{ match -> ParsedEmojiReaction(emoji, match.groupValues[1], isRemoval = true) }
|
||||
}
|
||||
}
|
||||
|
||||
// Generic iOS emoji patterns
|
||||
strings.iosGenericAdded?.let { pattern ->
|
||||
strings.iosGenericAdded?.takeIf { it.isNotBlank() }
|
||||
?.let { pattern ->
|
||||
reactionPatterns[Regex(pattern)] = { match ->
|
||||
if (match.groupValues.getOrNull(1) == "with a sticker") null // TODO: localize "with a sticker"
|
||||
// TODO: localize "with a sticker"
|
||||
if (match.groupValues.getOrNull(1) == "with a sticker") null
|
||||
else ParsedEmojiReaction(match.groupValues[1], match.groupValues[2])
|
||||
}
|
||||
}
|
||||
strings.iosGenericRemoved?.let { pattern ->
|
||||
strings.iosGenericRemoved?.takeIf { it.isNotBlank() }
|
||||
?.let { pattern ->
|
||||
removalPatterns[Regex(pattern)] = { match ->
|
||||
ParsedEmojiReaction(match.groupValues[1], match.groupValues[2], isRemoval = true)
|
||||
}
|
||||
@@ -162,7 +180,7 @@ class EmojiReactionRepositoryImpl @Inject constructor(
|
||||
private fun parseTruncatedMessages(originalMessageText: String): Regex {
|
||||
val reactionText = originalMessageText.trim()
|
||||
|
||||
val delimiter = "\u2026"
|
||||
val delimiter = MESSAGE_TRUNCATION_DELIMITER
|
||||
val index = reactionText.lastIndexOf(delimiter)
|
||||
val regexPattern = if (index == -1) {
|
||||
Regex.escape(reactionText)
|
||||
@@ -180,26 +198,50 @@ class EmojiReactionRepositoryImpl @Inject constructor(
|
||||
override fun findTargetMessage(
|
||||
threadId: Long,
|
||||
originalMessageText: String,
|
||||
realm: Realm
|
||||
realm: Realm,
|
||||
reactionDate: Long?,
|
||||
): Message? {
|
||||
val startTime = System.currentTimeMillis()
|
||||
val messages = realm.where(Message::class.java)
|
||||
.equalTo("threadId", threadId)
|
||||
.sort("date", Sort.DESCENDING)
|
||||
.findAll()
|
||||
val endTime = System.currentTimeMillis()
|
||||
Timber.d("Found ${messages.size} messages as potential emoji targets in ${endTime - startTime}ms")
|
||||
// Bound the search by assuming that target messages can't be newer than their reaction
|
||||
// But since order can occasionally be messed up (in MMS usually) add a tolerance of 60 seconds
|
||||
val latestDate = reactionDate?.plus(MESSAGE_DATE_TOLERANCE_MS)
|
||||
|
||||
fun candidateQuery() = realm.where(Message::class.java)
|
||||
.equalTo("threadId", threadId)
|
||||
.apply { latestDate?.let { lessThanOrEqualTo("date", it) } }
|
||||
|
||||
// Match the text directly with the messages that do not have the delimiter
|
||||
if (!originalMessageText.contains(MESSAGE_TRUNCATION_DELIMITER)) {
|
||||
candidateQuery()
|
||||
.equalTo("body", originalMessageText)
|
||||
.sort("date", Sort.DESCENDING)
|
||||
.findFirst()
|
||||
?.let {
|
||||
Timber.d("Found reaction target by exact body: message ID ${it.id}")
|
||||
return it
|
||||
}
|
||||
}
|
||||
|
||||
// If the message isn't matched directly, fetch all the messages that could be the target
|
||||
val candidates = candidateQuery()
|
||||
.sort("date", Sort.DESCENDING)
|
||||
.limit(MAX_TEXT_MATCH_CANDIDATES)
|
||||
.findAll()
|
||||
|
||||
val startTime = System.currentTimeMillis()
|
||||
val originalMessageRegex = parseTruncatedMessages(originalMessageText)
|
||||
val match = messages.find { message ->
|
||||
val match = candidates.find { message ->
|
||||
originalMessageRegex.matches(message.getText(false).trim())
|
||||
}
|
||||
Timber.d(
|
||||
"Scanned ${candidates.size} candidate emoji targets in " +
|
||||
"${System.currentTimeMillis() - startTime}ms"
|
||||
)
|
||||
if (match != null) {
|
||||
Timber.d("Found match for reaction target: message ID ${match.id}")
|
||||
return match
|
||||
}
|
||||
|
||||
Timber.w("No target message found for reaction text: '$originalMessageText'")
|
||||
Timber.w("No target message found for reaction text.")
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -270,9 +312,10 @@ class EmojiReactionRepositoryImpl @Inject constructor(
|
||||
val startTime = System.currentTimeMillis()
|
||||
|
||||
realm.delete(EmojiReaction::class.java)
|
||||
realm.where(Message::class.java).findAll().map {
|
||||
it.isEmojiReaction = false
|
||||
}
|
||||
realm.where(Message::class.java)
|
||||
.equalTo("isEmojiReaction", true)
|
||||
.findAll()
|
||||
.forEach { it.isEmojiReaction = false }
|
||||
|
||||
val allMessages = realm.where(Message::class.java)
|
||||
.beginGroup()
|
||||
@@ -287,7 +330,8 @@ class EmojiReactionRepositoryImpl @Inject constructor(
|
||||
.isNotEmpty("parts.text")
|
||||
.endGroup()
|
||||
.endGroup()
|
||||
.sort("date", Sort.ASCENDING) // parse oldest to newest to handle reactions & removals properly
|
||||
// parse oldest to newest to handle reactions & removals properly
|
||||
.sort("date", Sort.ASCENDING)
|
||||
.findAll()
|
||||
|
||||
val max = allMessages?.count() ?: 0
|
||||
@@ -300,7 +344,8 @@ class EmojiReactionRepositoryImpl @Inject constructor(
|
||||
val targetMessage = findTargetMessage(
|
||||
message.threadId,
|
||||
parsedReaction.originalMessage,
|
||||
realm
|
||||
realm,
|
||||
message.date,
|
||||
)
|
||||
saveEmojiReaction(
|
||||
message,
|
||||
@@ -308,18 +353,18 @@ class EmojiReactionRepositoryImpl @Inject constructor(
|
||||
targetMessage,
|
||||
realm,
|
||||
)
|
||||
progress++
|
||||
// Update the progress every 25 messages, and then at completion
|
||||
// that way we don't spam the UI
|
||||
if (progress % 25 == 0 || progress == max) {
|
||||
onProgress(
|
||||
SyncRepository.SyncProgress.ParsingEmojis(
|
||||
max = max,
|
||||
progress = progress,
|
||||
indeterminate = false
|
||||
)
|
||||
}
|
||||
progress++
|
||||
// Update the progress every 25 messages, and then at completion
|
||||
// that way we don't spam the UI
|
||||
if (progress % 25 == 0 || progress == max) {
|
||||
onProgress(
|
||||
SyncRepository.SyncProgress.ParsingEmojis(
|
||||
max = max,
|
||||
progress = progress,
|
||||
indeterminate = false
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -776,7 +776,8 @@ open class MessageRepositoryImpl @Inject constructor(
|
||||
val targetMessage = reactions.findTargetMessage(
|
||||
savedMessage.threadId,
|
||||
parsedReaction.originalMessage,
|
||||
realm
|
||||
realm,
|
||||
savedMessage.date,
|
||||
)
|
||||
realm.executeTransaction {
|
||||
reactions.saveEmojiReaction(
|
||||
|
||||
@@ -335,7 +335,8 @@ class SyncRepositoryImpl @Inject constructor(
|
||||
val targetMessage = reactions.findTargetMessage(
|
||||
threadId,
|
||||
parsedReaction.originalMessage,
|
||||
realm
|
||||
realm,
|
||||
date,
|
||||
)
|
||||
realm.executeTransaction {
|
||||
reactions.saveEmojiReaction(
|
||||
|
||||
Reference in New Issue
Block a user