diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 9cce60469..dfe8cd77b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,6 +10,7 @@ + = 31) { + PowerManager powerManager = (PowerManager) getContext().getSystemService(POWER_SERVICE); + if (!powerManager.isIgnoringBatteryOptimizations(getContext().getPackageName())) { + findPreference(PREF_BATTERY_OPTIMIZATION).setVisible(true); + findPreference(PREF_BATTERY_OPTIMIZATION).setOnPreferenceClickListener(preference -> { + findPreference(PREF_BATTERY_OPTIMIZATION).setVisible(false); + Intent i = new Intent(); + i.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); + i.setData(Uri.parse("package:" + getContext().getPackageName())); + startActivity(i); + return true; + }); + } + } findPreference(UserPreferences.PREF_PARALLEL_DOWNLOADS) .setOnPreferenceChangeListener( diff --git a/app/src/main/res/xml/preferences_network.xml b/app/src/main/res/xml/preferences_network.xml index 428c891ad..34832378f 100644 --- a/app/src/main/res/xml/preferences_network.xml +++ b/app/src/main/res/xml/preferences_network.xml @@ -2,8 +2,14 @@ + Every hour Every %d hours + Battery Optimization + For more reliable automatic downloads and automatic refresh, exclude AntennaPod from battery optimization. Tap to add an exception for AntennaPod. Continuous Playback Headphones or Bluetooth disconnect Headphones Reconnect