gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-cashless2ecash] branch master updated: fix: summary screen


From: gnunet
Subject: [taler-cashless2ecash] branch master updated: fix: summary screen
Date: Mon, 13 May 2024 00:18:06 +0200

This is an automated email from the git hooks/post-receive script.

joel-haeberli pushed a commit to branch master
in repository cashless2ecash.

The following commit(s) were added to refs/heads/master by this push:
     new e256cb0  fix: summary screen
e256cb0 is described below

commit e256cb05972af22b9121efca2a7251030b021784
Author: Joel-Haeberli <haebu@rubigen.ch>
AuthorDate: Mon May 13 00:17:56 2024 +0200

    fix: summary screen
---
 .../withdrawal/ExchangeSelectionScreen.kt          |  4 +-
 .../wallee_c2ec/withdrawal/SummaryActivity.kt      | 44 +++++++++++++---------
 .../wallee_c2ec/withdrawal/WithdrawalViewModel.kt  |  9 +++--
 3 files changed, 34 insertions(+), 23 deletions(-)

diff --git 
a/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/withdrawal/ExchangeSelectionScreen.kt
 
b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/withdrawal/ExchangeSelectionScreen.kt
index 24d0df9..0385086 100644
--- 
a/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/withdrawal/ExchangeSelectionScreen.kt
+++ 
b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/withdrawal/ExchangeSelectionScreen.kt
@@ -21,8 +21,8 @@ val exchanges = listOf(
     TalerTerminalConfig(
         "KUDOS Exchange (BFH)",
         "http://taler-c2ec.ti.bfh.ch";,
-        "Wallee-2",
-        "1A92pgloFR8WIgr0LDA+s9hbkO4EgyJlHj+3dQ9IJ9U="
+        "Wallee-3",
+        "YHrpzeHUyybGT5gOY9VAiZ7QAV/icOXtHPRKZTXv2n8="
     ),
 
     TalerTerminalConfig(
diff --git 
a/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/withdrawal/SummaryActivity.kt
 
b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/withdrawal/SummaryActivity.kt
index 88c9ccb..79128f4 100644
--- 
a/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/withdrawal/SummaryActivity.kt
+++ 
b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/withdrawal/SummaryActivity.kt
@@ -20,18 +20,14 @@ data class Summary(
     @Json(name = "amount") val amount: Amount,
     @Json(name = "fees") val fees: Amount,
     @Json(name = "currency") val currency: String,
-    @Json(name = "encodedWopid") val encodedWopid: String
+    @Json(name = "encodedWopid") val encodedWopid: String,
+    var success: Boolean = true
 )
 
 class SummaryActivity: ComponentActivity() {
 
     companion object {
-        var summary: Summary = Summary(
-            Amount(0,0),
-            Amount(0,0),
-            "",
-            ""
-        )
+        var summary: Summary = reset()
 
         private fun reset(): Summary = Summary(
             Amount(0,0),
@@ -49,19 +45,31 @@ class SummaryActivity: ComponentActivity() {
             Column (
                 horizontalAlignment = Alignment.CenterHorizontally
             ) {
-                Text(
-                    text = "Amount authorized",
-                    color = Color.Yellow,
-                    modifier = Modifier.background(color = Color.Black)
-                )
-                Text(text = "Summary")
-                Text(text = "Withdrawable Amount: ${summary.amount} 
${summary.currency}")
-                Text(text = "Fees: ${summary.fees} ${summary.currency}")
-                Text(text = "Withdrawal Operation ID (QR Code):")
-                QRCode(qrCodeContent = summary.encodedWopid, 2.dp)
+
+                if (summary.success) {
+                    Text(
+                        text = "Amount authorized",
+                        color = Color.Yellow,
+                        modifier = Modifier.background(color = Color.Black)
+                    )
+                    Text(text = "Summary")
+                    Text(text = "Withdrawable Amount: ${summary.amount} 
${summary.currency}")
+                    Text(text = "Fees: ${summary.fees} ${summary.currency}")
+                    Text(text = "Withdrawal Operation ID (QR Code):")
+                    QRCode(qrCodeContent = summary.encodedWopid, 2.dp)
+                } else {
+
+                    Text(text = "Failed processing transaction.")
+                    Text(text = "Withdrawal aborted.")
+                }
 
                 Button(onClick = {
-                    this@SummaryActivity.startActivity(Intent(baseContext, 
MainActivity::class.java))
+                    this@SummaryActivity.startActivity(
+                        Intent(
+                            baseContext,
+                            MainActivity::class.java
+                        )
+                    )
                     reset()
                     finish()
                 }) {
diff --git 
a/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/withdrawal/WithdrawalViewModel.kt
 
b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/withdrawal/WithdrawalViewModel.kt
index ed7148a..191e417 100644
--- 
a/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/withdrawal/WithdrawalViewModel.kt
+++ 
b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/withdrawal/WithdrawalViewModel.kt
@@ -2,13 +2,11 @@ package ch.bfh.habej2.wallee_c2ec.withdrawal
 
 import android.app.Activity
 import android.content.Intent
-import android.os.Bundle
 import androidx.compose.runtime.Stable
 import androidx.compose.runtime.derivedStateOf
 import androidx.compose.runtime.getValue
 import androidx.compose.runtime.mutableStateOf
 import androidx.compose.runtime.setValue
-import androidx.compose.ui.platform.LocalContext
 import androidx.lifecycle.ViewModel
 import androidx.lifecycle.viewModelScope
 import ch.bfh.habej2.wallee_c2ec.client.taler.TerminalClient
@@ -195,6 +193,7 @@ class WithdrawalViewModel(
         println("authorization state: ${_uiState.value.transactionState}")
         if (_uiState.value.transactionState == 
TransactionState.AUTHORIZATION_FAILED) {
             println("authorization failed... aborting withdrawal")
+            withdrawalOperationFailed()
             return
         }
 
@@ -245,7 +244,7 @@ class WithdrawalViewModel(
             terminalClient!!.sendConfirmationRequest(
                 _uiState.value.encodedWopid,
                 TerminalWithdrawalConfirmationRequest(
-                    _uiState.value.encodedWopid,
+                    _uiState.value.transactionId,
                     Amount(0, 0)
                 )
             ) {
@@ -282,6 +281,10 @@ class WithdrawalViewModel(
     fun withdrawalOperationFailed() {
         viewModelScope.launch {
             terminalClient!!.abortWithdrawal(uiState.value.encodedWopid) {}
+            SummaryActivity.summary.success = false
+            val activity = WithdrawalActivity()
+            val intent = Intent(activity, SummaryActivity::class.java)
+            activity.startActivity(intent)
         }
     }
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]