aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2020-10-01 00:36:01 +0530
committerHarsh Shandilya <me@msfjarvis.dev>2020-10-01 20:25:56 +0530
commit944efee00eafe52bf0748a1375149569325a6b85 (patch)
treec63f1fb1623cf460447688d117ba7442a84b9a20
parent98518ca49996d9ecfba06b9b68babc78210ed9d0 (diff)
PasswordCreationActivity: tweak logic for determining if identifier selection is needed
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/crypto/PasswordCreationActivity.kt4
1 files changed, 4 insertions, 0 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/crypto/PasswordCreationActivity.kt b/app/src/main/java/com/zeapo/pwdstore/crypto/PasswordCreationActivity.kt
index b5ab0008..eb1303fc 100644
--- a/app/src/main/java/com/zeapo/pwdstore/crypto/PasswordCreationActivity.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/crypto/PasswordCreationActivity.kt
@@ -255,6 +255,7 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
@OptIn(ExperimentalUnsignedTypes::class)
private fun parseGpgIdentifier(identifier: String): GpgIdentifier? {
+ if (identifier.isEmpty()) return null
// Match long key IDs:
// FF22334455667788 or 0xFF22334455667788
val maybeLongKeyId = identifier.removePrefix("0x").takeIf {
@@ -320,6 +321,9 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
.filter { it.isNotBlank() }
.map { line ->
parseGpgIdentifier(line) ?: run {
+ // The line being empty means this is most likely an empty `.gpg-id` file
+ // we created. Skip the validation so we can make the user add a real ID.
+ if (line.isEmpty()) return@run
if (line.removePrefix("0x").matches("[a-fA-F0-9]{8}".toRegex())) {
snackbar(message = resources.getString(R.string.short_key_ids_unsupported))
} else {