aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wallet/build.gradle2
-rw-r--r--wallet/src/main/java/net/taler/wallet/ReceiveFundsFragment.kt19
-rw-r--r--wallet/src/main/java/net/taler/wallet/SendFundsFragment.kt19
-rw-r--r--wallet/src/main/java/net/taler/wallet/Utils.kt12
-rw-r--r--wallet/src/main/java/net/taler/wallet/deposit/DepositFragment.kt22
-rw-r--r--wallet/src/main/java/net/taler/wallet/deposit/PayToUriFragment.kt46
-rw-r--r--wallet/src/main/java/net/taler/wallet/peer/IncomingPullPaymentFragment.kt13
-rw-r--r--wallet/src/main/java/net/taler/wallet/peer/IncomingPushPaymentFragment.kt13
-rw-r--r--wallet/src/main/java/net/taler/wallet/peer/OutgoingPullFragment.kt31
-rw-r--r--wallet/src/main/java/net/taler/wallet/peer/OutgoingPushFragment.kt25
-rw-r--r--wallet/src/main/java/net/taler/wallet/transactions/TransactionDepositFragment.kt13
-rw-r--r--wallet/src/main/java/net/taler/wallet/transactions/TransactionPeerFragment.kt13
-rw-r--r--wallet/src/main/java/net/taler/wallet/withdraw/manual/ManualWithdrawSuccessFragment.kt20
13 files changed, 115 insertions, 133 deletions
diff --git a/wallet/build.gradle b/wallet/build.gradle
index 729ad30..a0781d7 100644
--- a/wallet/build.gradle
+++ b/wallet/build.gradle
@@ -131,7 +131,7 @@ dependencies {
implementation "androidx.compose.material:material:1.3.1"
implementation "androidx.compose.material:material-icons-extended:1.3.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
- implementation 'com.google.android.material:compose-theme-adapter:1.2.1'
+ implementation "com.google.accompanist:accompanist-themeadapter-material:0.28.0"
// Lists and Selection
implementation "androidx.recyclerview:recyclerview:1.2.1"
diff --git a/wallet/src/main/java/net/taler/wallet/ReceiveFundsFragment.kt b/wallet/src/main/java/net/taler/wallet/ReceiveFundsFragment.kt
index cf01e59..647512c 100644
--- a/wallet/src/main/java/net/taler/wallet/ReceiveFundsFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/ReceiveFundsFragment.kt
@@ -54,7 +54,6 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
-import com.google.android.material.composethemeadapter.MdcTheme
import net.taler.common.Amount
import net.taler.wallet.exchanges.ExchangeItem
@@ -67,14 +66,12 @@ class ReceiveFundsFragment : Fragment() {
savedInstanceState: Bundle?,
): View = ComposeView(requireContext()).apply {
setContent {
- MdcTheme {
- Surface {
- ReceiveFundsIntro(
- model.transactionManager.selectedCurrency ?: error("No currency selected"),
- this@ReceiveFundsFragment::onManualWithdraw,
- this@ReceiveFundsFragment::onPeerPull,
- )
- }
+ TalerSurface {
+ ReceiveFundsIntro(
+ model.transactionManager.selectedCurrency ?: error("No currency selected"),
+ this@ReceiveFundsFragment::onManualWithdraw,
+ this@ReceiveFundsFragment::onPeerPull,
+ )
}
}
}
@@ -179,7 +176,9 @@ private fun ReceiveFundsIntro(
Text(text = stringResource(R.string.receive_withdraw))
}
Button(
- modifier = Modifier.weight(1f).height(IntrinsicSize.Max),
+ modifier = Modifier
+ .weight(1f)
+ .height(IntrinsicSize.Max),
onClick = {
val amount = getAmount(currency, text)
if (amount == null) isError = true
diff --git a/wallet/src/main/java/net/taler/wallet/SendFundsFragment.kt b/wallet/src/main/java/net/taler/wallet/SendFundsFragment.kt
index bb903c3..b16022d 100644
--- a/wallet/src/main/java/net/taler/wallet/SendFundsFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/SendFundsFragment.kt
@@ -51,7 +51,6 @@ import androidx.core.os.bundleOf
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
-import com.google.android.material.composethemeadapter.MdcTheme
import net.taler.common.Amount
class SendFundsFragment : Fragment() {
@@ -64,16 +63,14 @@ class SendFundsFragment : Fragment() {
savedInstanceState: Bundle?,
): View = ComposeView(requireContext()).apply {
setContent {
- MdcTheme {
- Surface {
- SendFundsIntro(
- currency = model.transactionManager.selectedCurrency
- ?: error("No currency selected"),
- hasSufficientBalance = model::hasSufficientBalance,
- onDeposit = this@SendFundsFragment::onDeposit,
- onPeerPush = this@SendFundsFragment::onPeerPush,
- )
- }
+ TalerSurface {
+ SendFundsIntro(
+ currency = model.transactionManager.selectedCurrency
+ ?: error("No currency selected"),
+ hasSufficientBalance = model::hasSufficientBalance,
+ onDeposit = this@SendFundsFragment::onDeposit,
+ onPeerPush = this@SendFundsFragment::onPeerPush,
+ )
}
}
}
diff --git a/wallet/src/main/java/net/taler/wallet/Utils.kt b/wallet/src/main/java/net/taler/wallet/Utils.kt
index c0ccbed..b9abb31 100644
--- a/wallet/src/main/java/net/taler/wallet/Utils.kt
+++ b/wallet/src/main/java/net/taler/wallet/Utils.kt
@@ -28,7 +28,10 @@ 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
@@ -83,6 +86,15 @@ 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/deposit/DepositFragment.kt b/wallet/src/main/java/net/taler/wallet/deposit/DepositFragment.kt
index 31dc03d..1486f08 100644
--- a/wallet/src/main/java/net/taler/wallet/deposit/DepositFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/deposit/DepositFragment.kt
@@ -53,11 +53,11 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
-import com.google.android.material.composethemeadapter.MdcTheme
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.collectAsStateLifecycleAware
class DepositFragment : Fragment() {
@@ -81,17 +81,15 @@ class DepositFragment : Fragment() {
}
return ComposeView(requireContext()).apply {
setContent {
- MdcTheme {
- Surface {
- val state = depositManager.depositState.collectAsStateLifecycleAware()
- MakeDepositComposable(
- state = state.value,
- amount = amount,
- presetName = receiverName,
- presetIban = iban,
- onMakeDeposit = this@DepositFragment::onDepositButtonClicked,
- )
- }
+ TalerSurface {
+ val state = depositManager.depositState.collectAsStateLifecycleAware()
+ MakeDepositComposable(
+ state = state.value,
+ amount = amount,
+ presetName = receiverName,
+ presetIban = iban,
+ onMakeDeposit = this@DepositFragment::onDepositButtonClicked,
+ )
}
}
}
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 ac1fd59..af43749 100644
--- a/wallet/src/main/java/net/taler/wallet/deposit/PayToUriFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/deposit/PayToUriFragment.kt
@@ -62,11 +62,11 @@ import androidx.core.os.bundleOf
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
-import com.google.android.material.composethemeadapter.MdcTheme
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
class PayToUriFragment : Fragment() {
private val model: MainViewModel by activityViewModels()
@@ -82,29 +82,27 @@ class PayToUriFragment : Fragment() {
val currencies = model.getCurrencies()
return ComposeView(requireContext()).apply {
setContent {
- MdcTheme {
- Surface {
- if (currencies.isEmpty()) Text(
- text = stringResource(id = R.string.payment_balance_insufficient),
- color = colorResource(id = R.color.red),
- ) else if (depositManager.isSupportedPayToUri(uri)) PayToComposable(
- currencies = model.getCurrencies(),
- getAmount = model::createAmount,
- onAmountChosen = { amount ->
- val u = Uri.parse(uri)
- val bundle = bundleOf(
- "amount" to amount.toJSONString(),
- "receiverName" to u.getQueryParameters("receiver-name")[0],
- "IBAN" to u.pathSegments.last(),
- )
- findNavController().navigate(
- R.id.action_nav_payto_uri_to_nav_deposit, bundle)
- },
- ) else Text(
- text = stringResource(id = R.string.uri_invalid),
- color = colorResource(id = R.color.red),
- )
- }
+ TalerSurface {
+ if (currencies.isEmpty()) Text(
+ text = stringResource(id = R.string.payment_balance_insufficient),
+ color = colorResource(id = R.color.red),
+ ) else if (depositManager.isSupportedPayToUri(uri)) PayToComposable(
+ currencies = model.getCurrencies(),
+ getAmount = model::createAmount,
+ onAmountChosen = { amount ->
+ val u = Uri.parse(uri)
+ val bundle = bundleOf(
+ "amount" to amount.toJSONString(),
+ "receiverName" to u.getQueryParameters("receiver-name")[0],
+ "IBAN" to u.pathSegments.last(),
+ )
+ findNavController().navigate(
+ R.id.action_nav_payto_uri_to_nav_deposit, bundle)
+ },
+ ) else Text(
+ text = stringResource(id = R.string.uri_invalid),
+ color = colorResource(id = R.color.red),
+ )
}
}
}
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 cd2f39b..c5c41d7 100644
--- a/wallet/src/main/java/net/taler/wallet/peer/IncomingPullPaymentFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/peer/IncomingPullPaymentFragment.kt
@@ -20,15 +20,14 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import androidx.compose.material.Surface
import androidx.compose.ui.platform.ComposeView
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
-import com.google.android.material.composethemeadapter.MdcTheme
import net.taler.wallet.MainViewModel
import net.taler.wallet.R
+import net.taler.wallet.TalerSurface
import net.taler.wallet.compose.collectAsStateLifecycleAware
class IncomingPullPaymentFragment : Fragment() {
@@ -49,12 +48,10 @@ class IncomingPullPaymentFragment : Fragment() {
}
return ComposeView(requireContext()).apply {
setContent {
- MdcTheme {
- Surface {
- val state = peerManager.incomingPullState.collectAsStateLifecycleAware()
- IncomingComposable(state, incomingPull) { terms ->
- peerManager.acceptPeerPullPayment(terms)
- }
+ TalerSurface {
+ val state = peerManager.incomingPullState.collectAsStateLifecycleAware()
+ IncomingComposable(state, incomingPull) { terms ->
+ peerManager.acceptPeerPullPayment(terms)
}
}
}
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 8429ecc..c0fbad9 100644
--- a/wallet/src/main/java/net/taler/wallet/peer/IncomingPushPaymentFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/peer/IncomingPushPaymentFragment.kt
@@ -20,15 +20,14 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import androidx.compose.material.Surface
import androidx.compose.ui.platform.ComposeView
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.lifecycleScope
import androidx.navigation.fragment.findNavController
-import com.google.android.material.composethemeadapter.MdcTheme
import net.taler.wallet.MainViewModel
import net.taler.wallet.R
+import net.taler.wallet.TalerSurface
import net.taler.wallet.compose.collectAsStateLifecycleAware
class IncomingPushPaymentFragment : Fragment() {
@@ -49,12 +48,10 @@ class IncomingPushPaymentFragment : Fragment() {
}
return ComposeView(requireContext()).apply {
setContent {
- MdcTheme {
- Surface {
- val state = peerManager.incomingPushState.collectAsStateLifecycleAware()
- IncomingComposable(state, incomingPush) { terms ->
- peerManager.acceptPeerPushPayment(terms)
- }
+ TalerSurface {
+ val state = peerManager.incomingPushState.collectAsStateLifecycleAware()
+ IncomingComposable(state, incomingPush) { terms ->
+ peerManager.acceptPeerPushPayment(terms)
}
}
}
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 24bedc4..8a226b3 100644
--- a/wallet/src/main/java/net/taler/wallet/peer/OutgoingPullFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/peer/OutgoingPullFragment.kt
@@ -20,15 +20,14 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import androidx.compose.material.Surface
import androidx.compose.ui.platform.ComposeView
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.navigation.findNavController
-import com.google.android.material.composethemeadapter.MdcTheme
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.collectAsStateLifecycleAware
import net.taler.wallet.exchanges.ExchangeItem
@@ -48,21 +47,19 @@ class OutgoingPullFragment : Fragment() {
val exchangeFlow = exchangeManager.findExchangeForCurrency(amount.currency)
return ComposeView(requireContext()).apply {
setContent {
- MdcTheme {
- Surface {
- val state = peerManager.pullState.collectAsStateLifecycleAware()
- if (state.value is OutgoingIntro) {
- val exchangeState =
- exchangeFlow.collectAsStateLifecycleAware(initial = null)
- OutgoingPullIntroComposable(
- amount = amount,
- exchangeState = exchangeState,
- onCreateInvoice = this@OutgoingPullFragment::onCreateInvoice,
- )
- } else {
- OutgoingPullResultComposable(state.value) {
- findNavController().popBackStack()
- }
+ TalerSurface {
+ val state = peerManager.pullState.collectAsStateLifecycleAware()
+ if (state.value is OutgoingIntro) {
+ val exchangeState =
+ exchangeFlow.collectAsStateLifecycleAware(initial = null)
+ OutgoingPullIntroComposable(
+ amount = amount,
+ exchangeState = exchangeState,
+ onCreateInvoice = this@OutgoingPullFragment::onCreateInvoice,
+ )
+ } else {
+ OutgoingPullResultComposable(state.value) {
+ findNavController().popBackStack()
}
}
}
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 ae0ef10..c9b3a78 100644
--- a/wallet/src/main/java/net/taler/wallet/peer/OutgoingPushFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/peer/OutgoingPushFragment.kt
@@ -20,15 +20,14 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import androidx.compose.material.Surface
import androidx.compose.ui.platform.ComposeView
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.navigation.findNavController
-import com.google.android.material.composethemeadapter.MdcTheme
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.collectAsStateLifecycleAware
class OutgoingPushFragment : Fragment() {
@@ -45,18 +44,16 @@ class OutgoingPushFragment : Fragment() {
} ?: error("no amount passed")
return ComposeView(requireContext()).apply {
setContent {
- MdcTheme {
- Surface {
- val state = peerManager.pushState.collectAsStateLifecycleAware()
- if (state.value is OutgoingIntro) {
- OutgoingPushIntroComposable(
- amount = amount,
- onSend = this@OutgoingPushFragment::onSend,
- )
- } else {
- OutgoingPushResultComposable(state.value) {
- findNavController().popBackStack()
- }
+ TalerSurface {
+ val state = peerManager.pushState.collectAsStateLifecycleAware()
+ if (state.value is OutgoingIntro) {
+ OutgoingPushIntroComposable(
+ amount = amount,
+ onSend = this@OutgoingPushFragment::onSend,
+ )
+ } else {
+ OutgoingPushResultComposable(state.value) {
+ findNavController().popBackStack()
}
}
}
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 5443942..0162502 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionDepositFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionDepositFragment.kt
@@ -20,9 +20,8 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import androidx.compose.material.Surface
import androidx.compose.ui.platform.ComposeView
-import com.google.android.material.composethemeadapter.MdcTheme
+import net.taler.wallet.TalerSurface
import net.taler.wallet.deposit.TransactionDepositComposable
class TransactionDepositFragment : TransactionDetailFragment() {
@@ -33,12 +32,10 @@ class TransactionDepositFragment : TransactionDetailFragment() {
savedInstanceState: Bundle?,
): View = ComposeView(requireContext()).apply {
setContent {
- MdcTheme {
- Surface {
- val t = transaction ?: error("No transaction")
- TransactionDepositComposable(t as TransactionDeposit) {
- onDeleteButtonClicked(t)
- }
+ TalerSurface {
+ val t = transaction ?: error("No transaction")
+ TransactionDepositComposable(t as TransactionDeposit) {
+ onDeleteButtonClicked(t)
}
}
}
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 b03eb39..52d6095 100644
--- a/wallet/src/main/java/net/taler/wallet/transactions/TransactionPeerFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/transactions/TransactionPeerFragment.kt
@@ -26,7 +26,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.MaterialTheme
-import androidx.compose.material.Surface
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment.Companion.CenterHorizontally
@@ -37,10 +36,10 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
-import com.google.android.material.composethemeadapter.MdcTheme
import net.taler.common.Amount
import net.taler.common.toAbsoluteTime
import net.taler.wallet.R
+import net.taler.wallet.TalerSurface
import net.taler.wallet.peer.TransactionPeerPullCreditComposable
import net.taler.wallet.peer.TransactionPeerPullDebitComposable
import net.taler.wallet.peer.TransactionPeerPushCreditComposable
@@ -54,12 +53,10 @@ class TransactionPeerFragment : TransactionDetailFragment() {
savedInstanceState: Bundle?,
): View = ComposeView(requireContext()).apply {
setContent {
- MdcTheme {
- Surface {
- val t = transaction ?: error("No transaction")
- TransactionPeerComposable(t) {
- onDeleteButtonClicked(t)
- }
+ TalerSurface {
+ val t = transaction ?: error("No transaction")
+ TransactionPeerComposable(t) {
+ onDeleteButtonClicked(t)
}
}
}
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 f019a5b..89ad08b 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
@@ -21,15 +21,14 @@ import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
-import androidx.compose.material.Surface
import androidx.compose.ui.platform.ComposeView
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
-import com.google.android.material.composethemeadapter.MdcTheme
import net.taler.common.startActivitySafe
import net.taler.wallet.MainViewModel
import net.taler.wallet.R
+import net.taler.wallet.TalerSurface
import net.taler.wallet.withdraw.WithdrawStatus
class ManualWithdrawSuccessFragment : Fragment() {
@@ -57,18 +56,15 @@ class ManualWithdrawSuccessFragment : Fragment() {
}
}
setContent {
- MdcTheme {
- Surface {
- when (status) {
- is WithdrawStatus.ManualTransferRequiredBitcoin -> {
- ScreenBitcoin(status, onBankAppClick, onCancelClick)
- }
- is WithdrawStatus.ManualTransferRequiredIBAN -> {
- ScreenIBAN(status, onBankAppClick, onCancelClick)
- }
+ TalerSurface {
+ when (status) {
+ is WithdrawStatus.ManualTransferRequiredBitcoin -> {
+ ScreenBitcoin(status, onBankAppClick, onCancelClick)
+ }
+ is WithdrawStatus.ManualTransferRequiredIBAN -> {
+ ScreenIBAN(status, onBankAppClick, onCancelClick)
}
}
-
}
}
}