feat(notification): support custom notification IDs

Update `NotificationSys.showNotification` to accept an optional `id`
parameter. This allows different notifications to be displayed
simultaneously by the system instead of overwriting each other.

In `SettingsFragment` and `PlayerFragment`, assign specific unique IDs
for test, share, and update notifications.
This commit is contained in:
2026-06-01 19:44:56 +02:00
parent 181ebd47df
commit d654d79bd5
3 changed files with 8 additions and 5 deletions
@@ -27,7 +27,7 @@ object NotificationSys {
} }
} }
fun showNotification(context: Context, title: String, content: String, intent: Intent? = null) { fun showNotification(context: Context, title: String, content: String, intent: Intent? = null, id: Int = NOTIFICATION_ID) {
val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
createNotificationChannel(context) createNotificationChannel(context)
@@ -51,6 +51,6 @@ object NotificationSys {
.setAutoCancel(true) .setAutoCancel(true)
.build() .build()
notificationManager.notify(NOTIFICATION_ID, notification) notificationManager.notify(id, notification)
} }
} }
@@ -885,7 +885,8 @@ class PlayerFragment : Fragment(),
requireContext(), requireContext(),
"${getString(R.string.app_name)} $latestVersion", "${getString(R.string.app_name)} $latestVersion",
getString(R.string.snackbar_update_available), getString(R.string.snackbar_update_available),
intent = updateIntent intent = updateIntent,
id = 1001
) )
} }
} }
@@ -330,7 +330,8 @@ class SettingsFragment : PreferenceFragmentCompat(), YesNoDialog.YesNoDialogList
NotificationSys.showNotification( NotificationSys.showNotification(
context, context,
getString(R.string.pref_test_notification_title), getString(R.string.pref_test_notification_title),
getString(R.string.notification_test_content) getString(R.string.notification_test_content),
id = 1003
) )
return@setOnPreferenceClickListener true return@setOnPreferenceClickListener true
} }
@@ -413,7 +414,8 @@ class SettingsFragment : PreferenceFragmentCompat(), YesNoDialog.YesNoDialogList
NotificationSys.showNotification( NotificationSys.showNotification(
context, context,
getString(R.string.pref_share_app_thank_title), getString(R.string.pref_share_app_thank_title),
getString(R.string.pref_share_app_thank_message) getString(R.string.pref_share_app_thank_message),
id = 1002
) )
} }
return@setOnPreferenceClickListener true return@setOnPreferenceClickListener true