summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2024-04-02 11:51:10 -0600
committerTorsten Grote <t@grobox.de>2024-04-15 15:53:36 -0300
commita06f8661e2e0293f1796a4c10987b7b3fc8ce301 (patch)
treeb05d51c27ea9e7defc31619169686161b8dafa10
parentcbb8e21f67820f876e0062941e747d6b3a88b648 (diff)
downloadtaler-android-a06f8661e2e0293f1796a4c10987b7b3fc8ce301.tar.gz
taler-android-a06f8661e2e0293f1796a4c10987b7b3fc8ce301.tar.bz2
taler-android-a06f8661e2e0293f1796a4c10987b7b3fc8ce301.zip
[wallet] Add support for taler://dev-experiment URI
bug 0008697
-rw-r--r--wallet/src/main/java/net/taler/wallet/HandleUriFragment.kt6
-rw-r--r--wallet/src/main/java/net/taler/wallet/MainViewModel.kt11
-rw-r--r--wallet/src/main/java/net/taler/wallet/backend/WalletBackendApi.kt2
3 files changed, 19 insertions, 0 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/HandleUriFragment.kt b/wallet/src/main/java/net/taler/wallet/HandleUriFragment.kt
index f0b502b..6b8db78 100644
--- a/wallet/src/main/java/net/taler/wallet/HandleUriFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/HandleUriFragment.kt
@@ -143,6 +143,12 @@ class HandleUriFragment: Fragment() {
val bundle = bundleOf("uri" to u2)
findNavController().navigate(R.id.action_handleUri_to_promptPayTemplate, bundle)
}
+ action.startsWith("dev-experiment/", ignoreCase = true) -> {
+ model.applyDevExperiment(u2) { error ->
+ showError(error)
+ }
+ findNavController().navigate(R.id.nav_main)
+ }
else -> {
showError(R.string.error_unsupported_uri, "From: $from\nURI: $u2")
findNavController().popBackStack()
diff --git a/wallet/src/main/java/net/taler/wallet/MainViewModel.kt b/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
index 0f4b94a..2534120 100644
--- a/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
+++ b/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
@@ -37,6 +37,7 @@ import net.taler.wallet.accounts.AccountManager
import net.taler.wallet.backend.BackendManager
import net.taler.wallet.backend.NotificationPayload
import net.taler.wallet.backend.NotificationReceiver
+import net.taler.wallet.backend.TalerErrorInfo
import net.taler.wallet.backend.VersionReceiver
import net.taler.wallet.backend.WalletBackendApi
import net.taler.wallet.backend.WalletCoreVersion
@@ -213,6 +214,16 @@ class MainViewModel(
}
}
+ fun applyDevExperiment(uri: String, onError: (e: TalerErrorInfo) -> Unit) {
+ viewModelScope.launch {
+ api.request<Unit>("applyDevExperiment") {
+ put("devExperimentUri", uri)
+ }.onError {
+ onError(it)
+ }
+ }
+ }
+
}
sealed class AmountResult {
diff --git a/wallet/src/main/java/net/taler/wallet/backend/WalletBackendApi.kt b/wallet/src/main/java/net/taler/wallet/backend/WalletBackendApi.kt
index 0619a4e..35d4cc0 100644
--- a/wallet/src/main/java/net/taler/wallet/backend/WalletBackendApi.kt
+++ b/wallet/src/main/java/net/taler/wallet/backend/WalletBackendApi.kt
@@ -59,6 +59,8 @@ class WalletBackendApi(
val config = WalletRunConfig(testing = Testing(
emitObservabilityEvents = true,
+ // TODO: enable conditionally and allow runtime toggling
+ devModeActive = true,
))
request("init", InitResponse.serializer()) {