aboutsummaryrefslogtreecommitdiff
path: root/wallet
diff options
context:
space:
mode:
Diffstat (limited to 'wallet')
-rw-r--r--wallet/build.gradle4
-rw-r--r--wallet/src/main/java/net/taler/wallet/MainActivity.kt25
-rw-r--r--wallet/src/main/java/net/taler/wallet/MainViewModel.kt2
-rw-r--r--wallet/src/main/java/net/taler/wallet/refund/RefundManager.kt35
-rw-r--r--wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt7
-rw-r--r--wallet/src/main/java/net/taler/wallet/transactions/TransactionManager.kt2
-rw-r--r--wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt7
-rw-r--r--wallet/src/main/res/values-fr/strings.xml2
-rw-r--r--wallet/src/main/res/values/strings.xml2
9 files changed, 58 insertions, 28 deletions
diff --git a/wallet/build.gradle b/wallet/build.gradle
index 329e271..da3f9a8 100644
--- a/wallet/build.gradle
+++ b/wallet/build.gradle
@@ -24,7 +24,7 @@ plugins {
id "de.undercouch.download"
}
-def walletCoreVersion = "v0.7.1-dev.19"
+def walletCoreVersion = "v0.7.1-dev.20"
static def versionCodeEpoch() {
return (new Date().getTime() / 1000).toInteger()
@@ -48,7 +48,7 @@ android {
minSdkVersion 24
targetSdkVersion 29
versionCode 6
- versionName "0.7.1.dev.19"
+ versionName "0.7.1.dev.20"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildConfigField "String", "WALLET_CORE_VERSION", "\"$walletCoreVersion\""
}
diff --git a/wallet/src/main/java/net/taler/wallet/MainActivity.kt b/wallet/src/main/java/net/taler/wallet/MainActivity.kt
index c7c31ca..838ed2d 100644
--- a/wallet/src/main/java/net/taler/wallet/MainActivity.kt
+++ b/wallet/src/main/java/net/taler/wallet/MainActivity.kt
@@ -163,15 +163,7 @@ class MainActivity : AppCompatActivity(), OnNavigationItemSelectedListener,
}
url.toLowerCase(ROOT).startsWith("taler://refund/") -> {
model.showProgressBar.value = true
- model.refundManager.refund(url).observe(this, Observer { status ->
- model.showProgressBar.value = false
- val res = when (status) {
- is RefundStatus.Error -> R.string.refund_error
- // TODO once wallet-core exposes currency, navigate to its transaction list
- is RefundStatus.Success -> R.string.refund_success
- }
- Snackbar.make(nav_view, res, LENGTH_LONG).show()
- })
+ model.refundManager.refund(url).observe(this, Observer(::onRefundResponse))
}
else -> {
Snackbar.make(
@@ -183,6 +175,21 @@ class MainActivity : AppCompatActivity(), OnNavigationItemSelectedListener,
}
}
+ private fun onRefundResponse(status: RefundStatus) {
+ model.showProgressBar.value = false
+ when (status) {
+ is RefundStatus.Error -> {
+ Snackbar.make(nav_view, R.string.refund_error, LENGTH_LONG).show()
+ }
+ is RefundStatus.Success -> {
+ val amount = status.response.amountRefundGranted
+ model.showTransactions(amount.currency)
+ val str = getString(R.string.refund_success, amount.amountStr)
+ Snackbar.make(nav_view, str, LENGTH_LONG).show()
+ }
+ }
+ }
+
private val triggerPaymentReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if (nav.currentDestination?.id == R.id.promptPayment) return
diff --git a/wallet/src/main/java/net/taler/wallet/MainViewModel.kt b/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
index 24a8f1e..6249551 100644
--- a/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
+++ b/wallet/src/main/java/net/taler/wallet/MainViewModel.kt
@@ -102,7 +102,7 @@ class MainViewModel(val app: Application) : AndroidViewModel(app) {
val paymentManager = PaymentManager(api, viewModelScope, mapper)
val pendingOperationsManager: PendingOperationsManager = PendingOperationsManager(api)
val transactionManager: TransactionManager = TransactionManager(api, viewModelScope, mapper)
- val refundManager = RefundManager(api)
+ val refundManager = RefundManager(api, viewModelScope)
val exchangeManager: ExchangeManager = ExchangeManager(api, mapper)
private val mTransactionsEvent = MutableLiveData<Event<String>>()
diff --git a/wallet/src/main/java/net/taler/wallet/refund/RefundManager.kt b/wallet/src/main/java/net/taler/wallet/refund/RefundManager.kt
index 5593486..fdacb0d 100644
--- a/wallet/src/main/java/net/taler/wallet/refund/RefundManager.kt
+++ b/wallet/src/main/java/net/taler/wallet/refund/RefundManager.kt
@@ -19,28 +19,43 @@ package net.taler.wallet.refund
import android.util.Log
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.launch
+import kotlinx.serialization.Serializable
+import net.taler.common.Amount
import net.taler.wallet.TAG
import net.taler.wallet.backend.WalletBackendApi
-import org.json.JSONObject
sealed class RefundStatus {
object Error : RefundStatus()
- object Success : RefundStatus()
+ data class Success(val response: RefundResponse) : RefundStatus()
}
-class RefundManager(private val walletBackendApi: WalletBackendApi) {
+@Serializable
+data class RefundResponse(
+ val amountEffectivePaid: Amount,
+ val amountRefundGranted: Amount,
+ val amountRefundGone: Amount,
+ val pendingAtExchange: Boolean
+)
+
+class RefundManager(
+ private val api: WalletBackendApi,
+ private val scope: CoroutineScope
+) {
fun refund(refundUri: String): LiveData<RefundStatus> {
val liveData = MutableLiveData<RefundStatus>()
- val args = JSONObject().also { it.put("talerRefundUri", refundUri) }
- walletBackendApi.sendRequest("applyRefund", args) { isError, result ->
- if (isError) {
- Log.e(TAG, "Refund Error: $result")
+ scope.launch {
+ api.request("applyRefund", RefundResponse.serializer()) {
+ put("talerRefundUri", refundUri)
+ }.onError {
+ Log.e(TAG, "Refund Error: $it")
// TODO show error string
liveData.postValue(RefundStatus.Error)
- } else {
- Log.e(TAG, "Refund Success: $result")
- liveData.postValue(RefundStatus.Success)
+ }.onSuccess {
+ Log.e(TAG, "Refund Success: $it")
+ liveData.postValue(RefundStatus.Success(it))
}
}
return liveData
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 0142978..be83b09 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionDetailFragment.kt
@@ -55,7 +55,8 @@ class TransactionDetailFragment : Fragment() {
}
override fun onCreateView(
- inflater: LayoutInflater, container: ViewGroup?,
+ inflater: LayoutInflater,
+ container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(transaction.detailPageLayout, container, false)
@@ -96,7 +97,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.withdrawalDetails is TalerBankIntegrationApi && !t.confirmed && t.withdrawalDetails.bankConfirmationUrl != null) {
+ if (t.pending && t.withdrawalDetails is TalerBankIntegrationApi &&
+ !t.confirmed && t.withdrawalDetails.bankConfirmationUrl != null
+ ) {
val i = Intent().apply {
data = Uri.parse(t.withdrawalDetails.bankConfirmationUrl)
}
diff --git a/wallet/src/main/java/net/taler/wallet/transactions/TransactionManager.kt b/wallet/src/main/java/net/taler/wallet/transactions/TransactionManager.kt
index b9f86b3..d398f57 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionManager.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionManager.kt
@@ -94,7 +94,7 @@ class TransactionManager(
val transactions: LinkedList<Transaction> = mapper.readValue(transactionsArray)
// TODO remove when fixed in wallet-core
transactions.sortWith(compareBy({ it.pending }, { it.timestamp.ms }, { it.transactionId }))
- transactions.reverse() // show latest first
+ transactions.reverse() // show latest first
mProgress.postValue(false)
liveData.postValue(TransactionsResult.Success(transactions))
// update all transactions on UiThread if there was a currency
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 1ba7e79..08f02fc 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/Transactions.kt
@@ -188,9 +188,14 @@ class TransactionRefund(
pending: Boolean,
val refundedTransactionId: String,
val info: TransactionInfo,
- val amountInvalid: Amount,
+ /**
+ * Part of the refund that couldn't be applied because the refund permissions were expired
+ */
+ val amountInvalid: Amount? = null,
error: TransactionError? = null,
+ @JsonProperty("amountEffective") // TODO remove when fixed in wallet-core
amountRaw: Amount,
+ @JsonProperty("amountRaw") // TODO remove when fixed in wallet-core
amountEffective: Amount
) : Transaction(transactionId, timestamp, pending, error, amountRaw, amountEffective) {
override val icon = R.drawable.transaction_refund
diff --git a/wallet/src/main/res/values-fr/strings.xml b/wallet/src/main/res/values-fr/strings.xml
index a96e23a..3a54659 100644
--- a/wallet/src/main/res/values-fr/strings.xml
+++ b/wallet/src/main/res/values-fr/strings.xml
@@ -80,7 +80,7 @@
<string name="settings_withdraw_testkudos_summary">Obtenez de l\'argent pour les tests</string>
<string name="settings_reset_summary">Détruit votre argent</string>
<string name="refund_error">Erreur lors du traitement du remboursement</string>
- <string name="refund_success">Remboursement reçu</string>
+ <string name="refund_success">Remboursement reçu: %s</string>
<string name="payment_error">Erreur : %s</string>
<string name="google_play_full_desc" tools:keep="@string/google_play_full_desc">Cette application est un portefeuille pour GNU Taler. Elle est très expérimentale et n\'est pas encore prête à être utilisée en production. GNU Taler est un système de paiement préservant la vie privée. Les clients peuvent rester anonymes, mais les commerçants ne peuvent pas cacher leurs revenus par des paiements avec GNU Taler. Cela permet d\'éviter l\'évasion fiscale et le blanchiment d\'argent. Le principal cas d\'utilisation de GNU Taler est celui des paiements ; il ne s\'agit pas d\'une réserve de valeur. Les paiements sont toujours garantis par une devise existante. Les paiements sont effectués après avoir échangé l\'argent existant en monnaie électronique avec l\'aide d\'un service d\'échange, c\'est-à-dire un fournisseur de services de paiement pour le Taler. Pour effectuer un paiement, les clients n\'ont besoin que d\'un portefeuille chargé. Un commerçant peut accepter des paiements sans que ses clients ne s\'inscrivent sur son site web. GNU Taler est immunisé contre de nombreux types de fraude, tels que l\'hameçonnage des informations relatives aux cartes de crédit ou la fraude par rétrofacturation. En cas de perte ou de vol, seule la quantité limitée d\'argent restant dans le portefeuille peut disparaître.</string>
<string name="payment_label_amount_total">Montant total :</string>
diff --git a/wallet/src/main/res/values/strings.xml b/wallet/src/main/res/values/strings.xml
index 1715ab3..a9f6c73 100644
--- a/wallet/src/main/res/values/strings.xml
+++ b/wallet/src/main/res/values/strings.xml
@@ -168,7 +168,7 @@ GNU Taler is immune against many types of fraud, such as phishing of credit card
<string name="refund_title">Refund</string>
<string name="refund_error">Error processing refund</string>
- <string name="refund_success">Refund received</string>
+ <string name="refund_success">Refund received: %s</string>
<string name="tip_title">Tip</string>
<string name="wifi_disabled_error">Turn on Wi-Fi to get free Wi-Fi</string>