From 00f6eb83c34428b515943da0be420976649dda3f Mon Sep 17 00:00:00 2001 From: J-Jamet Date: Wed, 15 Jan 2020 05:52:32 +0100 Subject: [PATCH] Fix close notification --- .../notifications/AttachmentFileNotificationService.kt | 10 ++++++---- .../com/kunzisoft/keepass/view/EntryContentsView.kt | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/kunzisoft/keepass/notifications/AttachmentFileNotificationService.kt b/app/src/main/java/com/kunzisoft/keepass/notifications/AttachmentFileNotificationService.kt index f908b1e86..c3a83ac78 100644 --- a/app/src/main/java/com/kunzisoft/keepass/notifications/AttachmentFileNotificationService.kt +++ b/app/src/main/java/com/kunzisoft/keepass/notifications/AttachmentFileNotificationService.kt @@ -17,7 +17,6 @@ import kotlin.collections.HashMap class AttachmentFileNotificationService: LockNotificationService() { - // Base notification Id, not used override val notificationId: Int = 10000 private var mActionTaskBinder = ActionTaskBinder() @@ -55,7 +54,8 @@ class AttachmentFileNotificationService: LockNotificationService() { if (downloadFileUri != null && intent.hasExtra(ATTACHMENT_KEY)) { - val nextNotificationId = (downloadFileUris.values.maxBy { it.notificationId }?.notificationId ?: notificationId) +1 + val nextNotificationId = (downloadFileUris.values.maxBy { it.notificationId } + ?.notificationId?.plus(1) ?: notificationId) val entryAttachment: EntryAttachment = intent.getParcelableExtra(ATTACHMENT_KEY) val attachmentNotification = AttachmentNotification(nextNotificationId, entryAttachment) @@ -84,7 +84,9 @@ class AttachmentFileNotificationService: LockNotificationService() { notificationManager?.cancelAll() downloadFileUris.clear() } - stopSelf() + if (downloadFileUris.isEmpty()) { + stopSelf() + } } } @@ -118,7 +120,7 @@ class AttachmentFileNotificationService: LockNotificationService() { Intent(this, AttachmentFileNotificationService::class.java).apply { // No action to delete the service putExtra(DOWNLOAD_FILE_URI_KEY, downloadFileUri) - }, PendingIntent.FLAG_UPDATE_CURRENT) + }, PendingIntent.FLAG_CANCEL_CURRENT) val fileName = DocumentFile.fromSingleUri(this, downloadFileUri)?.name ?: "" diff --git a/app/src/main/java/com/kunzisoft/keepass/view/EntryContentsView.kt b/app/src/main/java/com/kunzisoft/keepass/view/EntryContentsView.kt index bc291b949..2922e2562 100644 --- a/app/src/main/java/com/kunzisoft/keepass/view/EntryContentsView.kt +++ b/app/src/main/java/com/kunzisoft/keepass/view/EntryContentsView.kt @@ -41,6 +41,8 @@ import com.kunzisoft.keepass.model.EntryAttachment import com.kunzisoft.keepass.otp.OtpElement import com.kunzisoft.keepass.otp.OtpType import java.util.* +import androidx.recyclerview.widget.SimpleItemAnimator + class EntryContentsView @JvmOverloads constructor(context: Context, var attrs: AttributeSet? = null, @@ -127,6 +129,7 @@ class EntryContentsView @JvmOverloads constructor(context: Context, attachmentsListView?.apply { layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, true) adapter = attachmentsAdapter + (itemAnimator as SimpleItemAnimator).supportsChangeAnimations = false } creationDateView = findViewById(R.id.entry_created)