From 75f319e4c53e1f9acd343565cd16574dd7aa50c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honza=20Rychnovsk=C3=BD?= Date: Fri, 19 Jul 2024 18:08:44 +0200 Subject: [PATCH] [#1524] Restrict Google Play In-app update notes length (#1525) Closes #1524 --- .../src/main/kotlin/publish/ChangelogEntry.kt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/build-conventions-secant/src/main/kotlin/publish/ChangelogEntry.kt b/build-conventions-secant/src/main/kotlin/publish/ChangelogEntry.kt index 11a4f555..b52c193f 100644 --- a/build-conventions-secant/src/main/kotlin/publish/ChangelogEntry.kt +++ b/build-conventions-secant/src/main/kotlin/publish/ChangelogEntry.kt @@ -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 =