aboutsummaryrefslogtreecommitdiff
path: root/cashier/src
diff options
context:
space:
mode:
authorTorsten Grote <t@grobox.de>2022-07-01 14:54:22 -0300
committerTorsten Grote <t@grobox.de>2022-07-01 14:54:22 -0300
commit41b75e34f14c87b6db60152f26049ecc761b2526 (patch)
treefa0f7d64cd72851983684feecb30fa5f7025a6be /cashier/src
parent08213e48d4f4d16f8814b996474c3e098bd2c702 (diff)
downloadtaler-android-41b75e34f14c87b6db60152f26049ecc761b2526.tar.gz
taler-android-41b75e34f14c87b6db60152f26049ecc761b2526.tar.bz2
taler-android-41b75e34f14c87b6db60152f26049ecc761b2526.zip
[cashier] use error bottom sheet for config errors
Diffstat (limited to 'cashier/src')
-rw-r--r--cashier/src/main/java/net/taler/cashier/config/ConfigFragment.kt13
-rw-r--r--cashier/src/main/res/values/strings.xml2
2 files changed, 8 insertions, 7 deletions
diff --git a/cashier/src/main/java/net/taler/cashier/config/ConfigFragment.kt b/cashier/src/main/java/net/taler/cashier/config/ConfigFragment.kt
index a595a7f..2c0b447 100644
--- a/cashier/src/main/java/net/taler/cashier/config/ConfigFragment.kt
+++ b/cashier/src/main/java/net/taler/cashier/config/ConfigFragment.kt
@@ -37,6 +37,7 @@ import net.taler.cashier.MainViewModel
import net.taler.cashier.R
import net.taler.cashier.databinding.FragmentConfigBinding
import net.taler.common.exhaustive
+import net.taler.common.showError
// NOTE: HTTP should eventually be disabled.
private const val URL_BANK_TEST = "https://int.taler.net/sandbox/demobanks/default"
@@ -45,15 +46,15 @@ private const val URL_BANK_TEST_REGISTER = "$URL_BANK_TEST/accounts/register"
class ConfigFragment : Fragment() {
private val viewModel: MainViewModel by activityViewModels()
- private val configManager by lazy { viewModel.configManager}
+ private val configManager by lazy { viewModel.configManager }
private lateinit var ui: FragmentConfigBinding
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
- savedInstanceState: Bundle?
- ): View? {
+ savedInstanceState: Bundle?,
+ ): View {
ui = FragmentConfigBinding.inflate(inflater, container, false)
return ui.root
}
@@ -118,7 +119,8 @@ class ConfigFragment : Fragment() {
private fun checkConfig(config: Config): Boolean {
if (!config.bankUrl.startsWith("https://") &&
- !config.bankUrl.startsWith("http://")) {
+ !config.bankUrl.startsWith("http://")
+ ) {
ui.urlView.error = getString(R.string.config_bank_url_error)
ui.urlView.requestFocus()
return false
@@ -146,8 +148,7 @@ class ConfigFragment : Fragment() {
if (result.authError) {
Snackbar.make(requireView(), R.string.config_error_auth, LENGTH_LONG).show()
} else {
- val str = getString(R.string.config_error, result.msg)
- Snackbar.make(requireView(), str, LENGTH_LONG).show()
+ requireActivity().showError(getString(R.string.config_error), result.msg)
}
}
}.exhaustive
diff --git a/cashier/src/main/res/values/strings.xml b/cashier/src/main/res/values/strings.xml
index 4c000d8..bcaab74 100644
--- a/cashier/src/main/res/values/strings.xml
+++ b/cashier/src/main/res/values/strings.xml
@@ -7,7 +7,7 @@
<string name="config_button_save">Save</string>
<string name="config_bank_url_error">The address is invalid.</string>
<string name="config_username_error">Please enter your username!</string>
- <string name="config_error">Error retrieving configuration: %s</string>
+ <string name="config_error">Error retrieving configuration</string>
<string name="config_error_auth">Invalid username or password!</string>
<string name="config_error_offline" translatable="false">@string/balance_offline</string>
<string name="config_demo_hint">For testing, you can <![CDATA[<a href="%s">create a test account at the demo bank</a>]]>.</string>