Skip to content

Commit

Permalink
rfct: Move password dialog to Backpack
Browse files Browse the repository at this point in the history
  • Loading branch information
cyb3rko committed Jun 24, 2023
1 parent 93e783a commit 585251f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 123 deletions.

This file was deleted.

33 changes: 10 additions & 23 deletions app/src/main/kotlin/com/cyb3rko/pincredible/utils/BackupHandler.kt
Expand Up @@ -27,6 +27,7 @@ import com.cyb3rko.backpack.crypto.CryptoManager.Hash
import com.cyb3rko.backpack.data.Serializable
import com.cyb3rko.backpack.managers.StorageManager
import com.cyb3rko.backpack.modals.ErrorDialog
import com.cyb3rko.backpack.modals.PasswordDialog
import com.cyb3rko.backpack.utils.ObjectSerializer
import com.cyb3rko.backpack.utils.dateNow
import com.cyb3rko.backpack.utils.lastN
Expand All @@ -36,7 +37,6 @@ import com.cyb3rko.backpack.utils.withoutLast
import com.cyb3rko.backpack.utils.withoutLastN
import com.cyb3rko.pincredible.R
import com.cyb3rko.pincredible.data.PinTable
import com.cyb3rko.pincredible.modals.PasswordDialog
import com.cyb3rko.pincredible.modals.ProgressDialog
import java.io.File

Expand Down Expand Up @@ -80,19 +80,11 @@ internal object BackupHandler {
multiPin: Boolean,
singleBackup: SingleBackupStructure? = null
) {
PasswordDialog.show(
context,
R.string.dialog_backup_title
) { dialog, inputLayout, input ->
if (input.isNotEmpty() && input.length in 10..100) {
dialog.dismiss()
if (!multiPin) {
runSingleExport(context, uri, CryptoManager.shaHash(input), singleBackup!!)
} else {
runExport(context, uri, CryptoManager.shaHash(input))
}
PasswordDialog.show(context, R.string.dialog_backup_title) { input ->
if (!multiPin) {
runSingleExport(context, uri, CryptoManager.shaHash(input), singleBackup!!)
} else {
inputLayout.error = context.getString(R.string.dialog_name_error_length, 10, 100)
runExport(context, uri, CryptoManager.shaHash(input))
}
}
}
Expand Down Expand Up @@ -227,16 +219,11 @@ internal object BackupHandler {
context,
R.string.dialog_backup_title,
showError
) { dialog, inputLayout, input ->
if (input.isNotEmpty() && input.length in 10..100) {
dialog.dismiss()
if (backupType == BackupType.SINGLE_PIN) {
doRestoreSingleBackup(context, uri, input, onFinished)
} else if (backupType == BackupType.MULTI_PIN) {
doRestoreMultiBackup(context, uri, input, onFinished)
}
} else {
inputLayout.error = context.getString(R.string.dialog_name_error_length, 10, 100)
) { input ->
if (backupType == BackupType.SINGLE_PIN) {
doRestoreSingleBackup(context, uri, input, onFinished)
} else if (backupType == BackupType.MULTI_PIN) {
doRestoreMultiBackup(context, uri, input, onFinished)
}
}
}
Expand Down
40 changes: 0 additions & 40 deletions app/src/main/res/layout/dialog_password.xml

This file was deleted.

2 changes: 0 additions & 2 deletions app/src/main/res/values/strings.xml
Expand Up @@ -32,8 +32,6 @@
<string name="dialog_name_error_length">Use between %1$d-%2$d characters</string>
<string name="dialog_name_hint">Give it a name</string>
<string name="dialog_name_title">PIN Name</string>
<string name="dialog_password_hint">Your Password</string>
<string name="dialog_password_error">Invalid integrity, most likely wrong password</string>
<string name="dialog_backup_title">Encryption Password</string>
<string name="dialog_single_export_message">Exporting single PIN…</string>
<string name="dialog_single_export_finished">PIN export completed…</string>
Expand Down

0 comments on commit 585251f

Please sign in to comment.