commit 18167d4674587794e5bb93869bbb75131807f443 parent 5ac1b964fa4501aec96d369911e014f9e491d2bd Author: Iván Ávalos <avalos@disroot.org> Date: Tue, 24 Nov 2026 15:11:39 +0100 [wallet] fix crash #11998 Diffstat:
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/taler-kotlin-android/src/main/java/net/taler/common/Amount.kt b/taler-kotlin-android/src/main/java/net/taler/common/Amount.kt @@ -110,6 +110,8 @@ data class Amount( return Amount(checkCurrency(currency), value, fraction) } + fun isValidCurrency(currency: String): Boolean = REGEX_CURRENCY.matches(currency) + fun isValidAmountStr(str: String): Boolean { if (!REGEX_AMOUNT.matches(str)) return false if (str.count { it == '.' } > 1) return false diff --git a/wallet/src/main/java/net/taler/wallet/balances/Balances.kt b/wallet/src/main/java/net/taler/wallet/balances/Balances.kt @@ -99,7 +99,12 @@ sealed class ScopeInfo { } companion object { - fun fromPrefs(scope: PrefsScopeInfo) = when (scope.type) { + fun fromPrefs(scope: PrefsScopeInfo): ScopeInfo? { + if (!Amount.isValidCurrency(scope.currency)) return null + return fromPrefsType(scope) + } + + private fun fromPrefsType(scope: PrefsScopeInfo) = when (scope.type) { ScopeInfoType.GLOBAL -> Global(currency = scope.currency) ScopeInfoType.EXCHANGE -> Exchange( diff --git a/wallet/src/main/java/net/taler/wallet/main/ViewMode.kt b/wallet/src/main/java/net/taler/wallet/main/ViewMode.kt @@ -31,7 +31,9 @@ data class ViewMode( companion object { fun fromPrefs(prefs: PrefsViewMode2) = ViewMode( - selectedScope = prefs.selectedScope?.let { ScopeInfo.fromPrefs(it) }, + selectedScope = if (prefs.hasSelectedScope()) { + ScopeInfo.fromPrefs(prefs.selectedScope) + } else null, ) } } \ No newline at end of file