diff --git a/core/core-preferences/src/main/kotlin/com/f0x1d/logfox/preferences/shared/AppPreferences.kt b/core/core-preferences/src/main/kotlin/com/f0x1d/logfox/preferences/shared/AppPreferences.kt
index 2c0141e0..c1745f81 100644
--- a/core/core-preferences/src/main/kotlin/com/f0x1d/logfox/preferences/shared/AppPreferences.kt
+++ b/core/core-preferences/src/main/kotlin/com/f0x1d/logfox/preferences/shared/AppPreferences.kt
@@ -152,6 +152,10 @@ class AppPreferences @Inject constructor(
get() = get("pref_include_device_info_in_archives", true)
set(value) { put("pref_include_device_info_in_archives", value) }
+ var useSeparateNotificationsChannelsForCrashes
+ get() = get("pref_notifications_use_separate_channels", true)
+ set(value) { put("pref_notifications_use_separate_channels", value) }
+
var askedNotificationsPermission
get() = get("pref_asked_notifications_permission", false)
set(value) { put("pref_asked_notifications_permission", value) }
diff --git a/feature/feature-crashes-core/src/main/kotlin/com/f0x1d/logfox/feature/crashes/core/controller/CrashesNotificationsController.kt b/feature/feature-crashes-core/src/main/kotlin/com/f0x1d/logfox/feature/crashes/core/controller/CrashesNotificationsController.kt
index 19ca8b85..f7d58469 100644
--- a/feature/feature-crashes-core/src/main/kotlin/com/f0x1d/logfox/feature/crashes/core/controller/CrashesNotificationsController.kt
+++ b/feature/feature-crashes-core/src/main/kotlin/com/f0x1d/logfox/feature/crashes/core/controller/CrashesNotificationsController.kt
@@ -19,6 +19,7 @@ import com.f0x1d.logfox.intents.COPY_CRASH_INTENT_ID
import com.f0x1d.logfox.intents.makeBroadcastPendingIntent
import com.f0x1d.logfox.navigation.Directions
import com.f0x1d.logfox.navigation.NavGraphs
+import com.f0x1d.logfox.preferences.shared.AppPreferences
import com.f0x1d.logfox.strings.Strings
import com.f0x1d.logfox.ui.Icons
import dagger.hilt.android.qualifiers.ApplicationContext
@@ -33,6 +34,7 @@ internal interface CrashesNotificationsController {
@SuppressLint("MissingPermission")
internal class CrashesNotificationsControllerImpl @Inject constructor(
@ApplicationContext private val context: Context,
+ private val appPreferences: AppPreferences,
) : CrashesNotificationsController {
override fun sendErrorNotification(appCrash: AppCrash, crashLog: String?) {
@@ -42,7 +44,14 @@ internal class CrashesNotificationsControllerImpl @Inject constructor(
notify(
appCrash.packageName,
appCrash.notificationId,
- NotificationCompat.Builder(context, appCrash.notificationChannelId)
+ NotificationCompat.Builder(
+ context,
+ if (appPreferences.useSeparateNotificationsChannelsForCrashes) {
+ appCrash.notificationChannelId
+ } else {
+ CRASHES_CHANNEL_ID
+ },
+ )
.setContentTitle(
context.getString(
Strings.app_crashed,
@@ -80,26 +89,41 @@ internal class CrashesNotificationsControllerImpl @Inject constructor(
}
private fun createNotificationChannelFor(appCrash: AppCrash) {
- val crashTypeName = appCrash.crashType.readableName
- val groupId = "${CRASHES_CHANNEL_GROUP_ID}_$crashTypeName"
+ if (appPreferences.useSeparateNotificationsChannelsForCrashes) {
+ val crashTypeName = appCrash.crashType.readableName
+ val groupId = "${CRASHES_CHANNEL_GROUP_ID}_$crashTypeName"
- val crashesGroup = NotificationChannelGroupCompat.Builder(groupId)
- .setName(context.getString(Strings.type_crashes, crashTypeName))
- .build()
+ val crashesGroup = NotificationChannelGroupCompat.Builder(groupId)
+ .setName(context.getString(Strings.type_crashes, crashTypeName))
+ .build()
- val appCrashesChannel = NotificationChannelCompat.Builder(
- appCrash.notificationChannelId,
- NotificationManagerCompat.IMPORTANCE_HIGH,
- )
- .setName(context.getString(Strings.crashes_of, crashTypeName, appCrash.packageName))
- .setLightsEnabled(true)
- .setVibrationEnabled(true)
- .setGroup(groupId)
- .build()
+ val appCrashesChannel = NotificationChannelCompat.Builder(
+ appCrash.notificationChannelId,
+ NotificationManagerCompat.IMPORTANCE_HIGH,
+ )
+ .setName(context.getString(Strings.crashes_of, crashTypeName, appCrash.packageName))
+ .setLightsEnabled(true)
+ .setVibrationEnabled(true)
+ .setGroup(groupId)
+ .build()
+
+ context.notificationManagerCompat.apply {
+ createNotificationChannelGroupsCompat(listOf(crashesGroup))
+ createNotificationChannelsCompat(listOf(appCrashesChannel))
+ }
+ } else {
+ val crashesChannel = NotificationChannelCompat.Builder(
+ CRASHES_CHANNEL_ID,
+ NotificationManagerCompat.IMPORTANCE_HIGH,
+ )
+ .setName(context.getString(Strings.crashes))
+ .setLightsEnabled(true)
+ .setVibrationEnabled(true)
+ .build()
- context.notificationManagerCompat.apply {
- createNotificationChannelGroupsCompat(listOf(crashesGroup))
- createNotificationChannelsCompat(listOf(appCrashesChannel))
+ context.notificationManagerCompat.apply {
+ createNotificationChannelsCompat(listOf(crashesChannel))
+ }
}
}
@@ -115,6 +139,10 @@ internal class CrashesNotificationsControllerImpl @Inject constructor(
if (it.tag != null && it.tag.contains(".")) cancel(it.tag, it.id)
}
}
+
+ companion object {
+ private const val CRASHES_CHANNEL_ID = "crashes"
+ }
}
val AppCrash.notificationChannelId get() = "${CRASHES_CHANNEL_GROUP_ID}_${crashType.readableName}_$packageName"
diff --git a/feature/feature-crashes/src/main/kotlin/com/f0x1d/logfox/feature/crashes/ui/fragment/CrashDetailsFragment.kt b/feature/feature-crashes/src/main/kotlin/com/f0x1d/logfox/feature/crashes/ui/fragment/CrashDetailsFragment.kt
index 52b2cb41..91b10b51 100644
--- a/feature/feature-crashes/src/main/kotlin/com/f0x1d/logfox/feature/crashes/ui/fragment/CrashDetailsFragment.kt
+++ b/feature/feature-crashes/src/main/kotlin/com/f0x1d/logfox/feature/crashes/ui/fragment/CrashDetailsFragment.kt
@@ -69,7 +69,10 @@ class CrashDetailsFragment: BaseViewModelFragment
+
+
По имени
По новизне
По количеству сбоев
+ Использовать разные каналы уведомлений для уведомлений о сбоях
diff --git a/strings/src/main/res/values/strings.xml b/strings/src/main/res/values/strings.xml
index ce90b187..52a8161f 100644
--- a/strings/src/main/res/values/strings.xml
+++ b/strings/src/main/res/values/strings.xml
@@ -160,4 +160,5 @@
By name
By novelty
By crashes count
+ Use separate notifications channels for crashes notifications