mirror of
https://github.com/oxen-io/session-android.git
synced 2025-05-30 00:58:18 +00:00
Fade in Copied on copy password
This commit is contained in:
parent
a4008af36b
commit
7a1b5749aa
@ -359,14 +359,15 @@ dependencies {
|
|||||||
testImplementation 'org.robolectric:shadows-multidex:4.4'
|
testImplementation 'org.robolectric:shadows-multidex:4.4'
|
||||||
|
|
||||||
implementation 'com.github.bumptech.glide:compose:1.0.0-alpha.5'
|
implementation 'com.github.bumptech.glide:compose:1.0.0-alpha.5'
|
||||||
implementation 'androidx.compose.ui:ui:1.5.2'
|
implementation 'androidx.compose.ui:ui:1.6.2'
|
||||||
implementation 'androidx.compose.ui:ui-tooling:1.5.2'
|
implementation 'androidx.compose.animation:animation:1.6.2'
|
||||||
|
implementation 'androidx.compose.ui:ui-tooling:1.6.2'
|
||||||
implementation "com.google.accompanist:accompanist-themeadapter-appcompat:0.33.1-alpha"
|
implementation "com.google.accompanist:accompanist-themeadapter-appcompat:0.33.1-alpha"
|
||||||
implementation "com.google.accompanist:accompanist-pager-indicators:0.33.1-alpha"
|
implementation "com.google.accompanist:accompanist-pager-indicators:0.33.1-alpha"
|
||||||
implementation "androidx.compose.runtime:runtime-livedata:1.5.2"
|
implementation "androidx.compose.runtime:runtime-livedata:1.6.2"
|
||||||
|
|
||||||
implementation 'androidx.compose.foundation:foundation-layout:1.5.2'
|
implementation 'androidx.compose.foundation:foundation-layout:1.6.2'
|
||||||
implementation 'androidx.compose.material:material:1.5.2'
|
implementation 'androidx.compose.material:material:1.6.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
static def getLastCommitTimestamp() {
|
static def getLastCommitTimestamp() {
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package org.thoughtcrime.securesms.onboarding.recoverypassword
|
package org.thoughtcrime.securesms.onboarding.recoverypassword
|
||||||
|
|
||||||
import android.content.ClipData
|
|
||||||
import android.content.ClipboardManager
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.widget.Toast
|
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.compose.animation.AnimatedVisibility
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
|
import androidx.compose.animation.Crossfade
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.border
|
import androidx.compose.foundation.border
|
||||||
@ -17,6 +15,7 @@ import androidx.compose.foundation.layout.Box
|
|||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.height
|
import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
@ -33,7 +32,6 @@ import androidx.compose.runtime.mutableStateOf
|
|||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
|
||||||
import androidx.compose.ui.graphics.ColorFilter
|
import androidx.compose.ui.graphics.ColorFilter
|
||||||
import androidx.compose.ui.graphics.asImageBitmap
|
import androidx.compose.ui.graphics.asImageBitmap
|
||||||
import androidx.compose.ui.platform.ComposeView
|
import androidx.compose.ui.platform.ComposeView
|
||||||
@ -44,7 +42,6 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import org.session.libsession.utilities.TextSecurePreferences
|
|
||||||
import org.thoughtcrime.securesms.BaseActionBarActivity
|
import org.thoughtcrime.securesms.BaseActionBarActivity
|
||||||
import org.thoughtcrime.securesms.showSessionDialog
|
import org.thoughtcrime.securesms.showSessionDialog
|
||||||
import org.thoughtcrime.securesms.ui.AppTheme
|
import org.thoughtcrime.securesms.ui.AppTheme
|
||||||
@ -69,23 +66,11 @@ class RecoveryPasswordActivity : BaseActionBarActivity() {
|
|||||||
|
|
||||||
ComposeView(this).apply {
|
ComposeView(this).apply {
|
||||||
setContent {
|
setContent {
|
||||||
RecoveryPassword(viewModel.seed, viewModel.qrBitmap, { copySeed() }) { onHide() }
|
RecoveryPassword(viewModel.seed, viewModel.qrBitmap, { viewModel.copySeed(context) }) { onHide() }
|
||||||
}
|
}
|
||||||
}.let(::setContentView)
|
}.let(::setContentView)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun revealSeed() {
|
|
||||||
TextSecurePreferences.setHasViewedSeed(this, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun copySeed() {
|
|
||||||
revealSeed()
|
|
||||||
val clipboard = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
|
||||||
val clip = ClipData.newPlainText("Seed", viewModel.seed)
|
|
||||||
clipboard.setPrimaryClip(clip)
|
|
||||||
Toast.makeText(this, R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun onHide() {
|
private fun onHide() {
|
||||||
showSessionDialog {
|
showSessionDialog {
|
||||||
title("Hide Recovery Password Permanently")
|
title("Hide Recovery Password Permanently")
|
||||||
@ -130,7 +115,8 @@ fun RecoveryPassword(
|
|||||||
AppTheme {
|
AppTheme {
|
||||||
Column(
|
Column(
|
||||||
verticalArrangement = Arrangement.spacedBy(16.dp),
|
verticalArrangement = Arrangement.spacedBy(16.dp),
|
||||||
modifier = Modifier.verticalScroll(rememberScrollState())
|
modifier = Modifier
|
||||||
|
.verticalScroll(rememberScrollState())
|
||||||
.padding(bottom = 16.dp)
|
.padding(bottom = 16.dp)
|
||||||
) {
|
) {
|
||||||
RecoveryPasswordCell(seed, qrBitmap, copySeed)
|
RecoveryPasswordCell(seed, qrBitmap, copySeed)
|
||||||
@ -145,6 +131,10 @@ fun RecoveryPasswordCell(seed: String = "", qrBitmap: Bitmap? = null, copySeed:(
|
|||||||
mutableStateOf(false)
|
mutableStateOf(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val copied = remember {
|
||||||
|
mutableStateOf(false)
|
||||||
|
}
|
||||||
|
|
||||||
CellWithPaddingAndMargin {
|
CellWithPaddingAndMargin {
|
||||||
Column {
|
Column {
|
||||||
Row {
|
Row {
|
||||||
@ -159,13 +149,13 @@ fun RecoveryPasswordCell(seed: String = "", qrBitmap: Bitmap? = null, copySeed:(
|
|||||||
Text(
|
Text(
|
||||||
seed,
|
seed,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(vertical = 24.dp)
|
.padding(vertical = 24.dp)
|
||||||
.border(
|
.border(
|
||||||
width = 1.dp,
|
width = 1.dp,
|
||||||
color = classicDarkColors[3],
|
color = classicDarkColors[3],
|
||||||
shape = RoundedCornerShape(11.dp)
|
shape = RoundedCornerShape(11.dp)
|
||||||
)
|
)
|
||||||
.padding(24.dp),
|
.padding(24.dp),
|
||||||
style = MaterialTheme.typography.small.copy(fontFamily = FontFamily.Monospace),
|
style = MaterialTheme.typography.small.copy(fontFamily = FontFamily.Monospace),
|
||||||
color = LocalExtraColors.current.prominentButtonColor,
|
color = LocalExtraColors.current.prominentButtonColor,
|
||||||
)
|
)
|
||||||
@ -176,8 +166,8 @@ fun RecoveryPasswordCell(seed: String = "", qrBitmap: Bitmap? = null, copySeed:(
|
|||||||
backgroundColor = LocalExtraColors.current.lightCell,
|
backgroundColor = LocalExtraColors.current.lightCell,
|
||||||
elevation = 0.dp,
|
elevation = 0.dp,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.align(Alignment.CenterHorizontally)
|
.align(Alignment.CenterHorizontally)
|
||||||
.padding(vertical = 24.dp)
|
.padding(vertical = 24.dp)
|
||||||
) {
|
) {
|
||||||
Box {
|
Box {
|
||||||
qrBitmap?.let {
|
qrBitmap?.let {
|
||||||
@ -192,11 +182,12 @@ fun RecoveryPasswordCell(seed: String = "", qrBitmap: Bitmap? = null, copySeed:(
|
|||||||
painter = painterResource(id = R.drawable.session_shield),
|
painter = painterResource(id = R.drawable.session_shield),
|
||||||
contentDescription = "",
|
contentDescription = "",
|
||||||
tint = LocalExtraColors.current.onLightCell,
|
tint = LocalExtraColors.current.onLightCell,
|
||||||
modifier = Modifier.align(Alignment.Center)
|
modifier = Modifier
|
||||||
.width(46.dp)
|
.align(Alignment.Center)
|
||||||
.height(56.dp)
|
.width(46.dp)
|
||||||
.background(color = LocalExtraColors.current.lightCell)
|
.height(56.dp)
|
||||||
.padding(horizontal = 3.dp, vertical = 1.dp)
|
.background(color = LocalExtraColors.current.lightCell)
|
||||||
|
.padding(horizontal = 3.dp, vertical = 1.dp)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,7 +195,9 @@ fun RecoveryPasswordCell(seed: String = "", qrBitmap: Bitmap? = null, copySeed:(
|
|||||||
|
|
||||||
AnimatedVisibility(!showQr.value) {
|
AnimatedVisibility(!showQr.value) {
|
||||||
Row(horizontalArrangement = Arrangement.spacedBy(32.dp)) {
|
Row(horizontalArrangement = Arrangement.spacedBy(32.dp)) {
|
||||||
OutlineButton(text = stringResource(R.string.copy), modifier = Modifier.weight(1f), color = MaterialTheme.colors.onPrimary) { copySeed() }
|
Crossfade(targetState = if (copied.value) R.string.copied else R.string.copy, modifier = Modifier.weight(1f), label = "Copy to Copied CrossFade") {
|
||||||
|
OutlineButton(text = stringResource(it), modifier = Modifier.fillMaxWidth(), color = MaterialTheme.colors.onPrimary) { copySeed(); copied.value = true }
|
||||||
|
}
|
||||||
OutlineButton(text = "View QR", modifier = Modifier.weight(1f), color = MaterialTheme.colors.onPrimary) { showQr.toggle() }
|
OutlineButton(text = "View QR", modifier = Modifier.weight(1f), color = MaterialTheme.colors.onPrimary) { showQr.toggle() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package org.thoughtcrime.securesms.onboarding.recoverypassword
|
package org.thoughtcrime.securesms.onboarding.recoverypassword
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
|
import android.content.ClipData
|
||||||
|
import android.content.ClipboardManager
|
||||||
|
import android.content.Context
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import androidx.lifecycle.AndroidViewModel
|
import androidx.lifecycle.AndroidViewModel
|
||||||
import androidx.preference.PreferenceFragmentCompat.OnPreferenceStartFragmentCallback
|
import androidx.preference.PreferenceFragmentCompat.OnPreferenceStartFragmentCallback
|
||||||
@ -26,6 +29,13 @@ class RecoveryPasswordViewModel @Inject constructor(
|
|||||||
prefs.setHidePassword(true)
|
prefs.setHidePassword(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun copySeed(context: Context) {
|
||||||
|
TextSecurePreferences.setHasViewedSeed(context, true)
|
||||||
|
val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
|
val clip = ClipData.newPlainText("Seed", seed)
|
||||||
|
clipboard.setPrimaryClip(clip)
|
||||||
|
}
|
||||||
|
|
||||||
val seed by lazy {
|
val seed by lazy {
|
||||||
val hexEncodedSeed = IdentityKeyUtil.retrieve(application, IdentityKeyUtil.LOKI_SEED)
|
val hexEncodedSeed = IdentityKeyUtil.retrieve(application, IdentityKeyUtil.LOKI_SEED)
|
||||||
?: IdentityKeyUtil.getIdentityKeyPair(application).hexEncodedPrivateKey // Legacy account
|
?: IdentityKeyUtil.getIdentityKeyPair(application).hexEncodedPrivateKey // Legacy account
|
||||||
|
@ -708,6 +708,7 @@
|
|||||||
<!-- Session -->
|
<!-- Session -->
|
||||||
<string name="continue_2">Continue</string>
|
<string name="continue_2">Continue</string>
|
||||||
<string name="copy">Copy</string>
|
<string name="copy">Copy</string>
|
||||||
|
<string name="copied">Copied</string>
|
||||||
<string name="close">Close</string>
|
<string name="close">Close</string>
|
||||||
<string name="invalid_url">Invalid URL</string>
|
<string name="invalid_url">Invalid URL</string>
|
||||||
<string name="copied_to_clipboard">Copied to clipboard</string>
|
<string name="copied_to_clipboard">Copied to clipboard</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user