Organise notification channels into system-settings groups
Group the five channels under two headings in the system notification settings so they're easier to navigate: "Downloads & updates" (progress, installed, updates, export) and "Alerts" (errors and action-required). Purely organisational; channel importances and behaviour are unchanged.
This commit is contained in:
@@ -2,6 +2,7 @@ package com.aurora.store.util
|
|||||||
|
|
||||||
import android.app.Notification
|
import android.app.Notification
|
||||||
import android.app.NotificationChannel
|
import android.app.NotificationChannel
|
||||||
|
import android.app.NotificationChannelGroup
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
@@ -32,6 +33,10 @@ import kotlin.math.absoluteValue
|
|||||||
|
|
||||||
object NotificationUtil {
|
object NotificationUtil {
|
||||||
|
|
||||||
|
// Channel groups: headings the individual channels are filed under in system settings.
|
||||||
|
private const val GROUP_CHANNELS_ACTIVITY = "com.aurora.store.channels.ACTIVITY"
|
||||||
|
private const val GROUP_CHANNELS_ALERTS = "com.aurora.store.channels.ALERTS"
|
||||||
|
|
||||||
// Terminal install/failure notifications are bundled under a group so a bulk update
|
// Terminal install/failure notifications are bundled under a group so a bulk update
|
||||||
// shows a single collapsible summary instead of one notification per app.
|
// shows a single collapsible summary instead of one notification per app.
|
||||||
private const val GROUP_INSTALLED = "com.aurora.store.INSTALLED"
|
private const val GROUP_INSTALLED = "com.aurora.store.INSTALLED"
|
||||||
@@ -56,6 +61,21 @@ object NotificationUtil {
|
|||||||
notificationManager.deleteNotificationChannel(it)
|
notificationManager.deleteNotificationChannel(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Organise the channels under two headings in system settings: routine activity
|
||||||
|
// vs. things that need attention.
|
||||||
|
notificationManager.createNotificationChannelGroups(
|
||||||
|
listOf(
|
||||||
|
NotificationChannelGroup(
|
||||||
|
GROUP_CHANNELS_ACTIVITY,
|
||||||
|
context.getString(R.string.notification_group_activity)
|
||||||
|
),
|
||||||
|
NotificationChannelGroup(
|
||||||
|
GROUP_CHANNELS_ALERTS,
|
||||||
|
context.getString(R.string.notification_group_alerts)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
val channels = ArrayList<NotificationChannel>()
|
val channels = ArrayList<NotificationChannel>()
|
||||||
|
|
||||||
// Quiet, ongoing progress for active downloads. MIN keeps it collapsed and out
|
// Quiet, ongoing progress for active downloads. MIN keeps it collapsed and out
|
||||||
@@ -66,6 +86,7 @@ object NotificationUtil {
|
|||||||
context.getString(R.string.notification_channel_downloads),
|
context.getString(R.string.notification_channel_downloads),
|
||||||
NotificationManager.IMPORTANCE_MIN
|
NotificationManager.IMPORTANCE_MIN
|
||||||
).apply {
|
).apply {
|
||||||
|
group = GROUP_CHANNELS_ACTIVITY
|
||||||
setSound(null, null)
|
setSound(null, null)
|
||||||
setShowBadge(false)
|
setShowBadge(false)
|
||||||
}
|
}
|
||||||
@@ -79,6 +100,7 @@ object NotificationUtil {
|
|||||||
context.getString(R.string.notification_channel_install),
|
context.getString(R.string.notification_channel_install),
|
||||||
NotificationManager.IMPORTANCE_LOW
|
NotificationManager.IMPORTANCE_LOW
|
||||||
).apply {
|
).apply {
|
||||||
|
group = GROUP_CHANNELS_ACTIVITY
|
||||||
setSound(null, null)
|
setSound(null, null)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -90,6 +112,7 @@ object NotificationUtil {
|
|||||||
context.getString(R.string.notification_channel_updates),
|
context.getString(R.string.notification_channel_updates),
|
||||||
NotificationManager.IMPORTANCE_DEFAULT
|
NotificationManager.IMPORTANCE_DEFAULT
|
||||||
).apply {
|
).apply {
|
||||||
|
group = GROUP_CHANNELS_ACTIVITY
|
||||||
setSound(null, null)
|
setSound(null, null)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -101,6 +124,7 @@ object NotificationUtil {
|
|||||||
context.getString(R.string.notification_channel_export),
|
context.getString(R.string.notification_channel_export),
|
||||||
NotificationManager.IMPORTANCE_LOW
|
NotificationManager.IMPORTANCE_LOW
|
||||||
).apply {
|
).apply {
|
||||||
|
group = GROUP_CHANNELS_ACTIVITY
|
||||||
setSound(null, null)
|
setSound(null, null)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -112,7 +136,9 @@ object NotificationUtil {
|
|||||||
Constants.NOTIFICATION_CHANNEL_ALERTS,
|
Constants.NOTIFICATION_CHANNEL_ALERTS,
|
||||||
context.getString(R.string.notification_channel_alerts),
|
context.getString(R.string.notification_channel_alerts),
|
||||||
NotificationManager.IMPORTANCE_HIGH
|
NotificationManager.IMPORTANCE_HIGH
|
||||||
)
|
).apply {
|
||||||
|
group = GROUP_CHANNELS_ALERTS
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
notificationManager.createNotificationChannels(channels)
|
notificationManager.createNotificationChannels(channels)
|
||||||
|
|||||||
@@ -212,6 +212,8 @@
|
|||||||
<string name="dialog_title_self_update">"New update available"</string>
|
<string name="dialog_title_self_update">"New update available"</string>
|
||||||
<string name="dialog_desc_native_split">"You can not install bundled (split) apps via Native Installer. Change your installer to Session, Services or Root."</string>
|
<string name="dialog_desc_native_split">"You can not install bundled (split) apps via Native Installer. Change your installer to Session, Services or Root."</string>
|
||||||
<string name="notification_channel_alerts">Errors & alerts</string>
|
<string name="notification_channel_alerts">Errors & alerts</string>
|
||||||
|
<string name="notification_group_activity">Downloads & updates</string>
|
||||||
|
<string name="notification_group_alerts">Alerts</string>
|
||||||
<string name="notification_channel_export">App export notification</string>
|
<string name="notification_channel_export">App export notification</string>
|
||||||
<string name="notification_channel_install">Install notification</string>
|
<string name="notification_channel_install">Install notification</string>
|
||||||
<string name="notification_channel_downloads">Downloads notification</string>
|
<string name="notification_channel_downloads">Downloads notification</string>
|
||||||
|
|||||||
Reference in New Issue
Block a user