mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-20 18:38:26 +00:00
Fix copy mnemonic
This commit is contained in:
parent
aac228ba91
commit
1f7a1c7e0d
@ -45,7 +45,7 @@ import org.thoughtcrime.securesms.ui.h8
|
|||||||
internal fun RecoveryPasswordScreen(
|
internal fun RecoveryPasswordScreen(
|
||||||
mnemonic: String,
|
mnemonic: String,
|
||||||
seed: String? = null,
|
seed: String? = null,
|
||||||
copySeed:() -> Unit = {},
|
copyMnemonic:() -> Unit = {},
|
||||||
onHide:() -> Unit = {}
|
onHide:() -> Unit = {}
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
@ -55,7 +55,7 @@ internal fun RecoveryPasswordScreen(
|
|||||||
.verticalScroll(rememberScrollState())
|
.verticalScroll(rememberScrollState())
|
||||||
.padding(bottom = LocalDimensions.current.xsMargin)
|
.padding(bottom = LocalDimensions.current.xsMargin)
|
||||||
) {
|
) {
|
||||||
RecoveryPasswordCell(mnemonic, seed, copySeed)
|
RecoveryPasswordCell(mnemonic, seed, copyMnemonic)
|
||||||
HideRecoveryPasswordCell(onHide)
|
HideRecoveryPasswordCell(onHide)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ internal fun RecoveryPasswordScreen(
|
|||||||
private fun RecoveryPasswordCell(
|
private fun RecoveryPasswordCell(
|
||||||
mnemonic: String,
|
mnemonic: String,
|
||||||
seed: String?,
|
seed: String?,
|
||||||
copySeed:() -> Unit = {}
|
copyMnemonic:() -> Unit = {}
|
||||||
) {
|
) {
|
||||||
var showQr by remember {
|
var showQr by remember {
|
||||||
mutableStateOf(false)
|
mutableStateOf(false)
|
||||||
@ -113,7 +113,7 @@ private fun RecoveryPasswordCell(
|
|||||||
) {
|
) {
|
||||||
SlimOutlineCopyButton(
|
SlimOutlineCopyButton(
|
||||||
Modifier.weight(1f),
|
Modifier.weight(1f),
|
||||||
onClick = copySeed
|
onClick = copyMnemonic
|
||||||
)
|
)
|
||||||
SlimOutlineButton(
|
SlimOutlineButton(
|
||||||
stringResource(R.string.qrView),
|
stringResource(R.string.qrView),
|
||||||
|
@ -24,7 +24,7 @@ class RecoveryPasswordActivity : BaseActionBarActivity() {
|
|||||||
RecoveryPasswordScreen(
|
RecoveryPasswordScreen(
|
||||||
mnemonic = mnemonic,
|
mnemonic = mnemonic,
|
||||||
seed = seed,
|
seed = seed,
|
||||||
copySeed = { viewModel.copySeed(this) },
|
copyMnemonic = viewModel::copyMnemonic,
|
||||||
onHide = ::onHide
|
onHide = ::onHide
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import androidx.lifecycle.viewModelScope
|
|||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.MutableStateFlow
|
import kotlinx.coroutines.flow.MutableStateFlow
|
||||||
|
import kotlinx.coroutines.flow.SharingStarted
|
||||||
import kotlinx.coroutines.flow.filter
|
import kotlinx.coroutines.flow.filter
|
||||||
import kotlinx.coroutines.flow.filterNotNull
|
import kotlinx.coroutines.flow.filterNotNull
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
@ -31,17 +32,16 @@ class RecoveryPasswordViewModel @Inject constructor(
|
|||||||
val seed = MutableStateFlow<String?>(null)
|
val seed = MutableStateFlow<String?>(null)
|
||||||
val mnemonic = seed.filterNotNull()
|
val mnemonic = seed.filterNotNull()
|
||||||
.map { MnemonicCodec { MnemonicUtilities.loadFileContents(application, it) }.encode(it, MnemonicCodec.Language.Configuration.english) }
|
.map { MnemonicCodec { MnemonicUtilities.loadFileContents(application, it) }.encode(it, MnemonicCodec.Language.Configuration.english) }
|
||||||
|
.stateIn(viewModelScope, SharingStarted.Eagerly, "")
|
||||||
|
|
||||||
fun permanentlyHidePassword() {
|
fun permanentlyHidePassword() {
|
||||||
prefs.setHidePassword(true)
|
prefs.setHidePassword(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun copySeed(context: Context) {
|
fun copyMnemonic() {
|
||||||
val seed = seed.value ?: return
|
prefs.setHasViewedSeed(true)
|
||||||
TextSecurePreferences.setHasViewedSeed(context, true)
|
ClipData.newPlainText("Seed", mnemonic.value)
|
||||||
val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
.let(application.clipboard::setPrimaryClip)
|
||||||
val clip = ClipData.newPlainText("Seed", seed)
|
|
||||||
clipboard.setPrimaryClip(clip)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@ -51,3 +51,5 @@ class RecoveryPasswordViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val Context.clipboard get() = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
|
||||||
|
@ -5,7 +5,6 @@ import androidx.compose.foundation.background
|
|||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||||
import androidx.compose.foundation.text.selection.LocalTextSelectionColors
|
import androidx.compose.foundation.text.selection.LocalTextSelectionColors
|
||||||
import androidx.compose.foundation.text.selection.TextSelectionColors
|
|
||||||
import androidx.compose.material.LocalContentColor
|
import androidx.compose.material.LocalContentColor
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material.MaterialTheme
|
||||||
import androidx.compose.material.Shapes
|
import androidx.compose.material.Shapes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user