[#1524] Restrict Google Play In-app update notes length (#1525)

Closes #1524
This commit is contained in:
Honza Rychnovský 2024-07-19 18:08:44 +02:00 committed by GitHub
parent f862a4be97
commit 75f319e4c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 3 deletions

View File

@ -2,6 +2,9 @@ package publish
import com.google.gson.GsonBuilder
private const val RELEASE_NOTES_MAX_LENGTH = 500
private const val NEW_LINE_SIGN = "\n"
data class ChangelogEntry(
val version: String,
val date: String,
@ -27,9 +30,17 @@ data class ChangelogEntry(
}
private fun StringBuilder.appendChangeLogSection(section: ChangelogEntrySection) {
appendLine(section.title)
appendLine(section.content)
appendLine()
appendLineIfCan(section.title)
appendLineIfCan(section.content)
}
private fun StringBuilder.appendLineIfCan(line: String) {
if (length + line.length <= RELEASE_NOTES_MAX_LENGTH) {
append(line)
}
if (length + NEW_LINE_SIGN.length <= RELEASE_NOTES_MAX_LENGTH) {
append(NEW_LINE_SIGN)
}
}
fun toJsonString(): String =