Fix "Cannot connect to crypto provider"
Initialize `openPgpCallback` before `onSwitchAccount()` is called from the class initializer.
This commit is contained in:
parent
726027f961
commit
7edbe542bd
1 changed files with 18 additions and 19 deletions
|
@ -90,6 +90,24 @@ class RecipientPresenter(
|
|||
private val allRecipients: List<Recipient>
|
||||
get() = with(recipientMvpView) { toRecipients + ccRecipients + bccRecipients }
|
||||
|
||||
private val openPgpCallback = object : OpenPgpApiManagerCallback {
|
||||
override fun onOpenPgpProviderStatusChanged() {
|
||||
if (openPgpApiManager.openPgpProviderState == OpenPgpProviderState.UI_REQUIRED) {
|
||||
recipientMvpView.showErrorOpenPgpUserInteractionRequired()
|
||||
}
|
||||
asyncUpdateCryptoStatus()
|
||||
}
|
||||
|
||||
override fun onOpenPgpProviderError(error: OpenPgpProviderError) {
|
||||
when (error) {
|
||||
OpenPgpProviderError.ConnectionLost -> openPgpApiManager.refreshConnection()
|
||||
OpenPgpProviderError.VersionIncompatible -> recipientMvpView.showErrorOpenPgpIncompatible()
|
||||
OpenPgpProviderError.ConnectionFailed -> recipientMvpView.showErrorOpenPgpConnection()
|
||||
else -> recipientMvpView.showErrorOpenPgpConnection()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
recipientMvpView.setPresenter(this)
|
||||
recipientMvpView.setLoaderManager(loaderManager)
|
||||
|
@ -723,25 +741,6 @@ class RecipientPresenter(
|
|||
}
|
||||
}
|
||||
|
||||
private val openPgpCallback = object : OpenPgpApiManagerCallback {
|
||||
override fun onOpenPgpProviderStatusChanged() {
|
||||
if (openPgpApiManager.openPgpProviderState == OpenPgpProviderState.UI_REQUIRED) {
|
||||
recipientMvpView.showErrorOpenPgpUserInteractionRequired()
|
||||
}
|
||||
|
||||
asyncUpdateCryptoStatus()
|
||||
}
|
||||
|
||||
override fun onOpenPgpProviderError(error: OpenPgpProviderError) {
|
||||
when (error) {
|
||||
OpenPgpProviderError.ConnectionLost -> openPgpApiManager.refreshConnection()
|
||||
OpenPgpProviderError.VersionIncompatible -> recipientMvpView.showErrorOpenPgpIncompatible()
|
||||
OpenPgpProviderError.ConnectionFailed -> recipientMvpView.showErrorOpenPgpConnection()
|
||||
else -> recipientMvpView.showErrorOpenPgpConnection()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun Array<String>.toAddressArray(): Array<Address> {
|
||||
return flatMap { addressString ->
|
||||
Address.parseUnencoded(addressString).toList()
|
||||
|
|
Loading…
Reference in a new issue