aboutsummaryrefslogtreecommitdiff
path: root/wallet
diff options
context:
space:
mode:
authorTorsten Grote <t@grobox.de>2023-01-03 12:35:33 -0300
committerTorsten Grote <t@grobox.de>2023-01-03 12:35:33 -0300
commit5764a5c9228cf25662da697668a246fc3a4eedeb (patch)
tree02a7c0e0e5ddf1ff7f69d578fb09b08e6bcf8ff0 /wallet
parentf94169acb441b5993a82f080c5830d566793a752 (diff)
downloadtaler-android-5764a5c9228cf25662da697668a246fc3a4eedeb.tar.gz
taler-android-5764a5c9228cf25662da697668a246fc3a4eedeb.tar.bz2
taler-android-5764a5c9228cf25662da697668a246fc3a4eedeb.zip
[wallet] Add share button to Peer-Push (and adapt to new API)
#0007471
Diffstat (limited to 'wallet')
-rw-r--r--wallet/src/main/java/net/taler/wallet/ReceiveFundsFragment.kt1
-rw-r--r--wallet/src/main/java/net/taler/wallet/SendFundsFragment.kt1
-rw-r--r--wallet/src/main/java/net/taler/wallet/Utils.kt12
-rw-r--r--wallet/src/main/java/net/taler/wallet/compose/QrCodeUriComposable.kt45
-rw-r--r--wallet/src/main/java/net/taler/wallet/compose/ShareButton.kt71
-rw-r--r--wallet/src/main/java/net/taler/wallet/compose/Utils.kt11
-rw-r--r--wallet/src/main/java/net/taler/wallet/deposit/DepositFragment.kt2
-rw-r--r--wallet/src/main/java/net/taler/wallet/deposit/PayToUriFragment.kt2
-rw-r--r--wallet/src/main/java/net/taler/wallet/peer/IncomingPullPaymentFragment.kt2
-rw-r--r--wallet/src/main/java/net/taler/wallet/peer/IncomingPushPaymentFragment.kt2
-rw-r--r--wallet/src/main/java/net/taler/wallet/peer/OutgoingPullFragment.kt2
-rw-r--r--wallet/src/main/java/net/taler/wallet/peer/OutgoingPushFragment.kt2
-rw-r--r--wallet/src/main/java/net/taler/wallet/peer/OutgoingPushResultComposable.kt63
-rw-r--r--wallet/src/main/java/net/taler/wallet/peer/PeerManager.kt9
-rw-r--r--wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPullCredit.kt2
-rw-r--r--wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPushDebit.kt2
-rw-r--r--wallet/src/main/java/net/taler/wallet/transactions/TransactionDepositFragment.kt2
-rw-r--r--wallet/src/main/java/net/taler/wallet/transactions/TransactionPeerFragment.kt2
-rw-r--r--wallet/src/main/java/net/taler/wallet/withdraw/manual/ManualWithdrawSuccessFragment.kt2
19 files changed, 151 insertions, 84 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/ReceiveFundsFragment.kt b/wallet/src/main/java/net/taler/wallet/ReceiveFundsFragment.kt
index 8ae96ad..ac6b0bd 100644
--- a/wallet/src/main/java/net/taler/wallet/ReceiveFundsFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/ReceiveFundsFragment.kt
@@ -56,6 +56,7 @@ import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import net.taler.common.Amount
import net.taler.common.Amount.Companion.isValidAmountStr
+import net.taler.wallet.compose.TalerSurface
import net.taler.wallet.exchanges.ExchangeItem
class ReceiveFundsFragment : Fragment() {
diff --git a/wallet/src/main/java/net/taler/wallet/SendFundsFragment.kt b/wallet/src/main/java/net/taler/wallet/SendFundsFragment.kt
index c5348a3..90b4ee0 100644
--- a/wallet/src/main/java/net/taler/wallet/SendFundsFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/SendFundsFragment.kt
@@ -53,6 +53,7 @@ import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
import net.taler.common.Amount
import net.taler.common.Amount.Companion.isValidAmountStr
+import net.taler.wallet.compose.TalerSurface
class SendFundsFragment : Fragment() {
private val model: MainViewModel by activityViewModels()
diff --git a/wallet/src/main/java/net/taler/wallet/Utils.kt b/wallet/src/main/java/net/taler/wallet/Utils.kt
index 5679f21..7edc694 100644
--- a/wallet/src/main/java/net/taler/wallet/Utils.kt
+++ b/wallet/src/main/java/net/taler/wallet/Utils.kt
@@ -28,10 +28,7 @@ import android.os.Build.VERSION.SDK_INT
import android.widget.Toast
import android.widget.Toast.LENGTH_LONG
import androidx.annotation.RequiresApi
-import androidx.compose.material.Surface
-import androidx.compose.runtime.Composable
import androidx.core.content.getSystemService
-import com.google.accompanist.themeadapter.material.MdcTheme
import net.taler.common.Amount
import net.taler.common.AmountParserException
@@ -88,15 +85,6 @@ private fun connectToWifiDeprecated(context: Context, ssid: String) {
}
}
-@Composable
-fun TalerSurface(content: @Composable () -> Unit) {
- MdcTheme {
- Surface {
- content()
- }
- }
-}
-
fun cleanExchange(exchange: String) = exchange.let {
if (it.startsWith("https://", ignoreCase = true)) it.substring(8) else it
}.trimEnd('/')
diff --git a/wallet/src/main/java/net/taler/wallet/compose/QrCodeUriComposable.kt b/wallet/src/main/java/net/taler/wallet/compose/QrCodeUriComposable.kt
index 3f8ecd1..5359f1a 100644
--- a/wallet/src/main/java/net/taler/wallet/compose/QrCodeUriComposable.kt
+++ b/wallet/src/main/java/net/taler/wallet/compose/QrCodeUriComposable.kt
@@ -21,13 +21,17 @@ import android.content.ClipboardManager
import android.content.Context
import androidx.compose.foundation.Image
import androidx.compose.foundation.horizontalScroll
+import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.rememberScrollState
import androidx.compose.material.Button
+import androidx.compose.material.ButtonColors
+import androidx.compose.material.ButtonDefaults
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
@@ -36,11 +40,13 @@ import androidx.compose.material.icons.filled.ContentCopy
import androidx.compose.runtime.Composable
import androidx.compose.runtime.produceState
import androidx.compose.ui.Alignment
+import androidx.compose.ui.Alignment.Companion.CenterHorizontally
import androidx.compose.ui.Modifier
-import androidx.compose.ui.graphics.ImageBitmap
+import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.asImageBitmap
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.LocalInspectionMode
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.unit.Dp
@@ -58,12 +64,18 @@ fun ColumnScope.QrCodeUriComposable(
inBetween: (@Composable ColumnScope.() -> Unit)? = null,
) {
val qrCodeSize = getQrCodeSize()
- val qrState = produceState<ImageBitmap?>(null) {
+ val qrPlaceHolder = if (LocalInspectionMode.current) {
+ QrCodeManager.makeQrCode(talerUri, qrCodeSize.value.toInt()).asImageBitmap()
+ } else null
+ val qrState = produceState(qrPlaceHolder) {
value = QrCodeManager.makeQrCode(talerUri, qrCodeSize.value.toInt()).asImageBitmap()
}
qrState.value?.let { qrCode ->
Image(
- modifier = Modifier.size(qrCodeSize),
+ modifier = Modifier
+ .size(qrCodeSize)
+ .align(CenterHorizontally)
+ .padding(vertical = 8.dp),
bitmap = qrCode,
contentDescription = stringResource(id = R.string.button_scan_qr_code),
)
@@ -78,12 +90,23 @@ fun ColumnScope.QrCodeUriComposable(
text = talerUri,
)
}
- CopyToClipboardButton(
- modifier = Modifier,
- label = clipBoardLabel,
- content = talerUri,
- buttonText = buttonText,
- )
+ Row(
+ modifier = Modifier
+ .padding(horizontal = 16.dp)
+ .fillMaxWidth(),
+ horizontalArrangement = Arrangement.SpaceEvenly,
+ ) {
+ CopyToClipboardButton(
+ label = clipBoardLabel,
+ content = talerUri,
+ buttonText = buttonText,
+ colors = ButtonDefaults.buttonColors(backgroundColor = Color.Transparent)
+ )
+ ShareButton(
+ content = talerUri,
+ colors = ButtonDefaults.buttonColors(backgroundColor = Color.Transparent)
+ )
+ }
}
@Composable
@@ -100,14 +123,16 @@ fun CopyToClipboardButton(
content: String,
modifier: Modifier = Modifier,
buttonText: String = stringResource(R.string.copy),
+ colors: ButtonColors = ButtonDefaults.buttonColors(),
) {
val context = LocalContext.current
Button(
modifier = modifier,
+ colors = colors,
onClick = { copyToClipBoard(context, label, content) },
) {
Row(verticalAlignment = Alignment.CenterVertically) {
- Icon(Icons.Default.ContentCopy, stringResource(R.string.copy))
+ Icon(Icons.Default.ContentCopy, buttonText)
Text(
modifier = Modifier.padding(start = 8.dp),
text = buttonText,
diff --git a/wallet/src/main/java/net/taler/wallet/compose/ShareButton.kt b/wallet/src/main/java/net/taler/wallet/compose/ShareButton.kt
new file mode 100644
index 0000000..0ac7048
--- /dev/null
+++ b/wallet/src/main/java/net/taler/wallet/compose/ShareButton.kt
@@ -0,0 +1,71 @@
+/*
+ * This file is part of GNU Taler
+ * (C) 2023 Taler Systems S.A.
+ *
+ * GNU Taler is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation; either version 3, or (at your option) any later version.
+ *
+ * GNU Taler is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * GNU Taler; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+ */
+
+package net.taler.wallet.compose
+
+import android.content.Intent
+import android.content.Intent.ACTION_SEND
+import android.content.Intent.EXTRA_TEXT
+import androidx.compose.foundation.layout.Row
+import androidx.compose.foundation.layout.padding
+import androidx.compose.material.Button
+import androidx.compose.material.ButtonColors
+import androidx.compose.material.ButtonDefaults
+import androidx.compose.material.Icon
+import androidx.compose.material.MaterialTheme
+import androidx.compose.material.Text
+import androidx.compose.material.icons.Icons
+import androidx.compose.material.icons.filled.Share
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Alignment.Companion.CenterVertically
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.unit.dp
+import androidx.core.content.ContextCompat.startActivity
+import net.taler.wallet.R
+
+@Composable
+fun ShareButton(
+ content: String,
+ modifier: Modifier = Modifier,
+ buttonText: String = stringResource(R.string.share),
+ colors: ButtonColors = ButtonDefaults.buttonColors(),
+) {
+ val context = LocalContext.current
+ Button(
+ modifier = modifier,
+ colors = colors,
+ onClick = {
+ val sendIntent: Intent = Intent().apply {
+ action = ACTION_SEND
+ putExtra(EXTRA_TEXT, content)
+ type = "text/plain"
+ }
+ val shareIntent = Intent.createChooser(sendIntent, null)
+ startActivity(context, shareIntent, null)
+ },
+ ) {
+ Row(verticalAlignment = CenterVertically) {
+ Icon(Icons.Default.Share, buttonText)
+ Text(
+ modifier = Modifier.padding(start = 8.dp),
+ text = buttonText,
+ style = MaterialTheme.typography.body1,
+ )
+ }
+ }
+}
diff --git a/wallet/src/main/java/net/taler/wallet/compose/Utils.kt b/wallet/src/main/java/net/taler/wallet/compose/Utils.kt
index 21b04ed..8e3a032 100644
--- a/wallet/src/main/java/net/taler/wallet/compose/Utils.kt
+++ b/wallet/src/main/java/net/taler/wallet/compose/Utils.kt
@@ -16,6 +16,7 @@
package net.taler.wallet.compose
+import androidx.compose.material.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.collectAsState
@@ -24,6 +25,7 @@ import androidx.compose.ui.platform.LocalLifecycleOwner
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.flowWithLifecycle
+import com.google.accompanist.themeadapter.material.MdcTheme
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow
import kotlin.coroutines.CoroutineContext
@@ -51,3 +53,12 @@ fun <T : R, R> Flow<T>.collectAsStateLifecycleAware(
fun <T> StateFlow<T>.collectAsStateLifecycleAware(
context: CoroutineContext = EmptyCoroutineContext,
): State<T> = collectAsStateLifecycleAware(initial = value, context = context)
+
+@Composable
+fun TalerSurface(content: @Composable () -> Unit) {
+ MdcTheme {
+ Surface {
+ content()
+ }
+ }
+}
diff --git a/wallet/src/main/java/net/taler/wallet/deposit/DepositFragment.kt b/wallet/src/main/java/net/taler/wallet/deposit/DepositFragment.kt
index 1486f08..5d209ac 100644
--- a/wallet/src/main/java/net/taler/wallet/deposit/DepositFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/deposit/DepositFragment.kt
@@ -57,7 +57,7 @@ import net.taler.common.Amount
import net.taler.common.showError
import net.taler.wallet.MainViewModel
import net.taler.wallet.R
-import net.taler.wallet.TalerSurface
+import net.taler.wallet.compose.TalerSurface
import net.taler.wallet.compose.collectAsStateLifecycleAware
class DepositFragment : Fragment() {
diff --git a/wallet/src/main/java/net/taler/wallet/deposit/PayToUriFragment.kt b/wallet/src/main/java/net/taler/wallet/deposit/PayToUriFragment.kt
index af43749..47e8cfb 100644
--- a/wallet/src/main/java/net/taler/wallet/deposit/PayToUriFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/deposit/PayToUriFragment.kt
@@ -66,7 +66,7 @@ import net.taler.common.Amount
import net.taler.wallet.AmountResult
import net.taler.wallet.MainViewModel
import net.taler.wallet.R
-import net.taler.wallet.TalerSurface
+import net.taler.wallet.compose.TalerSurface
class PayToUriFragment : Fragment() {
private val model: MainViewModel by activityViewModels()
diff --git a/wallet/src/main/java/net/taler/wallet/peer/IncomingPullPaymentFragment.kt b/wallet/src/main/java/net/taler/wallet/peer/IncomingPullPaymentFragment.kt
index c5c41d7..6a74c30 100644
--- a/wallet/src/main/java/net/taler/wallet/peer/IncomingPullPaymentFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/peer/IncomingPullPaymentFragment.kt
@@ -27,7 +27,7 @@ import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import net.taler.wallet.MainViewModel
import net.taler.wallet.R
-import net.taler.wallet.TalerSurface
+import net.taler.wallet.compose.TalerSurface
import net.taler.wallet.compose.collectAsStateLifecycleAware
class IncomingPullPaymentFragment : Fragment() {
diff --git a/wallet/src/main/java/net/taler/wallet/peer/IncomingPushPaymentFragment.kt b/wallet/src/main/java/net/taler/wallet/peer/IncomingPushPaymentFragment.kt
index c0fbad9..56734e3 100644
--- a/wallet/src/main/java/net/taler/wallet/peer/IncomingPushPaymentFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/peer/IncomingPushPaymentFragment.kt
@@ -27,7 +27,7 @@ import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
import net.taler.wallet.MainViewModel
import net.taler.wallet.R
-import net.taler.wallet.TalerSurface
+import net.taler.wallet.compose.TalerSurface
import net.taler.wallet.compose.collectAsStateLifecycleAware
class IncomingPushPaymentFragment : Fragment() {
diff --git a/wallet/src/main/java/net/taler/wallet/peer/OutgoingPullFragment.kt b/wallet/src/main/java/net/taler/wallet/peer/OutgoingPullFragment.kt
index 8a226b3..b9634d5 100644
--- a/wallet/src/main/java/net/taler/wallet/peer/OutgoingPullFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/peer/OutgoingPullFragment.kt
@@ -27,7 +27,7 @@ import androidx.navigation.findNavController
import net.taler.common.Amount
import net.taler.wallet.MainViewModel
import net.taler.wallet.R
-import net.taler.wallet.TalerSurface
+import net.taler.wallet.compose.TalerSurface
import net.taler.wallet.compose.collectAsStateLifecycleAware
import net.taler.wallet.exchanges.ExchangeItem
diff --git a/wallet/src/main/java/net/taler/wallet/peer/OutgoingPushFragment.kt b/wallet/src/main/java/net/taler/wallet/peer/OutgoingPushFragment.kt
index c9b3a78..b110876 100644
--- a/wallet/src/main/java/net/taler/wallet/peer/OutgoingPushFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/peer/OutgoingPushFragment.kt
@@ -27,7 +27,7 @@ import androidx.navigation.findNavController
import net.taler.common.Amount
import net.taler.wallet.MainViewModel
import net.taler.wallet.R
-import net.taler.wallet.TalerSurface
+import net.taler.wallet.compose.TalerSurface
import net.taler.wallet.compose.collectAsStateLifecycleAware
class OutgoingPushFragment : Fragment() {
diff --git a/wallet/src/main/java/net/taler/wallet/peer/OutgoingPushResultComposable.kt b/wallet/src/main/java/net/taler/wallet/peer/OutgoingPushResultComposable.kt
index 6d8b5dc..5afac59 100644
--- a/wallet/src/main/java/net/taler/wallet/peer/OutgoingPushResultComposable.kt
+++ b/wallet/src/main/java/net/taler/wallet/peer/OutgoingPushResultComposable.kt
@@ -17,11 +17,8 @@
package net.taler.wallet.peer
import android.content.res.Configuration.UI_MODE_NIGHT_YES
-import androidx.compose.foundation.Image
-import androidx.compose.foundation.horizontalScroll
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
-import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
@@ -29,28 +26,21 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Button
import androidx.compose.material.CircularProgressIndicator
-import androidx.compose.material.Icon
-import androidx.compose.material.IconButton
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.material.Text
-import androidx.compose.material.icons.Icons
-import androidx.compose.material.icons.filled.ContentCopy
import androidx.compose.runtime.Composable
-import androidx.compose.ui.Alignment
import androidx.compose.ui.Alignment.Companion.CenterHorizontally
import androidx.compose.ui.Modifier
-import androidx.compose.ui.graphics.asImageBitmap
-import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.stringResource
-import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import net.taler.common.QrCodeManager
import net.taler.wallet.R
import net.taler.wallet.backend.TalerErrorInfo
-import net.taler.wallet.compose.copyToClipBoard
+import net.taler.wallet.compose.QrCodeUriComposable
+import net.taler.wallet.compose.TalerSurface
import net.taler.wallet.compose.getQrCodeSize
import org.json.JSONObject
@@ -95,42 +85,15 @@ private fun ColumnScope.PeerPushCreatingComposable() {
@Composable
private fun ColumnScope.PeerPushResponseComposable(state: OutgoingResponse) {
- val qrCodeSize = getQrCodeSize()
- Image(
- modifier = Modifier
- .size(qrCodeSize)
- .align(CenterHorizontally),
- bitmap = state.qrCode.asImageBitmap(),
- contentDescription = stringResource(id = R.string.button_scan_qr_code),
- )
- Text(
- modifier = Modifier.padding(horizontal = 16.dp),
- style = MaterialTheme.typography.body1,
- text = stringResource(id = R.string.receive_peer_invoice_uri),
- )
- val scrollState = rememberScrollState()
- Text(
- modifier = Modifier
- .horizontalScroll(scrollState)
- .padding(16.dp),
- fontFamily = FontFamily.Monospace,
- style = MaterialTheme.typography.body1,
- text = state.talerUri,
- )
- val context = LocalContext.current
- IconButton(
- modifier = Modifier
- .align(CenterHorizontally),
- onClick = { copyToClipBoard(context, "Invoice", state.talerUri) },
+ QrCodeUriComposable(
+ talerUri = state.talerUri,
+ clipBoardLabel = "Invoice",
) {
- Row(verticalAlignment = Alignment.CenterVertically) {
- Icon(Icons.Default.ContentCopy, stringResource(R.string.copy))
- Text(
- modifier = Modifier.padding(start = 8.dp),
- text = stringResource(R.string.copy),
- style = MaterialTheme.typography.body1,
- )
- }
+ Text(
+ modifier = Modifier.padding(horizontal = 16.dp),
+ style = MaterialTheme.typography.body1,
+ text = stringResource(id = R.string.receive_peer_invoice_uri),
+ )
}
}
@@ -154,10 +117,10 @@ fun PeerPushCreatingPreview() {
}
}
-@Preview
+@Preview(uiMode = UI_MODE_NIGHT_YES)
@Composable
fun PeerPushResponsePreview() {
- Surface {
+ TalerSurface {
val talerUri = "https://example.org/foo/bar/can/be/very/long/url/so/fit/it/on/screen"
val response = OutgoingResponse(talerUri, QrCodeManager.makeQrCode(talerUri))
OutgoingPushResultComposable(response) {}
@@ -167,7 +130,7 @@ fun PeerPushResponsePreview() {
@Preview(widthDp = 720, uiMode = UI_MODE_NIGHT_YES)
@Composable
fun PeerPushResponseLandscapePreview() {
- Surface {
+ TalerSurface {
val talerUri = "https://example.org/foo/bar/can/be/very/long/url/so/fit/it/on/screen"
val response = OutgoingResponse(talerUri, QrCodeManager.makeQrCode(talerUri))
OutgoingPushResultComposable(response) {}
diff --git a/wallet/src/main/java/net/taler/wallet/peer/PeerManager.kt b/wallet/src/main/java/net/taler/wallet/peer/PeerManager.kt
index 1e53e7c..5f26119 100644
--- a/wallet/src/main/java/net/taler/wallet/peer/PeerManager.kt
+++ b/wallet/src/main/java/net/taler/wallet/peer/PeerManager.kt
@@ -22,12 +22,16 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
+import kotlinx.serialization.encodeToString
+import kotlinx.serialization.json.Json
import net.taler.common.Amount
import net.taler.common.QrCodeManager
+import net.taler.common.Timestamp
import net.taler.wallet.TAG
import net.taler.wallet.backend.WalletBackendApi
import net.taler.wallet.exchanges.ExchangeItem
import org.json.JSONObject
+import java.util.concurrent.TimeUnit.DAYS
class PeerManager(
private val api: WalletBackendApi,
@@ -51,8 +55,8 @@ class PeerManager(
scope.launch(Dispatchers.IO) {
api.request("initiatePeerPullPayment", InitiatePeerPullPaymentResponse.serializer()) {
put("exchangeBaseUrl", exchange.exchangeBaseUrl)
- put("amount", amount.toJSONString())
put("partialContractTerms", JSONObject().apply {
+ put("amount", amount.toJSONString())
put("summary", summary)
})
}.onSuccess {
@@ -72,10 +76,13 @@ class PeerManager(
fun initiatePeerPushPayment(amount: Amount, summary: String) {
_outgoingPushState.value = OutgoingCreating
scope.launch(Dispatchers.IO) {
+ val expiry = Timestamp.fromMillis(System.currentTimeMillis() + DAYS.toMillis(3))
api.request("initiatePeerPushPayment", InitiatePeerPushPaymentResponse.serializer()) {
put("amount", amount.toJSONString())
put("partialContractTerms", JSONObject().apply {
+ put("amount", amount.toJSONString())
put("summary", summary)
+ put("purse_expiration", JSONObject(Json.encodeToString(expiry)))
})
}.onSuccess { response ->
val qrCode = QrCodeManager.makeQrCode(response.talerUri)
diff --git a/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPullCredit.kt b/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPullCredit.kt
index 02b3774..92264c7 100644
--- a/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPullCredit.kt
+++ b/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPullCredit.kt
@@ -65,7 +65,7 @@ fun ColumnScope.TransactionPeerPullCreditComposable(t: TransactionPeerPullCredit
QrCodeUriComposable(
talerUri = t.talerUri,
clipBoardLabel = "Invoice",
- buttonText = stringResource(id = R.string.copy_uri),
+ buttonText = stringResource(id = R.string.copy),
) {
Text(
modifier = Modifier.padding(horizontal = 16.dp),
diff --git a/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPushDebit.kt b/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPushDebit.kt
index f068fb8..88c27fe 100644
--- a/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPushDebit.kt
+++ b/wallet/src/main/java/net/taler/wallet/peer/TransactionPeerPushDebit.kt
@@ -64,7 +64,7 @@ fun ColumnScope.TransactionPeerPushDebitComposable(t: TransactionPeerPushDebit)
QrCodeUriComposable(
talerUri = t.talerUri,
clipBoardLabel = "Push payment",
- buttonText = stringResource(id = R.string.copy_uri),
+ buttonText = stringResource(id = R.string.copy),
) {
Text(
modifier = Modifier.padding(horizontal = 16.dp),
diff --git a/wallet/src/main/java/net/taler/wallet/transactions/TransactionDepositFragment.kt b/wallet/src/main/java/net/taler/wallet/transactions/TransactionDepositFragment.kt
index 0162502..60f9b20 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionDepositFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionDepositFragment.kt
@@ -21,7 +21,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.compose.ui.platform.ComposeView
-import net.taler.wallet.TalerSurface
+import net.taler.wallet.compose.TalerSurface
import net.taler.wallet.deposit.TransactionDepositComposable
class TransactionDepositFragment : TransactionDetailFragment() {
diff --git a/wallet/src/main/java/net/taler/wallet/transactions/TransactionPeerFragment.kt b/wallet/src/main/java/net/taler/wallet/transactions/TransactionPeerFragment.kt
index 52d6095..b7c347f 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionPeerFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionPeerFragment.kt
@@ -39,7 +39,7 @@ import androidx.compose.ui.unit.sp
import net.taler.common.Amount
import net.taler.common.toAbsoluteTime
import net.taler.wallet.R
-import net.taler.wallet.TalerSurface
+import net.taler.wallet.compose.TalerSurface
import net.taler.wallet.peer.TransactionPeerPullCreditComposable
import net.taler.wallet.peer.TransactionPeerPullDebitComposable
import net.taler.wallet.peer.TransactionPeerPushCreditComposable
diff --git a/wallet/src/main/java/net/taler/wallet/withdraw/manual/ManualWithdrawSuccessFragment.kt b/wallet/src/main/java/net/taler/wallet/withdraw/manual/ManualWithdrawSuccessFragment.kt
index 89ad08b..787a0b0 100644
--- a/wallet/src/main/java/net/taler/wallet/withdraw/manual/ManualWithdrawSuccessFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/withdraw/manual/ManualWithdrawSuccessFragment.kt
@@ -28,7 +28,7 @@ import androidx.navigation.fragment.findNavController
import net.taler.common.startActivitySafe
import net.taler.wallet.MainViewModel
import net.taler.wallet.R
-import net.taler.wallet.TalerSurface
+import net.taler.wallet.compose.TalerSurface
import net.taler.wallet.withdraw.WithdrawStatus
class ManualWithdrawSuccessFragment : Fragment() {