PasswordCreationActivity: tweak logic for determining if identifier selection is needed
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
98518ca499
commit
944efee00e
1 changed files with 4 additions and 0 deletions
|
@ -255,6 +255,7 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
|
||||||
|
|
||||||
@OptIn(ExperimentalUnsignedTypes::class)
|
@OptIn(ExperimentalUnsignedTypes::class)
|
||||||
private fun parseGpgIdentifier(identifier: String): GpgIdentifier? {
|
private fun parseGpgIdentifier(identifier: String): GpgIdentifier? {
|
||||||
|
if (identifier.isEmpty()) return null
|
||||||
// Match long key IDs:
|
// Match long key IDs:
|
||||||
// FF22334455667788 or 0xFF22334455667788
|
// FF22334455667788 or 0xFF22334455667788
|
||||||
val maybeLongKeyId = identifier.removePrefix("0x").takeIf {
|
val maybeLongKeyId = identifier.removePrefix("0x").takeIf {
|
||||||
|
@ -320,6 +321,9 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB
|
||||||
.filter { it.isNotBlank() }
|
.filter { it.isNotBlank() }
|
||||||
.map { line ->
|
.map { line ->
|
||||||
parseGpgIdentifier(line) ?: run {
|
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())) {
|
if (line.removePrefix("0x").matches("[a-fA-F0-9]{8}".toRegex())) {
|
||||||
snackbar(message = resources.getString(R.string.short_key_ids_unsupported))
|
snackbar(message = resources.getString(R.string.short_key_ids_unsupported))
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue