mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 16:40:32 +00:00
Fix toggling the system's settings for app notification
Do not open the setting for a specific notification channel (Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS), but the settings for all notifications by the app (Settings.ACTION_APP_NOTIFICATION_SETTINGS)
This commit is contained in:
parent
80bf47493e
commit
77aaa15082
@ -142,15 +142,13 @@ class NotificationHelper(val context: Context) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the system's notification settings for NewPipe on Android O (API 26) and later.
|
||||
* Open the system's notification settings for NewPipe on Android Oreo (API 26) and later.
|
||||
* Open the system's app settings for NewPipe on previous Android versions.
|
||||
*/
|
||||
fun openNewPipeSystemNotificationSettings(context: Context) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
val channelId = context.getString(R.string.streams_notification_channel_id)
|
||||
val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
||||
val intent = Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS)
|
||||
.putExtra(Settings.EXTRA_APP_PACKAGE, context.packageName)
|
||||
.putExtra(Settings.EXTRA_CHANNEL_ID, channelId)
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
context.startActivity(intent)
|
||||
} else {
|
||||
|
@ -57,7 +57,7 @@ class NotificationsSettingsFragment : BasePreferenceFragment(), OnSharedPreferen
|
||||
Snackbar.LENGTH_INDEFINITE
|
||||
).apply {
|
||||
setAction(R.string.settings) {
|
||||
activity?.let { NotificationHelper.openNewPipeSystemNotificationSettings(it) }
|
||||
NotificationHelper.openNewPipeSystemNotificationSettings(it.context)
|
||||
}
|
||||
setActionTextColor(Color.YELLOW)
|
||||
addCallback(object : Snackbar.Callback() {
|
||||
|
Loading…
Reference in New Issue
Block a user