Fix close notification

This commit is contained in:
J-Jamet
2020-01-15 05:52:32 +01:00
parent bbf51ebbec
commit 00f6eb83c3
2 changed files with 9 additions and 4 deletions

View File

@@ -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 ?: ""

View File

@@ -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)