aboutsummaryrefslogtreecommitdiff
path: root/merchant-terminal
diff options
context:
space:
mode:
authorTorsten Grote <t@grobox.de>2020-07-21 10:44:32 -0300
committerTorsten Grote <t@grobox.de>2020-07-21 15:06:53 -0300
commit5d3d85fa7190a70eea8fa67866c343005b9922b0 (patch)
tree784e53d20b17f63e5def8f0704e7539f338ed637 /merchant-terminal
parentc9fb036798fc533a07b4b75386b51151b31f8be0 (diff)
downloadtaler-android-5d3d85fa7190a70eea8fa67866c343005b9922b0.tar.gz
taler-android-5d3d85fa7190a70eea8fa67866c343005b9922b0.tar.bz2
taler-android-5d3d85fa7190a70eea8fa67866c343005b9922b0.zip
[pos] compare version from backend and show error if incompatible
Diffstat (limited to 'merchant-terminal')
-rw-r--r--merchant-terminal/src/main/java/net/taler/merchantpos/config/ConfigManager.kt13
-rw-r--r--merchant-terminal/src/main/res/values/strings.xml1
2 files changed, 7 insertions, 7 deletions
diff --git a/merchant-terminal/src/main/java/net/taler/merchantpos/config/ConfigManager.kt b/merchant-terminal/src/main/java/net/taler/merchantpos/config/ConfigManager.kt
index eee7905..a7aff18 100644
--- a/merchant-terminal/src/main/java/net/taler/merchantpos/config/ConfigManager.kt
+++ b/merchant-terminal/src/main/java/net/taler/merchantpos/config/ConfigManager.kt
@@ -34,14 +34,14 @@ import com.fasterxml.jackson.module.kotlin.readValue
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
+import net.taler.common.Version
+import net.taler.common.getIncompatibleStringOrNull
import net.taler.merchantlib.ConfigResponse
import net.taler.merchantlib.MerchantApi
import net.taler.merchantpos.LogErrorListener
import net.taler.merchantpos.R
import org.json.JSONObject
-private const val VERSION = "0:0:0"
-
private const val SETTINGS_NAME = "taler-merchant-terminal"
private const val SETTINGS_CONFIG_URL = "configUrl"
@@ -52,6 +52,8 @@ internal const val CONFIG_URL_DEMO = "https://docs.taler.net/_static/sample-pos-
internal const val CONFIG_USERNAME_DEMO = ""
internal const val CONFIG_PASSWORD_DEMO = ""
+private val VERSION = Version(1, 0, 0)
+
private val TAG = ConfigManager::class.java.simpleName
interface ConfigurationReceiver {
@@ -131,10 +133,9 @@ class ConfigManager(
merchantConfig: MerchantConfig,
configResponse: ConfigResponse
) = scope.launch(Dispatchers.Default) {
- // TODO do real matching
- if (VERSION != configResponse.version) {
- val str = context.getString(R.string.config_error_version)
- mConfigUpdateResult.postValue(ConfigUpdateResult.Error(str))
+ val versionIncompatible = VERSION.getIncompatibleStringOrNull(context, configResponse.version)
+ if (versionIncompatible != null) {
+ mConfigUpdateResult.postValue(ConfigUpdateResult.Error(versionIncompatible))
return@launch
}
for (receiver in configurationReceivers) {
diff --git a/merchant-terminal/src/main/res/values/strings.xml b/merchant-terminal/src/main/res/values/strings.xml
index 931f31c..b3dcd8d 100644
--- a/merchant-terminal/src/main/res/values/strings.xml
+++ b/merchant-terminal/src/main/res/values/strings.xml
@@ -22,7 +22,6 @@
<string name="config_password">Password</string>
<string name="config_ok">Fetch configuration</string>
<string name="config_auth_error">Error: Invalid username or password</string>
- <string name="config_error_version">Error: Incompatible backend version</string>
<string name="config_error_network">Error: Could not connect to configuration server</string>
<string name="config_error_category">Error: No valid product category found</string>
<string name="config_error_malformed">Error: The configuration JSON is malformed</string>