commit 676830530256e89674419a2d1555b5483fed2c52 parent a4ac5cdbbddd4c490d5802cf28cab93ab78912e6 Author: Joel-Haeberli <haebu@rubigen.ch> Date: Sun, 2 Jun 2024 13:47:17 +0200 release: wallee terminal app Diffstat:
8 files changed, 53 insertions(+), 38 deletions(-)
diff --git a/wallee-c2ec/app/release/app-release.apk b/wallee-c2ec/app/release/app-release.apk Binary files differ. diff --git a/wallee-c2ec/app/release/baselineProfiles/0/app-release.dm b/wallee-c2ec/app/release/baselineProfiles/0/app-release.dm Binary files differ. diff --git a/wallee-c2ec/app/release/baselineProfiles/1/app-release.dm b/wallee-c2ec/app/release/baselineProfiles/1/app-release.dm Binary files differ. diff --git a/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/withdrawal/AmountScreen.kt b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/withdrawal/AmountScreen.kt @@ -51,14 +51,14 @@ fun AmountScreen( ) ) - Text(text = "fees: ${uiState.withdrawalFees}") + Text(text = "fees: ${if (uiState.withdrawalFees.currency == "") "" else uiState.withdrawalFees}") - Text(text = "total: ${uiState.amount.plus(uiState.withdrawalFees)}") + Text(text = "total: ${if (uiState.withdrawalFees.currency == "") "" else uiState.amount.plus(uiState.withdrawalFees)}") Button(onClick = { println("clicked 'pay'") model.setupWithdrawal(activity, navigateToWhenAmountEntered) - }, enabled = model.validAmount(uiState.amountStr)) { + }, enabled = model.validAmount(uiState.amountStr) && uiState.withdrawalFees.currency != "") { Text(text = "withdraw") } diff --git a/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/withdrawal/ManageActivity.kt b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/withdrawal/ManageActivity.kt @@ -9,6 +9,7 @@ import androidx.compose.material3.Button import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Surface import androidx.compose.material3.Text +import androidx.compose.runtime.mutableStateOf import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import ch.bfh.habej2.wallee_c2ec.client.wallee.WalleeResponseHandler @@ -32,7 +33,9 @@ class ManageActivity : ComponentActivity() { companion object { - var SIM_WALLET_ENABLED = false + var SIM_WALLET_ENABLED = mutableStateOf(false) + + var INSTANT_SETTLEMENT_ENABLED = mutableStateOf(false) private data class Reg( @Json(name = "reserve_pub") val reservePubKey: String, @@ -85,16 +88,19 @@ class ManageActivity : ComponentActivity() { Text(text = "Execute Final Balance") } - TestTransactionScreen(walleeClient) + //TestTransactionScreen(walleeClient) - Button(onClick = { - SIM_WALLET_ENABLED = !SIM_WALLET_ENABLED - println("toggle sim wallet: $SIM_WALLET_ENABLED") + Button(onClick = { + SIM_WALLET_ENABLED.value = !SIM_WALLET_ENABLED.value }) { - Text(text = "toggle wallet simulation") + Text(text = "${if (SIM_WALLET_ENABLED.value) "disable" else "enable"} wallet simulation") } - Text(text = "sim wallet enabled? $SIM_WALLET_ENABLED") + Button(onClick = { + INSTANT_SETTLEMENT_ENABLED.value = !INSTANT_SETTLEMENT_ENABLED.value + }) { + Text(text = "${if (INSTANT_SETTLEMENT_ENABLED.value) "disable" else "enable"} instant settlement") + } Button(onClick = { onDestroy() diff --git a/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/withdrawal/RegisterParametersScreen.kt b/wallee-c2ec/app/src/main/java/ch/bfh/habej2/wallee_c2ec/withdrawal/RegisterParametersScreen.kt @@ -46,7 +46,7 @@ fun RegisterParametersScreen( AbortButton(model = model, activity = activity) Button(onClick = { - if (ManageActivity.SIM_WALLET_ENABLED) { + if (ManageActivity.SIM_WALLET_ENABLED.value) { ManageActivity.simulateParameterRegistration( uiState.terminalsApiBasePath, uiState.encodedWopid 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 @@ -7,12 +7,14 @@ import androidx.activity.compose.setContent import androidx.compose.foundation.background import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.width import androidx.compose.material3.Button import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.platform.LocalConfiguration import androidx.compose.ui.unit.dp import ch.bfh.habej2.wallee_c2ec.MainActivity import ch.bfh.habej2.wallee_c2ec.client.taler.TerminalClientImplementation @@ -44,35 +46,38 @@ class SummaryActivity : ComponentActivity() { super.onCreate(savedInstanceState) setContent { - if (summary.success) { - Column( - verticalArrangement = Arrangement.Center, - horizontalAlignment = Alignment.CenterHorizontally - ) { - Text( - text = "Amount authorized", - color = Color.Yellow, - modifier = Modifier.background(color = Color.Black) - ) - Text(text = "Summary") - Text(text = "Amount: ${summary.amount.toString(true)}") - Text(text = "Fees: ${summary.fees.toString(true)}") - // Text(text = "Withdrawal Operation ID (QR Code):") - // QRCode(qrCodeContent = summary.encodedWopid, 2.dp) + val configuration = LocalConfiguration.current + if (summary.success) { + Column( + Modifier.width(configuration.screenWidthDp.dp), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally + ) { + Text( + text = "Amount authorized", + color = Color.Yellow, + modifier = Modifier.background(color = Color.Black) + ) + Text(text = "Summary") + Text(text = "Amount: ${summary.amount.toString(true)}") + Text(text = "Fees: ${summary.fees.toString(true)}") + // Text(text = "Withdrawal Operation ID (QR Code):") + // QRCode(qrCodeContent = summary.encodedWopid, 2.dp) - finishButton() - } - } else { - Column( - verticalArrangement = Arrangement.Center, - horizontalAlignment = Alignment.CenterHorizontally - ) { - Text(text = "Failed authorizing payment.") - Text(text = "Withdrawal aborted.") + finishButton() + } + } else { + Column( + Modifier.width(configuration.screenWidthDp.dp), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally + ) { + Text(text = "Failed authorizing payment.") + Text(text = "Withdrawal aborted.") - finishButton() - } + finishButton() } + } } } 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 @@ -234,6 +234,10 @@ class WithdrawalViewModel( _uiState.value.transactionState = TransactionState.COMPLETED _uiState.value.transactionCompletion = completion + if (ManageActivity.INSTANT_SETTLEMENT_ENABLED.value) { + walleeClient.executeFinalBalance() + } + confirmationRequest(activity) } @@ -263,7 +267,7 @@ class WithdrawalViewModel( _uiState.value.encodedWopid, TerminalWithdrawalConfirmationRequest( _uiState.value.encodedWopid, - TerminalClient.FormatAmount(Amount(_uiState.value.currency, 0,0)) + _uiState.value.withdrawalFees.toJSONString() ) ) { if (!it) {