From 34e44a7a3616d431778bd7dd3d4ca9d4f433885b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Sun, 28 Mar 2021 22:45:20 +0200 Subject: [PATCH] [UI/App] Update build info dialog colors and text style. --- .../edziennik/utils/managers/BuildManager.kt | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/BuildManager.kt b/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/BuildManager.kt index 6c835066..a30c47cf 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/BuildManager.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/utils/managers/BuildManager.kt @@ -4,6 +4,7 @@ package pl.szczodrzynski.edziennik.utils.managers +import android.text.TextUtils import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity import com.google.android.material.dialog.MaterialAlertDialogBuilder @@ -64,13 +65,23 @@ class BuildManager(val app: App) : CoroutineScope { val yes = activity.getString(R.string.yes) val no = activity.getString(R.string.no) + val colorOnBackground = R.attr.colorOnBackground.resolveAttr(activity) + val mtrlGreen = R.color.md_green_500.resolveColor(activity) + val mtrlYellow = R.color.md_yellow_700.resolveColor(activity) + val mtrlRed = R.color.md_red_500.resolveColor(activity) + val fields = mapOf( R.string.build_version to BuildConfig.VERSION_BASE, - R.string.build_official to if (isOfficial) yes else no, + R.string.build_official to if (isOfficial) + yes.asColoredSpannable(mtrlGreen) + else + no.asColoredSpannable(mtrlRed), R.string.build_platform to when { isPlayRelease -> activity.getString(R.string.build_platform_play) isApkRelease -> activity.getString(R.string.build_platform_apk) - else -> activity.getString(R.string.build_platform_unofficial) + else -> activity + .getString(R.string.build_platform_unofficial) + .asColoredSpannable(mtrlYellow) }, R.string.build_branch to gitBranch, R.string.build_commit to gitHash?.substring(0, 8), @@ -84,8 +95,15 @@ class BuildManager(val app: App) : CoroutineScope { ) val message = fields.map { (key, value) -> - activity.getString(key) + ":\n" + value - }.join("\n\n") + TextUtils.concat( + activity + .getString(key) + .asBoldSpannable() + .asColoredSpannable(colorOnBackground), + ":\n", + value + ) + }.concat("\n\n") MaterialAlertDialogBuilder(activity) .setTitle(R.string.build_details)