Different channels for each type of notification #688

This commit is contained in:
J-Jamet
2020-11-19 11:31:03 +01:00
parent 6983f9f0b6
commit 253b053c2c
9 changed files with 57 additions and 8 deletions

View File

@@ -1,6 +1,7 @@
KeePassDX(2.9.2) KeePassDX(2.9.2)
* Prevent manual creation of existing field name #718 * Prevent manual creation of existing field name #718
* Harmonization of field names #789 * Harmonization of field names #789
* Different channels for each type of notification #688
* Fix search in OTP #780 * Fix search in OTP #780
* Fix empty OTP field after selection #781 * Fix empty OTP field after selection #781
* Fix same save shared info #783 * Fix same save shared info #783

View File

@@ -52,6 +52,14 @@ class AttachmentFileNotificationService: LockNotificationService() {
private val mainScope = CoroutineScope(Dispatchers.Main) private val mainScope = CoroutineScope(Dispatchers.Main)
override fun retrieveChannelId(): String {
return CHANNEL_ATTACHMENT_ID
}
override fun retrieveChannelName(): String {
return getString(R.string.entry_attachments)
}
inner class ActionTaskBinder: Binder() { inner class ActionTaskBinder: Binder() {
fun getService(): AttachmentFileNotificationService = this@AttachmentFileNotificationService fun getService(): AttachmentFileNotificationService = this@AttachmentFileNotificationService
@@ -430,6 +438,8 @@ class AttachmentFileNotificationService: LockNotificationService() {
companion object { companion object {
private val TAG = AttachmentFileNotificationService::javaClass.name private val TAG = AttachmentFileNotificationService::javaClass.name
private const val CHANNEL_ATTACHMENT_ID = "com.kunzisoft.keepass.notification.channel.attachment"
const val ACTION_ATTACHMENT_FILE_START_UPLOAD = "ACTION_ATTACHMENT_FILE_START_UPLOAD" const val ACTION_ATTACHMENT_FILE_START_UPLOAD = "ACTION_ATTACHMENT_FILE_START_UPLOAD"
const val ACTION_ATTACHMENT_FILE_START_DOWNLOAD = "ACTION_ATTACHMENT_FILE_START_DOWNLOAD" const val ACTION_ATTACHMENT_FILE_START_DOWNLOAD = "ACTION_ATTACHMENT_FILE_START_DOWNLOAD"
const val ACTION_ATTACHMENT_REMOVE = "ACTION_ATTACHMENT_REMOVE" const val ACTION_ATTACHMENT_REMOVE = "ACTION_ATTACHMENT_REMOVE"

View File

@@ -39,6 +39,14 @@ class ClipboardEntryNotificationService : LockNotificationService() {
private var notificationTimeoutMilliSecs: Long = 0 private var notificationTimeoutMilliSecs: Long = 0
private var cleanCopyNotificationTimerTask: Thread? = null private var cleanCopyNotificationTimerTask: Thread? = null
override fun retrieveChannelId(): String {
return CHANNEL_CLIPBOARD_ID
}
override fun retrieveChannelName(): String {
return getString(R.string.clipboard)
}
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
@@ -230,6 +238,8 @@ class ClipboardEntryNotificationService : LockNotificationService() {
private val TAG = ClipboardEntryNotificationService::class.java.name private val TAG = ClipboardEntryNotificationService::class.java.name
private const val CHANNEL_CLIPBOARD_ID = "com.kunzisoft.keepass.notification.channel.clipboard"
const val ACTION_NEW_NOTIFICATION = "ACTION_NEW_NOTIFICATION" const val ACTION_NEW_NOTIFICATION = "ACTION_NEW_NOTIFICATION"
const val EXTRA_ENTRY_INFO = "EXTRA_ENTRY_INFO" const val EXTRA_ENTRY_INFO = "EXTRA_ENTRY_INFO"
const val EXTRA_CLIPBOARD_FIELDS = "EXTRA_CLIPBOARD_FIELDS" const val EXTRA_CLIPBOARD_FIELDS = "EXTRA_CLIPBOARD_FIELDS"

View File

@@ -70,6 +70,14 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
private var mMessageId: Int? = null private var mMessageId: Int? = null
private var mWarningId: Int? = null private var mWarningId: Int? = null
override fun retrieveChannelId(): String {
return CHANNEL_DATABASE_ID
}
override fun retrieveChannelName(): String {
return getString(R.string.database)
}
inner class ActionTaskBinder: Binder() { inner class ActionTaskBinder: Binder() {
fun getService(): DatabaseTaskNotificationService = this@DatabaseTaskNotificationService fun getService(): DatabaseTaskNotificationService = this@DatabaseTaskNotificationService
@@ -760,6 +768,8 @@ open class DatabaseTaskNotificationService : LockNotificationService(), Progress
private val TAG = DatabaseTaskNotificationService::class.java.name private val TAG = DatabaseTaskNotificationService::class.java.name
private const val CHANNEL_DATABASE_ID = "com.kunzisoft.keepass.notification.channel.database"
const val ACTION_DATABASE_CREATE_TASK = "ACTION_DATABASE_CREATE_TASK" const val ACTION_DATABASE_CREATE_TASK = "ACTION_DATABASE_CREATE_TASK"
const val ACTION_DATABASE_LOAD_TASK = "ACTION_DATABASE_LOAD_TASK" const val ACTION_DATABASE_LOAD_TASK = "ACTION_DATABASE_LOAD_TASK"
const val ACTION_DATABASE_ASSIGN_PASSWORD_TASK = "ACTION_DATABASE_ASSIGN_PASSWORD_TASK" const val ACTION_DATABASE_ASSIGN_PASSWORD_TASK = "ACTION_DATABASE_ASSIGN_PASSWORD_TASK"

View File

@@ -40,6 +40,14 @@ class KeyboardEntryNotificationService : LockNotificationService() {
private var pendingDeleteIntent: PendingIntent? = null private var pendingDeleteIntent: PendingIntent? = null
override fun retrieveChannelId(): String {
return CHANNEL_MAGIKEYBOARD_ID
}
override fun retrieveChannelName(): String {
return getString(R.string.magic_keyboard_title)
}
private fun stopNotificationAndSendLockIfNeeded() { private fun stopNotificationAndSendLockIfNeeded() {
// Clear the entry if define in preferences // Clear the entry if define in preferences
if (PreferencesUtil.isClearKeyboardNotificationEnable(this)) { if (PreferencesUtil.isClearKeyboardNotificationEnable(this)) {
@@ -145,8 +153,9 @@ class KeyboardEntryNotificationService : LockNotificationService() {
private const val TAG = "KeyboardEntryNotifSrv" private const val TAG = "KeyboardEntryNotifSrv"
const val ENTRY_INFO_KEY = "ENTRY_INFO_KEY" private const val CHANNEL_MAGIKEYBOARD_ID = "com.kunzisoft.keepass.notification.channel.magikeyboard"
const val ENTRY_INFO_KEY = "ENTRY_INFO_KEY"
const val ACTION_CLEAN_KEYBOARD_ENTRY = "ACTION_CLEAN_KEYBOARD_ENTRY" const val ACTION_CLEAN_KEYBOARD_ENTRY = "ACTION_CLEAN_KEYBOARD_ENTRY"
fun launchNotificationIfAllowed(context: Context, entry: EntryInfo, toast: Boolean) { fun launchNotificationIfAllowed(context: Context, entry: EntryInfo, toast: Boolean) {

View File

@@ -20,7 +20,6 @@
package com.kunzisoft.keepass.notifications package com.kunzisoft.keepass.notifications
import android.content.Intent import android.content.Intent
import com.kunzisoft.keepass.timeout.TimeoutHelper
import com.kunzisoft.keepass.utils.LockReceiver import com.kunzisoft.keepass.utils.LockReceiver
import com.kunzisoft.keepass.utils.registerLockReceiver import com.kunzisoft.keepass.utils.registerLockReceiver
import com.kunzisoft.keepass.utils.unregisterLockReceiver import com.kunzisoft.keepass.utils.unregisterLockReceiver

View File

@@ -24,6 +24,14 @@ abstract class NotificationService : Service() {
return null return null
} }
open fun retrieveChannelId(): String {
return CHANNEL_ID
}
open fun retrieveChannelName(): String {
return CHANNEL_NAME
}
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
@@ -31,9 +39,9 @@ abstract class NotificationService : Service() {
// Create notification channel for Oreo+ // Create notification channel for Oreo+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (notificationManager?.getNotificationChannel(CHANNEL_ID_KEEPASS) == null) { if (notificationManager?.getNotificationChannel(retrieveChannelId()) == null) {
val channel = NotificationChannel(CHANNEL_ID_KEEPASS, val channel = NotificationChannel(retrieveChannelId(),
CHANNEL_NAME_KEEPASS, retrieveChannelName(),
NotificationManager.IMPORTANCE_DEFAULT).apply { NotificationManager.IMPORTANCE_DEFAULT).apply {
enableVibration(false) enableVibration(false)
setSound(null, null) setSound(null, null)
@@ -51,7 +59,7 @@ abstract class NotificationService : Service() {
} }
protected fun buildNewNotification(): NotificationCompat.Builder { protected fun buildNewNotification(): NotificationCompat.Builder {
return NotificationCompat.Builder(this, CHANNEL_ID_KEEPASS) return NotificationCompat.Builder(this, retrieveChannelId())
.setColor(colorNotificationAccent) .setColor(colorNotificationAccent)
.setPriority(NotificationCompat.PRIORITY_DEFAULT) .setPriority(NotificationCompat.PRIORITY_DEFAULT)
.setVisibility(NotificationCompat.VISIBILITY_SECRET) .setVisibility(NotificationCompat.VISIBILITY_SECRET)
@@ -70,7 +78,7 @@ abstract class NotificationService : Service() {
} }
companion object { companion object {
const val CHANNEL_ID_KEEPASS = "com.kunzisoft.keepass.notification.channel" private const val CHANNEL_ID = "com.kunzisoft.keepass.notification.channel"
const val CHANNEL_NAME_KEEPASS = "KeePassDX notification" private const val CHANNEL_NAME = "KeePassDX notification"
} }
} }

View File

@@ -1,5 +1,6 @@
* Prevent manual creation of existing field name #718 * Prevent manual creation of existing field name #718
* Harmonization of field names #789 * Harmonization of field names #789
* Different channels for each type of notification #688
* Fix search in OTP #780 * Fix search in OTP #780
* Fix empty OTP field after selection #781 * Fix empty OTP field after selection #781
* Fix same save shared info #783 * Fix same save shared info #783

View File

@@ -1,5 +1,6 @@
* Préviens la création manuelle d'un nom de champ existant #718 * Préviens la création manuelle d'un nom de champ existant #718
* Harmonisation des noms de champ #789 * Harmonisation des noms de champ #789
* Différents canaux pour chaque type de notification #688
* Correction de la recherche de l'OTP #780 * Correction de la recherche de l'OTP #780
* Correction de champ OTP vide après sélection #781 * Correction de champ OTP vide après sélection #781
* Correction de la sauvegarde d'une même info partagée #783 * Correction de la sauvegarde d'une même info partagée #783