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