aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wallet/src/main/java/net/taler/wallet/MainActivity.kt3
-rw-r--r--wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt5
-rw-r--r--wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt40
-rw-r--r--wallet/src/main/res/navigation/nav_graph.xml7
4 files changed, 47 insertions, 8 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/MainActivity.kt b/wallet/src/main/java/net/taler/wallet/MainActivity.kt
index a048446..fdb8cf8 100644
--- a/wallet/src/main/java/net/taler/wallet/MainActivity.kt
+++ b/wallet/src/main/java/net/taler/wallet/MainActivity.kt
@@ -158,7 +158,8 @@ class MainActivity : AppCompatActivity(), OnNavigationItemSelectedListener,
}
url.toLowerCase(ROOT).startsWith("taler://withdraw/") -> {
Log.v(TAG, "navigating!")
- nav.navigate(R.id.action_nav_main_to_promptWithdraw)
+ // there's more than one entry point, so use global action
+ nav.navigate(R.id.action_global_promptWithdraw)
model.withdrawManager.getWithdrawalInfo(url)
}
url.toLowerCase(ROOT).startsWith("taler://refund/") -> {
diff --git a/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt b/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
index f78d98f..0142978 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
@@ -41,6 +41,7 @@ import net.taler.common.toAbsoluteTime
import net.taler.wallet.MainViewModel
import net.taler.wallet.R
import net.taler.wallet.cleanExchange
+import net.taler.wallet.transactions.WithdrawalDetails.TalerBankIntegrationApi
class TransactionDetailFragment : Fragment() {
@@ -95,9 +96,9 @@ class TransactionDetailFragment : Fragment() {
private fun bind(t: TransactionWithdrawal) {
effectiveAmountLabel.text = getString(R.string.withdraw_total)
effectiveAmountView.text = t.amountEffective.toString()
- if (t.pending && !t.confirmed && t.bankConfirmationUrl != null) {
+ if (t.pending && t.withdrawalDetails is TalerBankIntegrationApi && !t.confirmed && t.withdrawalDetails.bankConfirmationUrl != null) {
val i = Intent().apply {
- data = Uri.parse(t.bankConfirmationUrl)
+ data = Uri.parse(t.withdrawalDetails.bankConfirmationUrl)
}
if (i.isSafe(requireContext())) {
confirmWithdrawalButton.setOnClickListener { startActivity(i) }
diff --git a/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt b/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt
index 27384d8..ccc40eb 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt
@@ -33,6 +33,8 @@ import net.taler.common.ContractProduct
import net.taler.common.Timestamp
import net.taler.wallet.R
import net.taler.wallet.cleanExchange
+import net.taler.wallet.transactions.WithdrawalDetails.ManualTransfer
+import net.taler.wallet.transactions.WithdrawalDetails.TalerBankIntegrationApi
@JsonTypeInfo(use = NAME, include = PROPERTY, property = "type")
@JsonSubTypes(
@@ -80,8 +82,7 @@ class TransactionWithdrawal(
timestamp: Timestamp,
pending: Boolean,
val exchangeBaseUrl: String,
- val confirmed: Boolean,
- val bankConfirmationUrl: String?,
+ val withdrawalDetails: WithdrawalDetails,
error: TransactionError? = null,
amountRaw: Amount,
amountEffective: Amount
@@ -91,6 +92,41 @@ class TransactionWithdrawal(
override val amountType = AmountType.Positive
override fun getTitle(context: Context) = cleanExchange(exchangeBaseUrl)
override val generalTitleRes = R.string.withdraw_title
+ val confirmed: Boolean =
+ withdrawalDetails is TalerBankIntegrationApi && withdrawalDetails.confirmed
+}
+
+@JsonTypeInfo(use = NAME, include = PROPERTY, property = "type")
+@JsonSubTypes(
+ Type(value = TalerBankIntegrationApi::class, name = "taler-bank-integration-api"),
+ Type(value = ManualTransfer::class, name = "manual-transfer")
+)
+sealed class WithdrawalDetails {
+ @JsonTypeName("manual-transfer")
+ class ManualTransfer(
+ /**
+ * Payto URIs that the exchange supports.
+ *
+ * Already contains the amount and message.
+ */
+ val exchangePaytoUris: List<String>
+ ) : WithdrawalDetails()
+
+ @JsonTypeName("taler-bank-integration-api")
+ class TalerBankIntegrationApi(
+ /**
+ * Set to true if the bank has confirmed the withdrawal, false if not.
+ * An unconfirmed withdrawal usually requires user-input
+ * and should be highlighted in the UI.
+ * See also bankConfirmationUrl below.
+ */
+ val confirmed: Boolean,
+
+ /**
+ * If the withdrawal is unconfirmed, this can include a URL for user-initiated confirmation.
+ */
+ val bankConfirmationUrl: String?
+ ) : WithdrawalDetails()
}
@JsonTypeName("payment")
diff --git a/wallet/src/main/res/navigation/nav_graph.xml b/wallet/src/main/res/navigation/nav_graph.xml
index 1242857..c9a98f0 100644
--- a/wallet/src/main/res/navigation/nav_graph.xml
+++ b/wallet/src/main/res/navigation/nav_graph.xml
@@ -29,9 +29,6 @@
android:id="@+id/action_nav_main_to_promptPayment"
app:destination="@id/promptPayment" />
<action
- android:id="@+id/action_nav_main_to_promptWithdraw"
- app:destination="@id/promptWithdraw" />
- <action
android:id="@+id/action_nav_main_to_nav_transactions"
app:destination="@id/nav_transactions" />
<action
@@ -165,6 +162,10 @@
tools:layout="@layout/fragment_error" />
<action
+ android:id="@+id/action_global_promptWithdraw"
+ app:destination="@id/promptWithdraw" />
+
+ <action
android:id="@+id/action_global_promptPayment"
app:destination="@id/promptPayment" />