extend regex, up version, fix enter on android tv
This commit is contained in:
@@ -7,7 +7,7 @@ plugins {
|
||||
alias(libs.plugins.convention.ktor.client)
|
||||
}
|
||||
|
||||
val appVersion = "1.25.2"
|
||||
val appVersion = "1.25.3"
|
||||
|
||||
android {
|
||||
buildFeatures { buildConfig = true }
|
||||
|
||||
+4
-4
@@ -6,7 +6,7 @@ import ru.shadowsparky.chat.domain.TextToken
|
||||
|
||||
@Factory
|
||||
class MovieTextParser : ChatTextParser {
|
||||
private val regex = Regex("«(.*?)»|\"(.*?)\"")
|
||||
private val regex = Regex("«(.*?)»|\"(.*?)\"|\\*\\*(.*?)\\*\\*")
|
||||
|
||||
override fun parse(content: String): List<TextToken> {
|
||||
val tokens = mutableListOf<TextToken>()
|
||||
@@ -16,11 +16,11 @@ class MovieTextParser : ChatTextParser {
|
||||
tokens.add(TextToken.Plain(content.substring(lastIndex, matchResult.range.first)))
|
||||
}
|
||||
val movieTitle = matchResult.groupValues[1].takeIf { it.isNotEmpty() }
|
||||
?: matchResult.groupValues[2]
|
||||
tokens.add(TextToken.Link(text = movieTitle))
|
||||
?: matchResult.groupValues[2].takeIf { it.isNotEmpty() }
|
||||
?: matchResult.groupValues[3]
|
||||
tokens.add(TextToken.Link(movieTitle))
|
||||
lastIndex = matchResult.range.last + 1
|
||||
}
|
||||
|
||||
if (lastIndex < content.length) {
|
||||
tokens.add(TextToken.Plain(content.substring(lastIndex)))
|
||||
}
|
||||
|
||||
+3
-2
@@ -247,7 +247,8 @@ private fun MessageBubble(
|
||||
boxModifier = boxModifier.focusBorder(false).onKeyEvent {
|
||||
if (it.type == KeyEventType.KeyDown) {
|
||||
when (it.key) {
|
||||
Key.Enter -> dialog = true
|
||||
Key.Enter,
|
||||
Key.DirectionCenter -> dialog = true
|
||||
else -> onKeyEvent(it)
|
||||
}
|
||||
}
|
||||
@@ -362,7 +363,7 @@ private fun ScrollableMessage(
|
||||
true
|
||||
}
|
||||
|
||||
Key.Enter -> {
|
||||
Key.Enter, Key.DirectionCenter -> {
|
||||
onEnter()
|
||||
true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user