From 8a9f5d49f8bc14f348861b15fbe883a6fba2c24c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Ma=C5=A1a?= Date: Sat, 20 Feb 2021 12:13:55 +0100 Subject: [PATCH 1/2] Update Android Gradle Plugin --- build.gradle.kts | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 21638c1f5..4990802ae 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ buildscript { } dependencies { - classpath("com.android.tools.build:gradle:7.0.0-alpha05") + classpath("com.android.tools.build:gradle:7.0.0-alpha07") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.21") // Firebase-related dependencies diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 2488a5718..c9db02aa6 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Mon Aug 31 09:56:08 CEST 2020 distributionBase=GRADLE_USER_HOME -distributionUrl=https://services.gradle.org/distributions/gradle-6.8-bin.zip +distributionUrl=https://services.gradle.org/distributions/gradle-6.8.1-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME From ca810d53b1be3391edd06bd8acac59ae5ac40439 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franti=C5=A1ek=20Ma=C5=A1a?= Date: Sat, 20 Feb 2021 12:15:15 +0100 Subject: [PATCH 2/2] Use locale-agnostic formatting for encumbrance --- .../wfrp_master/inventory/domain/Encumbrance.kt | 9 +++------ .../wfrp_master/inventory/domain/EncumbranceTest.kt | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/inventory/src/main/java/cz/frantisekmasa/wfrp_master/inventory/domain/Encumbrance.kt b/app/inventory/src/main/java/cz/frantisekmasa/wfrp_master/inventory/domain/Encumbrance.kt index 060140410..e714ff450 100644 --- a/app/inventory/src/main/java/cz/frantisekmasa/wfrp_master/inventory/domain/Encumbrance.kt +++ b/app/inventory/src/main/java/cz/frantisekmasa/wfrp_master/inventory/domain/Encumbrance.kt @@ -4,6 +4,7 @@ import android.os.Parcelable import com.fasterxml.jackson.annotation.JsonValue import cz.frantisekmasa.wfrp_master.core.domain.Stats import kotlinx.parcelize.Parcelize +import java.text.DecimalFormat @Parcelize data class Encumbrance( @@ -12,6 +13,7 @@ data class Encumbrance( ) : Parcelable { companion object { val Zero: Encumbrance = Encumbrance(0.0) + private val formatter = DecimalFormat("#,##0.###") fun maximumForCharacter(characteristics: Stats): Encumbrance = Encumbrance( (characteristics.strengthBonus + characteristics.toughnessBonus).toDouble() @@ -26,12 +28,7 @@ data class Encumbrance( operator fun times(multiplier: Int) = Encumbrance(value * multiplier) operator fun plus(addend: Encumbrance) = Encumbrance(value + addend.value) - override fun toString(): String = value.formatWithMaximumDecimalPlaces(3) + override fun toString(): String = formatter.format(value) } fun Iterable.sum(): Encumbrance = fold(Encumbrance.Zero) { a, b -> a + b } - -private fun Double.formatWithMaximumDecimalPlaces(decimals: Int) = - "%.${decimals}f".format(this) - .trimEnd('0') - .trimEnd('.') diff --git a/app/inventory/src/test/java/cz/frantisekmasa/wfrp_master/inventory/domain/EncumbranceTest.kt b/app/inventory/src/test/java/cz/frantisekmasa/wfrp_master/inventory/domain/EncumbranceTest.kt index cf28830cd..4d0612e73 100644 --- a/app/inventory/src/test/java/cz/frantisekmasa/wfrp_master/inventory/domain/EncumbranceTest.kt +++ b/app/inventory/src/test/java/cz/frantisekmasa/wfrp_master/inventory/domain/EncumbranceTest.kt @@ -35,5 +35,6 @@ class EncumbranceTest { assertEquals("0.001", Encumbrance(0.001).toString()) assertEquals("10", Encumbrance(10.000).toString()) assertEquals("12", Encumbrance(12.0).toString()) + assertEquals("12,000", Encumbrance(12000.0).toString()) } } \ No newline at end of file