summaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorHarsh Shandilya <me@msfjarvis.dev>2022-03-13 18:37:29 +0530
committerGitHub <noreply@github.com>2022-03-13 13:07:29 +0000
commit6fc1fafe991d8c2a21340e41293fe130c88d48fa (patch)
treefe1f92948cd6de5baebd3dbcd48dcd45be8498b8 /app/src/main
parent7868c6d08e5139b4b5e44b1d458730a2f628e5d5 (diff)
Misc PGP v2 fixes (#1784)
* Don't throw in PGPKeyImportActivity when no file is selected * PGPSettings: mark import option as dependent on V2 backend pref
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/pgp/PGPKeyImportActivity.kt17
-rw-r--r--app/src/main/java/dev/msfjarvis/aps/ui/settings/PGPSettings.kt10
2 files changed, 15 insertions, 12 deletions
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/pgp/PGPKeyImportActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/pgp/PGPKeyImportActivity.kt
index b97de5e0..02ea4fc3 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/pgp/PGPKeyImportActivity.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/pgp/PGPKeyImportActivity.kt
@@ -29,7 +29,7 @@ class PGPKeyImportActivity : AppCompatActivity() {
registerForActivityResult(OpenDocument()) { uri ->
runCatching {
if (uri == null) {
- throw IllegalStateException("Selected URI was null")
+ return@runCatching null
}
val keyInputStream =
contentResolver.openInputStream(uri)
@@ -41,13 +41,14 @@ class PGPKeyImportActivity : AppCompatActivity() {
}
.mapBoth(
{ key ->
- require(key != null) { "Key cannot be null here" }
- MaterialAlertDialogBuilder(this)
- .setTitle(getString(R.string.pgp_key_import_succeeded))
- .setMessage(getString(R.string.pgp_key_import_succeeded_message, tryGetId(key)))
- .setPositiveButton(android.R.string.ok) { _, _ -> finish() }
- .setOnCancelListener { finish() }
- .show()
+ if (key != null) {
+ MaterialAlertDialogBuilder(this)
+ .setTitle(getString(R.string.pgp_key_import_succeeded))
+ .setMessage(getString(R.string.pgp_key_import_succeeded_message, tryGetId(key)))
+ .setPositiveButton(android.R.string.ok) { _, _ -> finish() }
+ .setOnCancelListener { finish() }
+ .show()
+ }
},
{ throwable ->
MaterialAlertDialogBuilder(this)
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/settings/PGPSettings.kt b/app/src/main/java/dev/msfjarvis/aps/ui/settings/PGPSettings.kt
index 86f23c32..b81af006 100644
--- a/app/src/main/java/dev/msfjarvis/aps/ui/settings/PGPSettings.kt
+++ b/app/src/main/java/dev/msfjarvis/aps/ui/settings/PGPSettings.kt
@@ -18,13 +18,15 @@ class PGPSettings(private val activity: FragmentActivity) : SettingsProvider {
override fun provideSettings(builder: PreferenceScreen.Builder) {
builder.apply {
- checkBox(Feature.EnablePGPainlessBackend.configKey) {
- title = "Enable new PGP backend"
- persistent = true
- }
+ val enablePGPainless =
+ checkBox(Feature.EnablePGPainlessBackend.configKey) {
+ title = "Enable new PGP backend"
+ persistent = true
+ }
pref("_") {
title = "Import PGP key"
persistent = false
+ dependency = enablePGPainless.key
onClick {
activity.launchActivity(PGPKeyImportActivity::class.java)
false