Set the recovery phrase as being viewed when the user has visited the… (#846)

* Set the recovery phrase as being viewed when the user has visited the RecoveryPasswordActivity

* Fix scenario whereby permanently hiding the recovery phrase via the banner does not

---------

Co-authored-by: alansley <aclansley@gmail.com>
pull/1710/head
AL-Session 4 months ago committed by GitHub
parent 5e43dd6ef7
commit b2e8b1ccc5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -130,7 +130,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
private val onPickImage = registerForActivityResult(
ActivityResultContracts.StartActivityForResult()
){ result ->
if (result.resultCode != Activity.RESULT_OK) return@registerForActivityResult
if (result.resultCode != RESULT_OK) return@registerForActivityResult
val outputFile = Uri.fromFile(File(cacheDir, "cropped"))
val inputFile: Uri? = result.data?.data ?: viewModel.getTempFile()?.let(Uri::fromFile)
@ -140,7 +140,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
private val hideRecoveryLauncher = registerForActivityResult(
ActivityResultContracts.StartActivityForResult()
) { result ->
if (result.resultCode != Activity.RESULT_OK) return@registerForActivityResult
if (result.resultCode != RESULT_OK) return@registerForActivityResult
if(result.data?.getBooleanExtra(RecoveryPasswordActivity.RESULT_RECOVERY_HIDDEN, false) == true){
viewModel.permanentlyHidePassword()

@ -5,11 +5,14 @@ import android.os.Bundle
import androidx.activity.viewModels
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
import network.loki.messenger.R
import org.session.libsession.utilities.TextSecurePreferences
import org.thoughtcrime.securesms.BaseActionBarActivity
import org.thoughtcrime.securesms.ui.setComposeContent
@AndroidEntryPoint
class RecoveryPasswordActivity : BaseActionBarActivity() {
companion object {
@ -18,6 +21,8 @@ class RecoveryPasswordActivity : BaseActionBarActivity() {
private val viewModel: RecoveryPasswordViewModel by viewModels()
@Inject lateinit var prefs: TextSecurePreferences
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
supportActionBar!!.title = resources.getString(R.string.sessionRecoveryPassword)
@ -33,10 +38,20 @@ class RecoveryPasswordActivity : BaseActionBarActivity() {
val returnIntent = Intent()
returnIntent.putExtra(RESULT_RECOVERY_HIDDEN, true)
setResult(RESULT_OK, returnIntent)
// The returnIntent assumes we're going back to the SettingsActivity, which handles the result - but
// if we entered this activity through the recovery phrase banner then we're going back to the
// HomeActivity, which does not. As such we'll write the change here to cover all our bases.
prefs.setHidePassword(true)
finish()
},
copyMnemonic = viewModel::copyMnemonic
)
}
// Set the seed as having been viewed when the user has seen this activity, which
// removes the reminder banner on the HomeActivity.
prefs.setHasViewedSeed(true)
}
}

@ -7,21 +7,19 @@ import android.content.Context
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
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
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
import org.session.libsession.utilities.AppTextSecurePreferences
import org.session.libsession.utilities.TextSecurePreferences
import org.session.libsignal.crypto.MnemonicCodec
import org.session.libsignal.utilities.hexEncodedPrivateKey
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil
import org.thoughtcrime.securesms.crypto.MnemonicUtilities
import javax.inject.Inject
@HiltViewModel
class RecoveryPasswordViewModel @Inject constructor(

Loading…
Cancel
Save