mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-02-08 08:08:45 +01:00
Improve room previews for RTL/LTR mixes of name and message
Change-Id: Ic8634ca41cef1c052e8f5769cf40f08e7e4e140c
This commit is contained in:
parent
983b71dc4b
commit
6a96b50b84
@ -17,6 +17,7 @@
|
||||
package im.vector.app.core.resources
|
||||
|
||||
import android.content.res.Resources
|
||||
import android.view.View
|
||||
import androidx.annotation.NonNull
|
||||
import androidx.annotation.PluralsRes
|
||||
import androidx.annotation.StringRes
|
||||
@ -57,4 +58,6 @@ class StringProvider @Inject constructor(private val resources: Resources) {
|
||||
fun getQuantityString(@PluralsRes resId: Int, quantity: Int, vararg formatArgs: Any?): String {
|
||||
return resources.getQuantityString(resId, quantity, *formatArgs)
|
||||
}
|
||||
|
||||
fun preferRTL(): Boolean = resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_RTL
|
||||
}
|
||||
|
@ -146,14 +146,18 @@ class DisplayableEventFormatter @Inject constructor(
|
||||
|
||||
private fun simpleFormat(senderName: String, body: CharSequence, appendAuthor: Boolean): CharSequence {
|
||||
return if (appendAuthor) {
|
||||
val forceDirectionChar = if (stringProvider.preferRTL()) "\u200f" else "\u200e"
|
||||
span {
|
||||
text = senderName
|
||||
textColor = colorProvider.getColorFromAttribute(R.attr.vctr_content_primary)
|
||||
}
|
||||
.append(": ")
|
||||
text = forceDirectionChar
|
||||
}.append(
|
||||
span {
|
||||
text = senderName
|
||||
textColor = colorProvider.getColorFromAttribute(R.attr.vctr_content_primary)
|
||||
})
|
||||
.append(": $forceDirectionChar")
|
||||
.append(body)
|
||||
} else {
|
||||
body
|
||||
"\u2068$body"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user