diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2020-11-06 14:37:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-06 14:37:43 +0100 |
commit | d6c00574b493d432f3ecfc0fabf4801a91fc70f6 (patch) | |
tree | 1a959c9eab867f156022a2bccb212981abedffc4 /app/src | |
parent | adcab6f9832b4a77b888e6e00c3ccf8efd60f64a (diff) | |
parent | 7ac4f1856144d37916eadce03af5957c6d5a2a4f (diff) | |
download | AntennaPod-d6c00574b493d432f3ecfc0fabf4801a91fc70f6.zip |
Merge pull request #4615 from ByteHamster/notification-channels-consistency
Use system notification settings on supported devices instead of our own
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java | 13 | ||||
-rw-r--r-- | app/src/main/res/xml/preferences_notifications.xml | 41 |
2 files changed, 35 insertions, 19 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java index 99fd12021..7b533cf4e 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java @@ -1,7 +1,9 @@ package de.danoeh.antennapod.fragment.preferences; import android.content.Intent; +import android.os.Build; import android.os.Bundle; +import android.provider.Settings; import androidx.appcompat.app.AppCompatActivity; import androidx.preference.PreferenceFragmentCompat; import com.bytehamster.lib.preferencesearch.SearchConfiguration; @@ -10,6 +12,7 @@ import de.danoeh.antennapod.R; import de.danoeh.antennapod.activity.BugReportActivity; import de.danoeh.antennapod.activity.PreferenceActivity; import de.danoeh.antennapod.core.util.IntentUtils; +import de.danoeh.antennapod.core.util.gui.NotificationUtils; import de.danoeh.antennapod.fragment.preferences.about.AboutFragment; public class MainPreferencesFragment extends PreferenceFragmentCompat { @@ -70,10 +73,16 @@ public class MainPreferencesFragment extends PreferenceFragmentCompat { return true; }); findPreference(PREF_NOTIFICATION).setOnPreferenceClickListener(preference -> { - ((PreferenceActivity) getActivity()).openScreen(R.xml.preferences_notifications); + if (Build.VERSION.SDK_INT >= 26) { + Intent intent = new Intent(); + intent.setAction(Settings.ACTION_APP_NOTIFICATION_SETTINGS); + intent.putExtra(Settings.EXTRA_APP_PACKAGE, getActivity().getPackageName()); + startActivity(intent); + } else { + ((PreferenceActivity) getActivity()).openScreen(R.xml.preferences_notifications); + } return true; }); - findPreference(PREF_ABOUT).setOnPreferenceClickListener( preference -> { getParentFragmentManager().beginTransaction().replace(R.id.content, new AboutFragment()) diff --git a/app/src/main/res/xml/preferences_notifications.xml b/app/src/main/res/xml/preferences_notifications.xml index 3aa907ca8..237ea5c99 100644 --- a/app/src/main/res/xml/preferences_notifications.xml +++ b/app/src/main/res/xml/preferences_notifications.xml @@ -2,21 +2,28 @@ <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"> - <SwitchPreferenceCompat - android:defaultValue="true" - android:enabled="true" - android:key="prefShowDownloadReport" - android:summary="@string/pref_showDownloadReport_sum" - android:title="@string/pref_showDownloadReport_title" /> - <SwitchPreferenceCompat - android:defaultValue="false" - android:enabled="true" - android:key="prefShowAutoDownloadReport" - android:summary="@string/pref_showAutoDownloadReport_sum" - android:title="@string/pref_showAutoDownloadReport_title" /> - <SwitchPreferenceCompat - android:defaultValue="true" - android:key="pref_gpodnet_notifications" - android:summary="@string/pref_gpodnet_notifications_sum" - android:title="@string/pref_gpodnet_notifications_title" /> + <PreferenceCategory + android:title="@string/notification_group_news"> + <SwitchPreferenceCompat + android:defaultValue="false" + android:enabled="true" + android:key="prefShowAutoDownloadReport" + android:summary="@string/notification_channel_episode_auto_download" + android:title="@string/notification_channel_auto_download" /> + </PreferenceCategory> + + <PreferenceCategory + android:title="@string/notification_group_errors"> + <SwitchPreferenceCompat + android:defaultValue="true" + android:enabled="true" + android:key="prefShowDownloadReport" + android:summary="@string/notification_channel_download_error_description" + android:title="@string/notification_channel_download_error" /> + <SwitchPreferenceCompat + android:defaultValue="true" + android:key="pref_gpodnet_notifications" + android:summary="@string/notification_channel_sync_error_description" + android:title="@string/notification_channel_sync_error" /> + </PreferenceCategory> </PreferenceScreen>
\ No newline at end of file |