Fix clean clipboard after killing app by swap

This commit is contained in:
J-Jamet
2019-10-26 08:58:36 +02:00
parent ef7387f2f3
commit 3732ff1ebc

View File

@@ -72,11 +72,7 @@ class ClipboardEntryNotificationService : EntryNotificationService() {
} }
ACTION_CLEAN_CLIPBOARD == intent.action -> { ACTION_CLEAN_CLIPBOARD == intent.action -> {
stopTask(cleanCopyNotificationTimerTask) stopTask(cleanCopyNotificationTimerTask)
try { cleanClipboard()
clipboardHelper?.cleanClipboard()
} catch (e: SamsungClipboardException) {
Log.e(TAG, "Clipboard can't be cleaned", e)
}
stopNotificationAndSendLockIfNeeded() stopNotificationAndSendLockIfNeeded()
} }
else -> for (actionKey in ClipboardEntryNotificationField.allActionKeys) { else -> for (actionKey in ClipboardEntryNotificationField.allActionKeys) {
@@ -204,11 +200,7 @@ class ClipboardEntryNotificationService : EntryNotificationService() {
notificationManager?.cancel(myNotificationId) notificationManager?.cancel(myNotificationId)
// Clean password only if no next field // Clean password only if no next field
if (nextFields.size <= 0) if (nextFields.size <= 0)
try { cleanClipboard()
clipboardHelper?.cleanClipboard()
} catch (e: SamsungClipboardException) {
Log.e(TAG, "Clipboard can't be cleaned", e)
}
} }
cleanCopyNotificationTimerTask?.start() cleanCopyNotificationTimerTask?.start()
} else { } else {
@@ -222,6 +214,20 @@ class ClipboardEntryNotificationService : EntryNotificationService() {
} }
private fun cleanClipboard() {
try {
clipboardHelper?.cleanClipboard()
} catch (e: SamsungClipboardException) {
Log.e(TAG, "Clipboard can't be cleaned", e)
}
}
override fun onTaskRemoved(rootIntent: Intent?) {
cleanClipboard()
super.onTaskRemoved(rootIntent)
}
override fun onDestroy() { override fun onDestroy() {
stopTask(cleanCopyNotificationTimerTask) stopTask(cleanCopyNotificationTimerTask)