[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-android] branch master updated (0bf92f7 -> 6622f7d)
From: |
gnunet |
Subject: |
[taler-taler-android] branch master updated (0bf92f7 -> 6622f7d) |
Date: |
Tue, 17 Jan 2023 16:24:22 +0100 |
This is an automated email from the git hooks/post-receive script.
torsten-grote pushed a change to branch master
in repository taler-android.
from 0bf92f7 [cashier] Trim URL and credentials in ConfigFragment
new 9049e30 [wallet] Initial implementation of KYC handling
new 6622f7d [wallet] Clean up KYC handling a bit
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
wallet/src/main/java/net/taler/wallet/Utils.kt | 12 ++++++++++++
.../java/net/taler/wallet/backend/WalletResponse.kt | 3 +++
.../taler/wallet/transactions/TransactionAdapter.kt | 12 ++++++++++++
.../transactions/TransactionWithdrawalFragment.kt | 21 ++++++++++++++++++---
.../wallet/transactions/TransactionsFragment.kt | 12 ++++++++++++
.../net/taler/wallet/withdraw/WithdrawManager.kt | 2 ++
.../res/layout/fragment_transaction_withdrawal.xml | 19 +++++++++++++++++--
.../src/main/res/layout/list_item_transaction.xml | 13 ++++++++++++-
wallet/src/main/res/values/strings.xml | 1 +
9 files changed, 89 insertions(+), 6 deletions(-)
diff --git a/wallet/src/main/java/net/taler/wallet/Utils.kt
b/wallet/src/main/java/net/taler/wallet/Utils.kt
index 7edc694..d5abca2 100644
--- a/wallet/src/main/java/net/taler/wallet/Utils.kt
+++ b/wallet/src/main/java/net/taler/wallet/Utils.kt
@@ -31,6 +31,9 @@ import androidx.annotation.RequiresApi
import androidx.core.content.getSystemService
import net.taler.common.Amount
import net.taler.common.AmountParserException
+import net.taler.wallet.backend.TalerErrorInfo
+import net.taler.wallet.transactions.Transaction
+import net.taler.wallet.withdraw.ERROR_KYC
const val CURRENCY_BTC = "BITCOINBTC"
@@ -96,3 +99,12 @@ fun getAmount(currency: String, text: String): Amount? {
null
}
}
+
+fun <T> Transaction.handleKyc(notRequired: () -> T, required: (TalerErrorInfo)
-> T): T {
+ return error?.let { error ->
+ when (error.code) {
+ ERROR_KYC -> required(error)
+ else -> notRequired()
+ }
+ } ?: notRequired()
+}
diff --git a/wallet/src/main/java/net/taler/wallet/backend/WalletResponse.kt
b/wallet/src/main/java/net/taler/wallet/backend/WalletResponse.kt
index e52fd4f..c87c28c 100644
--- a/wallet/src/main/java/net/taler/wallet/backend/WalletResponse.kt
+++ b/wallet/src/main/java/net/taler/wallet/backend/WalletResponse.kt
@@ -68,6 +68,9 @@ data class TalerErrorInfo(
// Error details
@Serializable(JSONObjectDeserializer::class)
val details: JSONObject? = null,
+
+ // KYC URL (in case KYC is required)
+ val kycUrl: String? = null,
) {
val userFacingMsg: String
get() {
diff --git
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt
index b11f438..fa30f5c 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionAdapter.kt
@@ -32,9 +32,11 @@ import androidx.recyclerview.selection.SelectionTracker
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.Adapter
import androidx.recyclerview.widget.RecyclerView.ViewHolder
+import com.google.android.material.button.MaterialButton
import net.taler.common.exhaustive
import net.taler.common.toRelativeTime
import net.taler.wallet.R
+import net.taler.wallet.handleKyc
import net.taler.wallet.transactions.TransactionAdapter.TransactionViewHolder
internal class TransactionAdapter(
@@ -78,6 +80,7 @@ internal class TransactionAdapter(
private val icon: ImageView = v.findViewById(R.id.icon)
private val title: TextView = v.findViewById(R.id.title)
private val extraInfoView: TextView =
v.findViewById(R.id.extraInfoView)
+ private val actionButton: MaterialButton =
v.findViewById(R.id.actionButton)
private val time: TextView = v.findViewById(R.id.time)
private val amount: TextView = v.findViewById(R.id.amount)
private val pendingView: TextView = v.findViewById(R.id.pendingView)
@@ -95,6 +98,7 @@ internal class TransactionAdapter(
}
title.text = transaction.getTitle(context)
bindExtraInfo(transaction)
+ bindActionButton(transaction)
time.text = transaction.timestamp.ms.toRelativeTime(context)
bindAmount(transaction)
pendingView.visibility = if (transaction.pending) VISIBLE else GONE
@@ -123,6 +127,14 @@ internal class TransactionAdapter(
}
}
+ private fun bindActionButton(transaction: Transaction) {
+ actionButton.visibility = transaction.handleKyc({ GONE }) {
+ actionButton.setOnClickListener {
listener.onActionButtonClicked(transaction) }
+ actionButton.setText(R.string.transaction_action_kyc)
+ VISIBLE
+ }
+ }
+
private fun bindAmount(transaction: Transaction) {
val amountStr = transaction.amountEffective.amountStr
when (transaction.amountType) {
diff --git
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionWithdrawalFragment.kt
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionWithdrawalFragment.kt
index ff8d272..31c70b5 100644
---
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionWithdrawalFragment.kt
+++
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionWithdrawalFragment.kt
@@ -22,6 +22,8 @@ import android.net.Uri
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
+import android.view.View.GONE
+import android.view.View.VISIBLE
import android.view.ViewGroup
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
@@ -31,6 +33,7 @@ import net.taler.wallet.MainViewModel
import net.taler.wallet.R
import net.taler.wallet.cleanExchange
import net.taler.wallet.databinding.FragmentTransactionWithdrawalBinding
+import net.taler.wallet.handleKyc
import net.taler.wallet.transactions.WithdrawalDetails.ManualTransfer
import net.taler.wallet.transactions.WithdrawalDetails.TalerBankIntegrationApi
import net.taler.wallet.withdraw.createManualTransferRequired
@@ -57,6 +60,7 @@ class TransactionWithdrawalFragment :
TransactionDetailFragment() {
ui.effectiveAmountLabel.text = getString(R.string.withdraw_total)
ui.effectiveAmountView.text = t.amountEffective.toString()
setupConfirmWithdrawalButton(t)
+ setupActionButton(t)
ui.chosenAmountLabel.text = getString(R.string.amount_chosen)
ui.chosenAmountView.text =
getString(R.string.amount_positive, t.amountRaw.toString())
@@ -101,10 +105,21 @@ class TransactionWithdrawalFragment :
TransactionDetailFragment() {
)
withdrawManager.viewManualWithdrawal(status)
findNavController().navigate(
-
R.id.action_nav_transactions_detail_withdrawal_to_nav_exchange_manual_withdrawal_success)
+
R.id.action_nav_transactions_detail_withdrawal_to_nav_exchange_manual_withdrawal_success
+ )
}
- } else ui.confirmWithdrawalButton.visibility = View.GONE
- } else ui.confirmWithdrawalButton.visibility = View.GONE
+ } else ui.confirmWithdrawalButton.visibility = GONE
+ } else ui.confirmWithdrawalButton.visibility = GONE
}
+ private fun setupActionButton(t: TransactionWithdrawal) {
+ ui.actionButton.visibility = t.handleKyc({ GONE }) {
+ ui.actionButton.setText(R.string.transaction_action_kyc)
+ val i = Intent(ACTION_VIEW).apply {
+ data = Uri.parse(it.kycUrl)
+ }
+ ui.actionButton.setOnClickListener { startActivitySafe(i) }
+ VISIBLE
+ }
+ }
}
diff --git
a/wallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt
b/wallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt
index 969b0de..20da36b 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionsFragment.kt
@@ -16,6 +16,8 @@
package net.taler.wallet.transactions
+import android.content.Intent
+import android.net.Uri
import android.os.Bundle
import android.view.ActionMode
import android.view.LayoutInflater
@@ -39,12 +41,15 @@ import
androidx.recyclerview.widget.LinearLayoutManager.VERTICAL
import net.taler.common.Amount
import net.taler.common.fadeIn
import net.taler.common.fadeOut
+import net.taler.common.startActivitySafe
import net.taler.wallet.MainViewModel
import net.taler.wallet.R
import net.taler.wallet.databinding.FragmentTransactionsBinding
+import net.taler.wallet.handleKyc
interface OnTransactionClickListener {
fun onTransactionClicked(transaction: Transaction)
+ fun onActionButtonClicked(transaction: Transaction)
}
class TransactionsFragment : Fragment(), OnTransactionClickListener,
ActionMode.Callback {
@@ -177,6 +182,13 @@ class TransactionsFragment : Fragment(),
OnTransactionClickListener, ActionMode.
}
}
+ override fun onActionButtonClicked(transaction: Transaction) {
+ transaction.handleKyc({ error("Unhandled Action Button Event") }) {
+ val i = Intent(Intent.ACTION_VIEW, Uri.parse(it.kycUrl))
+ startActivitySafe(i)
+ }
+ }
+
private fun onTransactionsResult(result: TransactionsResult) = when
(result) {
is TransactionsResult.Error -> {
ui.list.fadeOut()
diff --git a/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt
b/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt
index 1698a10..326c9d8 100644
--- a/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt
+++ b/wallet/src/main/java/net/taler/wallet/withdraw/WithdrawManager.kt
@@ -35,6 +35,8 @@ import net.taler.wallet.exchanges.ExchangeFees
import net.taler.wallet.exchanges.ExchangeItem
import net.taler.wallet.withdraw.WithdrawStatus.ReceivedDetails
+const val ERROR_KYC = 7025
+
sealed class WithdrawStatus {
data class Loading(val talerWithdrawUri: String? = null) : WithdrawStatus()
data class NeedsExchange(val exchangeSelection: Event<ExchangeSelection>)
: WithdrawStatus()
diff --git a/wallet/src/main/res/layout/fragment_transaction_withdrawal.xml
b/wallet/src/main/res/layout/fragment_transaction_withdrawal.xml
index 78d1667..783b2d9 100644
--- a/wallet/src/main/res/layout/fragment_transaction_withdrawal.xml
+++ b/wallet/src/main/res/layout/fragment_transaction_withdrawal.xml
@@ -62,19 +62,33 @@
android:drawableLeft="@drawable/ic_account_balance"
android:text="@string/withdraw_button_confirm_bank"
app:drawableTint="?attr/colorOnPrimarySurface"
- app:layout_constraintBottom_toTopOf="@+id/chosenAmountLabel"
+ app:layout_constraintBottom_toTopOf="@+id/actionButton"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/effectiveAmountView"
tools:ignore="RtlHardcoded" />
+ <Button
+ android:id="@+id/actionButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginVertical="10dp"
+ android:backgroundTint="@color/colorAccent"
+ android:visibility="gone"
+ app:layout_constraintBottom_toTopOf="@id/chosenAmountLabel"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@id/confirmWithdrawalButton"
+ tools:text="@string/transaction_action_kyc"
+ tools:visibility="visible" />
+
<TextView
android:id="@+id/chosenAmountLabel"
style="@style/TransactionLabel"
app:layout_constraintBottom_toTopOf="@+id/chosenAmountView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/confirmWithdrawalButton"
+ app:layout_constraintTop_toBottomOf="@+id/actionButton"
tools:text="@string/amount_chosen" />
<TextView
@@ -127,6 +141,7 @@
android:id="@+id/deleteButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
+ android:layout_marginVertical="10dp"
android:text="@string/transactions_delete"
app:backgroundTint="@color/red"
app:icon="@drawable/ic_delete"
diff --git a/wallet/src/main/res/layout/list_item_transaction.xml
b/wallet/src/main/res/layout/list_item_transaction.xml
index 64d9045..232afb8 100644
--- a/wallet/src/main/res/layout/list_item_transaction.xml
+++ b/wallet/src/main/res/layout/list_item_transaction.xml
@@ -62,6 +62,17 @@
tools:text="@string/withdraw_waiting_confirm"
tools:visibility="visible" />
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/actionButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:visibility="gone"
+ app:backgroundTint="@color/colorAccent"
+ app:layout_constraintStart_toStartOf="@id/title"
+ app:layout_constraintTop_toBottomOf="@id/extraInfoView"
+ tools:text="Complete KYC"
+ tools:visibility="visible"/>
+
<TextView
android:id="@+id/time"
android:layout_width="0dp"
@@ -72,7 +83,7 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/barrier"
app:layout_constraintStart_toStartOf="@+id/title"
- app:layout_constraintTop_toBottomOf="@+id/extraInfoView"
+ app:layout_constraintTop_toBottomOf="@+id/actionButton"
tools:text="23 min ago" />
<androidx.constraintlayout.widget.Barrier
diff --git a/wallet/src/main/res/values/strings.xml
b/wallet/src/main/res/values/strings.xml
index 51c2ff3..52dacfe 100644
--- a/wallet/src/main/res/values/strings.xml
+++ b/wallet/src/main/res/values/strings.xml
@@ -105,6 +105,7 @@ GNU Taler is immune against many types of fraud, such as
phishing of credit card
<string name="transaction_peer_pull_credit">Invoice</string>
<string name="transaction_peer_pull_debit">Invoice paid</string>
<string name="transaction_peer_push_credit">Push payment</string>
+ <string name="transaction_action_kyc">Complete KYC</string>
<string name="payment_title">Payment</string>
<string name="payment_fee">+%s payment fee</string>
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-android] branch master updated (0bf92f7 -> 6622f7d),
gnunet <=