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
This commit is contained in:
parent
7868c6d08e
commit
6fc1fafe99
2 changed files with 15 additions and 12 deletions
|
@ -29,7 +29,7 @@ class PGPKeyImportActivity : AppCompatActivity() {
|
||||||
registerForActivityResult(OpenDocument()) { uri ->
|
registerForActivityResult(OpenDocument()) { uri ->
|
||||||
runCatching {
|
runCatching {
|
||||||
if (uri == null) {
|
if (uri == null) {
|
||||||
throw IllegalStateException("Selected URI was null")
|
return@runCatching null
|
||||||
}
|
}
|
||||||
val keyInputStream =
|
val keyInputStream =
|
||||||
contentResolver.openInputStream(uri)
|
contentResolver.openInputStream(uri)
|
||||||
|
@ -41,13 +41,14 @@ class PGPKeyImportActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
.mapBoth(
|
.mapBoth(
|
||||||
{ key ->
|
{ key ->
|
||||||
require(key != null) { "Key cannot be null here" }
|
if (key != null) {
|
||||||
MaterialAlertDialogBuilder(this)
|
MaterialAlertDialogBuilder(this)
|
||||||
.setTitle(getString(R.string.pgp_key_import_succeeded))
|
.setTitle(getString(R.string.pgp_key_import_succeeded))
|
||||||
.setMessage(getString(R.string.pgp_key_import_succeeded_message, tryGetId(key)))
|
.setMessage(getString(R.string.pgp_key_import_succeeded_message, tryGetId(key)))
|
||||||
.setPositiveButton(android.R.string.ok) { _, _ -> finish() }
|
.setPositiveButton(android.R.string.ok) { _, _ -> finish() }
|
||||||
.setOnCancelListener { finish() }
|
.setOnCancelListener { finish() }
|
||||||
.show()
|
.show()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{ throwable ->
|
{ throwable ->
|
||||||
MaterialAlertDialogBuilder(this)
|
MaterialAlertDialogBuilder(this)
|
||||||
|
|
|
@ -18,13 +18,15 @@ class PGPSettings(private val activity: FragmentActivity) : SettingsProvider {
|
||||||
|
|
||||||
override fun provideSettings(builder: PreferenceScreen.Builder) {
|
override fun provideSettings(builder: PreferenceScreen.Builder) {
|
||||||
builder.apply {
|
builder.apply {
|
||||||
checkBox(Feature.EnablePGPainlessBackend.configKey) {
|
val enablePGPainless =
|
||||||
title = "Enable new PGP backend"
|
checkBox(Feature.EnablePGPainlessBackend.configKey) {
|
||||||
persistent = true
|
title = "Enable new PGP backend"
|
||||||
}
|
persistent = true
|
||||||
|
}
|
||||||
pref("_") {
|
pref("_") {
|
||||||
title = "Import PGP key"
|
title = "Import PGP key"
|
||||||
persistent = false
|
persistent = false
|
||||||
|
dependency = enablePGPainless.key
|
||||||
onClick {
|
onClick {
|
||||||
activity.launchActivity(PGPKeyImportActivity::class.java)
|
activity.launchActivity(PGPKeyImportActivity::class.java)
|
||||||
false
|
false
|
||||||
|
|
Loading…
Reference in a new issue