aboutsummaryrefslogtreecommitdiff
path: root/wallet
diff options
context:
space:
mode:
authorTorsten Grote <t@grobox.de>2021-12-07 17:05:30 -0300
committerTorsten Grote <t@grobox.de>2021-12-07 17:05:30 -0300
commit72813a244580285ab268a6257097ece4e73bbb14 (patch)
tree5741ef7d5bca6111a353269caa45604e02b7d993 /wallet
parent095f67dd25ceeff5df388ef42f73de963dd9348b (diff)
downloadtaler-android-72813a244580285ab268a6257097ece4e73bbb14.tar.gz
taler-android-72813a244580285ab268a6257097ece4e73bbb14.tar.bz2
taler-android-72813a244580285ab268a6257097ece4e73bbb14.zip
Add copy to clipboard button to withdrawal details
Diffstat (limited to 'wallet')
-rw-r--r--wallet/build.gradle3
-rw-r--r--wallet/src/main/java/net/taler/wallet/UriInputFragment.kt2
-rw-r--r--wallet/src/main/java/net/taler/wallet/withdraw/ManualWithdrawSuccessFragment.kt124
3 files changed, 56 insertions, 73 deletions
diff --git a/wallet/build.gradle b/wallet/build.gradle
index 27894e9..51fee9a 100644
--- a/wallet/build.gradle
+++ b/wallet/build.gradle
@@ -129,7 +129,8 @@ dependencies {
implementation 'androidx.compose.material:material:1.0.5'
implementation 'androidx.compose.animation:animation:1.0.5'
implementation 'androidx.compose.ui:ui-tooling:1.0.5'
- implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.4.0'
+ implementation 'androidx.compose.material:material-icons-extended:1.0.5'
+ implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
implementation "com.google.android.material:compose-theme-adapter:1.1.1"
// Lists and Selection
diff --git a/wallet/src/main/java/net/taler/wallet/UriInputFragment.kt b/wallet/src/main/java/net/taler/wallet/UriInputFragment.kt
index f4a5f23..b42e7d1 100644
--- a/wallet/src/main/java/net/taler/wallet/UriInputFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/UriInputFragment.kt
@@ -38,7 +38,7 @@ class UriInputFragment : Fragment() {
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
- ): View? {
+ ): View {
ui = FragmentUriInputBinding.inflate(inflater, container, false)
return ui.root
}
diff --git a/wallet/src/main/java/net/taler/wallet/withdraw/ManualWithdrawSuccessFragment.kt b/wallet/src/main/java/net/taler/wallet/withdraw/ManualWithdrawSuccessFragment.kt
index 1f84278..cb22c04 100644
--- a/wallet/src/main/java/net/taler/wallet/withdraw/ManualWithdrawSuccessFragment.kt
+++ b/wallet/src/main/java/net/taler/wallet/withdraw/ManualWithdrawSuccessFragment.kt
@@ -16,6 +16,9 @@
package net.taler.wallet.withdraw
+import android.content.ClipData
+import android.content.ClipboardManager
+import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
@@ -27,23 +30,30 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
-import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentWidth
+import androidx.compose.foundation.rememberScrollState
+import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Button
+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.Companion.CenterHorizontally
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.platform.ComposeView
+import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
+import androidx.core.content.getSystemService
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import com.google.android.material.composethemeadapter.MdcTheme
@@ -51,7 +61,6 @@ import net.taler.common.startActivitySafe
import net.taler.lib.common.Amount
import net.taler.wallet.MainViewModel
import net.taler.wallet.R
-import net.taler.wallet.cleanExchange
class ManualWithdrawSuccessFragment : Fragment() {
private val model: MainViewModel by activityViewModels()
@@ -89,10 +98,11 @@ private fun Screen(
status: WithdrawStatus.ManualTransferRequired,
bankAppClick: (() -> Unit)?,
) {
+ val scrollState = rememberScrollState()
Column(modifier = Modifier
- .fillMaxWidth()
.padding(all = 16.dp)
.wrapContentWidth(CenterHorizontally)
+ .verticalScroll(scrollState)
) {
Text(
text = stringResource(R.string.withdraw_manual_ready_title),
@@ -111,79 +121,16 @@ private fun Screen(
modifier = Modifier
.padding(vertical = 8.dp)
)
- Row {
- Text(
- text = stringResource(R.string.withdraw_manual_ready_iban),
- style = MaterialTheme.typography.body1,
- fontWeight = FontWeight.Bold,
- modifier = Modifier
- .padding(vertical = 8.dp)
- .weight(0.3f)
- )
- Text(
- text = status.iban,
- style = MaterialTheme.typography.body1,
- modifier = Modifier
- .padding(vertical = 8.dp)
- .weight(0.7f)
- )
- }
- Row {
- Text(
- text = stringResource(R.string.withdraw_manual_ready_subject),
- style = MaterialTheme.typography.body1,
- fontWeight = FontWeight.Bold,
- modifier = Modifier
- .padding(vertical = 8.dp)
- .weight(0.3f)
- )
- Text(
- text = status.subject,
- style = MaterialTheme.typography.body1,
- modifier = Modifier
- .padding(vertical = 8.dp)
- .weight(0.7f)
- )
- }
- Row {
- Text(
- text = stringResource(R.string.amount_chosen),
- style = MaterialTheme.typography.body1,
- fontWeight = FontWeight.Bold,
- modifier = Modifier
- .padding(vertical = 8.dp)
- .weight(0.3f)
- )
- Text(
- text = status.amountRaw.toString(),
- style = MaterialTheme.typography.body1,
- modifier = Modifier
- .padding(vertical = 8.dp)
- .weight(0.7f)
- )
- }
- Row {
- Text(
- text = stringResource(R.string.withdraw_exchange),
- style = MaterialTheme.typography.body1,
- modifier = Modifier
- .padding(vertical = 8.dp)
- .weight(0.3f)
- )
- Text(
- text = cleanExchange(status.exchangeBaseUrl),
- style = MaterialTheme.typography.body1,
- modifier = Modifier
- .padding(vertical = 8.dp)
- .weight(0.7f)
- .alpha(0.7f)
- )
- }
+ DetailRow(stringResource(R.string.withdraw_manual_ready_iban), status.iban)
+ DetailRow(stringResource(R.string.withdraw_manual_ready_subject), status.subject)
+ DetailRow(stringResource(R.string.amount_chosen), status.amountRaw.toString())
+ DetailRow(stringResource(R.string.withdraw_exchange), status.exchangeBaseUrl, false)
Text(
text = stringResource(R.string.withdraw_manual_ready_warning),
style = MaterialTheme.typography.body2,
color = colorResource(R.color.notice_text),
modifier = Modifier
+ .align(CenterHorizontally)
.padding(all = 8.dp)
.background(colorResource(R.color.notice_background))
.border(BorderStroke(2.dp, colorResource(R.color.notice_border)))
@@ -202,6 +149,35 @@ private fun Screen(
}
}
+@Composable
+fun DetailRow(label: String, content: String, copy: Boolean = true) {
+ val context = LocalContext.current
+ Row {
+ Column(
+ modifier = Modifier
+ .weight(0.3f)) {
+ Text(
+ text = label,
+ style = MaterialTheme.typography.body1,
+ fontWeight = if (copy) FontWeight.Bold else FontWeight.Normal,
+ )
+ if (copy) {
+ IconButton(
+ onClick = { copyToClipBoard(context, label, content) },
+ ) { Icon(Icons.Default.ContentCopy, stringResource(R.string.copy)) }
+ }
+ }
+ Text(
+ text = content,
+ style = MaterialTheme.typography.body1,
+ modifier = Modifier
+ .padding(vertical = 8.dp)
+ .weight(0.7f)
+ .then(if (copy) Modifier else Modifier.alpha(0.7f))
+ )
+ }
+}
+
@Preview
@Composable
fun PreviewScreen() {
@@ -215,3 +191,9 @@ fun PreviewScreen() {
)) {}
}
}
+
+private fun copyToClipBoard(context: Context, label: String, str: String) {
+ val clipboard = context.getSystemService<ClipboardManager>()
+ val clip = ClipData.newPlainText(label, str)
+ clipboard?.setPrimaryClip(clip)
+}