AutofillDecryptActivity: Show toast on Main dispatcher (#717)

Without this the activity will crash rather than display the error

Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
Harsh Shandilya 2020-04-17 23:04:18 +05:30 committed by GitHub
parent b94b52a42d
commit 0e1dd641d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -212,11 +212,13 @@ class AutofillDecryptActivity : Activity(), CoroutineScope {
OpenPgpApi.RESULT_CODE_ERROR -> { OpenPgpApi.RESULT_CODE_ERROR -> {
val error = result.getParcelableExtra<OpenPgpError>(OpenPgpApi.RESULT_ERROR) val error = result.getParcelableExtra<OpenPgpError>(OpenPgpApi.RESULT_ERROR)
if (error != null) { if (error != null) {
Toast.makeText( withContext(Dispatchers.Main) {
applicationContext, Toast.makeText(
"Error from OpenKeyChain: ${error.message}", applicationContext,
Toast.LENGTH_LONG "Error from OpenKeyChain: ${error.message}",
).show() Toast.LENGTH_LONG
).show()
}
e { "OpenPgpApi ACTION_DECRYPT_VERIFY failed (${error.errorId}): ${error.message}" } e { "OpenPgpApi ACTION_DECRYPT_VERIFY failed (${error.errorId}): ${error.message}" }
} }
null null