Fixed issue with bubbles + fixed french translation issue

This commit is contained in:
Sylvain Berfini 2021-04-01 17:23:42 +02:00
parent d165b04307
commit 2b6ac73d9e
4 changed files with 31 additions and 5 deletions

View file

@ -20,6 +20,7 @@
package org.linphone.compatibility package org.linphone.compatibility
import android.annotation.TargetApi import android.annotation.TargetApi
import android.app.NotificationChannel
import android.app.NotificationManager import android.app.NotificationManager
import android.content.ContentValues import android.content.ContentValues
import android.content.Context import android.content.Context
@ -30,6 +31,7 @@ import android.provider.MediaStore
import android.view.View import android.view.View
import android.view.contentcapture.ContentCaptureContext import android.view.contentcapture.ContentCaptureContext
import android.view.contentcapture.ContentCaptureSession import android.view.contentcapture.ContentCaptureSession
import androidx.core.app.NotificationManagerCompat
import org.linphone.R import org.linphone.R
import org.linphone.core.ChatRoom import org.linphone.core.ChatRoom
import org.linphone.core.Content import org.linphone.core.Content
@ -41,6 +43,24 @@ import org.linphone.utils.LinphoneUtils
@TargetApi(29) @TargetApi(29)
class Api29Compatibility { class Api29Compatibility {
companion object { companion object {
fun createMessageChannel(
context: Context,
notificationManager: NotificationManagerCompat
) {
// Create messages notification channel
val id = context.getString(R.string.notification_channel_chat_id)
val name = context.getString(R.string.notification_channel_chat_name)
val description = context.getString(R.string.notification_channel_chat_name)
val channel = NotificationChannel(id, name, NotificationManager.IMPORTANCE_HIGH)
channel.description = description
channel.lightColor = context.getColor(R.color.notification_led_color)
channel.enableLights(true)
channel.enableVibration(true)
channel.setShowBadge(true)
channel.setAllowBubbles(true)
notificationManager.createNotificationChannel(channel)
}
fun extractLocusIdFromIntent(intent: Intent): String? { fun extractLocusIdFromIntent(intent: Intent): String? {
return intent.getStringExtra(Intent.EXTRA_LOCUS_ID) return intent.getStringExtra(Intent.EXTRA_LOCUS_ID)
} }

View file

@ -84,9 +84,13 @@ class Compatibility {
Api26Compatibility.createServiceChannel(context, notificationManager) Api26Compatibility.createServiceChannel(context, notificationManager)
Api26Compatibility.createMissedCallChannel(context, notificationManager) Api26Compatibility.createMissedCallChannel(context, notificationManager)
Api26Compatibility.createIncomingCallChannel(context, notificationManager) Api26Compatibility.createIncomingCallChannel(context, notificationManager)
if (Version.sdkAboveOrEqual(Version.API29_ANDROID_10)) {
Api29Compatibility.createMessageChannel(context, notificationManager)
} else {
Api26Compatibility.createMessageChannel(context, notificationManager) Api26Compatibility.createMessageChannel(context, notificationManager)
} }
} }
}
fun getOverlayType(): Int { fun getOverlayType(): Int {
if (Version.sdkAboveOrEqual(Version.API26_O_80)) { if (Version.sdkAboveOrEqual(Version.API26_O_80)) {

View file

@ -737,9 +737,11 @@ class NotificationsManager(private val context: Context) {
.setDeleteIntent(getMarkMessageAsReadPendingIntent(notifiable)) .setDeleteIntent(getMarkMessageAsReadPendingIntent(notifiable))
} }
if (Compatibility.canChatMessageChannelBubble(context)) { if (!Compatibility.canChatMessageChannelBubble(context)) {
notificationBuilder.bubbleMetadata = bubble Log.w("[Notifications Manager] This conversation wasn't granted bubble permission yet")
} }
// We still need to set the bubbleMetadata, otherwise user won't ever be able to enable bubbles!
notificationBuilder.bubbleMetadata = bubble
return notificationBuilder.build() return notificationBuilder.build()
} }

View file

@ -553,8 +553,8 @@
<string name="content_description_toggle_audio_menu">Afficher ou masquer le menu de sélection du périphérique audio</string> <string name="content_description_toggle_audio_menu">Afficher ou masquer le menu de sélection du périphérique audio</string>
<string name="chat_message_notification_hidden_content">&lt;Censuré&gt;</string> <string name="chat_message_notification_hidden_content">&lt;Censuré&gt;</string>
<string name="content_description_enable_speaker">Envoyer le son vers le haut-parleur</string> <string name="content_description_enable_speaker">Envoyer le son vers le haut-parleur</string>
<string name="call_settings_overlay_title">Superposition des notifications push sur l\'écran</string> <string name="call_settings_overlay_title">Notification d\'appel flottante</string>
<string name="call_settings_overlay_summary">L\'autorisation d\'afficher les notifications push en superposition est requise</string> <string name="call_settings_overlay_summary">Une autorisation explicite est requise</string>
<string name="chat_settings_mark_as_read_notif_dismissal_title">Marquer comme lu lorsque la notification est supprimée</string> <string name="chat_settings_mark_as_read_notif_dismissal_title">Marquer comme lu lorsque la notification est supprimée</string>
<string name="chat_settings_launcher_shortcuts_summary">Seront remplacés par les raccourcis de contacts si activés</string> <string name="chat_settings_launcher_shortcuts_summary">Seront remplacés par les raccourcis de contacts si activés</string>
<string name="account_settings_transport_title">Transport</string> <string name="account_settings_transport_title">Transport</string>