mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2025-12-04 15:49:33 +01:00
Fix clipboard notification timeout
This commit is contained in:
@@ -35,11 +35,9 @@ import java.util.*
|
||||
|
||||
class ClipboardEntryNotificationService : LockNotificationService() {
|
||||
|
||||
override var notificationId = 485
|
||||
private var cleanNotificationTimerTask: Thread? = null
|
||||
private var notificationTimeoutMilliSecs: Long = 0
|
||||
|
||||
override val notificationId = 485
|
||||
private var clipboardHelper: ClipboardHelper? = null
|
||||
private var notificationTimeoutMilliSecs: Long = 0
|
||||
private var cleanCopyNotificationTimerTask: Thread? = null
|
||||
|
||||
override fun onCreate() {
|
||||
@@ -131,29 +129,11 @@ class ClipboardEntryNotificationService : LockNotificationService() {
|
||||
getCopyPendingIntent(fieldToAdd, fieldsToAdd))
|
||||
}
|
||||
}
|
||||
|
||||
notificationManager?.cancel(notificationId)
|
||||
notificationManager?.notify(++notificationId, builder.build())
|
||||
|
||||
val myNotificationId = notificationId
|
||||
stopTask(cleanNotificationTimerTask)
|
||||
// If timer
|
||||
if (notificationTimeoutMilliSecs != NEVER) {
|
||||
cleanNotificationTimerTask = Thread {
|
||||
try {
|
||||
Thread.sleep(notificationTimeoutMilliSecs)
|
||||
} catch (e: InterruptedException) {
|
||||
cleanNotificationTimerTask = null
|
||||
}
|
||||
notificationManager?.cancel(myNotificationId)
|
||||
}
|
||||
cleanNotificationTimerTask?.start()
|
||||
}
|
||||
notificationManager?.notify(notificationId, builder.build())
|
||||
}
|
||||
|
||||
private fun copyField(fieldToCopy: ClipboardEntryNotificationField, nextFields: ArrayList<ClipboardEntryNotificationField>) {
|
||||
stopTask(cleanCopyNotificationTimerTask)
|
||||
stopTask(cleanNotificationTimerTask)
|
||||
|
||||
try {
|
||||
clipboardHelper?.copyToClipboard(fieldToCopy.label, fieldToCopy.value)
|
||||
@@ -231,9 +211,7 @@ class ClipboardEntryNotificationService : LockNotificationService() {
|
||||
override fun onDestroy() {
|
||||
|
||||
stopTask(cleanCopyNotificationTimerTask)
|
||||
stopTask(cleanNotificationTimerTask)
|
||||
cleanCopyNotificationTimerTask = null
|
||||
cleanNotificationTimerTask = null
|
||||
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import com.kunzisoft.keepass.utils.LOCK_ACTION
|
||||
|
||||
class DatabaseOpenNotificationService: LockNotificationService() {
|
||||
|
||||
override var notificationId: Int = 340
|
||||
override val notificationId: Int = 340
|
||||
|
||||
private fun stopNotificationAndSendLock() {
|
||||
// Send lock action
|
||||
|
||||
@@ -26,7 +26,7 @@ import kotlin.collections.ArrayList
|
||||
|
||||
class DatabaseTaskNotificationService : NotificationService(), ProgressTaskUpdater {
|
||||
|
||||
override var notificationId: Int = 575
|
||||
override val notificationId: Int = 575
|
||||
|
||||
private var actionRunnableAsyncTask: ActionRunnableAsyncTask? = null
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.kunzisoft.keepass.utils.LOCK_ACTION
|
||||
|
||||
class KeyboardEntryNotificationService : LockNotificationService() {
|
||||
|
||||
override var notificationId = 486
|
||||
override val notificationId = 486
|
||||
private var cleanNotificationTimerTask: Thread? = null
|
||||
private var notificationTimeoutMilliSecs: Long = 0
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ abstract class NotificationService : Service() {
|
||||
protected var notificationManager: NotificationManagerCompat? = null
|
||||
private var colorNotificationAccent: Int = 0
|
||||
|
||||
protected abstract var notificationId: Int
|
||||
protected abstract val notificationId: Int
|
||||
|
||||
override fun onBind(intent: Intent): IBinder? {
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user