Remove hand-rolled CoroutineScope and fix inverted conditions (#1386)

This commit is contained in:
Harsh Shandilya 2021-04-18 14:15:45 +05:30 committed by GitHub
parent a3ebcfcc62
commit 7710ca9024
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 11 deletions

View file

@ -40,10 +40,7 @@ import kotlin.coroutines.Continuation
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
import kotlin.coroutines.suspendCoroutine
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancelChildren
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import me.msfjarvis.openpgpktx.util.OpenPgpApi
@ -53,7 +50,7 @@ import org.openintents.openpgp.OpenPgpError
@RequiresApi(Build.VERSION_CODES.O)
@AndroidEntryPoint
class AutofillDecryptActivity : AppCompatActivity(), CoroutineScope {
class AutofillDecryptActivity : AppCompatActivity() {
companion object {
@ -101,9 +98,6 @@ class AutofillDecryptActivity : AppCompatActivity(), CoroutineScope {
private var continueAfterUserInteraction: Continuation<Intent>? = null
private lateinit var directoryStructure: DirectoryStructure
override val coroutineContext
get() = Dispatchers.IO + SupervisorJob()
override fun onStart() {
super.onStart()
val filePath =
@ -124,7 +118,7 @@ class AutofillDecryptActivity : AppCompatActivity(), CoroutineScope {
val action = if (isSearchAction) AutofillAction.Search else AutofillAction.Match
directoryStructure = AutofillPreferences.directoryStructure(this)
d { action.toString() }
launch {
lifecycleScope.launch {
val credentials = decryptCredential(File(filePath))
if (credentials == null) {
setResult(RESULT_CANCELED)
@ -141,7 +135,6 @@ class AutofillDecryptActivity : AppCompatActivity(), CoroutineScope {
override fun onDestroy() {
super.onDestroy()
coroutineContext.cancelChildren()
}
private suspend fun executeOpenPgpApi(data: Intent, input: InputStream, output: OutputStream): Intent? {

View file

@ -91,7 +91,7 @@ class DecryptActivity : BasePgpActivity(), OpenPgpServiceConnection.OnBound {
passwordEntry?.let { entry ->
if (menu != null) {
menu.findItem(R.id.edit_password).isVisible = true
if (entry.password.isNullOrBlank()) {
if (!entry.password.isNullOrBlank()) {
menu.findItem(R.id.share_password_as_plaintext).isVisible = true
menu.findItem(R.id.copy_password).isVisible = true
}
@ -189,7 +189,7 @@ class DecryptActivity : BasePgpActivity(), OpenPgpServiceConnection.OnBound {
passwordEntry = entry
invalidateOptionsMenu()
if (entry.password.isNullOrBlank()) {
if (!entry.password.isNullOrBlank()) {
items.add(FieldItem.createPasswordField(entry.password!!))
}