summaryrefslogtreecommitdiff
path: root/cashier/src/main
diff options
context:
space:
mode:
authorTorsten Grote <t@grobox.de>2020-03-18 14:24:41 -0300
committerTorsten Grote <t@grobox.de>2020-03-18 14:24:41 -0300
commita4796ec47d89a851b260b6fc195494547208a025 (patch)
treed2941b68ff2ce22c523e7aa634965033b1100560 /cashier/src/main
downloadtaler-android-a4796ec47d89a851b260b6fc195494547208a025.tar.gz
taler-android-a4796ec47d89a851b260b6fc195494547208a025.tar.bz2
taler-android-a4796ec47d89a851b260b6fc195494547208a025.zip
Merge all three apps into one repository
Diffstat (limited to 'cashier/src/main')
-rw-r--r--cashier/src/main/AndroidManifest.xml32
-rw-r--r--cashier/src/main/ic_launcher-web.pngbin0 -> 30434 bytes
-rw-r--r--cashier/src/main/java/net/taler/cashier/Amount.kt45
-rw-r--r--cashier/src/main/java/net/taler/cashier/BalanceFragment.kt182
-rw-r--r--cashier/src/main/java/net/taler/cashier/ConfigFragment.kt139
-rw-r--r--cashier/src/main/java/net/taler/cashier/HttpHelper.kt102
-rw-r--r--cashier/src/main/java/net/taler/cashier/MainActivity.kt62
-rw-r--r--cashier/src/main/java/net/taler/cashier/MainViewModel.kt148
-rw-r--r--cashier/src/main/java/net/taler/cashier/Utils.kt91
-rw-r--r--cashier/src/main/java/net/taler/cashier/withdraw/ErrorFragment.kt55
-rw-r--r--cashier/src/main/java/net/taler/cashier/withdraw/NfcManager.kt234
-rw-r--r--cashier/src/main/java/net/taler/cashier/withdraw/QrCodeManager.kt42
-rw-r--r--cashier/src/main/java/net/taler/cashier/withdraw/TransactionFragment.kt174
-rw-r--r--cashier/src/main/java/net/taler/cashier/withdraw/WithdrawManager.kt232
-rw-r--r--cashier/src/main/res/drawable-w550dp/ic_arrow.xml11
-rw-r--r--cashier/src/main/res/drawable/ic_arrow.xml11
-rw-r--r--cashier/src/main/res/drawable/ic_check_circle.xml10
-rw-r--r--cashier/src/main/res/drawable/ic_clear.xml9
-rw-r--r--cashier/src/main/res/drawable/ic_error.xml11
-rw-r--r--cashier/src/main/res/drawable/ic_launcher_foreground.xml15
-rw-r--r--cashier/src/main/res/drawable/ic_withdraw.xml10
-rw-r--r--cashier/src/main/res/layout-w550dp/fragment_balance.xml222
-rw-r--r--cashier/src/main/res/layout-w550dp/fragment_transaction.xml111
-rw-r--r--cashier/src/main/res/layout/activity_main.xml51
-rw-r--r--cashier/src/main/res/layout/fragment_balance.xml225
-rw-r--r--cashier/src/main/res/layout/fragment_config.xml112
-rw-r--r--cashier/src/main/res/layout/fragment_error.xml65
-rw-r--r--cashier/src/main/res/layout/fragment_transaction.xml100
-rw-r--r--cashier/src/main/res/menu/balance.xml30
-rw-r--r--cashier/src/main/res/mipmap-anydpi-v26/ic_launcher.xml5
-rw-r--r--cashier/src/main/res/mipmap-hdpi/ic_launcher.pngbin0 -> 3687 bytes
-rw-r--r--cashier/src/main/res/mipmap-mdpi/ic_launcher.pngbin0 -> 2408 bytes
-rw-r--r--cashier/src/main/res/mipmap-xhdpi/ic_launcher.pngbin0 -> 4875 bytes
-rw-r--r--cashier/src/main/res/mipmap-xxhdpi/ic_launcher.pngbin0 -> 7673 bytes
-rw-r--r--cashier/src/main/res/mipmap-xxxhdpi/ic_launcher.pngbin0 -> 10362 bytes
-rw-r--r--cashier/src/main/res/navigation/nav_graph.xml73
-rw-r--r--cashier/src/main/res/values-night/colors.xml20
-rw-r--r--cashier/src/main/res/values/colors.xml10
-rw-r--r--cashier/src/main/res/values/dimens.xml3
-rw-r--r--cashier/src/main/res/values/ic_launcher_background.xml4
-rw-r--r--cashier/src/main/res/values/strings.xml39
-rw-r--r--cashier/src/main/res/values/styles.xml28
-rw-r--r--cashier/src/main/res/xml/backup_descriptor.xml19
43 files changed, 2732 insertions, 0 deletions
diff --git a/cashier/src/main/AndroidManifest.xml b/cashier/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..345c9a1
--- /dev/null
+++ b/cashier/src/main/AndroidManifest.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ package="net.taler.cashier">
+
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+ <uses-permission android:name="android.permission.INTERNET" />
+ <uses-permission android:name="android.permission.NFC" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@mipmap/ic_launcher"
+ android:label="@string/app_name"
+ android:fullBackupContent="@xml/backup_descriptor"
+ android:supportsRtl="true"
+ android:theme="@style/AppTheme"
+ android:roundIcon="@mipmap/ic_launcher"
+ tools:ignore="GoogleAppIndexingWarning">
+
+ <activity
+ android:name=".MainActivity"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme.NoActionBar">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+
+ </application>
+
+</manifest>
diff --git a/cashier/src/main/ic_launcher-web.png b/cashier/src/main/ic_launcher-web.png
new file mode 100644
index 0000000..04a58c6
--- /dev/null
+++ b/cashier/src/main/ic_launcher-web.png
Binary files differ
diff --git a/cashier/src/main/java/net/taler/cashier/Amount.kt b/cashier/src/main/java/net/taler/cashier/Amount.kt
new file mode 100644
index 0000000..2c237c8
--- /dev/null
+++ b/cashier/src/main/java/net/taler/cashier/Amount.kt
@@ -0,0 +1,45 @@
+/*
+ * This file is part of GNU Taler
+ * (C) 2020 Taler Systems S.A.
+ *
+ * GNU Taler is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3, or (at your option) any later version.
+ *
+ * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+package net.taler.cashier
+
+data class Amount(val currency: String, val amount: String) {
+
+ companion object {
+
+ private val SIGNED_REGEX = Regex("""([+\-])(\w+):([0-9.]+)""")
+
+ @Suppress("unused")
+ fun fromString(strAmount: String): Amount {
+ val components = strAmount.split(":")
+ return Amount(components[0], components[1])
+ }
+
+ fun fromStringSigned(strAmount: String): Amount? {
+ val groups = SIGNED_REGEX.matchEntire(strAmount)?.groupValues ?: emptyList()
+ if (groups.size < 4) return null
+ var amount = groups[3].toDoubleOrNull() ?: return null
+ if (groups[1] == "-") amount *= -1
+ val currency = groups[2]
+ val amountStr = amount.toString()
+ // only display as many digits as required to precisely render the balance
+ return Amount(currency, amountStr.removeSuffix(".0"))
+ }
+ }
+
+ override fun toString() = "$amount $currency"
+
+}
diff --git a/cashier/src/main/java/net/taler/cashier/BalanceFragment.kt b/cashier/src/main/java/net/taler/cashier/BalanceFragment.kt
new file mode 100644
index 0000000..b3a0221
--- /dev/null
+++ b/cashier/src/main/java/net/taler/cashier/BalanceFragment.kt
@@ -0,0 +1,182 @@
+/*
+ * This file is part of GNU Taler
+ * (C) 2020 Taler Systems S.A.
+ *
+ * GNU Taler is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3, or (at your option) any later version.
+ *
+ * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+package net.taler.cashier
+
+import android.annotation.SuppressLint
+import android.os.Bundle
+import android.view.LayoutInflater
+import android.view.Menu
+import android.view.MenuInflater
+import android.view.MenuItem
+import android.view.View
+import android.view.View.VISIBLE
+import android.view.ViewGroup
+import android.view.inputmethod.EditorInfo
+import androidx.fragment.app.Fragment
+import androidx.fragment.app.activityViewModels
+import androidx.lifecycle.Observer
+import androidx.navigation.fragment.findNavController
+import kotlinx.android.synthetic.main.fragment_balance.*
+import net.taler.cashier.BalanceFragmentDirections.Companion.actionBalanceFragmentToTransactionFragment
+import net.taler.cashier.withdraw.LastTransaction
+import net.taler.cashier.withdraw.WithdrawStatus
+
+sealed class BalanceResult {
+ object Error : BalanceResult()
+ object Offline : BalanceResult()
+ class Success(val amount: Amount) : BalanceResult()
+}
+
+class BalanceFragment : Fragment() {
+
+ private val viewModel: MainViewModel by activityViewModels()
+ private val withdrawManager by lazy { viewModel.withdrawManager }
+
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ setHasOptionsMenu(true)
+ return inflater.inflate(R.layout.fragment_balance, container, false)
+ }
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ withdrawManager.lastTransaction.observe(viewLifecycleOwner, Observer { lastTransaction ->
+ onLastTransaction(lastTransaction)
+ })
+ viewModel.balance.observe(viewLifecycleOwner, Observer { result ->
+ when (result) {
+ is BalanceResult.Success -> onBalanceUpdated(result.amount)
+ else -> onBalanceUpdated(null, result is BalanceResult.Offline)
+ }
+ })
+ button5.setOnClickListener { onAmountButtonPressed(5) }
+ button10.setOnClickListener { onAmountButtonPressed(10) }
+ button20.setOnClickListener { onAmountButtonPressed(20) }
+ button50.setOnClickListener { onAmountButtonPressed(50) }
+
+ if (savedInstanceState != null) {
+ amountView.editText!!.setText(savedInstanceState.getCharSequence("amountView"))
+ }
+ amountView.editText!!.setOnEditorActionListener { _, actionId, _ ->
+ if (actionId == EditorInfo.IME_ACTION_GO) {
+ onAmountConfirmed(getAmountFromView())
+ true
+ } else false
+ }
+ viewModel.currency.observe(viewLifecycleOwner, Observer { currency ->
+ currencyView.text = currency
+ })
+ confirmWithdrawalButton.setOnClickListener { onAmountConfirmed(getAmountFromView()) }
+ }
+
+ override fun onStart() {
+ super.onStart()
+ // update balance if there's a config
+ if (viewModel.hasConfig()) {
+ viewModel.getBalance()
+ }
+ }
+
+ override fun onSaveInstanceState(outState: Bundle) {
+ super.onSaveInstanceState(outState)
+ // for some reason automatic restore isn't working at the moment!?
+ amountView?.editText?.text.let {
+ outState.putCharSequence("amountView", it)
+ }
+ }
+
+ override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
+ inflater.inflate(R.menu.balance, menu)
+ super.onCreateOptionsMenu(menu, inflater)
+ }
+
+ override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
+ R.id.action_reconfigure -> {
+ findNavController().navigate(viewModel.configDestination)
+ true
+ }
+ R.id.action_lock -> {
+ viewModel.lock()
+ findNavController().navigate(viewModel.configDestination)
+ true
+ }
+ else -> super.onOptionsItemSelected(item)
+ }
+
+ private fun onBalanceUpdated(amount: Amount?, isOffline: Boolean = false) {
+ val uiList = listOf(
+ introView,
+ button5, button10, button20, button50,
+ amountView, currencyView, confirmWithdrawalButton
+ )
+ if (amount == null) {
+ balanceView.text =
+ getString(if (isOffline) R.string.balance_offline else R.string.balance_error)
+ uiList.forEach { it.fadeOut() }
+ } else {
+ @SuppressLint("SetTextI18n")
+ balanceView.text = "${amount.amount} ${amount.currency}"
+ uiList.forEach { it.fadeIn() }
+ }
+ progressBar.fadeOut()
+ }
+
+ private fun onAmountButtonPressed(amount: Int) {
+ amountView.editText!!.setText(amount.toString())
+ amountView.error = null
+ }
+
+ private fun getAmountFromView(): Int {
+ val str = amountView.editText!!.text.toString()
+ if (str.isBlank()) return 0
+ return Integer.parseInt(str)
+ }
+
+ private fun onAmountConfirmed(amount: Int) {
+ if (amount <= 0) {
+ amountView.error = getString(R.string.withdraw_error_zero)
+ } else if (!withdrawManager.hasSufficientBalance(amount)) {
+ amountView.error = getString(R.string.withdraw_error_insufficient_balance)
+ } else {
+ amountView.error = null
+ withdrawManager.withdraw(amount)
+ actionBalanceFragmentToTransactionFragment().let {
+ findNavController().navigate(it)
+ }
+ }
+ }
+
+ private fun onLastTransaction(lastTransaction: LastTransaction?) {
+ val status = lastTransaction?.withdrawStatus
+ val text = when (status) {
+ is WithdrawStatus.Success -> getString(
+ R.string.transaction_last_success, lastTransaction.withdrawAmount
+ )
+ is WithdrawStatus.Aborted -> getString(R.string.transaction_last_aborted)
+ else -> getString(R.string.transaction_last_error)
+ }
+ lastTransactionView.text = text
+ val drawable = if (status == WithdrawStatus.Success)
+ R.drawable.ic_check_circle
+ else
+ R.drawable.ic_error
+ lastTransactionView.setCompoundDrawablesRelativeWithIntrinsicBounds(drawable, 0, 0, 0)
+ lastTransactionView.visibility = VISIBLE
+ }
+
+}
diff --git a/cashier/src/main/java/net/taler/cashier/ConfigFragment.kt b/cashier/src/main/java/net/taler/cashier/ConfigFragment.kt
new file mode 100644
index 0000000..b9a97e5
--- /dev/null
+++ b/cashier/src/main/java/net/taler/cashier/ConfigFragment.kt
@@ -0,0 +1,139 @@
+/*
+ * This file is part of GNU Taler
+ * (C) 2020 Taler Systems S.A.
+ *
+ * GNU Taler is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3, or (at your option) any later version.
+ *
+ * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+package net.taler.cashier
+
+import android.os.Bundle
+import android.text.method.LinkMovementMethod
+import android.view.LayoutInflater
+import android.view.View
+import android.view.View.INVISIBLE
+import android.view.View.VISIBLE
+import android.view.ViewGroup
+import android.view.inputmethod.InputMethodManager
+import androidx.core.content.ContextCompat.getSystemService
+import androidx.core.text.HtmlCompat
+import androidx.core.text.HtmlCompat.FROM_HTML_MODE_LEGACY
+import androidx.fragment.app.Fragment
+import androidx.fragment.app.activityViewModels
+import androidx.lifecycle.Observer
+import androidx.navigation.fragment.findNavController
+import com.google.android.material.snackbar.Snackbar
+import com.google.android.material.snackbar.Snackbar.LENGTH_LONG
+import kotlinx.android.synthetic.main.fragment_config.*
+
+private const val URL_BANK_TEST = "https://bank.test.taler.net"
+private const val URL_BANK_TEST_REGISTER = "$URL_BANK_TEST/accounts/register"
+
+class ConfigFragment : Fragment() {
+
+ private val viewModel: MainViewModel by activityViewModels()
+
+ override fun onCreateView(
+ inflater: LayoutInflater,
+ container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ return inflater.inflate(R.layout.fragment_config, container, false)
+ }
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ if (savedInstanceState == null) {
+ if (viewModel.config.bankUrl.isBlank()) {
+ urlView.editText!!.setText(URL_BANK_TEST)
+ } else {
+ urlView.editText!!.setText(viewModel.config.bankUrl)
+ }
+ usernameView.editText!!.setText(viewModel.config.username)
+ passwordView.editText!!.setText(viewModel.config.password)
+ } else {
+ urlView.editText!!.setText(savedInstanceState.getCharSequence("urlView"))
+ usernameView.editText!!.setText(savedInstanceState.getCharSequence("usernameView"))
+ passwordView.editText!!.setText(savedInstanceState.getCharSequence("passwordView"))
+ }
+ saveButton.setOnClickListener {
+ val config = Config(
+ bankUrl = urlView.editText!!.text.toString(),
+ username = usernameView.editText!!.text.toString(),
+ password = passwordView.editText!!.text.toString()
+ )
+ if (checkConfig(config)) {
+ // show progress
+ saveButton.visibility = INVISIBLE
+ progressBar.visibility = VISIBLE
+ // kick off check and observe result
+ viewModel.checkAndSaveConfig(config)
+ viewModel.configResult.observe(viewLifecycleOwner, onConfigResult)
+ // hide keyboard
+ val inputMethodManager =
+ getSystemService(requireContext(), InputMethodManager::class.java)!!
+ inputMethodManager.hideSoftInputFromWindow(view.windowToken, 0)
+ }
+ }
+ demoView.text = HtmlCompat.fromHtml(
+ getString(R.string.config_demo_hint, URL_BANK_TEST_REGISTER), FROM_HTML_MODE_LEGACY
+ )
+ demoView.movementMethod = LinkMovementMethod.getInstance()
+ }
+
+ override fun onStart() {
+ super.onStart()
+ // focus on password if it is the only missing value (like after locking)
+ if (urlView.editText!!.text.isNotBlank()
+ && usernameView.editText!!.text.isNotBlank()
+ && passwordView.editText!!.text.isBlank()) {
+ passwordView.editText!!.requestFocus()
+ }
+ }
+
+ override fun onSaveInstanceState(outState: Bundle) {
+ super.onSaveInstanceState(outState)
+ // for some reason automatic restore isn't working at the moment!?
+ outState.putCharSequence("urlView", urlView.editText?.text)
+ outState.putCharSequence("usernameView", usernameView.editText?.text)
+ outState.putCharSequence("passwordView", passwordView.editText?.text)
+ }
+
+ private fun checkConfig(config: Config): Boolean {
+ if (!config.bankUrl.startsWith("https://")) {
+ urlView.error = getString(R.string.config_bank_url_error)
+ urlView.requestFocus()
+ return false
+ }
+ if (config.username.isBlank()) {
+ usernameView.error = getString(R.string.config_username_error)
+ usernameView.requestFocus()
+ return false
+ }
+ urlView.isErrorEnabled = false
+ return true
+ }
+
+ private val onConfigResult = Observer<ConfigResult> { result ->
+ if (result == null) return@Observer
+ if (result.success) {
+ val action = ConfigFragmentDirections.actionConfigFragmentToBalanceFragment()
+ findNavController().navigate(action)
+ } else {
+ val res = if (result.authError) R.string.config_error_auth else R.string.config_error
+ Snackbar.make(view!!, res, LENGTH_LONG).show()
+ }
+ saveButton.visibility = VISIBLE
+ progressBar.visibility = INVISIBLE
+ viewModel.configResult.removeObservers(viewLifecycleOwner)
+ }
+
+}
diff --git a/cashier/src/main/java/net/taler/cashier/HttpHelper.kt b/cashier/src/main/java/net/taler/cashier/HttpHelper.kt
new file mode 100644
index 0000000..06b06db
--- /dev/null
+++ b/cashier/src/main/java/net/taler/cashier/HttpHelper.kt
@@ -0,0 +1,102 @@
+/*
+ * This file is part of GNU Taler
+ * (C) 2020 Taler Systems S.A.
+ *
+ * GNU Taler is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3, or (at your option) any later version.
+ *
+ * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+package net.taler.cashier
+
+import android.util.Log
+import androidx.annotation.WorkerThread
+import okhttp3.Credentials
+import okhttp3.MediaType
+import okhttp3.OkHttpClient
+import okhttp3.Request
+import okhttp3.RequestBody
+import org.json.JSONObject
+
+object HttpHelper {
+
+ private val TAG = HttpHelper::class.java.simpleName
+ private const val MIME_TYPE_JSON = "application/json"
+
+ @WorkerThread
+ fun makeJsonGetRequest(url: String, config: Config): HttpJsonResult {
+ val request = Request.Builder()
+ .addHeader("Accept", MIME_TYPE_JSON)
+ .url(url)
+ .get()
+ .build()
+ val response = try {
+ getHttpClient(config.username, config.password)
+ .newCall(request)
+ .execute()
+ } catch (e: Exception) {
+ Log.e(TAG, "Error retrieving $url", e)
+ return HttpJsonResult.Error(500)
+ }
+ return if (response.code() == 200 && response.body() != null) {
+ val jsonObject = JSONObject(response.body()!!.string())
+ HttpJsonResult.Success(jsonObject)
+ } else {
+ Log.e(TAG, "Received status ${response.code()} from $url expected 200")
+ HttpJsonResult.Error(response.code())
+ }
+ }
+
+ private val MEDIA_TYPE_JSON = MediaType.parse("$MIME_TYPE_JSON; charset=utf-8")
+
+ @WorkerThread
+ fun makeJsonPostRequest(url: String, body: String, config: Config): HttpJsonResult {
+ val request = Request.Builder()
+ .addHeader("Accept", MIME_TYPE_JSON)
+ .url(url)
+ .post(RequestBody.create(MEDIA_TYPE_JSON, body))
+ .build()
+ val response = try {
+ getHttpClient(config.username, config.password)
+ .newCall(request)
+ .execute()
+ } catch (e: Exception) {
+ Log.e(TAG, "Error retrieving $url", e)
+ return HttpJsonResult.Error(500)
+ }
+ return if (response.code() == 200 && response.body() != null) {
+ val jsonObject = JSONObject(response.body()!!.string())
+ HttpJsonResult.Success(jsonObject)
+ } else {
+ Log.e(TAG, "Received status ${response.code()} from $url expected 200")
+ HttpJsonResult.Error(response.code())
+ }
+ }
+
+ private fun getHttpClient(username: String, password: String) =
+ OkHttpClient.Builder().authenticator { _, response ->
+ val credential = Credentials.basic(username, password)
+ if (credential == response.request().header("Authorization")) {
+ // If we already failed with these credentials, don't retry
+ return@authenticator null
+ }
+ response
+ .request()
+ .newBuilder()
+ .header("Authorization", credential)
+ .build()
+ }.build()
+
+}
+
+sealed class HttpJsonResult {
+ class Error(val statusCode: Int) : HttpJsonResult()
+ class Success(val json: JSONObject) : HttpJsonResult()
+}
diff --git a/cashier/src/main/java/net/taler/cashier/MainActivity.kt b/cashier/src/main/java/net/taler/cashier/MainActivity.kt
new file mode 100644
index 0000000..b238054
--- /dev/null
+++ b/cashier/src/main/java/net/taler/cashier/MainActivity.kt
@@ -0,0 +1,62 @@
+/*
+ * This file is part of GNU Taler
+ * (C) 2020 Taler Systems S.A.
+ *
+ * GNU Taler is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3, or (at your option) any later version.
+ *
+ * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+package net.taler.cashier
+
+import android.content.Intent
+import android.content.Intent.*
+import android.os.Bundle
+import androidx.activity.viewModels
+import androidx.appcompat.app.AppCompatActivity
+import androidx.navigation.NavController
+import androidx.navigation.fragment.NavHostFragment
+import kotlinx.android.synthetic.main.activity_main.*
+
+class MainActivity : AppCompatActivity() {
+
+ private val viewModel: MainViewModel by viewModels()
+ private lateinit var nav: NavController
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_main)
+ setSupportActionBar(toolbar)
+ val navHostFragment =
+ supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment
+ nav = navHostFragment.navController
+ }
+
+ override fun onStart() {
+ super.onStart()
+ if (!viewModel.hasConfig()) {
+ nav.navigate(viewModel.configDestination)
+ }
+ }
+
+ override fun onBackPressed() {
+ if (!viewModel.hasConfig() && nav.currentDestination?.id == R.id.configFragment) {
+ // we are in the configuration screen and need a config to continue
+ val intent = Intent(ACTION_MAIN).apply {
+ addCategory(CATEGORY_HOME)
+ flags = FLAG_ACTIVITY_NEW_TASK
+ }
+ startActivity(intent)
+ } else {
+ super.onBackPressed()
+ }
+ }
+
+}
diff --git a/cashier/src/main/java/net/taler/cashier/MainViewModel.kt b/cashier/src/main/java/net/taler/cashier/MainViewModel.kt
new file mode 100644
index 0000000..3874038
--- /dev/null
+++ b/cashier/src/main/java/net/taler/cashier/MainViewModel.kt
@@ -0,0 +1,148 @@
+/*
+ * This file is part of GNU Taler
+ * (C) 2020 Taler Systems S.A.
+ *
+ * GNU Taler is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3, or (at your option) any later version.
+ *
+ * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+package net.taler.cashier
+
+import android.annotation.SuppressLint
+import android.app.Application
+import android.util.Log
+import androidx.annotation.UiThread
+import androidx.annotation.WorkerThread
+import androidx.lifecycle.AndroidViewModel
+import androidx.lifecycle.LiveData
+import androidx.lifecycle.MutableLiveData
+import androidx.lifecycle.viewModelScope
+import androidx.security.crypto.EncryptedSharedPreferences
+import androidx.security.crypto.EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV
+import androidx.security.crypto.EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
+import androidx.security.crypto.MasterKeys
+import androidx.security.crypto.MasterKeys.AES256_GCM_SPEC
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.launch
+import net.taler.cashier.Amount.Companion.fromStringSigned
+import net.taler.cashier.HttpHelper.makeJsonGetRequest
+import net.taler.cashier.withdraw.WithdrawManager
+
+private val TAG = MainViewModel::class.java.simpleName
+
+private const val PREF_NAME = "net.taler.cashier.prefs"
+private const val PREF_KEY_BANK_URL = "bankUrl"
+private const val PREF_KEY_USERNAME = "username"
+private const val PREF_KEY_PASSWORD = "password"
+private const val PREF_KEY_CURRENCY = "currency"
+
+class MainViewModel(private val app: Application) : AndroidViewModel(app) {
+
+ val configDestination = ConfigFragmentDirections.actionGlobalConfigFragment()
+
+ private val masterKeyAlias = MasterKeys.getOrCreate(AES256_GCM_SPEC)
+ private val prefs = EncryptedSharedPreferences.create(
+ PREF_NAME, masterKeyAlias, app, AES256_SIV, AES256_GCM
+ )
+
+ internal var config = Config(
+ bankUrl = prefs.getString(PREF_KEY_BANK_URL, "")!!,
+ username = prefs.getString(PREF_KEY_USERNAME, "")!!,
+ password = prefs.getString(PREF_KEY_PASSWORD, "")!!
+ )
+
+ private val mCurrency = MutableLiveData<String>(
+ prefs.getString(PREF_KEY_CURRENCY, null)
+ )
+ internal val currency: LiveData<String> = mCurrency
+
+ private val mConfigResult = MutableLiveData<ConfigResult>()
+ val configResult: LiveData<ConfigResult> = mConfigResult
+
+ private val mBalance = MutableLiveData<BalanceResult>()
+ val balance: LiveData<BalanceResult> = mBalance
+
+ internal val withdrawManager = WithdrawManager(app, this)
+
+ fun hasConfig() = config.bankUrl.isNotEmpty()
+ && config.username.isNotEmpty()
+ && config.password.isNotEmpty()
+
+ /**
+ * Start observing [configResult] after calling this to get the result async.
+ * Warning: Ignore null results that are used to reset old results.
+ */
+ @UiThread
+ fun checkAndSaveConfig(config: Config) {
+ mConfigResult.value = null
+ viewModelScope.launch(Dispatchers.IO) {
+ val url = "${config.bankUrl}/accounts/${config.username}/balance"
+ Log.d(TAG, "Checking config: $url")
+ val result = when (val response = makeJsonGetRequest(url, config)) {
+ is HttpJsonResult.Success -> {
+ val balance = response.json.getString("balance")
+ val amount = fromStringSigned(balance)!!
+ mCurrency.postValue(amount.currency)
+ prefs.edit().putString(PREF_KEY_CURRENCY, amount.currency).apply()
+ // save config
+ saveConfig(config)
+ ConfigResult(true)
+ }
+ is HttpJsonResult.Error -> {
+ val authError = response.statusCode == 401
+ ConfigResult(false, authError)
+ }
+ }
+ mConfigResult.postValue(result)
+ }
+ }
+
+ @WorkerThread
+ @SuppressLint("ApplySharedPref")
+ private fun saveConfig(config: Config) {
+ this.config = config
+ prefs.edit()
+ .putString(PREF_KEY_BANK_URL, config.bankUrl)
+ .putString(PREF_KEY_USERNAME, config.username)
+ .putString(PREF_KEY_PASSWORD, config.password)
+ .commit()
+ }
+
+ fun getBalance() = viewModelScope.launch(Dispatchers.IO) {
+ check(hasConfig()) { "No config to get balance" }
+ val url = "${config.bankUrl}/accounts/${config.username}/balance"
+ Log.d(TAG, "Checking balance at $url")
+ val result = when (val response = makeJsonGetRequest(url, config)) {
+ is HttpJsonResult.Success -> {
+ val balance = response.json.getString("balance")
+ fromStringSigned(balance)?.let { BalanceResult.Success(it) } ?: BalanceResult.Error
+ }
+ is HttpJsonResult.Error -> {
+ if (app.isOnline()) BalanceResult.Error
+ else BalanceResult.Offline
+ }
+ }
+ mBalance.postValue(result)
+ }
+
+ fun lock() {
+ saveConfig(config.copy(password = ""))
+ }
+
+}
+
+data class Config(
+ val bankUrl: String,
+ val username: String,
+ val password: String
+)
+
+class ConfigResult(val success: Boolean, val authError: Boolean = false)
diff --git a/cashier/src/main/java/net/taler/cashier/Utils.kt b/cashier/src/main/java/net/taler/cashier/Utils.kt
new file mode 100644
index 0000000..62f7a77
--- /dev/null
+++ b/cashier/src/main/java/net/taler/cashier/Utils.kt
@@ -0,0 +1,91 @@
+/*
+ * This file is part of GNU Taler
+ * (C) 2020 Taler Systems S.A.
+ *
+ * GNU Taler is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3, or (at your option) any later version.
+ *
+ * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+package net.taler.cashier
+
+import android.content.Context
+import android.content.Context.CONNECTIVITY_SERVICE
+import android.net.ConnectivityManager
+import android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET
+import android.os.Build.VERSION.SDK_INT
+import android.view.View
+import android.view.View.INVISIBLE
+import android.view.View.VISIBLE
+
+object Utils {
+
+ private const val HEX_CHARS = "0123456789ABCDEF"
+
+ fun hexStringToByteArray(data: String): ByteArray {
+ val result = ByteArray(data.length / 2)
+
+ for (i in data.indices step 2) {
+ val firstIndex = HEX_CHARS.indexOf(data[i])
+ val secondIndex = HEX_CHARS.indexOf(data[i + 1])
+
+ val octet = firstIndex.shl(4).or(secondIndex)
+ result[i.shr(1)] = octet.toByte()
+ }
+ return result
+ }
+
+
+ private val HEX_CHARS_ARRAY = HEX_CHARS.toCharArray()
+
+ @Suppress("unused")
+ fun toHex(byteArray: ByteArray): String {
+ val result = StringBuffer()
+
+ byteArray.forEach {
+ val octet = it.toInt()
+ val firstIndex = (octet and 0xF0).ushr(4)
+ val secondIndex = octet and 0x0F
+ result.append(HEX_CHARS_ARRAY[firstIndex])
+ result.append(HEX_CHARS_ARRAY[secondIndex])
+ }
+ return result.toString()
+ }
+
+}
+
+fun View.fadeIn(endAction: () -> Unit = {}) {
+ if (visibility == VISIBLE) return
+ alpha = 0f
+ visibility = VISIBLE
+ animate().alpha(1f).withEndAction {
+ endAction.invoke()
+ }.start()
+}
+
+fun View.fadeOut(endAction: () -> Unit = {}) {
+ if (visibility == INVISIBLE) return
+ animate().alpha(0f).withEndAction {
+ visibility = INVISIBLE
+ alpha = 1f
+ endAction.invoke()
+ }.start()
+}
+
+fun Context.isOnline(): Boolean {
+ val cm = getSystemService(CONNECTIVITY_SERVICE) as ConnectivityManager
+ return if (SDK_INT < 29) {
+ @Suppress("DEPRECATION")
+ cm.activeNetworkInfo?.isConnected == true
+ } else {
+ val capabilities = cm.getNetworkCapabilities(cm.activeNetwork) ?: return false
+ capabilities.hasCapability(NET_CAPABILITY_INTERNET)
+ }
+}
diff --git a/cashier/src/main/java/net/taler/cashier/withdraw/ErrorFragment.kt b/cashier/src/main/java/net/taler/cashier/withdraw/ErrorFragment.kt
new file mode 100644
index 0000000..ceffcec
--- /dev/null
+++ b/cashier/src/main/java/net/taler/cashier/withdraw/ErrorFragment.kt
@@ -0,0 +1,55 @@
+/*
+ * This file is part of GNU Taler
+ * (C) 2020 Taler Systems S.A.
+ *
+ * GNU Taler is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3, or (at your option) any later version.
+ *
+ * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+package net.taler.cashier.withdraw
+
+import android.os.Bundle
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.fragment.app.Fragment
+import androidx.fragment.app.activityViewModels
+import androidx.lifecycle.Observer
+import androidx.navigation.fragment.findNavController
+import kotlinx.android.synthetic.main.fragment_error.*
+import net.taler.cashier.MainViewModel
+import net.taler.cashier.R
+
+class ErrorFragment : Fragment() {
+
+ private val viewModel: MainViewModel by activityViewModels()
+ private val withdrawManager by lazy { viewModel.withdrawManager }
+
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ return inflater.inflate(R.layout.fragment_error, container, false)
+ }
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ withdrawManager.withdrawStatus.observe(viewLifecycleOwner, Observer { status ->
+ if (status is WithdrawStatus.Aborted) {
+ textView.setText(R.string.transaction_aborted)
+ }
+ })
+ withdrawManager.completeTransaction()
+ backButton.setOnClickListener {
+ findNavController().popBackStack()
+ }
+ }
+
+}
diff --git a/cashier/src/main/java/net/taler/cashier/withdraw/NfcManager.kt b/cashier/src/main/java/net/taler/cashier/withdraw/NfcManager.kt
new file mode 100644
index 0000000..a487b5f
--- /dev/null
+++ b/cashier/src/main/java/net/taler/cashier/withdraw/NfcManager.kt
@@ -0,0 +1,234 @@
+/*
+ * This file is part of GNU Taler
+ * (C) 2020 Taler Systems S.A.
+ *
+ * GNU Taler is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3, or (at your option) any later version.
+ *
+ * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+package net.taler.cashier.withdraw
+
+import android.app.Activity
+import android.content.Context
+import android.nfc.NfcAdapter
+import android.nfc.NfcAdapter.FLAG_READER_NFC_A
+import android.nfc.NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK
+import android.nfc.NfcAdapter.getDefaultAdapter
+import android.nfc.Tag
+import android.nfc.tech.IsoDep
+import android.util.Log
+import net.taler.cashier.Utils.hexStringToByteArray
+import org.json.JSONObject
+import java.io.ByteArrayOutputStream
+import java.net.URL
+import javax.net.ssl.HttpsURLConnection
+
+@Suppress("unused")
+private const val TALER_AID = "A0000002471001"
+
+class NfcManager : NfcAdapter.ReaderCallback {
+
+ companion object {
+ const val TAG = "taler-merchant"
+
+ /**
+ * Returns true if NFC is supported and false otherwise.
+ */
+ fun hasNfc(context: Context): Boolean {
+ return getNfcAdapter(context) != null
+ }
+
+ /**
+ * Enables NFC reader mode. Don't forget to call [stop] afterwards.
+ */
+ fun start(activity: Activity, nfcManager: NfcManager) {
+ getNfcAdapter(activity)?.enableReaderMode(activity, nfcManager, nfcManager.flags, null)
+ }
+
+ /**
+ * Disables NFC reader mode. Call after [start].
+ */
+ fun stop(activity: Activity) {
+ getNfcAdapter(activity)?.disableReaderMode(activity)
+ }
+
+ private fun getNfcAdapter(context: Context): NfcAdapter? {
+ return getDefaultAdapter(context)
+ }
+ }
+
+ private val flags = FLAG_READER_NFC_A or FLAG_READER_SKIP_NDEF_CHECK
+
+ private var tagString: String? = null
+ private var currentTag: IsoDep? = null
+
+ fun setTagString(tagString: String) {
+ this.tagString = tagString
+ }
+
+ override fun onTagDiscovered(tag: Tag?) {
+
+ Log.v(TAG, "tag discovered")
+
+ val isoDep = IsoDep.get(tag)
+ isoDep.connect()
+
+ currentTag = isoDep
+
+ isoDep.transceive(apduSelectFile())
+
+ val tagString: String? = tagString
+ if (tagString != null) {
+ isoDep.transceive(apduPutTalerData(1, tagString.toByteArray()))
+ }
+
+ // FIXME: use better pattern for sleeps in between requests
+ // -> start with fast polling, poll more slowly if no requests are coming
+
+ while (true) {
+ try {
+ val reqFrame = isoDep.transceive(apduGetData())
+ if (reqFrame.size < 2) {
+ Log.v(TAG, "request frame too small")
+ break
+ }
+ val req = ByteArray(reqFrame.size - 2)
+ if (req.isEmpty()) {
+ continue
+ }
+ reqFrame.copyInto(req, 0, 0, reqFrame.size - 2)
+ val jsonReq = JSONObject(req.toString(Charsets.UTF_8))
+ val reqId = jsonReq.getInt("id")
+ Log.v(TAG, "got request $jsonReq")
+ val jsonInnerReq = jsonReq.getJSONObject("request")
+ val method = jsonInnerReq.getString("method")
+ val urlStr = jsonInnerReq.getString("url")
+ Log.v(TAG, "url '$urlStr'")
+ Log.v(TAG, "method '$method'")
+ val url = URL(urlStr)
+ val conn: HttpsURLConnection = url.openConnection() as HttpsURLConnection
+ conn.setRequestProperty("Accept", "application/json")
+ conn.connectTimeout = 5000
+ conn.doInput = true
+ when (method) {
+ "get" -> {
+ conn.requestMethod = "GET"
+ }
+ "postJson" -> {
+ conn.requestMethod = "POST"
+ conn.doOutput = true
+ conn.setRequestProperty("Content-Type", "application/json; utf-8")
+ val body = jsonInnerReq.getString("body")
+ conn.outputStream.write(body.toByteArray(Charsets.UTF_8))
+ }
+ else -> {
+ throw Exception("method not supported")
+ }
+ }
+ Log.v(TAG, "connecting")
+ conn.connect()
+ Log.v(TAG, "connected")
+
+ val statusCode = conn.responseCode
+ val tunnelResp = JSONObject()
+ tunnelResp.put("id", reqId)
+ tunnelResp.put("status", conn.responseCode)
+
+ if (statusCode == 200) {
+ val stream = conn.inputStream
+ val httpResp = stream.buffered().readBytes()
+ tunnelResp.put("responseJson", JSONObject(httpResp.toString(Charsets.UTF_8)))
+ }
+
+ Log.v(TAG, "sending: $tunnelResp")
+
+ isoDep.transceive(apduPutTalerData(2, tunnelResp.toString().toByteArray()))
+ } catch (e: Exception) {
+ Log.v(TAG, "exception during NFC loop: $e")
+ break
+ }
+ }
+
+ isoDep.close()
+ }
+
+ private fun writeApduLength(stream: ByteArrayOutputStream, size: Int) {
+ when {
+ size == 0 -> {
+ // No size field needed!
+ }
+ size <= 255 -> // One byte size field
+ stream.write(size)
+ size <= 65535 -> {
+ stream.write(0)
+ // FIXME: is this supposed to be little or big endian?
+ stream.write(size and 0xFF)
+ stream.write((size ushr 8) and 0xFF)
+ }
+ else -> throw Error("payload too big")
+ }
+ }
+
+ private fun apduSelectFile(): ByteArray {
+ return hexStringToByteArray("00A4040007A0000002471001")
+ }
+
+ private fun apduPutData(payload: ByteArray): ByteArray {
+ val stream = ByteArrayOutputStream()
+
+ // Class
+ stream.write(0x00)
+
+ // Instruction 0xDA = put data
+ stream.write(0xDA)
+
+ // Instruction parameters
+ // (proprietary encoding)
+ stream.write(0x01)
+ stream.write(0x00)
+
+ writeApduLength(stream, payload.size)
+
+ stream.write(payload)
+
+ return stream.toByteArray()
+ }
+
+ private fun apduPutTalerData(talerInst: Int, payload: ByteArray): ByteArray {
+ val realPayload = ByteArrayOutputStream()
+ realPayload.write(talerInst)
+ realPayload.write(payload)
+ return apduPutData(realPayload.toByteArray())
+ }
+
+ private fun apduGetData(): ByteArray {
+ val stream = ByteArrayOutputStream()
+
+ // Class
+ stream.write(0x00)
+
+ // Instruction 0xCA = get data
+ stream.write(0xCA)
+
+ // Instruction parameters
+ // (proprietary encoding)
+ stream.write(0x01)
+ stream.write(0x00)
+
+ // Max expected response size, two
+ // zero bytes denotes 65536
+ stream.write(0x0)
+ stream.write(0x0)
+
+ return stream.toByteArray()
+ }
+
+}
diff --git a/cashier/src/main/java/net/taler/cashier/withdraw/QrCodeManager.kt b/cashier/src/main/java/net/taler/cashier/withdraw/QrCodeManager.kt
new file mode 100644
index 0000000..e3ffa92
--- /dev/null
+++ b/cashier/src/main/java/net/taler/cashier/withdraw/QrCodeManager.kt
@@ -0,0 +1,42 @@
+/*
+ * This file is part of GNU Taler
+ * (C) 2020 Taler Systems S.A.
+ *
+ * GNU Taler is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3, or (at your option) any later version.
+ *
+ * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+package net.taler.cashier.withdraw
+
+import android.graphics.Bitmap
+import android.graphics.Bitmap.Config.RGB_565
+import android.graphics.Color.BLACK
+import android.graphics.Color.WHITE
+import com.google.zxing.BarcodeFormat.QR_CODE
+import com.google.zxing.qrcode.QRCodeWriter
+
+object QrCodeManager {
+
+ fun makeQrCode(text: String, size: Int = 256): Bitmap {
+ val qrCodeWriter = QRCodeWriter()
+ val bitMatrix = qrCodeWriter.encode(text, QR_CODE, size, size)
+ val height = bitMatrix.height
+ val width = bitMatrix.width
+ val bmp = Bitmap.createBitmap(width, height, RGB_565)
+ for (x in 0 until width) {
+ for (y in 0 until height) {
+ bmp.setPixel(x, y, if (bitMatrix.get(x, y)) BLACK else WHITE)
+ }
+ }
+ return bmp
+ }
+
+}
diff --git a/cashier/src/main/java/net/taler/cashier/withdraw/TransactionFragment.kt b/cashier/src/main/java/net/taler/cashier/withdraw/TransactionFragment.kt
new file mode 100644
index 0000000..8b782b0
--- /dev/null
+++ b/cashier/src/main/java/net/taler/cashier/withdraw/TransactionFragment.kt
@@ -0,0 +1,174 @@
+/*
+ * This file is part of GNU Taler
+ * (C) 2020 Taler Systems S.A.
+ *
+ * GNU Taler is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3, or (at your option) any later version.
+ *
+ * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+package net.taler.cashier.withdraw
+
+import android.os.Bundle
+import android.view.LayoutInflater
+import android.view.View
+import android.view.View.INVISIBLE
+import android.view.View.VISIBLE
+import android.view.ViewGroup
+import androidx.core.content.ContextCompat.getColor
+import androidx.fragment.app.Fragment
+import androidx.fragment.app.activityViewModels
+import androidx.lifecycle.Observer
+import androidx.navigation.fragment.findNavController
+import kotlinx.android.synthetic.main.fragment_transaction.*
+import net.taler.cashier.MainViewModel
+import net.taler.cashier.R
+import net.taler.cashier.fadeIn
+import net.taler.cashier.fadeOut
+import net.taler.cashier.withdraw.TransactionFragmentDirections.Companion.actionTransactionFragmentToBalanceFragment
+import net.taler.cashier.withdraw.TransactionFragmentDirections.Companion.actionTransactionFragmentToErrorFragment
+import net.taler.cashier.withdraw.WithdrawResult.Error
+import net.taler.cashier.withdraw.WithdrawResult.InsufficientBalance
+import net.taler.cashier.withdraw.WithdrawResult.Success
+
+class TransactionFragment : Fragment() {
+
+ private val viewModel: MainViewModel by activityViewModels()
+ private val withdrawManager by lazy { viewModel.withdrawManager }
+ private val nfcManager = NfcManager()
+
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?,
+ savedInstanceState: Bundle?
+ ): View? {
+ return inflater.inflate(R.layout.fragment_transaction, container, false)
+ }
+
+ override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
+ withdrawManager.withdrawAmount.observe(viewLifecycleOwner, Observer { amount ->
+ amountView.text = amount
+ })
+ withdrawManager.withdrawResult.observe(viewLifecycleOwner, Observer { result ->
+ onWithdrawResultReceived(result)
+ })
+ withdrawManager.withdrawStatus.observe(viewLifecycleOwner, Observer { status ->
+ onWithdrawStatusChanged(status)
+ })
+
+ // change intro text depending on whether NFC is available or not
+ val hasNfc = NfcManager.hasNfc(requireContext())
+ val intro = if (hasNfc) R.string.transaction_intro_nfc else R.string.transaction_intro
+ introView.setText(intro)
+
+ cancelButton.setOnClickListener {
+ findNavController().popBackStack()
+ }
+ }
+
+ override fun onStart() {
+ super.onStart()
+ if (withdrawManager.withdrawResult.value is Success) {
+ NfcManager.start(requireActivity(), nfcManager)
+ }
+ }
+
+ override fun onStop() {
+ super.onStop()
+ NfcManager.stop(requireActivity())
+ }
+
+ override fun onDestroy() {
+ super.onDestroy()
+ if (!requireActivity().isChangingConfigurations) {
+ withdrawManager.abort()
+ }
+ }
+
+ private fun onWithdrawResultReceived(result: WithdrawResult?) {
+ if (result != null) {
+ progressBar.animate()
+ .alpha(0f)
+ .withEndAction { progressBar?.visibility = INVISIBLE }
+ .setDuration(750)
+ .start()
+ }
+ when (result) {
+ is InsufficientBalance -> {
+ val c = getColor(requireContext(), R.color.design_default_color_error)
+ introView.setTextColor(c)
+ introView.text = getString(R.string.withdraw_error_insufficient_balance)
+ }
+ is Error -> {
+ val c = getColor(requireContext(), R.color.design_default_color_error)
+ introView.setTextColor(c)
+ introView.text = result.msg
+ }
+ is Success -> {
+ // start NFC
+ nfcManager.setTagString(result.talerUri)
+ NfcManager.start(
+ requireActivity(),
+ nfcManager
+ )
+ // show QR code
+ qrCodeView.alpha = 0f
+ qrCodeView.animate()
+ .alpha(1f)
+ .withStartAction {
+ qrCodeView.visibility = VISIBLE
+ qrCodeView.setImageBitmap(result.qrCode)
+ }
+ .setDuration(750)
+ .start()
+ }
+ }
+ }
+
+ private fun onWithdrawStatusChanged(status: WithdrawStatus?): Any = when (status) {
+ is WithdrawStatus.SelectionDone -> {
+ qrCodeView.fadeOut {
+ qrCodeView?.setImageResource(R.drawable.ic_arrow)
+ qrCodeView?.fadeIn()
+ }
+ introView.fadeOut {
+ introView?.text = getString(R.string.transaction_intro_scanned)
+ introView?.fadeIn {
+ confirmButton?.isEnabled = true
+ confirmButton?.setOnClickListener {
+ withdrawManager.confirm(status.withdrawalId)
+ }
+ }
+ }
+ }
+ is WithdrawStatus.Confirming -> {
+ confirmButton.isEnabled = false
+ qrCodeView.fadeOut()
+ progressBar.fadeIn()
+ }
+ is WithdrawStatus.Success -> {
+ withdrawManager.completeTransaction()
+ actionTransactionFragmentToBalanceFragment().let {
+ findNavController().navigate(it)
+ }
+ }
+ is WithdrawStatus.Aborted -> onError()
+ is WithdrawStatus.Error -> onError()
+ null -> {
+ // no-op
+ }
+ }
+
+ private fun onError() {
+ actionTransactionFragmentToErrorFragment().let {
+ findNavController().navigate(it)
+ }
+ }
+
+}
diff --git a/cashier/src/main/java/net/taler/cashier/withdraw/WithdrawManager.kt b/cashier/src/main/java/net/taler/cashier/withdraw/WithdrawManager.kt
new file mode 100644
index 0000000..4c618ac
--- /dev/null
+++ b/cashier/src/main/java/net/taler/cashier/withdraw/WithdrawManager.kt
@@ -0,0 +1,232 @@
+/*
+ * This file is part of GNU Taler
+ * (C) 2020 Taler Systems S.A.
+ *
+ * GNU Taler is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3, or (at your option) any later version.
+ *
+ * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+package net.taler.cashier.withdraw
+
+import android.app.Application
+import android.graphics.Bitmap
+import android.os.CountDownTimer
+import android.util.Log
+import androidx.annotation.UiThread
+import androidx.lifecycle.LiveData
+import androidx.lifecycle.MutableLiveData
+import androidx.lifecycle.viewModelScope
+import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.Job
+import kotlinx.coroutines.launch
+import net.taler.cashier.BalanceResult
+import net.taler.cashier.HttpHelper.makeJsonGetRequest
+import net.taler.cashier.HttpHelper.makeJsonPostRequest
+import net.taler.cashier.HttpJsonResult.Error
+import net.taler.cashier.HttpJsonResult.Success
+import net.taler.cashier.MainViewModel
+import net.taler.cashier.R
+import org.json.JSONObject
+import java.util.concurrent.TimeUnit.MINUTES
+import java.util.concurrent.TimeUnit.SECONDS
+
+private val TAG = WithdrawManager::class.java.simpleName
+
+private val INTERVAL = SECONDS.toMillis(1)
+private val TIMEOUT = MINUTES.toMillis(2)
+
+class WithdrawManager(
+ private val app: Application,
+ private val viewModel: MainViewModel
+) {
+ private val scope
+ get() = viewModel.viewModelScope
+
+ private val config
+ get() = viewModel.config
+
+ private val currency: String?
+ get() = viewModel.currency.value
+
+ private var withdrawStatusCheck: Job? = null
+
+ private val mWithdrawAmount = MutableLiveData<String>()
+ val withdrawAmount: LiveData<String> = mWithdrawAmount
+
+ private val mWithdrawResult = MutableLiveData<WithdrawResult>()
+ val withdrawResult: LiveData<WithdrawResult> = mWithdrawResult
+
+ private val mWithdrawStatus = MutableLiveData<WithdrawStatus>()
+ val withdrawStatus: LiveData<WithdrawStatus> = mWithdrawStatus
+
+ private val mLastTransaction = MutableLiveData<LastTransaction>()
+ val lastTransaction: LiveData<LastTransaction> = mLastTransaction
+
+ @UiThread
+ fun hasSufficientBalance(amount: Int): Boolean {
+ val balanceResult = viewModel.balance.value
+ if (balanceResult !is BalanceResult.Success) return false
+ val balanceStr = balanceResult.amount.amount
+ val balanceDouble = balanceStr.toDouble()
+ return amount <= balanceDouble
+ }
+
+ @UiThread
+ fun withdraw(amount: Int) {
+ check(amount > 0) { "Withdraw amount was <= 0" }
+ check(currency != null) { "Currency is null" }
+ mWithdrawResult.value = null
+ mWithdrawAmount.value = "$amount $currency"
+ scope.launch(Dispatchers.IO) {
+ val url = "${config.bankUrl}/accounts/${config.username}/withdrawals"
+ Log.d(TAG, "Starting withdrawal at $url")
+ val body = JSONObject(mapOf("amount" to "${currency}:${amount}")).toString()
+ when (val result = makeJsonPostRequest(url, body, config)) {
+ is Success -> {
+ val talerUri = result.json.getString("taler_withdraw_uri")
+ val withdrawResult = WithdrawResult.Success(
+ id = result.json.getString("withdrawal_id"),
+ talerUri = talerUri,
+ qrCode = QrCodeManager.makeQrCode(talerUri)
+ )
+ mWithdrawResult.postValue(withdrawResult)
+ timer.start()
+ }
+ is Error -> {
+ val errorStr = app.getString(R.string.withdraw_error_fetch)
+ mWithdrawResult.postValue(WithdrawResult.Error(errorStr))
+ }
+ }
+ }
+ }
+
+ private val timer: CountDownTimer = object : CountDownTimer(TIMEOUT, INTERVAL) {
+ override fun onTick(millisUntilFinished: Long) {
+ val result = withdrawResult.value
+ if (result is WithdrawResult.Success) {
+ // check for active jobs and only do one at a time
+ val hasActiveCheck = withdrawStatusCheck?.isActive ?: false
+ if (!hasActiveCheck) {
+ withdrawStatusCheck = checkWithdrawStatus(result.id)
+ }
+ } else {
+ cancel()
+ }
+ }
+
+ override fun onFinish() {
+ abort()
+ mWithdrawStatus.postValue(WithdrawStatus.Error)
+ cancel()
+ }
+ }
+
+ private fun checkWithdrawStatus(withdrawalId: String) = scope.launch(Dispatchers.IO) {
+ val url = "${config.bankUrl}/accounts/${config.username}/withdrawals/${withdrawalId}"
+ Log.d(TAG, "Checking withdraw status at $url")
+ val response = makeJsonGetRequest(url, config)
+ if (response !is Success) return@launch // ignore errors and continue trying
+ val oldStatus = mWithdrawStatus.value
+ when {
+ response.json.getBoolean("aborted") -> {
+ cancelWithdrawStatusCheck()
+ mWithdrawStatus.postValue(WithdrawStatus.Aborted)
+ }
+ response.json.getBoolean("confirmation_done") -> {
+ if (oldStatus !is WithdrawStatus.Success) {
+ cancelWithdrawStatusCheck()
+ mWithdrawStatus.postValue(WithdrawStatus.Success)
+ viewModel.getBalance()
+ }
+ }
+ response.json.getBoolean("selection_done") -> {
+ // only update status, if there's none, yet
+ // so we don't re-notify or overwrite newer status info
+ if (oldStatus == null) {
+ mWithdrawStatus.postValue(WithdrawStatus.SelectionDone(withdrawalId))
+ }
+ }
+ }
+ }
+
+ private fun cancelWithdrawStatusCheck() {
+ timer.cancel()
+ withdrawStatusCheck?.cancel()
+ }
+
+ /**
+ * Aborts the last [withdrawResult], if it exists und there is no [withdrawStatus].
+ * Otherwise this is a no-op.
+ */
+ @UiThread
+ fun abort() {
+ val result = withdrawResult.value
+ val status = withdrawStatus.value
+ if (result is WithdrawResult.Success && status == null) {
+ cancelWithdrawStatusCheck()
+ abort(result.id)
+ }
+ }
+
+ private fun abort(withdrawalId: String) = scope.launch(Dispatchers.IO) {
+ val url = "${config.bankUrl}/accounts/${config.username}/withdrawals/${withdrawalId}/abort"
+ Log.d(TAG, "Aborting withdrawal at $url")
+ makeJsonPostRequest(url, "", config)
+ }
+
+ @UiThread
+ fun confirm(withdrawalId: String) {
+ mWithdrawStatus.value = WithdrawStatus.Confirming
+ scope.launch(Dispatchers.IO) {
+ val url =
+ "${config.bankUrl}/accounts/${config.username}/withdrawals/${withdrawalId}/confirm"
+ Log.d(TAG, "Confirming withdrawal at $url")
+ when (val result = makeJsonPostRequest(url, "", config)) {
+ is Success -> {
+ // no-op still waiting for [timer] to confirm our confirmation
+ }
+ is Error -> {
+ Log.e(TAG, "Error confirming withdrawal. Status code: ${result.statusCode}")
+ mWithdrawStatus.postValue(WithdrawStatus.Error)
+ }
+ }
+ }
+ }
+
+ @UiThread
+ fun completeTransaction() {
+ mLastTransaction.value = LastTransaction(withdrawAmount.value!!, withdrawStatus.value!!)
+ withdrawStatusCheck = null
+ mWithdrawAmount.value = null
+ mWithdrawResult.value = null
+ mWithdrawStatus.value = null
+ }
+
+}
+
+sealed class WithdrawResult {
+ object InsufficientBalance : WithdrawResult()
+ class Error(val msg: String) : WithdrawResult()
+ class Success(val id: String, val talerUri: String, val qrCode: Bitmap) : WithdrawResult()
+}
+
+sealed class WithdrawStatus {
+ object Error : WithdrawStatus()
+ object Aborted : WithdrawStatus()
+ class SelectionDone(val withdrawalId: String) : WithdrawStatus()
+ object Confirming : WithdrawStatus()
+ object Success : WithdrawStatus()
+}
+
+data class LastTransaction(
+ val withdrawAmount: String,
+ val withdrawStatus: WithdrawStatus
+)
diff --git a/cashier/src/main/res/drawable-w550dp/ic_arrow.xml b/cashier/src/main/res/drawable-w550dp/ic_arrow.xml
new file mode 100644
index 0000000..331ea06
--- /dev/null
+++ b/cashier/src/main/res/drawable-w550dp/ic_arrow.xml
@@ -0,0 +1,11 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:alpha="0.56"
+ android:tint="@color/green"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#000000"
+ android:pathData="M20,5.41 L18.59,4 7,15.59V9H5V19H15V17H8.41" />
+</vector>
diff --git a/cashier/src/main/res/drawable/ic_arrow.xml b/cashier/src/main/res/drawable/ic_arrow.xml
new file mode 100644
index 0000000..d7578bd
--- /dev/null
+++ b/cashier/src/main/res/drawable/ic_arrow.xml
@@ -0,0 +1,11 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:alpha="0.56"
+ android:tint="@color/green"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#000000"
+ android:pathData="M5,5.41 L6.41,4 18,15.59V9h2V19H10v-2h6.59" />
+</vector>
diff --git a/cashier/src/main/res/drawable/ic_check_circle.xml b/cashier/src/main/res/drawable/ic_check_circle.xml
new file mode 100644
index 0000000..d43d6ba
--- /dev/null
+++ b/cashier/src/main/res/drawable/ic_check_circle.xml
@@ -0,0 +1,10 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:alpha="0.56"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM10,17l-5,-5 1.41,-1.41L10,14.17l7.59,-7.59L19,8l-9,9z" />
+</vector>
diff --git a/cashier/src/main/res/drawable/ic_clear.xml b/cashier/src/main/res/drawable/ic_clear.xml
new file mode 100644
index 0000000..f50fd99
--- /dev/null
+++ b/cashier/src/main/res/drawable/ic_clear.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z" />
+</vector>
diff --git a/cashier/src/main/res/drawable/ic_error.xml b/cashier/src/main/res/drawable/ic_error.xml
new file mode 100644
index 0000000..b7e22a0
--- /dev/null
+++ b/cashier/src/main/res/drawable/ic_error.xml
@@ -0,0 +1,11 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:alpha="0.56"
+ android:tint="@color/red"
+ android:viewportWidth="24.0"
+ android:viewportHeight="24.0">
+ <path
+ android:fillColor="#FF000000"
+ android:pathData="M12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM13,17h-2v-2h2v2zM13,13h-2L11,7h2v6z" />
+</vector>
diff --git a/cashier/src/main/res/drawable/ic_launcher_foreground.xml b/cashier/src/main/res/drawable/ic_launcher_foreground.xml
new file mode 100644
index 0000000..fbaac05
--- /dev/null
+++ b/cashier/src/main/res/drawable/ic_launcher_foreground.xml
@@ -0,0 +1,15 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:width="108dp"
+ android:height="108dp"
+ android:viewportWidth="48"
+ android:viewportHeight="48">
+ <group
+ android:translateX="12"
+ android:translateY="12">
+ <path
+ android:pathData="M6,3L6,6L9,6L9,7L6.25,7C5.05,7 4.0508,8 4.0508,9L3.5,16L20.5,16L20,9C19.8,8 18.8008,7 17.8008,7L11,7L11,6L14,6L14,3L6,3zM7,4L13,4L13,5L7,5L7,4zM6,9L8,9L8,10L6,10L6,9zM9,9L11,9L11,10L9,10L9,9zM13,9L18,9L18,11L13,11L13,9zM6,11L8,11L8,12L6,12L6,11zM9,11L11,11L11,12L9,12L9,11zM6,13L8,13L8,14L6,14L6,13zM9,13L11,13L11,14L9,14L9,13zM2,17L2,21L22,21L22,17L2,17zM4.7422,17.291L7.2695,17.291L7.2695,17.7793L6.3574,17.7793L6.3574,20.6777L5.6543,20.6777L5.6543,17.7793L4.7422,17.7793L4.7422,17.291zM11.0078,17.291L12.3613,17.291L12.3613,20.1895L13.0098,20.1895L13.0098,20.6777L10.9238,20.6777L10.9238,20.1895L11.6563,20.1895L11.6563,17.7793L11.0078,17.7793L11.0078,17.291zM8.9688,18.1992C9.092,18.1992 9.2128,18.2081 9.332,18.2266C9.4513,18.245 9.5646,18.2782 9.6719,18.3242C9.7792,18.3703 9.8736,18.4302 9.9531,18.5039C10.0326,18.5745 10.0892,18.6559 10.125,18.748C10.1608,18.8371 10.1797,18.9274 10.1797,19.0195L10.1797,20.6777L9.4746,20.6777L9.4746,20.3828L9.4395,20.4238C9.348,20.519 9.2329,20.5915 9.0938,20.6406C8.9546,20.6898 8.8092,20.7129 8.6582,20.7129C8.531,20.7129 8.4083,20.6978 8.2891,20.6641C8.1698,20.6303 8.066,20.5756 7.9785,20.502C7.8951,20.4252 7.8366,20.3393 7.8008,20.2441C7.765,20.149 7.7461,20.0514 7.7461,19.9531C7.7461,19.8549 7.7688,19.7592 7.8125,19.6641C7.8602,19.5689 7.932,19.4847 8.0273,19.4141C8.1227,19.3434 8.2284,19.2899 8.3477,19.25C8.4669,19.2101 8.5916,19.1814 8.7188,19.166C8.8459,19.1476 8.9743,19.1387 9.1055,19.1387L9.4746,19.1387L9.4746,19.0195C9.4746,18.9551 9.452,18.8951 9.4043,18.8398C9.3606,18.7846 9.2964,18.7461 9.2129,18.7246C9.1334,18.7 9.0522,18.6875 8.9688,18.6875C8.8932,18.6875 8.8177,18.6964 8.7422,18.7148C8.6667,18.7333 8.6024,18.7673 8.5508,18.8164C8.4991,18.8625 8.4651,18.9143 8.4492,18.9727L7.7813,18.834C7.813,18.702 7.8905,18.5849 8.0137,18.4805C8.1369,18.3761 8.2823,18.3036 8.4492,18.2637C8.6201,18.2207 8.7939,18.1992 8.9688,18.1992zM14.9473,18.1992C15.1221,18.1992 15.2921,18.2243 15.4551,18.2734C15.622,18.3226 15.7618,18.3995 15.873,18.5039C15.9883,18.6083 16.0695,18.7246 16.1172,18.8535C16.1649,18.9825 16.1875,19.1149 16.1875,19.25L16.1875,19.7012L14.4121,19.7012C14.416,19.7564 14.4255,19.8119 14.4414,19.8672C14.4613,19.9317 14.4953,19.9924 14.543,20.0508C14.5946,20.106 14.6607,20.149 14.7402,20.1797C14.8197,20.2104 14.9028,20.2266 14.9902,20.2266C15.0737,20.2266 15.1549,20.214 15.2344,20.1895C15.3139,20.1618 15.38,20.1206 15.4316,20.0684C15.4833,20.0131 15.5211,19.9531 15.5449,19.8887L16.1934,20.0781C16.1377,20.2071 16.0509,20.3225 15.9316,20.4238C15.8124,20.5251 15.6689,20.5985 15.502,20.6445C15.335,20.6906 15.1651,20.7129 14.9902,20.7129C14.8154,20.7129 14.6416,20.6906 14.4707,20.6445C14.3038,20.5954 14.1602,20.5212 14.041,20.4199C13.9218,20.3155 13.8368,20.1965 13.7852,20.0645C13.7335,19.9324 13.709,19.7992 13.709,19.6641L13.709,19.25C13.709,19.1149 13.7316,18.9825 13.7793,18.8535C13.827,18.7246 13.9063,18.6083 14.0176,18.5039C14.1328,18.3995 14.2726,18.3226 14.4355,18.2734C14.6025,18.2243 14.7724,18.1992 14.9473,18.1992zM18.502,18.1992C18.6172,18.1992 18.7286,18.2207 18.8359,18.2637C18.9432,18.3036 19.032,18.3599 19.1035,18.4336C19.179,18.5073 19.23,18.5879 19.2578,18.6738L18.6016,18.9121C18.5817,18.8507 18.5383,18.7988 18.4707,18.7559C18.4071,18.7098 18.3335,18.6875 18.25,18.6875C18.1228,18.6875 18.019,18.7304 17.9355,18.8164C17.8561,18.9024 17.8031,18.9935 17.7793,19.0918C17.7594,19.1808 17.75,19.2703 17.75,19.3594L17.75,20.6777L17.0469,20.6777L17.0469,18.2363L17.75,18.2363L17.75,18.6602C17.7778,18.6049 17.8118,18.5502 17.8516,18.498C17.9191,18.409 18.0097,18.3365 18.125,18.2813C18.2442,18.226 18.3708,18.1992 18.502,18.1992zM14.9473,18.6875C14.8638,18.6875 14.7826,18.7045 14.7031,18.7383C14.6276,18.769 14.5691,18.8128 14.5254,18.8711C14.4817,18.9294 14.4514,18.9922 14.4355,19.0566C14.4236,19.1088 14.4161,19.1607 14.4121,19.2129L15.4844,19.2129C15.4804,19.1607 15.4729,19.1088 15.4609,19.0566C15.445,18.9922 15.4148,18.9294 15.3711,18.8711C15.3274,18.8128 15.265,18.769 15.1855,18.7383C15.11,18.7045 15.0307,18.6875 14.9473,18.6875zM9.1055,19.627C9.0101,19.627 8.9157,19.6359 8.8203,19.6543C8.7249,19.6696 8.638,19.7045 8.5625,19.7598C8.487,19.812 8.4492,19.8764 8.4492,19.9531C8.4492,20.0084 8.4719,20.0594 8.5156,20.1055C8.5593,20.1515 8.616,20.1847 8.6875,20.2031C8.759,20.2185 8.8308,20.2266 8.9023,20.2266C9.0057,20.2266 9.1058,20.2068 9.2012,20.1699C9.2966,20.13 9.3664,20.0737 9.4102,20C9.4539,19.9263 9.4746,19.8502 9.4746,19.7734L9.4746,19.627L9.1055,19.627z"
+ android:fillColor="#f9f9f9"
+ tools:ignore="VectorPath" />
+ </group>
+</vector>
diff --git a/cashier/src/main/res/drawable/ic_withdraw.xml b/cashier/src/main/res/drawable/ic_withdraw.xml
new file mode 100644
index 0000000..b694a2b
--- /dev/null
+++ b/cashier/src/main/res/drawable/ic_withdraw.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#000000"
+ android:pathData="M3 0V3H0V5H3V8H5V5H8V3H5V0H3M9 3V6H6V9H3V19C3 20.1 3.89 21 5 21H19C20.11 21 21 20.11 21 19V18H12C10.9 18 10 17.11 10 16V8C10 6.9 10.89 6 12 6H21V5C21 3.9 20.11 3 19 3H9M12 8V16H22V8H12M16 10.5C16.83 10.5 17.5 11.17 17.5 12C17.5 12.83 16.83 13.5 16 13.5C15.17 13.5 14.5 12.83 14.5 12C14.5 11.17 15.17 10.5 16 10.5Z" />
+</vector>
diff --git a/cashier/src/main/res/layout-w550dp/fragment_balance.xml b/cashier/src/main/res/layout-w550dp/fragment_balance.xml
new file mode 100644
index 0000000..d04698b
--- /dev/null
+++ b/cashier/src/main/res/layout-w550dp/fragment_balance.xml
@@ -0,0 +1,222 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ This file is part of GNU Taler
+ ~ (C) 2020 Taler Systems S.A.
+ ~
+ ~ GNU Taler is free software; you can redistribute it and/or modify it under the
+ ~ terms of the GNU General Public License as published by the Free Software
+ ~ Foundation; either version 3, or (at your option) any later version.
+ ~
+ ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU General Public License along with
+ ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ -->
+
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".BalanceFragment">
+
+ <TextView
+ android:id="@+id/lastTransactionView"
+ style="@style/Widget.MaterialComponents.Snackbar.FullWidth"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:background="?attr/colorPrimaryDark"
+ android:drawableStart="@drawable/ic_check_circle"
+ android:drawablePadding="8dp"
+ android:drawableTint="?attr/colorOnPrimarySurface"
+ android:gravity="center_vertical"
+ android:padding="8dp"
+ android:textColor="?attr/colorOnPrimarySurface"
+ android:visibility="gone"
+ app:layout_constraintEnd_toStartOf="@+id/guideline"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ tools:text="@string/transaction_last_success"
+ tools:visibility="visible" />
+
+ <View
+ android:id="@+id/balanceBackground"
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ android:background="@color/background"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="@+id/guideline"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/lastTransactionView" />
+
+ <TextView
+ android:id="@+id/balanceLabel"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="32dp"
+ android:layout_marginTop="32dp"
+ android:layout_marginEnd="32dp"
+ android:text="@string/balance_current_label"
+ android:textAppearance="@style/TextAppearance.AppCompat.Medium"
+ app:layout_constraintBottom_toTopOf="@+id/balanceView"
+ app:layout_constraintEnd_toStartOf="@+id/guideline"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/lastTransactionView"
+ app:layout_constraintVertical_bias="0.0"
+ app:layout_constraintVertical_chainStyle="packed" />
+
+ <TextView
+ android:id="@+id/balanceView"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/default_margin"
+ android:gravity="center"
+ android:textAppearance="@style/TextAppearance.AppCompat.Headline"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toStartOf="@+id/guideline"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/balanceLabel"
+ tools:text="100 KUDOS" />
+
+ <ProgressBar
+ android:id="@+id/progressBar"
+ style="?android:attr/progressBarStyle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:layout_constraintBottom_toBottomOf="@+id/balanceView"
+ app:layout_constraintEnd_toEndOf="@+id/balanceView"
+ app:layout_constraintStart_toStartOf="@+id/balanceView"
+ app:layout_constraintTop_toTopOf="@+id/balanceView" />
+
+ <androidx.constraintlayout.widget.Guideline
+ android:id="@+id/guideline"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ app:layout_constraintGuide_percent="0.5" />
+
+ <TextView
+ android:id="@+id/introView"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_margin="32dp"
+ android:text="@string/withdraw_into"
+ android:textAlignment="center"
+ android:textAppearance="@style/TextAppearance.AppCompat.Medium"
+ android:visibility="invisible"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="@+id/guideline"
+ app:layout_constraintTop_toTopOf="parent"
+ tools:visibility="visible" />
+
+ <Button
+ android:id="@+id/button5"
+ style="@style/AmountButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="5"
+ android:visibility="invisible"
+ app:layout_constraintEnd_toStartOf="@+id/button10"
+ app:layout_constraintHorizontal_chainStyle="packed"
+ app:layout_constraintStart_toStartOf="@+id/guideline"
+ app:layout_constraintTop_toBottomOf="@+id/introView"
+ tools:ignore="HardcodedText"
+ tools:visibility="visible" />
+
+ <Button
+ android:id="@+id/button10"
+ style="@style/AmountButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="10"
+ android:visibility="invisible"
+ app:layout_constraintEnd_toStartOf="@+id/button20"
+ app:layout_constraintStart_toEndOf="@+id/button5"
+ app:layout_constraintTop_toBottomOf="@+id/introView"
+ tools:ignore="HardcodedText"
+ tools:visibility="visible" />
+
+ <Button
+ android:id="@+id/button20"
+ style="@style/AmountButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="20"
+ android:visibility="invisible"
+ app:layout_constraintEnd_toStartOf="@+id/button50"
+ app:layout_constraintStart_toEndOf="@+id/button10"
+ app:layout_constraintTop_toBottomOf="@+id/introView"
+ tools:ignore="HardcodedText"
+ tools:visibility="visible" />
+
+ <Button
+ android:id="@+id/button50"
+ style="@style/AmountButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="50"
+ android:visibility="invisible"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toEndOf="@+id/button20"
+ app:layout_constraintTop_toBottomOf="@+id/introView"
+ tools:ignore="HardcodedText"
+ tools:visibility="visible" />
+
+ <com.google.android.material.textfield.TextInputLayout
+ android:id="@+id/amountView"
+ style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="32dp"
+ android:hint="@string/withdraw_input_amount"
+ android:visibility="invisible"
+ app:endIconDrawable="@drawable/ic_clear"
+ app:endIconMode="clear_text"
+ app:endIconTint="?attr/colorControlNormal"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="@+id/guideline"
+ app:layout_constraintTop_toBottomOf="@+id/button5"
+ tools:visibility="visible">
+
+ <com.google.android.material.textfield.TextInputEditText
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="6"
+ android:imeOptions="actionGo"
+ android:inputType="number"
+ android:maxLength="4" />
+
+ </com.google.android.material.textfield.TextInputLayout>
+
+ <TextView
+ android:id="@+id/currencyView"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_margin="16dp"
+ android:visibility="invisible"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toEndOf="@+id/amountView"
+ app:layout_constraintTop_toTopOf="@+id/amountView"
+ tools:text="TESTKUDOS"
+ tools:visibility="visible" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/confirmWithdrawalButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/default_margin"
+ android:backgroundTint="@color/green"
+ android:drawableLeft="@drawable/ic_withdraw"
+ android:drawableTint="?attr/colorOnPrimarySurface"
+ android:text="@string/withdraw_button_confirm"
+ android:visibility="invisible"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="@+id/guideline"
+ app:layout_constraintTop_toBottomOf="@+id/amountView"
+ app:layout_constraintVertical_bias="1.0"
+ tools:ignore="RtlHardcoded"
+ tools:visibility="visible" />
+
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/cashier/src/main/res/layout-w550dp/fragment_transaction.xml b/cashier/src/main/res/layout-w550dp/fragment_transaction.xml
new file mode 100644
index 0000000..610ed28
--- /dev/null
+++ b/cashier/src/main/res/layout-w550dp/fragment_transaction.xml
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ This file is part of GNU Taler
+ ~ (C) 2020 Taler Systems S.A.
+ ~
+ ~ GNU Taler is free software; you can redistribute it and/or modify it under the
+ ~ terms of the GNU General Public License as published by the Free Software
+ ~ Foundation; either version 3, or (at your option) any later version.
+ ~
+ ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU General Public License along with
+ ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ -->
+
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".withdraw.TransactionFragment">
+
+ <TextView
+ android:id="@+id/introView"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_margin="32dp"
+ android:gravity="center_horizontal"
+ android:text="@string/transaction_intro"
+ android:textAppearance="@style/TextAppearance.AppCompat.Medium"
+ app:layout_constraintEnd_toStartOf="@+id/guideline"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ <TextView
+ android:id="@+id/amountView"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_margin="32dp"
+ android:gravity="center_horizontal"
+ android:textAppearance="@style/TextAppearance.AppCompat.Headline"
+ app:layout_constraintEnd_toStartOf="@+id/guideline"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/introView"
+ tools:text="50 KUDOS" />
+
+ <androidx.constraintlayout.widget.Guideline
+ android:id="@+id/guideline"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ app:layout_constraintGuide_percent="0.5" />
+
+ <ImageView
+ android:id="@+id/qrCodeView"
+ android:layout_width="256dp"
+ android:layout_height="256dp"
+ android:layout_margin="32dp"
+ android:keepScreenOn="true"
+ android:visibility="invisible"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="@+id/guideline"
+ app:layout_constraintTop_toTopOf="parent"
+ tools:ignore="ContentDescription"
+ tools:src="@drawable/ic_arrow"
+ tools:visibility="visible" />
+
+ <ProgressBar
+ android:id="@+id/progressBar"
+ style="?android:attr/progressBarStyleLarge"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:layout_constraintBottom_toBottomOf="@+id/qrCodeView"
+ app:layout_constraintEnd_toEndOf="@+id/qrCodeView"
+ app:layout_constraintStart_toStartOf="@+id/qrCodeView"
+ app:layout_constraintTop_toTopOf="@+id/qrCodeView" />
+
+ <Button
+ android:id="@+id/cancelButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="16dp"
+ android:backgroundTint="@color/red"
+ android:text="@string/transaction_abort"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toStartOf="@+id/confirmButton"
+ app:layout_constraintHorizontal_bias="0.5"
+ app:layout_constraintHorizontal_chainStyle="spread_inside"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/qrCodeView"
+ app:layout_constraintVertical_bias="1.0" />
+
+ <Button
+ android:id="@+id/confirmButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="16dp"
+ android:backgroundTint="@color/green"
+ android:enabled="false"
+ android:text="@string/transaction_confirm"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintEnd_toStartOf="@+id/guideline"
+ app:layout_constraintHorizontal_bias="0.5"
+ app:layout_constraintStart_toEndOf="@+id/cancelButton"
+ tools:enabled="true" />
+
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/cashier/src/main/res/layout/activity_main.xml b/cashier/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..e41b842
--- /dev/null
+++ b/cashier/src/main/res/layout/activity_main.xml
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ This file is part of GNU Taler
+ ~ (C) 2020 Taler Systems S.A.
+ ~
+ ~ GNU Taler is free software; you can redistribute it and/or modify it under the
+ ~ terms of the GNU General Public License as published by the Free Software
+ ~ Foundation; either version 3, or (at your option) any later version.
+ ~
+ ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU General Public License along with
+ ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ -->
+
+<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".MainActivity">
+
+ <com.google.android.material.appbar.AppBarLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:theme="@style/AppTheme.AppBarOverlay">
+
+ <com.google.android.material.appbar.MaterialToolbar
+ android:id="@+id/toolbar"
+ style="@style/AppTheme.Toolbar"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content" />
+
+ </com.google.android.material.appbar.AppBarLayout>
+
+ <androidx.fragment.app.FragmentContainerView
+ android:id="@+id/nav_host_fragment"
+ android:name="androidx.navigation.fragment.NavHostFragment"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ app:defaultNavHost="true"
+ app:layout_behavior="@string/appbar_scrolling_view_behavior"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintLeft_toLeftOf="parent"
+ app:layout_constraintRight_toRightOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ app:navGraph="@navigation/nav_graph" />
+
+</androidx.coordinatorlayout.widget.CoordinatorLayout>
diff --git a/cashier/src/main/res/layout/fragment_balance.xml b/cashier/src/main/res/layout/fragment_balance.xml
new file mode 100644
index 0000000..5dafc59
--- /dev/null
+++ b/cashier/src/main/res/layout/fragment_balance.xml
@@ -0,0 +1,225 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ This file is part of GNU Taler
+ ~ (C) 2020 Taler Systems S.A.
+ ~
+ ~ GNU Taler is free software; you can redistribute it and/or modify it under the
+ ~ terms of the GNU General Public License as published by the Free Software
+ ~ Foundation; either version 3, or (at your option) any later version.
+ ~
+ ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU General Public License along with
+ ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ -->
+
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".BalanceFragment">
+
+ <TextView
+ android:id="@+id/lastTransactionView"
+ style="@style/Widget.MaterialComponents.Snackbar.FullWidth"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:background="?attr/colorPrimaryDark"
+ android:drawableStart="@drawable/ic_check_circle"
+ android:drawablePadding="8dp"
+ android:drawableTint="?attr/colorOnPrimarySurface"
+ android:gravity="center_vertical"
+ android:padding="8dp"
+ android:textColor="?attr/colorOnPrimarySurface"
+ android:visibility="gone"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ tools:text="@string/transaction_last_success"
+ tools:visibility="visible" />
+
+ <View
+ android:id="@+id/balanceBackground"
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ android:background="@color/background"
+ app:layout_constraintBottom_toBottomOf="@+id/balanceView"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/lastTransactionView" />
+
+ <TextView
+ android:id="@+id/balanceLabel"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/default_margin"
+ android:text="@string/balance_current_label"
+ android:textAppearance="@style/TextAppearance.AppCompat.Medium"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/lastTransactionView" />
+
+ <TextView
+ android:id="@+id/balanceView"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:paddingStart="@dimen/default_margin"
+ android:paddingTop="8dp"
+ android:gravity="center"
+ android:paddingEnd="@dimen/default_margin"
+ android:paddingBottom="@dimen/default_margin"
+ android:textAppearance="@style/TextAppearance.AppCompat.Headline"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/balanceLabel"
+ tools:text="100 KUDOS" />
+
+ <ProgressBar
+ android:id="@+id/progressBar"
+ style="?android:attr/progressBarStyle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:layout_constraintBottom_toBottomOf="@+id/balanceView"
+ app:layout_constraintEnd_toEndOf="@+id/balanceView"
+ app:layout_constraintStart_toStartOf="@+id/balanceView"
+ app:layout_constraintTop_toTopOf="@+id/balanceView" />
+
+ <TextView
+ android:id="@+id/introView"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="@dimen/default_margin"
+ android:layout_marginTop="32dp"
+ android:layout_marginEnd="@dimen/default_margin"
+ android:text="@string/withdraw_into"
+ android:textAlignment="center"
+ android:textAppearance="@style/TextAppearance.AppCompat.Medium"
+ android:visibility="invisible"
+ app:layout_constraintBottom_toTopOf="@+id/button5"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/balanceBackground"
+ app:layout_constraintVertical_bias="0.25"
+ app:layout_constraintVertical_chainStyle="packed"
+ tools:visibility="visible" />
+
+ <Button
+ android:id="@+id/button5"
+ style="@style/AmountButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="5"
+ android:visibility="invisible"
+ app:layout_constraintBottom_toTopOf="@+id/amountView"
+ app:layout_constraintEnd_toStartOf="@+id/button10"
+ app:layout_constraintHorizontal_bias="0.5"
+ app:layout_constraintHorizontal_chainStyle="packed"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/introView"
+ tools:ignore="HardcodedText"
+ tools:visibility="visible" />
+
+ <Button
+ android:id="@+id/button10"
+ style="@style/AmountButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="10"
+ android:visibility="invisible"
+ app:layout_constraintEnd_toStartOf="@+id/button20"
+ app:layout_constraintStart_toEndOf="@+id/button5"
+ app:layout_constraintTop_toBottomOf="@+id/introView"
+ tools:ignore="HardcodedText"
+ tools:visibility="visible" />
+
+ <Button
+ android:id="@+id/button20"
+ style="@style/AmountButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="20"
+ android:visibility="invisible"
+ app:layout_constraintEnd_toStartOf="@+id/button50"
+ app:layout_constraintStart_toEndOf="@+id/button10"
+ app:layout_constraintTop_toBottomOf="@+id/introView"
+ tools:ignore="HardcodedText"
+ tools:visibility="visible" />
+
+ <Button
+ android:id="@+id/button50"
+ style="@style/AmountButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="50"
+ android:visibility="invisible"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toEndOf="@+id/button20"
+ app:layout_constraintTop_toBottomOf="@+id/introView"
+ tools:ignore="HardcodedText"
+ tools:visibility="visible" />
+
+ <com.google.android.material.textfield.TextInputLayout
+ android:id="@+id/amountView"
+ style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginStart="@dimen/default_margin"
+ android:layout_marginTop="@dimen/default_margin"
+ android:hint="@string/withdraw_input_amount"
+ android:visibility="invisible"
+ app:endIconDrawable="@drawable/ic_clear"
+ app:endIconMode="clear_text"
+ app:endIconTint="?attr/colorControlNormal"
+ app:layout_constraintBottom_toTopOf="@+id/confirmWithdrawalButton"
+ app:layout_constraintEnd_toStartOf="@+id/currencyView"
+ app:layout_constraintHorizontal_bias="0.5"
+ app:layout_constraintHorizontal_chainStyle="packed"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/button5"
+ tools:visibility="visible">
+
+ <com.google.android.material.textfield.TextInputEditText
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:ems="6"
+ android:imeOptions="actionGo"
+ android:inputType="number"
+ android:maxLength="4" />
+
+ </com.google.android.material.textfield.TextInputLayout>
+
+ <TextView
+ android:id="@+id/currencyView"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/default_margin"
+ android:textAppearance="@style/TextAppearance.AppCompat.Medium"
+ android:visibility="invisible"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintHorizontal_bias="0.5"
+ app:layout_constraintStart_toEndOf="@+id/amountView"
+ app:layout_constraintTop_toTopOf="@+id/amountView"
+ tools:text="TESTKUDOS"
+ tools:visibility="visible" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/confirmWithdrawalButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/default_margin"
+ android:backgroundTint="@color/green"
+ android:drawableLeft="@drawable/ic_withdraw"
+ android:drawableTint="?attr/colorOnPrimarySurface"
+ android:text="@string/withdraw_button_confirm"
+ android:visibility="invisible"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintHorizontal_bias="0.5"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/amountView"
+ tools:ignore="RtlHardcoded"
+ tools:visibility="visible" />
+
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/cashier/src/main/res/layout/fragment_config.xml b/cashier/src/main/res/layout/fragment_config.xml
new file mode 100644
index 0000000..47ec6f9
--- /dev/null
+++ b/cashier/src/main/res/layout/fragment_config.xml
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ This file is part of GNU Taler
+ ~ (C) 2020 Taler Systems S.A.
+ ~
+ ~ GNU Taler is free software; you can redistribute it and/or modify it under the
+ ~ terms of the GNU General Public License as published by the Free Software
+ ~ Foundation; either version 3, or (at your option) any later version.
+ ~
+ ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU General Public License along with
+ ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ -->
+
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+
+ <com.google.android.material.textfield.TextInputLayout
+ android:id="@+id/urlView"
+ style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/default_margin"
+ android:hint="@string/config_bank_url"
+ app:endIconMode="clear_text"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent">
+
+ <com.google.android.material.textfield.TextInputEditText
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textUri" />
+
+ </com.google.android.material.textfield.TextInputLayout>
+
+ <com.google.android.material.textfield.TextInputLayout
+ android:id="@+id/usernameView"
+ style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/default_margin"
+ android:hint="@string/config_username"
+ app:boxBackgroundMode="outline"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/urlView">
+
+ <com.google.android.material.textfield.TextInputEditText
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:inputType="text" />
+
+ </com.google.android.material.textfield.TextInputLayout>
+
+ <com.google.android.material.textfield.TextInputLayout
+ android:id="@+id/passwordView"
+ style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/default_margin"
+ android:hint="@string/config_password"
+ app:boxBackgroundMode="outline"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/usernameView"
+ app:passwordToggleEnabled="true">
+
+ <com.google.android.material.textfield.TextInputEditText
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textWebPassword" />
+
+ </com.google.android.material.textfield.TextInputLayout>
+
+ <Button
+ android:id="@+id/saveButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/default_margin"
+ android:text="@string/config_button_save"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/passwordView" />
+
+ <ProgressBar
+ android:id="@+id/progressBar"
+ style="?android:attr/progressBarStyle"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:visibility="invisible"
+ app:layout_constraintBottom_toBottomOf="@+id/saveButton"
+ app:layout_constraintEnd_toEndOf="@+id/saveButton"
+ app:layout_constraintStart_toStartOf="@+id/saveButton"
+ app:layout_constraintTop_toTopOf="@+id/saveButton"
+ tools:visibility="visible" />
+
+ <TextView
+ android:id="@+id/demoView"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_margin="@dimen/default_margin"
+ android:text="@string/config_demo_hint"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/saveButton" />
+
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/cashier/src/main/res/layout/fragment_error.xml b/cashier/src/main/res/layout/fragment_error.xml
new file mode 100644
index 0000000..ac34c85
--- /dev/null
+++ b/cashier/src/main/res/layout/fragment_error.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ This file is part of GNU Taler
+ ~ (C) 2020 Taler Systems S.A.
+ ~
+ ~ GNU Taler is free software; you can redistribute it and/or modify it under the
+ ~ terms of the GNU General Public License as published by the Free Software
+ ~ Foundation; either version 3, or (at your option) any later version.
+ ~
+ ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU General Public License along with
+ ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ -->
+
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/frameLayout"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".withdraw.ErrorFragment">
+
+ <ImageView
+ android:id="@+id/imageView"
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ android:layout_margin="32dp"
+ android:src="@drawable/ic_error"
+ app:layout_constraintBottom_toTopOf="@+id/textView"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintHorizontal_bias="0.5"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ tools:ignore="ContentDescription" />
+
+ <androidx.appcompat.widget.AppCompatTextView
+ android:id="@+id/textView"
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ android:layout_margin="32dp"
+ android:text="@string/transaction_error"
+ android:textAlignment="center"
+ android:textColor="@color/red"
+ app:autoSizeMaxTextSize="42sp"
+ app:autoSizeTextType="uniform"
+ app:layout_constraintBottom_toTopOf="@+id/backButton"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintHorizontal_bias="0.5"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/imageView" />
+
+ <Button
+ android:id="@+id/backButton"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_margin="16dp"
+ android:text="@string/transaction_button_back"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent" />
+
+</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file
diff --git a/cashier/src/main/res/layout/fragment_transaction.xml b/cashier/src/main/res/layout/fragment_transaction.xml
new file mode 100644
index 0000000..3affbf2
--- /dev/null
+++ b/cashier/src/main/res/layout/fragment_transaction.xml
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ This file is part of GNU Taler
+ ~ (C) 2020 Taler Systems S.A.
+ ~
+ ~ GNU Taler is free software; you can redistribute it and/or modify it under the
+ ~ terms of the GNU General Public License as published by the Free Software
+ ~ Foundation; either version 3, or (at your option) any later version.
+ ~
+ ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU General Public License along with
+ ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ -->
+
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context=".withdraw.TransactionFragment">
+
+ <TextView
+ android:id="@+id/introView"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_margin="32dp"
+ android:gravity="center_horizontal"
+ android:text="@string/transaction_intro"
+ android:textAppearance="@style/TextAppearance.AppCompat.Medium"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
+ <TextView
+ android:id="@+id/amountView"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_margin="32dp"
+ android:gravity="center_horizontal"
+ android:textAppearance="@style/TextAppearance.AppCompat.Headline"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/introView"
+ tools:text="50 KUDOS" />
+
+ <ImageView
+ android:id="@+id/qrCodeView"
+ android:layout_width="256dp"
+ android:layout_height="256dp"
+ android:layout_margin="32dp"
+ android:keepScreenOn="true"
+ android:visibility="invisible"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/amountView"
+ tools:ignore="ContentDescription"
+ tools:src="@drawable/ic_arrow"
+ tools:visibility="visible" />
+
+ <ProgressBar
+ android:id="@+id/progressBar"
+ style="?android:attr/progressBarStyleLarge"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ app:layout_constraintBottom_toBottomOf="@+id/qrCodeView"
+ app:layout_constraintEnd_toEndOf="@+id/qrCodeView"
+ app:layout_constraintStart_toStartOf="@+id/qrCodeView"
+ app:layout_constraintTop_toTopOf="@+id/qrCodeView" />
+
+ <Button
+ android:id="@+id/cancelButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="16dp"
+ android:backgroundTint="@color/red"
+ android:text="@string/transaction_abort"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toStartOf="@+id/confirmButton"
+ app:layout_constraintHorizontal_chainStyle="spread_inside"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/qrCodeView"
+ app:layout_constraintVertical_bias="1.0" />
+
+ <Button
+ android:id="@+id/confirmButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_margin="16dp"
+ android:backgroundTint="@color/green"
+ android:enabled="false"
+ android:text="@string/transaction_confirm"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toEndOf="@+id/cancelButton"
+ tools:enabled="true" />
+
+</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/cashier/src/main/res/menu/balance.xml b/cashier/src/main/res/menu/balance.xml
new file mode 100644
index 0000000..bc64af3
--- /dev/null
+++ b/cashier/src/main/res/menu/balance.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ This file is part of GNU Taler
+ ~ (C) 2020 Taler Systems S.A.
+ ~
+ ~ GNU Taler is free software; you can redistribute it and/or modify it under the
+ ~ terms of the GNU General Public License as published by the Free Software
+ ~ Foundation; either version 3, or (at your option) any later version.
+ ~
+ ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU General Public License along with
+ ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ -->
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+
+ <item
+ android:id="@+id/action_reconfigure"
+ android:title="@string/action_reconfigure"
+ app:showAsAction="never" />
+ <item
+ android:id="@+id/action_lock"
+ android:title="@string/action_lock"
+ app:showAsAction="never" />
+
+</menu>
diff --git a/cashier/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/cashier/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 0000000..7353dbd
--- /dev/null
+++ b/cashier/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+ <background android:drawable="@color/ic_launcher_background"/>
+ <foreground android:drawable="@drawable/ic_launcher_foreground"/>
+</adaptive-icon> \ No newline at end of file
diff --git a/cashier/src/main/res/mipmap-hdpi/ic_launcher.png b/cashier/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..c52928c
--- /dev/null
+++ b/cashier/src/main/res/mipmap-hdpi/ic_launcher.png
Binary files differ
diff --git a/cashier/src/main/res/mipmap-mdpi/ic_launcher.png b/cashier/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..b97178b
--- /dev/null
+++ b/cashier/src/main/res/mipmap-mdpi/ic_launcher.png
Binary files differ
diff --git a/cashier/src/main/res/mipmap-xhdpi/ic_launcher.png b/cashier/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..8f92c07
--- /dev/null
+++ b/cashier/src/main/res/mipmap-xhdpi/ic_launcher.png
Binary files differ
diff --git a/cashier/src/main/res/mipmap-xxhdpi/ic_launcher.png b/cashier/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..214cbea
--- /dev/null
+++ b/cashier/src/main/res/mipmap-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/cashier/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/cashier/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..b959cd3
--- /dev/null
+++ b/cashier/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Binary files differ
diff --git a/cashier/src/main/res/navigation/nav_graph.xml b/cashier/src/main/res/navigation/nav_graph.xml
new file mode 100644
index 0000000..49f8881
--- /dev/null
+++ b/cashier/src/main/res/navigation/nav_graph.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ This file is part of GNU Taler
+ ~ (C) 2020 Taler Systems S.A.
+ ~
+ ~ GNU Taler is free software; you can redistribute it and/or modify it under the
+ ~ terms of the GNU General Public License as published by the Free Software
+ ~ Foundation; either version 3, or (at your option) any later version.
+ ~
+ ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU General Public License along with
+ ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ -->
+
+<navigation xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:id="@+id/nav_graph"
+ app:startDestination="@id/balanceFragment"
+ tools:ignore="UnusedNavigation">
+
+ <fragment
+ android:id="@+id/configFragment"
+ android:name="net.taler.cashier.ConfigFragment"
+ android:label="ConfigFragment"
+ tools:layout="@layout/fragment_config">
+ <action
+ android:id="@+id/action_configFragment_to_balanceFragment"
+ app:destination="@id/balanceFragment"
+ app:launchSingleTop="true"
+ app:popUpTo="@id/balanceFragment" />
+ </fragment>
+
+ <fragment
+ android:id="@+id/balanceFragment"
+ android:name="net.taler.cashier.BalanceFragment"
+ android:label="fragment_balance"
+ tools:layout="@layout/fragment_balance">
+ <action
+ android:id="@+id/action_balanceFragment_to_transactionFragment"
+ app:destination="@id/transactionFragment" />
+ </fragment>
+
+ <fragment
+ android:id="@+id/transactionFragment"
+ android:name="net.taler.cashier.withdraw.TransactionFragment"
+ android:label="fragment_transaction"
+ tools:layout="@layout/fragment_transaction">
+ <action
+ android:id="@+id/action_transactionFragment_to_errorFragment"
+ app:destination="@id/errorFragment"
+ app:launchSingleTop="true"
+ app:popUpTo="@+id/balanceFragment" />
+ <action
+ android:id="@+id/action_transactionFragment_to_balanceFragment"
+ app:destination="@id/balanceFragment"
+ app:launchSingleTop="true"
+ app:popUpTo="@+id/balanceFragment" />
+ </fragment>
+
+ <fragment
+ android:id="@+id/errorFragment"
+ android:name="net.taler.cashier.withdraw.ErrorFragment"
+ tools:layout="@layout/fragment_error" />
+
+ <action
+ android:id="@+id/action_global_configFragment"
+ app:destination="@id/configFragment"
+ app:launchSingleTop="true" />
+
+</navigation>
diff --git a/cashier/src/main/res/values-night/colors.xml b/cashier/src/main/res/values-night/colors.xml
new file mode 100644
index 0000000..55dde58
--- /dev/null
+++ b/cashier/src/main/res/values-night/colors.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ This file is part of GNU Taler
+ ~ (C) 2020 Taler Systems S.A.
+ ~
+ ~ GNU Taler is free software; you can redistribute it and/or modify it under the
+ ~ terms of the GNU General Public License as published by the Free Software
+ ~ Foundation; either version 3, or (at your option) any later version.
+ ~
+ ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU General Public License along with
+ ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ -->
+
+<resources>
+ <color name="background">#222222</color>
+</resources>
diff --git a/cashier/src/main/res/values/colors.xml b/cashier/src/main/res/values/colors.xml
new file mode 100644
index 0000000..61338da
--- /dev/null
+++ b/cashier/src/main/res/values/colors.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <color name="colorPrimary">#1565C0</color>
+ <color name="colorPrimaryDark">#6A1B9A</color>
+ <color name="colorAccent">#D81B60</color>
+
+ <color name="background">#F1F1F1</color>
+ <color name="green">#388E3C</color>
+ <color name="red">#D32F2F</color>
+</resources>
diff --git a/cashier/src/main/res/values/dimens.xml b/cashier/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..9d9d85a
--- /dev/null
+++ b/cashier/src/main/res/values/dimens.xml
@@ -0,0 +1,3 @@
+<resources>
+ <dimen name="default_margin">16dp</dimen>
+</resources>
diff --git a/cashier/src/main/res/values/ic_launcher_background.xml b/cashier/src/main/res/values/ic_launcher_background.xml
new file mode 100644
index 0000000..3862264
--- /dev/null
+++ b/cashier/src/main/res/values/ic_launcher_background.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <color name="ic_launcher_background">#1565C0</color>
+</resources> \ No newline at end of file
diff --git a/cashier/src/main/res/values/strings.xml b/cashier/src/main/res/values/strings.xml
new file mode 100644
index 0000000..5df5bfa
--- /dev/null
+++ b/cashier/src/main/res/values/strings.xml
@@ -0,0 +1,39 @@
+<resources>
+ <string name="app_name">Taler Cashier</string>
+
+ <string name="config_bank_url">Bank API address</string>
+ <string name="config_username">Username</string>
+ <string name="config_password">Password</string>
+ <string name="config_button_save">Save</string>
+ <string name="config_bank_url_error">The address in invalid.</string>
+ <string name="config_username_error">Please enter your username</string>
+ <string name="config_error">Error retrieving configuration</string>
+ <string name="config_error_auth">Invalid username or password</string>
+ <string name="config_demo_hint">For testing, you can <![CDATA[<a href="%s">create a test account at the demo bank</a>]]>.</string>
+
+ <string name="balance_current_label">Current balance</string>
+ <string name="balance_error">ERROR</string>
+ <string name="balance_offline">Offline. Please connect to the Internet</string>
+ <string name="action_reconfigure">Reconfigure</string>
+ <string name="action_lock">Lock</string>
+
+ <string name="withdraw_input_amount">Amount</string>
+ <string name="withdraw_into">How much e-cash should be withdrawn?</string>
+ <string name="withdraw_error_zero">Enter positive amount</string>
+ <string name="withdraw_error_insufficient_balance">Insufficient balance</string>
+ <string name="withdraw_error_fetch">Error communicating with bank</string>
+ <string name="withdraw_button_confirm">Withdraw</string>
+
+ <string name="transaction_intro">Scan code\nwith the Taler wallet app\nto get</string>
+ <string name="transaction_intro_nfc">Scan code or use NFC\nwith the Taler wallet app\nto get</string>
+ <string name="transaction_intro_scanned">Please confirm the transaction!</string>
+ <string name="transaction_confirm">Confirm</string>
+ <string name="transaction_abort">Abort</string>
+ <string name="transaction_error">Transaction error</string>
+ <string name="transaction_aborted">Transaction aborted</string>
+ <string name="transaction_button_back">Go back</string>
+ <string name="transaction_last_success">Last Transaction: %s withdrawn</string>
+ <string name="transaction_last_aborted">Last Transaction: Aborted</string>
+ <string name="transaction_last_error">Last Transaction: Error</string>
+
+</resources>
diff --git a/cashier/src/main/res/values/styles.xml b/cashier/src/main/res/values/styles.xml
new file mode 100644
index 0000000..4339684
--- /dev/null
+++ b/cashier/src/main/res/values/styles.xml
@@ -0,0 +1,28 @@
+<resources>
+
+ <style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
+ <item name="colorPrimary">@color/colorPrimary</item>
+ <item name="colorOnPrimary">@color/design_default_color_background</item>
+ <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+ <item name="colorSecondary">@color/colorAccent</item>
+ <item name="colorOnSecondary">@color/design_default_color_background</item>
+ <item name="colorAccent">@color/colorAccent</item>
+ </style>
+
+ <style name="AppTheme.NoActionBar">
+ <item name="windowActionBar">false</item>
+ <item name="windowNoTitle">true</item>
+ </style>
+
+ <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.MaterialComponents.ActionBar" />
+
+ <style name="AppTheme.Toolbar" parent="Widget.MaterialComponents.Toolbar.Primary" />
+
+ <style name="AmountButton" parent="Widget.MaterialComponents.Button">
+ <item name="android:minWidth">48dp</item>
+ <item name="android:layout_marginStart">@dimen/default_margin</item>
+ <item name="android:layout_marginEnd">@dimen/default_margin</item>
+ <item name="android:layout_marginTop">16dp</item>
+ </style>
+
+</resources>
diff --git a/cashier/src/main/res/xml/backup_descriptor.xml b/cashier/src/main/res/xml/backup_descriptor.xml
new file mode 100644
index 0000000..a298494
--- /dev/null
+++ b/cashier/src/main/res/xml/backup_descriptor.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ This file is part of GNU Taler
+ ~ (C) 2020 Taler Systems S.A.
+ ~
+ ~ GNU Taler is free software; you can redistribute it and/or modify it under the
+ ~ terms of the GNU General Public License as published by the Free Software
+ ~ Foundation; either version 3, or (at your option) any later version.
+ ~
+ ~ GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ ~ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ ~ A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ ~
+ ~ You should have received a copy of the GNU General Public License along with
+ ~ GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ -->
+
+<full-backup-content>
+
+</full-backup-content>