diff --git a/app/src/main/java/org/thoughtcrime/securesms/onboarding/recoverypassword/RecoveryPasswordActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/onboarding/recoverypassword/RecoveryPasswordActivity.kt
index b721639014..45890980f9 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/onboarding/recoverypassword/RecoveryPasswordActivity.kt
+++ b/app/src/main/java/org/thoughtcrime/securesms/onboarding/recoverypassword/RecoveryPasswordActivity.kt
@@ -202,25 +202,13 @@ fun RecoveryPasswordCell(seed: String = "", qrBitmap: Bitmap? = null, copySeed:(
AnimatedVisibility(!showQr.value) {
Row(horizontalArrangement = Arrangement.spacedBy(32.dp)) {
- var copied by remember { mutableStateOf(false) }
- if (copied) LaunchedEffectAsync {
- delay(2.seconds)
- copied = false
- }
OutlineButton(
modifier = Modifier.weight(1f),
color = MaterialTheme.colors.onPrimary,
- onClick = {
- copySeed()
- copied = true
- }
+ onClick = copySeed,
+ temporaryContent = { Text(stringResource(R.string.copied)) }
) {
- AnimatedVisibility(!copied) {
- Text(stringResource(R.string.copy))
- }
- AnimatedVisibility(copied) {
- Text(stringResource(R.string.copied))
- }
+ Text(stringResource(R.string.copy))
}
OutlineButton(text = stringResource(R.string.qrView), modifier = Modifier.weight(1f), color = MaterialTheme.colors.onPrimary) { showQr.toggle() }
}
diff --git a/app/src/main/java/org/thoughtcrime/securesms/ui/Components.kt b/app/src/main/java/org/thoughtcrime/securesms/ui/Components.kt
index cdad3115dd..e4d2d4c37a 100644
--- a/app/src/main/java/org/thoughtcrime/securesms/ui/Components.kt
+++ b/app/src/main/java/org/thoughtcrime/securesms/ui/Components.kt
@@ -1,6 +1,7 @@
package org.thoughtcrime.securesms.ui
import androidx.annotation.DrawableRes
+import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.ScrollState
@@ -34,7 +35,11 @@ import androidx.compose.material.Text
import androidx.compose.material.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
+import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
@@ -58,6 +63,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.viewinterop.AndroidView
import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import network.loki.messenger.R
import org.session.libsession.utilities.recipients.Recipient
@@ -66,6 +72,7 @@ import org.thoughtcrime.securesms.components.ProfilePictureView
import org.thoughtcrime.securesms.conversation.disappearingmessages.ui.OptionsCard
import kotlin.math.min
import kotlin.math.roundToInt
+import kotlin.time.Duration.Companion.seconds
@Composable
fun OutlineButton(
@@ -110,6 +117,42 @@ fun OutlineButton(
}
}
+@Composable
+fun OutlineButton(
+ temporaryContent: @Composable () -> Unit,
+ modifier: Modifier = Modifier,
+ color: Color = LocalExtraColors.current.prominentButtonColor,
+ onClick: () -> Unit = {},
+ content: @Composable () -> Unit = {}
+) {
+ var clicked by remember { mutableStateOf(false) }
+ if (clicked) LaunchedEffectAsync {
+ delay(2.seconds)
+ clicked = false
+ }
+
+ OutlinedButton(
+ modifier = modifier,
+ onClick = {
+ onClick()
+ clicked = true
+ },
+ border = BorderStroke(1.dp, color),
+ shape = RoundedCornerShape(percent = 50),
+ colors = ButtonDefaults.outlinedButtonColors(
+ contentColor = color,
+ backgroundColor = Color.Unspecified
+ )
+ ) {
+ AnimatedVisibility(clicked) {
+ temporaryContent()
+ }
+ AnimatedVisibility(!clicked) {
+ content()
+ }
+ }
+}
+
@Composable
fun FilledButton(
text: String,
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index d7bef7b100..023f767d01 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -133,7 +133,6 @@
User settings
Username
Privacy
- Recovery password
Recovery password menu item
Edit user nickname
Apply