|
|
@ -228,7 +228,7 @@ class NotificationUtils @Inject constructor( |
|
|
|
true |
|
|
|
true |
|
|
|
/** TODO EAx vectorPreferences.areThreadMessagesEnabled() */ |
|
|
|
/** TODO EAx vectorPreferences.areThreadMessagesEnabled() */ |
|
|
|
-> buildOpenThreadIntent(roomInfo, threadId) |
|
|
|
-> buildOpenThreadIntent(roomInfo, threadId) |
|
|
|
else -> buildOpenRoomIntent(roomInfo.roomId) |
|
|
|
else -> buildOpenRoomIntent(roomInfo.sessionId, roomInfo.roomId) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val smallIcon = R.drawable.ic_notification |
|
|
|
val smallIcon = R.drawable.ic_notification |
|
|
@ -259,8 +259,7 @@ class NotificationUtils @Inject constructor( |
|
|
|
) |
|
|
|
) |
|
|
|
// Auto-bundling is enabled for 4 or more notifications on API 24+ (N+) |
|
|
|
// Auto-bundling is enabled for 4 or more notifications on API 24+ (N+) |
|
|
|
// devices and all Wear devices. But we want a custom grouping, so we specify the groupID |
|
|
|
// devices and all Wear devices. But we want a custom grouping, so we specify the groupID |
|
|
|
// TODO Group should be current user display name |
|
|
|
.setGroup(roomInfo.sessionId) |
|
|
|
.setGroup(buildMeta.applicationName) |
|
|
|
|
|
|
|
// In order to avoid notification making sound twice (due to the summary notification) |
|
|
|
// In order to avoid notification making sound twice (due to the summary notification) |
|
|
|
.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_ALL) |
|
|
|
.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_ALL) |
|
|
|
.setSmallIcon(smallIcon) |
|
|
|
.setSmallIcon(smallIcon) |
|
|
@ -287,7 +286,8 @@ class NotificationUtils @Inject constructor( |
|
|
|
// Mark room as read |
|
|
|
// Mark room as read |
|
|
|
val markRoomReadIntent = Intent(context, NotificationBroadcastReceiver::class.java) |
|
|
|
val markRoomReadIntent = Intent(context, NotificationBroadcastReceiver::class.java) |
|
|
|
markRoomReadIntent.action = actionIds.markRoomRead |
|
|
|
markRoomReadIntent.action = actionIds.markRoomRead |
|
|
|
markRoomReadIntent.data = createIgnoredUri(roomInfo.roomId) |
|
|
|
markRoomReadIntent.data = createIgnoredUri("markRead?${roomInfo.sessionId}&$${roomInfo.roomId}") |
|
|
|
|
|
|
|
markRoomReadIntent.putExtra(NotificationBroadcastReceiver.KEY_SESSION_ID, roomInfo.sessionId) |
|
|
|
markRoomReadIntent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomInfo.roomId) |
|
|
|
markRoomReadIntent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomInfo.roomId) |
|
|
|
val markRoomReadPendingIntent = PendingIntent.getBroadcast( |
|
|
|
val markRoomReadPendingIntent = PendingIntent.getBroadcast( |
|
|
|
context, |
|
|
|
context, |
|
|
@ -307,7 +307,7 @@ class NotificationUtils @Inject constructor( |
|
|
|
|
|
|
|
|
|
|
|
// Quick reply |
|
|
|
// Quick reply |
|
|
|
if (!roomInfo.hasSmartReplyError) { |
|
|
|
if (!roomInfo.hasSmartReplyError) { |
|
|
|
buildQuickReplyIntent(roomInfo.roomId, threadId, senderDisplayNameForReplyCompat)?.let { replyPendingIntent -> |
|
|
|
buildQuickReplyIntent(roomInfo.sessionId, roomInfo.roomId, threadId, senderDisplayNameForReplyCompat)?.let { replyPendingIntent -> |
|
|
|
val remoteInput = RemoteInput.Builder(NotificationBroadcastReceiver.KEY_TEXT_REPLY) |
|
|
|
val remoteInput = RemoteInput.Builder(NotificationBroadcastReceiver.KEY_TEXT_REPLY) |
|
|
|
.setLabel(stringProvider.getString(StringR.string.action_quick_reply)) |
|
|
|
.setLabel(stringProvider.getString(StringR.string.action_quick_reply)) |
|
|
|
.build() |
|
|
|
.build() |
|
|
@ -332,8 +332,9 @@ class NotificationUtils @Inject constructor( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
val intent = Intent(context, NotificationBroadcastReceiver::class.java) |
|
|
|
val intent = Intent(context, NotificationBroadcastReceiver::class.java) |
|
|
|
intent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomInfo.roomId) |
|
|
|
|
|
|
|
intent.action = actionIds.dismissRoom |
|
|
|
intent.action = actionIds.dismissRoom |
|
|
|
|
|
|
|
intent.putExtra(NotificationBroadcastReceiver.KEY_SESSION_ID, roomInfo.sessionId) |
|
|
|
|
|
|
|
intent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomInfo.roomId) |
|
|
|
val pendingIntent = PendingIntent.getBroadcast( |
|
|
|
val pendingIntent = PendingIntent.getBroadcast( |
|
|
|
context.applicationContext, |
|
|
|
context.applicationContext, |
|
|
|
clock.epochMillis().toInt(), |
|
|
|
clock.epochMillis().toInt(), |
|
|
@ -347,8 +348,7 @@ class NotificationUtils @Inject constructor( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun buildRoomInvitationNotification( |
|
|
|
fun buildRoomInvitationNotification( |
|
|
|
inviteNotifiableEvent: InviteNotifiableEvent, |
|
|
|
inviteNotifiableEvent: InviteNotifiableEvent |
|
|
|
matrixId: String |
|
|
|
|
|
|
|
): Notification { |
|
|
|
): Notification { |
|
|
|
val accentColor = ContextCompat.getColor(context, R.color.notification_accent_color) |
|
|
|
val accentColor = ContextCompat.getColor(context, R.color.notification_accent_color) |
|
|
|
// Build the pending intent for when the notification is clicked |
|
|
|
// Build the pending intent for when the notification is clicked |
|
|
@ -359,7 +359,7 @@ class NotificationUtils @Inject constructor( |
|
|
|
.setOnlyAlertOnce(true) |
|
|
|
.setOnlyAlertOnce(true) |
|
|
|
.setContentTitle(inviteNotifiableEvent.roomName ?: buildMeta.applicationName) |
|
|
|
.setContentTitle(inviteNotifiableEvent.roomName ?: buildMeta.applicationName) |
|
|
|
.setContentText(inviteNotifiableEvent.description) |
|
|
|
.setContentText(inviteNotifiableEvent.description) |
|
|
|
.setGroup(buildMeta.applicationName) |
|
|
|
.setGroup(inviteNotifiableEvent.sessionId) |
|
|
|
.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_ALL) |
|
|
|
.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_ALL) |
|
|
|
.setSmallIcon(smallIcon) |
|
|
|
.setSmallIcon(smallIcon) |
|
|
|
.setColor(accentColor) |
|
|
|
.setColor(accentColor) |
|
|
@ -368,7 +368,8 @@ class NotificationUtils @Inject constructor( |
|
|
|
// offer to type a quick reject button |
|
|
|
// offer to type a quick reject button |
|
|
|
val rejectIntent = Intent(context, NotificationBroadcastReceiver::class.java) |
|
|
|
val rejectIntent = Intent(context, NotificationBroadcastReceiver::class.java) |
|
|
|
rejectIntent.action = actionIds.reject |
|
|
|
rejectIntent.action = actionIds.reject |
|
|
|
rejectIntent.data = createIgnoredUri("$roomId&$matrixId") |
|
|
|
rejectIntent.data = createIgnoredUri("rejectInvite?${inviteNotifiableEvent.sessionId}&$roomId") |
|
|
|
|
|
|
|
rejectIntent.putExtra(NotificationBroadcastReceiver.KEY_SESSION_ID, inviteNotifiableEvent.sessionId) |
|
|
|
rejectIntent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomId) |
|
|
|
rejectIntent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomId) |
|
|
|
val rejectIntentPendingIntent = PendingIntent.getBroadcast( |
|
|
|
val rejectIntentPendingIntent = PendingIntent.getBroadcast( |
|
|
|
context, |
|
|
|
context, |
|
|
@ -386,7 +387,8 @@ class NotificationUtils @Inject constructor( |
|
|
|
// offer to type a quick accept button |
|
|
|
// offer to type a quick accept button |
|
|
|
val joinIntent = Intent(context, NotificationBroadcastReceiver::class.java) |
|
|
|
val joinIntent = Intent(context, NotificationBroadcastReceiver::class.java) |
|
|
|
joinIntent.action = actionIds.join |
|
|
|
joinIntent.action = actionIds.join |
|
|
|
joinIntent.data = createIgnoredUri("$roomId&$matrixId") |
|
|
|
joinIntent.data = createIgnoredUri("acceptInvite?${inviteNotifiableEvent.sessionId}&$roomId") |
|
|
|
|
|
|
|
joinIntent.putExtra(NotificationBroadcastReceiver.KEY_SESSION_ID, inviteNotifiableEvent.sessionId) |
|
|
|
joinIntent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomId) |
|
|
|
joinIntent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomId) |
|
|
|
val joinIntentPendingIntent = PendingIntent.getBroadcast( |
|
|
|
val joinIntentPendingIntent = PendingIntent.getBroadcast( |
|
|
|
context, |
|
|
|
context, |
|
|
@ -433,7 +435,6 @@ class NotificationUtils @Inject constructor( |
|
|
|
|
|
|
|
|
|
|
|
fun buildSimpleEventNotification( |
|
|
|
fun buildSimpleEventNotification( |
|
|
|
simpleNotifiableEvent: SimpleNotifiableEvent, |
|
|
|
simpleNotifiableEvent: SimpleNotifiableEvent, |
|
|
|
matrixId: String |
|
|
|
|
|
|
|
): Notification { |
|
|
|
): Notification { |
|
|
|
val accentColor = ContextCompat.getColor(context, R.color.notification_accent_color) |
|
|
|
val accentColor = ContextCompat.getColor(context, R.color.notification_accent_color) |
|
|
|
// Build the pending intent for when the notification is clicked |
|
|
|
// Build the pending intent for when the notification is clicked |
|
|
@ -445,7 +446,7 @@ class NotificationUtils @Inject constructor( |
|
|
|
.setOnlyAlertOnce(true) |
|
|
|
.setOnlyAlertOnce(true) |
|
|
|
.setContentTitle(buildMeta.applicationName) |
|
|
|
.setContentTitle(buildMeta.applicationName) |
|
|
|
.setContentText(simpleNotifiableEvent.description) |
|
|
|
.setContentText(simpleNotifiableEvent.description) |
|
|
|
.setGroup(buildMeta.applicationName) |
|
|
|
.setGroup(simpleNotifiableEvent.sessionId) |
|
|
|
.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_ALL) |
|
|
|
.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_ALL) |
|
|
|
.setSmallIcon(smallIcon) |
|
|
|
.setSmallIcon(smallIcon) |
|
|
|
.setColor(accentColor) |
|
|
|
.setColor(accentColor) |
|
|
@ -476,81 +477,45 @@ class NotificationUtils @Inject constructor( |
|
|
|
.build() |
|
|
|
.build() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun buildOpenRoomIntent(roomId: String): PendingIntent? { |
|
|
|
private fun buildOpenRoomIntent(sessionId: String, roomId: String): PendingIntent? { |
|
|
|
return null |
|
|
|
val roomIntent = intentProvider.getIntent(sessionId = sessionId, roomId = roomId, threadId = null) |
|
|
|
/* |
|
|
|
roomIntent.action = actionIds.tapToView |
|
|
|
val roomIntentTap = RoomDetailActivity.newIntent(context, TimelineArgs(roomId = roomId, switchToParentSpace = true), true) |
|
|
|
|
|
|
|
roomIntentTap.action = actionIds.tapToView |
|
|
|
|
|
|
|
// pending intent get reused by system, this will mess up the extra params, so put unique info to avoid that |
|
|
|
// pending intent get reused by system, this will mess up the extra params, so put unique info to avoid that |
|
|
|
roomIntentTap.data = createIgnoredUri("openRoom?$roomId") |
|
|
|
roomIntent.data = createIgnoredUri("openRoom?$sessionId&$roomId") |
|
|
|
|
|
|
|
|
|
|
|
// Recreate the back stack |
|
|
|
return PendingIntent.getActivity( |
|
|
|
return TaskStackBuilder.create(context) |
|
|
|
context, |
|
|
|
.addNextIntentWithParentStack(HomeActivity.newIntent(context, firstStartMainActivity = false)) |
|
|
|
clock.epochMillis().toInt(), |
|
|
|
.addNextIntent(roomIntentTap) |
|
|
|
roomIntent, |
|
|
|
.getPendingIntent( |
|
|
|
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntentCompat.FLAG_IMMUTABLE |
|
|
|
clock.epochMillis().toInt(), |
|
|
|
) |
|
|
|
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntentCompat.FLAG_IMMUTABLE |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun buildOpenThreadIntent(roomInfo: RoomEventGroupInfo, threadId: String?): PendingIntent? { |
|
|
|
private fun buildOpenThreadIntent(roomInfo: RoomEventGroupInfo, threadId: String?): PendingIntent? { |
|
|
|
return null |
|
|
|
val sessionId = roomInfo.sessionId |
|
|
|
/* |
|
|
|
val roomId = roomInfo.roomId |
|
|
|
val threadTimelineArgs = ThreadTimelineArgs( |
|
|
|
val threadIntentTap = intentProvider.getIntent(sessionId = sessionId, roomId = roomId, threadId = threadId) |
|
|
|
startsThread = false, |
|
|
|
|
|
|
|
roomId = roomInfo.roomId, |
|
|
|
|
|
|
|
rootThreadEventId = threadId, |
|
|
|
|
|
|
|
showKeyboard = false, |
|
|
|
|
|
|
|
displayName = roomInfo.roomDisplayName, |
|
|
|
|
|
|
|
avatarUrl = null, |
|
|
|
|
|
|
|
roomEncryptionTrustLevel = null, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
val threadIntentTap = ThreadsActivity.newIntent( |
|
|
|
|
|
|
|
context = context, |
|
|
|
|
|
|
|
threadTimelineArgs = threadTimelineArgs, |
|
|
|
|
|
|
|
threadListArgs = null, |
|
|
|
|
|
|
|
firstStartMainActivity = true, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
threadIntentTap.action = actionIds.tapToView |
|
|
|
threadIntentTap.action = actionIds.tapToView |
|
|
|
// pending intent get reused by system, this will mess up the extra params, so put unique info to avoid that |
|
|
|
// pending intent get reused by system, this will mess up the extra params, so put unique info to avoid that |
|
|
|
threadIntentTap.data = createIgnoredUri("openThread?$threadId") |
|
|
|
threadIntentTap.data = createIgnoredUri("openThread?$sessionId&$roomId&$threadId") |
|
|
|
|
|
|
|
|
|
|
|
val roomIntent = RoomDetailActivity.newIntent( |
|
|
|
return PendingIntent.getActivity( |
|
|
|
context = context, |
|
|
|
context, |
|
|
|
timelineArgs = TimelineArgs( |
|
|
|
clock.epochMillis().toInt(), |
|
|
|
roomId = roomInfo.roomId, |
|
|
|
threadIntentTap, |
|
|
|
switchToParentSpace = true |
|
|
|
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntentCompat.FLAG_IMMUTABLE |
|
|
|
), |
|
|
|
|
|
|
|
firstStartMainActivity = false |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
// Recreate the back stack |
|
|
|
|
|
|
|
return TaskStackBuilder.create(context) |
|
|
|
|
|
|
|
.addNextIntentWithParentStack(HomeActivity.newIntent(context, firstStartMainActivity = false)) |
|
|
|
|
|
|
|
.addNextIntentWithParentStack(roomIntent) |
|
|
|
|
|
|
|
.addNextIntent(threadIntentTap) |
|
|
|
|
|
|
|
.getPendingIntent( |
|
|
|
|
|
|
|
clock.epochMillis().toInt(), |
|
|
|
|
|
|
|
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntentCompat.FLAG_IMMUTABLE |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun buildOpenHomePendingIntentForSummary(): PendingIntent { |
|
|
|
private fun buildOpenHomePendingIntentForSummary(sessionId: String): PendingIntent { |
|
|
|
TODO() |
|
|
|
val intent = intentProvider.getIntent(sessionId = sessionId, roomId = null, threadId = null) |
|
|
|
/* |
|
|
|
intent.data = createIgnoredUri("tapSummary?$sessionId") |
|
|
|
val intent = HomeActivity.newIntent(context, firstStartMainActivity = false, clearNotification = true) |
|
|
|
|
|
|
|
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP |
|
|
|
|
|
|
|
intent.data = createIgnoredUri("tapSummary") |
|
|
|
|
|
|
|
val mainIntent = MainActivity.getIntentWithNextIntent(context, intent) |
|
|
|
|
|
|
|
return PendingIntent.getActivity( |
|
|
|
return PendingIntent.getActivity( |
|
|
|
context, |
|
|
|
context, |
|
|
|
Random.nextInt(1000), |
|
|
|
clock.epochMillis().toInt(), |
|
|
|
mainIntent, |
|
|
|
intent, |
|
|
|
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntentCompat.FLAG_IMMUTABLE |
|
|
|
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntentCompat.FLAG_IMMUTABLE |
|
|
|
) |
|
|
|
) |
|
|
|
*/ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
/* |
|
|
@ -560,12 +525,18 @@ class NotificationUtils @Inject constructor( |
|
|
|
However, for Android devices running Marshmallow and below (API level 23 and below), |
|
|
|
However, for Android devices running Marshmallow and below (API level 23 and below), |
|
|
|
it will be more appropriate to use an activity. Since you have to provide your own UI. |
|
|
|
it will be more appropriate to use an activity. Since you have to provide your own UI. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private fun buildQuickReplyIntent(roomId: String, threadId: String?, senderName: String?): PendingIntent? { |
|
|
|
private fun buildQuickReplyIntent( |
|
|
|
|
|
|
|
sessionId: String, |
|
|
|
|
|
|
|
roomId: String, |
|
|
|
|
|
|
|
threadId: String?, |
|
|
|
|
|
|
|
senderName: String? |
|
|
|
|
|
|
|
): PendingIntent? { |
|
|
|
val intent: Intent |
|
|
|
val intent: Intent |
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
|
|
|
intent = Intent(context, NotificationBroadcastReceiver::class.java) |
|
|
|
intent = Intent(context, NotificationBroadcastReceiver::class.java) |
|
|
|
intent.action = actionIds.smartReply |
|
|
|
intent.action = actionIds.smartReply |
|
|
|
intent.data = createIgnoredUri(roomId) |
|
|
|
intent.data = createIgnoredUri("quickReply?$sessionId&$roomId") |
|
|
|
|
|
|
|
intent.putExtra(NotificationBroadcastReceiver.KEY_SESSION_ID, sessionId) |
|
|
|
intent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomId) |
|
|
|
intent.putExtra(NotificationBroadcastReceiver.KEY_ROOM_ID, roomId) |
|
|
|
threadId?.let { |
|
|
|
threadId?.let { |
|
|
|
intent.putExtra(NotificationBroadcastReceiver.KEY_THREAD_ID, it) |
|
|
|
intent.putExtra(NotificationBroadcastReceiver.KEY_THREAD_ID, it) |
|
|
@ -602,6 +573,7 @@ class NotificationUtils @Inject constructor( |
|
|
|
* Build the summary notification. |
|
|
|
* Build the summary notification. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
fun buildSummaryListNotification( |
|
|
|
fun buildSummaryListNotification( |
|
|
|
|
|
|
|
sessionId: String, |
|
|
|
style: NotificationCompat.InboxStyle?, |
|
|
|
style: NotificationCompat.InboxStyle?, |
|
|
|
compatSummary: String, |
|
|
|
compatSummary: String, |
|
|
|
noisy: Boolean, |
|
|
|
noisy: Boolean, |
|
|
@ -615,12 +587,12 @@ class NotificationUtils @Inject constructor( |
|
|
|
// used in compat < N, after summary is built based on child notifications |
|
|
|
// used in compat < N, after summary is built based on child notifications |
|
|
|
.setWhen(lastMessageTimestamp) |
|
|
|
.setWhen(lastMessageTimestamp) |
|
|
|
.setStyle(style) |
|
|
|
.setStyle(style) |
|
|
|
.setContentTitle(buildMeta.applicationName) |
|
|
|
.setContentTitle(sessionId) |
|
|
|
.setCategory(NotificationCompat.CATEGORY_MESSAGE) |
|
|
|
.setCategory(NotificationCompat.CATEGORY_MESSAGE) |
|
|
|
.setSmallIcon(smallIcon) |
|
|
|
.setSmallIcon(smallIcon) |
|
|
|
// set content text to support devices running API level < 24 |
|
|
|
// set content text to support devices running API level < 24 |
|
|
|
.setContentText(compatSummary) |
|
|
|
.setContentText(compatSummary) |
|
|
|
.setGroup(buildMeta.applicationName) |
|
|
|
.setGroup(sessionId) |
|
|
|
// set this notification as the summary for the group |
|
|
|
// set this notification as the summary for the group |
|
|
|
.setGroupSummary(true) |
|
|
|
.setGroupSummary(true) |
|
|
|
.setColor(accentColor) |
|
|
|
.setColor(accentColor) |
|
|
@ -639,15 +611,16 @@ class NotificationUtils @Inject constructor( |
|
|
|
priority = NotificationCompat.PRIORITY_LOW |
|
|
|
priority = NotificationCompat.PRIORITY_LOW |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.setContentIntent(buildOpenHomePendingIntentForSummary()) |
|
|
|
.setContentIntent(buildOpenHomePendingIntentForSummary(sessionId)) |
|
|
|
.setDeleteIntent(getDismissSummaryPendingIntent()) |
|
|
|
.setDeleteIntent(getDismissSummaryPendingIntent(sessionId)) |
|
|
|
.build() |
|
|
|
.build() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun getDismissSummaryPendingIntent(): PendingIntent { |
|
|
|
private fun getDismissSummaryPendingIntent(sessionId: String): PendingIntent { |
|
|
|
val intent = Intent(context, NotificationBroadcastReceiver::class.java) |
|
|
|
val intent = Intent(context, NotificationBroadcastReceiver::class.java) |
|
|
|
intent.action = actionIds.dismissSummary |
|
|
|
intent.action = actionIds.dismissSummary |
|
|
|
intent.data = createIgnoredUri("deleteSummary") |
|
|
|
intent.data = createIgnoredUri("deleteSummary?$sessionId") |
|
|
|
|
|
|
|
intent.putExtra(NotificationBroadcastReceiver.KEY_SESSION_ID, sessionId) |
|
|
|
return PendingIntent.getBroadcast( |
|
|
|
return PendingIntent.getBroadcast( |
|
|
|
context.applicationContext, |
|
|
|
context.applicationContext, |
|
|
|
0, |
|
|
|
0, |
|
|
@ -703,23 +676,6 @@ class NotificationUtils @Inject constructor( |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun createTemporaryNotification(): Notification { |
|
|
|
|
|
|
|
val contentIntent = intentProvider.getMainIntent() |
|
|
|
|
|
|
|
val pendingIntent = PendingIntent.getActivity(context, 0, contentIntent, PendingIntentCompat.FLAG_IMMUTABLE) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return NotificationCompat.Builder(context, NOISY_NOTIFICATION_CHANNEL_ID) |
|
|
|
|
|
|
|
.setContentTitle(buildMeta.applicationName) |
|
|
|
|
|
|
|
.setContentText(stringProvider.getString(R.string.notification_new_messages_temporary)) |
|
|
|
|
|
|
|
.setSmallIcon(R.drawable.ic_notification) |
|
|
|
|
|
|
|
.setLargeIcon(getBitmap(context, R.drawable.element_logo_green)) |
|
|
|
|
|
|
|
.setColor(ContextCompat.getColor(context, R.color.notification_accent_color)) |
|
|
|
|
|
|
|
.setPriority(NotificationCompat.PRIORITY_MAX) |
|
|
|
|
|
|
|
.setCategory(NotificationCompat.CATEGORY_STATUS) |
|
|
|
|
|
|
|
.setAutoCancel(true) |
|
|
|
|
|
|
|
.setContentIntent(pendingIntent) |
|
|
|
|
|
|
|
.build() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun getBitmap(context: Context, @DrawableRes drawableRes: Int): Bitmap? { |
|
|
|
private fun getBitmap(context: Context, @DrawableRes drawableRes: Int): Bitmap? { |
|
|
|
val drawable = ResourcesCompat.getDrawable(context.resources, drawableRes, null) ?: return null |
|
|
|
val drawable = ResourcesCompat.getDrawable(context.resources, drawableRes, null) ?: return null |
|
|
|
val canvas = Canvas() |
|
|
|
val canvas = Canvas() |
|
|
|