git.iko.soy/opencode-android
on d29e57b help sign in
34 lines 1.4 kB history raw
1package soy.iko.opencode.notification
3import android.app.NotificationChannel
4import android.app.NotificationManager
5import android.content.Context
6import soy.iko.opencode.R
8/**
9 * The app's notification channels. Created once at startup (idempotent — recreating an
10 * existing channel is a no-op). Two channels keep user control granular:
11 *
12 * - [STATUS]: low-importance, no sound. Used by the foreground service's persistent
13 * "agent running" indicator.
14 * - [COMPLETED]: default importance. Used when a background session finishes a run.
15 */
16object NotificationChannels {
17 const val STATUS = "run_status"
18 const val COMPLETED = "session_completed"
20 fun create(context: Context) {
21 val nm = context.getSystemService(Context.NOTIFICATION_SERVICE) as? NotificationManager ?: return
22 nm.createNotificationChannel(
23 NotificationChannel(STATUS, context.getString(R.string.notif_channel_status), NotificationManager.IMPORTANCE_LOW).apply {
24 description = context.getString(R.string.notif_channel_status_desc)
25 setShowBadge(false)
26 },
27 )
28 nm.createNotificationChannel(
29 NotificationChannel(COMPLETED, context.getString(R.string.notif_channel_completed), NotificationManager.IMPORTANCE_DEFAULT).apply {
30 description = context.getString(R.string.notif_channel_completed_desc)
31 },
32 )
33 }