disallow closing password dialog in start activity

This commit is contained in:
- 2025-01-05 20:51:53 +01:00
parent d654081cd4
commit 874cd13df5
4 changed files with 12 additions and 3 deletions

View File

@ -159,7 +159,7 @@ class SettingsActivity : MoneroActivity() {
}
displaySeedButton.setOnClickListener {
val passwordDialog = PasswordBottomSheetDialog(walletService!!.getWalletOrThrow().info.path, object : PasswordBottomSheetDialog.Listener {
val passwordDialog = PasswordBottomSheetDialog(walletService!!.getWalletOrThrow().info.path, false, object : PasswordBottomSheetDialog.Listener {
override fun onCorrectPasswordSubmitted(self: PasswordBottomSheetDialog, password: String) {
self.dismiss()
displaySeedDialog()

View File

@ -2,6 +2,7 @@ package org.monfluo.wallet
import android.content.Intent
import android.os.Bundle
import androidx.activity.OnBackPressedCallback
import org.monfluo.wallet.fragment.dialog.PasswordBottomSheetDialog
import org.monfluo.wallet.util.Constants
import org.monfluo.wallet.util.Helper
@ -33,7 +34,7 @@ class StartActivity : WalletOpeningActivity() {
} else {
Timber.d("${walletPaths.size} wallets found but multi-wallet mode is not enabled, asking for password to open a wallet")
val walletPath = walletPaths.find { it.endsWith(Constants.DEFAULT_WALLET_NAME) } ?: walletPaths.first()
val passwordDialog = PasswordBottomSheetDialog(walletPath, object : PasswordBottomSheetDialog.Listener {
val passwordDialog = PasswordBottomSheetDialog(walletPath, true, object : PasswordBottomSheetDialog.Listener {
override fun onCorrectPasswordSubmitted(self: PasswordBottomSheetDialog, password: String) {
self.dismiss()
openWallet(walletPath, password)

View File

@ -26,7 +26,7 @@ class WalletActivity : WalletOpeningActivity() {
val walletPaths = org.monfluo.wallet.model.WalletManager.instance.findWallets(Helper.getWalletRoot(this).absolutePath)
adapter = WalletAdapter(walletPaths, object : WalletAdapter.AccountAdapterListener {
override fun onWalletSelected(walletPath: String) {
val passwordDialog = PasswordBottomSheetDialog(walletPath, object : PasswordBottomSheetDialog.Listener {
val passwordDialog = PasswordBottomSheetDialog(walletPath, false, object : PasswordBottomSheetDialog.Listener {
override fun onCorrectPasswordSubmitted(self: PasswordBottomSheetDialog, password: String) {
self.dismiss()
openWallet(walletPath, password)

View File

@ -8,12 +8,15 @@ import android.widget.Button
import android.widget.EditText
import android.widget.ImageButton
import android.widget.Toast
import androidx.activity.OnBackPressedCallback
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import org.monfluo.wallet.R
import org.monfluo.wallet.util.Helper.getClipBoardText
import timber.log.Timber
class PasswordBottomSheetDialog(
private val walletPath: String,
preventGoingBack: Boolean,
private val listener: Listener,
) : BottomSheetDialogFragment() {
@ -21,6 +24,10 @@ class PasswordBottomSheetDialog(
private lateinit var unlockButton: Button
private lateinit var pastePasswordImageButton: ImageButton
init {
isCancelable = !preventGoingBack
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
@ -60,6 +67,7 @@ class PasswordBottomSheetDialog(
walletPassword
)
}
interface Listener {
fun onCorrectPasswordSubmitted(self: PasswordBottomSheetDialog, password: String)
}