From 73058d10a8e28fe4e7636ad5c73eeb8651369cdb Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Thu, 5 Mar 2020 21:05:50 +0530 Subject: Resolve various memory leaks (#637) This migrates the clipboard clear logic into a foreground service that allows us to also provide a notification that runs the clear task immediately on click, rather than wait for the timeout. Co-authored-by: Aditya Wasan Signed-off-by: Harsh Shandilya --- app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app/src/main/java/com/zeapo/pwdstore/autofill') diff --git a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.kt b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.kt index 22e49919..2d9eb813 100644 --- a/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.kt +++ b/app/src/main/java/com/zeapo/pwdstore/autofill/AutofillService.kt @@ -518,7 +518,7 @@ class AutofillService : AccessibilityService(), CoroutineScope by CoroutineScope if (entry?.hasUsername() == true) { lastPassword = entry val ttl = Integer.parseInt(settings!!.getString("general_show_time", "45")!!) - Toast.makeText(applicationContext, getString(R.string.autofill_toast_username, ttl), Toast.LENGTH_LONG).show() + withContext(Dispatchers.Main) { Toast.makeText(applicationContext, getString(R.string.autofill_toast_username, ttl), Toast.LENGTH_LONG).show() } lastPasswordMaxDate = System.currentTimeMillis() + ttl * 1000L } } catch (e: UnsupportedEncodingException) { @@ -537,7 +537,7 @@ class AutofillService : AccessibilityService(), CoroutineScope by CoroutineScope OpenPgpApi.RESULT_CODE_ERROR -> { val error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR) if (error != null) { - Toast.makeText(applicationContext, "Error from OpenKeyChain : ${error.message}", Toast.LENGTH_LONG).show() + withContext(Dispatchers.Main) { Toast.makeText(applicationContext, "Error from OpenKeyChain : ${error.message}", Toast.LENGTH_LONG).show() } Timber.tag(Constants.TAG).e("onError getErrorId: ${error.errorId}") Timber.tag(Constants.TAG).e("onError getMessage: ${error.message}") } -- cgit v1.2.3