From c192b489684c47cc9d9f5452ea1a773623b0a1db Mon Sep 17 00:00:00 2001 From: Andries Smit Date: Thu, 17 Feb 2022 23:35:31 +0100 Subject: [PATCH] fix rh gs with empty args --- .../utils/resources/ResourceHelperImplementation.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/info/nightscout/androidaps/utils/resources/ResourceHelperImplementation.kt b/core/src/main/java/info/nightscout/androidaps/utils/resources/ResourceHelperImplementation.kt index b21285bc43..7224b4ec00 100644 --- a/core/src/main/java/info/nightscout/androidaps/utils/resources/ResourceHelperImplementation.kt +++ b/core/src/main/java/info/nightscout/androidaps/utils/resources/ResourceHelperImplementation.kt @@ -20,20 +20,21 @@ import javax.inject.Inject */ class ResourceHelperImplementation @Inject constructor(private val context: Context, private val fabricPrivacy: FabricPrivacy) : ResourceHelper { - override fun gs(@StringRes id: Int): String = gs(id, null) + override fun gs(@StringRes id: Int): String = context.getString(id) override fun gs(@StringRes id: Int, vararg args: Any?) : String { return try { context.getString(id, *args) } catch (exception: Exception) { - val resourceName = context.resources.getResourceEntryName(id); + val resourceName = context.resources.getResourceEntryName(id) + val resourceValue = context.getString(id) val currentLocale: Locale = context.resources.configuration.locale - fabricPrivacy.logMessage("Failed to get string for resource $resourceName ($id) for locale $currentLocale with args ${args.map{it.toString()}}") + fabricPrivacy.logMessage("Failed to get string for resource $resourceName ($id) '$resourceValue' for locale $currentLocale with args ${args.map{it.toString()}}") fabricPrivacy.logException(exception) try { gsNotLocalised(id, *args) } catch (exceptionNonLocalized: Exception) { - fabricPrivacy.logMessage("Fallback failed to get string for resource $resourceName ($id) with args ${args.map { it.toString() }}") + fabricPrivacy.logMessage("Fallback failed to get string for resource $resourceName ($id) '$resourceValue' with args ${args.map { it.toString() }}") fabricPrivacy.logException(exceptionNonLocalized) "FAILED to get string $resourceName" }