mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
Use better names for API.
This commit is contained in:
committed by
Benoit Marty
parent
7ee00a65d8
commit
6fe85dc579
+6
-6
@@ -19,8 +19,8 @@ import io.element.android.libraries.di.annotations.ApplicationContext
|
||||
import timber.log.Timber
|
||||
|
||||
interface NotificationDisplayer {
|
||||
fun showNotificationMessage(tag: String?, id: Int, notification: Notification): Boolean
|
||||
fun cancelNotificationMessage(tag: String?, id: Int)
|
||||
fun showNotification(tag: String?, id: Int, notification: Notification): Boolean
|
||||
fun cancelNotification(tag: String?, id: Int)
|
||||
fun displayDiagnosticNotification(notification: Notification): Boolean
|
||||
fun dismissDiagnosticNotification()
|
||||
}
|
||||
@@ -30,7 +30,7 @@ class DefaultNotificationDisplayer(
|
||||
@ApplicationContext private val context: Context,
|
||||
private val notificationManager: NotificationManagerCompat
|
||||
) : NotificationDisplayer {
|
||||
override fun showNotificationMessage(tag: String?, id: Int, notification: Notification): Boolean {
|
||||
override fun showNotification(tag: String?, id: Int, notification: Notification): Boolean {
|
||||
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
|
||||
Timber.w("Not allowed to notify.")
|
||||
return false
|
||||
@@ -40,12 +40,12 @@ class DefaultNotificationDisplayer(
|
||||
return true
|
||||
}
|
||||
|
||||
override fun cancelNotificationMessage(tag: String?, id: Int) {
|
||||
override fun cancelNotification(tag: String?, id: Int) {
|
||||
notificationManager.cancel(tag, id)
|
||||
}
|
||||
|
||||
override fun displayDiagnosticNotification(notification: Notification): Boolean {
|
||||
return showNotificationMessage(
|
||||
return showNotification(
|
||||
tag = "DIAGNOSTIC",
|
||||
id = NOTIFICATION_ID_DIAGNOSTIC,
|
||||
notification = notification
|
||||
@@ -53,7 +53,7 @@ class DefaultNotificationDisplayer(
|
||||
}
|
||||
|
||||
override fun dismissDiagnosticNotification() {
|
||||
cancelNotificationMessage(
|
||||
cancelNotification(
|
||||
tag = "DIAGNOSTIC",
|
||||
id = NOTIFICATION_ID_DIAGNOSTIC
|
||||
)
|
||||
|
||||
+6
-6
@@ -74,7 +74,7 @@ class NotificationRenderer(
|
||||
// Remove summary first to avoid briefly displaying it after dismissing the last notification
|
||||
if (summaryNotification == SummaryNotification.Removed) {
|
||||
Timber.tag(loggerTag.value).d("Removing summary notification")
|
||||
notificationDisplayer.cancelNotificationMessage(
|
||||
notificationDisplayer.cancelNotification(
|
||||
tag = null,
|
||||
id = NotificationIdProvider.getSummaryNotificationId(currentUser.userId)
|
||||
)
|
||||
@@ -85,7 +85,7 @@ class NotificationRenderer(
|
||||
roomId = notificationData.roomId,
|
||||
threadId = notificationData.threadId
|
||||
)
|
||||
notificationDisplayer.showNotificationMessage(
|
||||
notificationDisplayer.showNotification(
|
||||
tag = tag,
|
||||
id = NotificationIdProvider.getRoomMessagesNotificationId(currentUser.userId),
|
||||
notification = notificationData.notification
|
||||
@@ -95,7 +95,7 @@ class NotificationRenderer(
|
||||
invitationNotifications.forEach { notificationData ->
|
||||
if (useCompleteNotificationFormat) {
|
||||
Timber.tag(loggerTag.value).d("Updating invitation notification ${notificationData.tag}")
|
||||
notificationDisplayer.showNotificationMessage(
|
||||
notificationDisplayer.showNotification(
|
||||
tag = notificationData.tag,
|
||||
id = NotificationIdProvider.getRoomInvitationNotificationId(currentUser.userId),
|
||||
notification = notificationData.notification
|
||||
@@ -106,7 +106,7 @@ class NotificationRenderer(
|
||||
simpleNotifications.forEach { notificationData ->
|
||||
if (useCompleteNotificationFormat) {
|
||||
Timber.tag(loggerTag.value).d("Updating simple notification ${notificationData.tag}")
|
||||
notificationDisplayer.showNotificationMessage(
|
||||
notificationDisplayer.showNotification(
|
||||
tag = notificationData.tag,
|
||||
id = NotificationIdProvider.getRoomEventNotificationId(currentUser.userId),
|
||||
notification = notificationData.notification
|
||||
@@ -117,7 +117,7 @@ class NotificationRenderer(
|
||||
// Show only the first fallback notification
|
||||
if (fallbackNotifications.isNotEmpty()) {
|
||||
Timber.tag(loggerTag.value).d("Showing fallback notification")
|
||||
notificationDisplayer.showNotificationMessage(
|
||||
notificationDisplayer.showNotification(
|
||||
tag = "FALLBACK",
|
||||
id = NotificationIdProvider.getFallbackNotificationId(currentUser.userId),
|
||||
notification = fallbackNotifications.first().notification
|
||||
@@ -127,7 +127,7 @@ class NotificationRenderer(
|
||||
// Update summary last to avoid briefly displaying it before other notifications
|
||||
if (summaryNotification is SummaryNotification.Update) {
|
||||
Timber.tag(loggerTag.value).d("Updating summary notification")
|
||||
notificationDisplayer.showNotificationMessage(
|
||||
notificationDisplayer.showNotification(
|
||||
tag = null,
|
||||
id = NotificationIdProvider.getSummaryNotificationId(currentUser.userId),
|
||||
notification = summaryNotification.notification
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ class DefaultOnRedactedEventReceived(
|
||||
oldMessage.person
|
||||
)
|
||||
messagingStyle.messages[messageToRedactIndex] = newMessage
|
||||
notificationDisplayer.showNotificationMessage(
|
||||
notificationDisplayer.showNotification(
|
||||
statusBarNotification.tag,
|
||||
statusBarNotification.id,
|
||||
NotificationCompat.Builder(context, notification)
|
||||
|
||||
Reference in New Issue
Block a user