Skip to content

Commit a90d336

Browse files
committed
Work around linter to add mutable pending intents or bubbles
Signed-off-by: rapterjet2004 <juliuslinus1@gmail.com>
1 parent be14316 commit a90d336

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

app/src/main/java/com/nextcloud/talk/utils/NotificationUtils.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
*/
88
package com.nextcloud.talk.utils
99

10+
import android.annotation.SuppressLint
1011
import android.app.Notification
1112
import android.app.NotificationChannel
1213
import android.app.NotificationManager
14+
import android.app.PendingIntent
1315
import android.content.Context
1416
import android.content.Intent
1517
import android.graphics.Bitmap
@@ -76,6 +78,7 @@ object NotificationUtils {
7678
private const val BUBBLE_ICON_CONTENT_RATIO = 0.68f
7779
private const val BUBBLE_SIZE_MULTIPLIER = 4
7880
private const val MIN_BUBBLE_CONTENT_RATIO = 0.5f
81+
private const val PENDING_INTENT_FLAG_IMMUTABLE = 0x02000000
7982
private val bubbleIconCache = ConcurrentHashMap<String, IconCompat>()
8083

8184
enum class NotificationChannels {
@@ -687,6 +690,7 @@ object NotificationUtils {
687690
ShortcutManagerCompat.pushDynamicShortcut(context, shortcut)
688691
}
689692

693+
@SuppressLint("WrongConstant")
690694
private fun createBubbleNotification(
691695
context: Context,
692696
bubbleInfo: BubbleInfo,
@@ -695,22 +699,22 @@ object NotificationUtils {
695699
// Use the same request code calculation as NotificationWorker
696700
val bubbleRequestCode = calculateCRC32("bubble_${bubbleInfo.roomToken}").toInt()
697701

698-
val bubbleIntent = android.app.PendingIntent.getActivity(
702+
val bubbleIntent = PendingIntent.getActivity(
699703
context,
700704
bubbleRequestCode,
701705
BubbleActivity.newIntent(context, bubbleInfo.roomToken, data.conversationName),
702-
android.app.PendingIntent.FLAG_UPDATE_CURRENT or android.app.PendingIntent.FLAG_IMMUTABLE
706+
PendingIntent.FLAG_UPDATE_CURRENT or PENDING_INTENT_FLAG_IMMUTABLE
703707
)
704708

705-
val contentIntent = android.app.PendingIntent.getActivity(
709+
val contentIntent = PendingIntent.getActivity(
706710
context,
707711
bubbleRequestCode,
708712
Intent(context, ChatActivity::class.java).apply {
709713
putExtra(BundleKeys.KEY_ROOM_TOKEN, bubbleInfo.roomToken)
710714
bubbleInfo.conversationName?.let { putExtra(BundleKeys.KEY_CONVERSATION_NAME, it) }
711715
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TOP
712716
},
713-
android.app.PendingIntent.FLAG_UPDATE_CURRENT or android.app.PendingIntent.FLAG_IMMUTABLE
717+
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
714718
)
715719

716720
val bubbleData = androidx.core.app.NotificationCompat.BubbleMetadata.Builder(

0 commit comments

Comments
 (0)