diff options
Diffstat (limited to 'wallet/src/main/java/net/taler')
3 files changed, 43 insertions, 5 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") |