diff options
author | Harsh Shandilya <me@msfjarvis.dev> | 2021-04-18 14:15:45 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-18 08:45:45 +0000 |
commit | 7710ca90248d6111c54eb452b1dca27dd4a53f22 (patch) | |
tree | 134245f7b309fd4c4ad70cb3045000d92ea75da3 /app/src/main/java | |
parent | a3ebcfcc62749fccd47b91eea4f9dc530aa261bd (diff) |
Remove hand-rolled CoroutineScope and fix inverted conditions (#1386)
Diffstat (limited to 'app/src/main/java')
-rw-r--r-- | app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillDecryptActivity.kt | 11 | ||||
-rw-r--r-- | app/src/main/java/dev/msfjarvis/aps/ui/crypto/DecryptActivity.kt | 4 |
2 files changed, 4 insertions, 11 deletions
diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillDecryptActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillDecryptActivity.kt index 7a36899b..79fc44aa 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillDecryptActivity.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/autofill/AutofillDecryptActivity.kt @@ -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? { diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/DecryptActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/DecryptActivity.kt index f50410d4..571afb12 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/DecryptActivity.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/DecryptActivity.kt @@ -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!!)) } |