mirror of
https://github.com/yogeshpaliyal/KeyPass.git
synced 2026-01-11 01:09:42 -06:00
feat: Crash Fix for invalid secret key (#888)
This commit is contained in:
committed by
GitHub
parent
60c195edc0
commit
e0a3b7a104
@@ -1 +1 @@
|
||||
openjdk64-11.0.11
|
||||
openjdk64-17.0.7
|
||||
|
||||
@@ -31,16 +31,19 @@ import androidx.compose.ui.window.Dialog
|
||||
import androidx.hilt.navigation.compose.hiltViewModel
|
||||
import com.yogeshpaliyal.common.constants.ScannerType
|
||||
import com.yogeshpaliyal.common.utils.TOTPHelper
|
||||
import com.yogeshpaliyal.keypass.R
|
||||
import com.yogeshpaliyal.keypass.ui.detail.components.BottomBar
|
||||
import com.yogeshpaliyal.keypass.ui.detail.components.Fields
|
||||
import com.yogeshpaliyal.keypass.ui.redux.actions.CopyToClipboard
|
||||
import com.yogeshpaliyal.keypass.ui.redux.actions.GoBackAction
|
||||
import com.yogeshpaliyal.keypass.ui.redux.actions.NavigationAction
|
||||
import com.yogeshpaliyal.keypass.ui.redux.actions.ToastAction
|
||||
import com.yogeshpaliyal.keypass.ui.redux.states.PasswordGeneratorState
|
||||
import org.reduxkotlin.compose.rememberDispatcher
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.OutputStream
|
||||
import java.net.MalformedURLException
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
@@ -80,7 +83,13 @@ fun AccountDetailPage(
|
||||
}
|
||||
ScannerType.Secret -> {
|
||||
it.scannedText ?: return@rememberLauncherForActivityResult
|
||||
val totp = TOTPHelper(it.scannedText)
|
||||
var totp: TOTPHelper? = null
|
||||
try {
|
||||
totp = TOTPHelper(it.scannedText)
|
||||
} catch (e: MalformedURLException) {
|
||||
dispatchAction(ToastAction(R.string.invalid_secret_key))
|
||||
return@rememberLauncherForActivityResult
|
||||
}
|
||||
var newAccountModel = accountModel.copy(secret = totp.secret)
|
||||
|
||||
if (newAccountModel.title.isNullOrEmpty()) {
|
||||
|
||||
@@ -110,5 +110,6 @@
|
||||
<string name="keepass_backup">KeePass Backup</string>
|
||||
<string name="keepass_backup_desc">Choose KeePass CSV file to import</string>
|
||||
<string name="generate_qr_code">Export</string>
|
||||
<string name="invalid_secret_key">Invalid secret key format</string>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -26,4 +26,6 @@ android.defaults.buildfeatures.buildconfig=true
|
||||
android.nonTransitiveRClass=false
|
||||
android.nonFinalResIds=false
|
||||
|
||||
kotlin.mpp.androidGradlePluginCompatibility.nowarn=true
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user