fix(android): Fix multiple notification issues
- Fix updating the notification causing another vibration - Fix the "mark as read" intent being stuck
This commit is contained in:
parent
4ec44ab3e1
commit
2adefecc92
@ -1,8 +1,6 @@
|
||||
package org.moxxy.moxxy_native.notifications
|
||||
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import org.moxxy.moxxy_native.TAG
|
||||
|
||||
/*
|
||||
* Extract all user-added extra key-value pairs from @intent.
|
||||
@ -10,9 +8,7 @@ import org.moxxy.moxxy_native.TAG
|
||||
fun extractPayloadMapFromIntent(intent: Intent): Map<String?, String?> {
|
||||
val extras = mutableMapOf<String?, String?>()
|
||||
intent.extras?.keySet()!!.forEach {
|
||||
Log.d(TAG, "Checking $it -> ${intent.extras!!.get(it)}")
|
||||
if (it.startsWith("payload_")) {
|
||||
Log.d(TAG, "Adding $it")
|
||||
extras[it.substring(8)] = intent.extras!!.getString(it)
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ class NotificationsImplementation(private val context: Context) : MoxxyNotificat
|
||||
context.applicationContext,
|
||||
0,
|
||||
replyIntent,
|
||||
PendingIntent.FLAG_MUTABLE,
|
||||
PendingIntent.FLAG_MUTABLE or PendingIntent.FLAG_UPDATE_CURRENT,
|
||||
)
|
||||
val replyAction = NotificationCompat.Action.Builder(
|
||||
R.drawable.reply,
|
||||
@ -113,13 +113,14 @@ class NotificationsImplementation(private val context: Context) : MoxxyNotificat
|
||||
|
||||
notification.extra?.forEach {
|
||||
putExtra("payload_${it.key}", it.value)
|
||||
Log.d(TAG, "Adding payload_${it.key} -> ${it.value}")
|
||||
}
|
||||
}
|
||||
val markAsReadPendingIntent = PendingIntent.getBroadcast(
|
||||
context.applicationContext,
|
||||
0,
|
||||
markAsReadIntent,
|
||||
PendingIntent.FLAG_IMMUTABLE,
|
||||
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT,
|
||||
)
|
||||
val markAsReadAction = NotificationCompat.Action.Builder(
|
||||
R.drawable.mark_as_read,
|
||||
@ -250,7 +251,7 @@ class NotificationsImplementation(private val context: Context) : MoxxyNotificat
|
||||
setCategory(Notification.CATEGORY_MESSAGE)
|
||||
|
||||
// Prevent no notification when we replied before
|
||||
setOnlyAlertOnce(false)
|
||||
setOnlyAlertOnce(true)
|
||||
|
||||
// Automatically dismiss the notification on tap
|
||||
setAutoCancel(true)
|
||||
|
Loading…
Reference in New Issue
Block a user