mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 20:18:36 +00:00
Add text formatting support to release notes channel.
This commit is contained in:
@@ -187,10 +187,31 @@ class RetrieveRemoteAnnouncementsJob private constructor(private val force: Bool
|
||||
resolvedNotes
|
||||
.filterNotNull()
|
||||
.forEach { note ->
|
||||
val body = "${note.translation.title}\n\n${note.translation.body}"
|
||||
val title = "${note.translation.title}\n\n"
|
||||
val body = "$title${note.translation.body}"
|
||||
val bodyRangeList = BodyRangeList.newBuilder()
|
||||
.addStyle(BodyRangeList.BodyRange.Style.BOLD, 0, note.translation.title.length)
|
||||
|
||||
if (note.translation.bodyRanges?.isNotEmpty() == true) {
|
||||
note.translation.bodyRanges
|
||||
.filter { it.style != null && it.start != null && it.length != null }
|
||||
.map { it.copy(start = it.start!! + title.length) }
|
||||
.forEach {
|
||||
val style = when (it.style!!) {
|
||||
"bold" -> BodyRangeList.BodyRange.Style.BOLD
|
||||
"italic" -> BodyRangeList.BodyRange.Style.ITALIC
|
||||
"strikethrough" -> BodyRangeList.BodyRange.Style.STRIKETHROUGH
|
||||
"spoiler" -> BodyRangeList.BodyRange.Style.SPOILER
|
||||
"mono" -> BodyRangeList.BodyRange.Style.MONOSPACE
|
||||
else -> null
|
||||
}
|
||||
|
||||
if (style != null && it.start!! in body.indices && (it.start + it.length!! - 1) in body.indices) {
|
||||
bodyRangeList.addStyle(style, it.start, it.length)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (note.releaseNote.link?.isNotEmpty() == true && note.translation.linkText?.isNotEmpty() == true) {
|
||||
val linkIndex = body.indexOf(note.translation.linkText)
|
||||
if (linkIndex != -1 && linkIndex + note.translation.linkText.length < body.length) {
|
||||
@@ -405,7 +426,14 @@ class RetrieveRemoteAnnouncementsJob private constructor(private val force: Bool
|
||||
@JsonProperty val linkText: String?,
|
||||
@JsonProperty val title: String,
|
||||
@JsonProperty val body: String,
|
||||
@JsonProperty val callToActionText: String?
|
||||
@JsonProperty val callToActionText: String?,
|
||||
@JsonProperty val bodyRanges: List<ReleaseNoteBodyRange>?
|
||||
)
|
||||
|
||||
data class ReleaseNoteBodyRange(
|
||||
@JsonProperty val style: String?,
|
||||
@JsonProperty val start: Int?,
|
||||
@JsonProperty val length: Int?
|
||||
)
|
||||
|
||||
data class TranslatedRemoteMegaphone(
|
||||
|
||||
Reference in New Issue
Block a user