mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-22 21:58:53 +01:00
use generic google messages regex
This commit is contained in:
@@ -1,7 +1,4 @@
|
|||||||
{
|
{
|
||||||
"emoji_reaction_google_messages_added": "^\u200A\u200B(.+?)\u200B to “\u200A(.+?)\u200A”\u200A$",
|
|
||||||
"emoji_reaction_google_messages_removed": "^\u200ARemoved \u200C(.+?)\u200C from “\u200A(.+?)\u200A”\u200A$",
|
|
||||||
|
|
||||||
"emoji_reaction_ios_generic_added": "^Reacted (.+?) to “(.+?)”$",
|
"emoji_reaction_ios_generic_added": "^Reacted (.+?) to “(.+?)”$",
|
||||||
"emoji_reaction_ios_generic_removed": "^Removed (.+?) from “(.+?)”$",
|
"emoji_reaction_ios_generic_removed": "^Removed (.+?) from “(.+?)”$",
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
{
|
{
|
||||||
"emoji_reaction_google_messages_added": "^\u200AРеакция \u200B(.+?)\u200B на \"\u200A(.+?)\u200A\"\u200A$",
|
|
||||||
"emoji_reaction_google_messages_removed": "^\u200AРеакция \u200C(.+?)\u200C удалена из \"\u200A(.+?)\u200A\"\u200A$",
|
|
||||||
|
|
||||||
"emoji_reaction_ios_heart_added": "^Очень понравилось «(.+?)»$",
|
"emoji_reaction_ios_heart_added": "^Очень понравилось «(.+?)»$",
|
||||||
|
|
||||||
"emoji_reaction_ios_like_added": "^Понравилось «(.+?)»$",
|
"emoji_reaction_ios_like_added": "^Понравилось «(.+?)»$",
|
||||||
|
|||||||
@@ -34,10 +34,17 @@ class EmojiReactionRepositoryImpl @Inject constructor(
|
|||||||
private val keyManager: KeyManager,
|
private val keyManager: KeyManager,
|
||||||
private val moshi: Moshi,
|
private val moshi: Moshi,
|
||||||
) : EmojiReactionRepository {
|
) : EmojiReactionRepository {
|
||||||
|
// We use an ordered map to make sure we can test tapback regexes before generic ones
|
||||||
// We use an ordered map to make sure we test tapback regexes before generic ones
|
private val reactionPatterns: LinkedHashMap<Regex, (MatchResult) -> ParsedEmojiReaction?> = linkedMapOf(
|
||||||
private val reactionPatterns: LinkedHashMap<Regex, (MatchResult) -> ParsedEmojiReaction?> = linkedMapOf()
|
Regex( // Google Messages
|
||||||
private val removalPatterns: LinkedHashMap<Regex, (MatchResult) -> ParsedEmojiReaction?> = linkedMapOf()
|
"(?s)^\u200a[^\u200b\u200a]*\u200b([^\u200b]*)\u200b[^\u200b\u200a]*\u200a(.*)\u200a[^\u200b\u200a]*\u200a\\Z"
|
||||||
|
) 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 -> ParsedEmojiReaction(match.groupValues[1], match.groupValues[2], isRemoval = true) }
|
||||||
|
)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val assetEntries = loadEmojiPatternEntriesFromAssets()
|
val assetEntries = loadEmojiPatternEntriesFromAssets()
|
||||||
@@ -57,14 +64,6 @@ class EmojiReactionRepositoryImpl @Inject constructor(
|
|||||||
reactionPatterns: LinkedHashMap<Regex, (MatchResult) -> ParsedEmojiReaction?>,
|
reactionPatterns: LinkedHashMap<Regex, (MatchResult) -> ParsedEmojiReaction?>,
|
||||||
removalPatterns: LinkedHashMap<Regex, (MatchResult) -> ParsedEmojiReaction?>
|
removalPatterns: LinkedHashMap<Regex, (MatchResult) -> ParsedEmojiReaction?>
|
||||||
) {
|
) {
|
||||||
// Google Messages
|
|
||||||
strings.googleAdded?.let { pattern ->
|
|
||||||
reactionPatterns[Regex(pattern)] = { match -> ParsedEmojiReaction(match.groupValues[1], match.groupValues[2]) }
|
|
||||||
}
|
|
||||||
strings.googleRemoved?.let { pattern ->
|
|
||||||
removalPatterns[Regex(pattern)] = { match -> ParsedEmojiReaction(match.groupValues[1], match.groupValues[2], isRemoval = true) }
|
|
||||||
}
|
|
||||||
|
|
||||||
// iOS tapbacks (important to add these before generic emoji patterns as the regexes may overlap)
|
// iOS tapbacks (important to add these before generic emoji patterns as the regexes may overlap)
|
||||||
listOf(
|
listOf(
|
||||||
Triple("❤️", strings.iosHeartAdded, strings.iosHeartRemoved),
|
Triple("❤️", strings.iosHeartAdded, strings.iosHeartRemoved),
|
||||||
|
|||||||
@@ -5,9 +5,6 @@ import com.squareup.moshi.JsonClass
|
|||||||
|
|
||||||
@JsonClass(generateAdapter = false)
|
@JsonClass(generateAdapter = false)
|
||||||
data class EmojiPatternStrings(
|
data class EmojiPatternStrings(
|
||||||
@Json(name = "emoji_reaction_google_messages_added") val googleAdded: String? = null,
|
|
||||||
@Json(name = "emoji_reaction_google_messages_removed") val googleRemoved: String? = null,
|
|
||||||
|
|
||||||
@Json(name = "emoji_reaction_ios_generic_added") val iosGenericAdded: String? = null,
|
@Json(name = "emoji_reaction_ios_generic_added") val iosGenericAdded: String? = null,
|
||||||
@Json(name = "emoji_reaction_ios_generic_removed") val iosGenericRemoved: String? = null,
|
@Json(name = "emoji_reaction_ios_generic_removed") val iosGenericRemoved: String? = null,
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user