Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,6 @@ object BoomerangRenderNotifications {
.build()
}

fun buildCompleteNotification(context: Context): Notification {
ensureChannel(context)
val contentIntent = PendingIntent.getActivity(
context,
1,
Intent(context, MainActivity::class.java).apply {
flags = Intent.FLAG_ACTIVITY_SINGLE_TOP or Intent.FLAG_ACTIVITY_CLEAR_TOP
},
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE,
)
return NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(android.R.drawable.stat_sys_download)
.setContentTitle(context.getString(R.string.notification_loop_export_complete_title))
.setContentText(context.getString(R.string.notification_loop_export_complete_text))
.setContentIntent(contentIntent)
.setAutoCancel(true)
.setPriority(NotificationCompat.PRIORITY_LOW)
.build()
}

fun createForegroundInfo(context: Context, progressPercent: Int): ForegroundInfo {
val notification = buildProgressNotification(context, progressPercent)
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@
<string name="notification_loop_export_channel_desc">Progress while your loop is being created</string>
<string name="notification_loop_export_title">Creating your loop…</string>
<string name="notification_loop_export_progress">%1$d%% complete</string>
<string name="notification_loop_export_complete_title">Loop ready</string>
<string name="notification_loop_export_complete_text">Tap to open OpenLoop</string>

<!-- Post-save snackbars (slice 06) -->
<!-- Kind-neutral: the same snackbar follows a saved loop and a captured photo. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,4 @@ class BoomerangRenderNotificationsRobolectricTest {
val flags = Shadows.shadowOf(pendingIntent).flags
assertTrue(flags and PendingIntent.FLAG_IMMUTABLE != 0)
}

@Test
fun buildCompleteNotification_usesImmutablePendingIntent() {
val notification = BoomerangRenderNotifications.buildCompleteNotification(context)
val pendingIntent = requireNotNull(notification.contentIntent)

val flags = Shadows.shadowOf(pendingIntent).flags
assertTrue(flags and PendingIntent.FLAG_IMMUTABLE != 0)
}
}
Loading