@@ -24,7 +24,9 @@ import android.content.ClipData
2424import android.content.ClipboardManager
2525import android.content.Context
2626import android.content.Intent
27+ import android.os.Build
2728import android.os.Bundle
29+ import android.provider.Settings
2830import androidx.preference.Preference
2931import androidx.preference.PreferenceFragmentCompat
3032import androidx.preference.PreferenceScreen
@@ -50,6 +52,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
5052 private var subsectionMore: Preference ? = null
5153 private var prefPrivacyPolicy: Preference ? = null
5254 private var subsectionWhatsNew: Preference ? = null
55+ private var subsectionNotifications: Preference ? = null
5356 private var prefAboutApp: Preference ? = null
5457
5558 override fun onCreatePreferences (savedInstanceState : Bundle ? , rootKey : String? ) {
@@ -61,6 +64,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
6164 subsectionMore = findPreference(SUBSECTION_MORE )
6265 prefPrivacyPolicy = findPreference(PREFERENCE_PRIVACY_POLICY )
6366 subsectionWhatsNew = findPreference(SUBSECTION_WHATSNEW )
67+ subsectionNotifications = findPreference(SUBSECTION_NOTIFICATIONS )
6468 prefAboutApp = findPreference(PREFERENCE_ABOUT_APP )
6569
6670 subsectionPictureUploads?.isVisible = settingsViewModel.isThereAttachedAccount()
@@ -89,6 +93,18 @@ class SettingsFragment : PreferenceFragmentCompat() {
8993 true
9094 }
9195
96+ if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .O ) {
97+ subsectionNotifications?.setOnPreferenceClickListener {
98+ val intent = Intent (Settings .ACTION_APP_NOTIFICATION_SETTINGS ).apply {
99+ putExtra(Settings .EXTRA_APP_PACKAGE , requireContext().packageName)
100+ }
101+ startActivity(intent)
102+ true
103+ }
104+ } else {
105+ settingsScreen.removePreferenceFromScreen(subsectionNotifications)
106+ }
107+
92108 prefAboutApp?.apply {
93109 summary = String .format(
94110 getString(R .string.prefs_app_version_summary),
@@ -114,6 +130,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
114130 private const val SUBSECTION_PICTURE_UPLOADS = " picture_uploads_subsection"
115131 private const val SUBSECTION_VIDEO_UPLOADS = " video_uploads_subsection"
116132 private const val SUBSECTION_MORE = " more_subsection"
133+ private const val SUBSECTION_NOTIFICATIONS = " notifications_subsection"
117134
118135 // Remove preference with nullability check
119136 fun PreferenceScreen?.removePreferenceFromScreen (preference : Preference ? ) {
0 commit comments