diff --git a/app/src/main/java/net/programmierecke/radiodroid2/FragmentPlayerSmall.java b/app/src/main/java/net/programmierecke/radiodroid2/FragmentPlayerSmall.java index 5a3cbe1be..2cc9ff453 100644 --- a/app/src/main/java/net/programmierecke/radiodroid2/FragmentPlayerSmall.java +++ b/app/src/main/java/net/programmierecke/radiodroid2/FragmentPlayerSmall.java @@ -192,17 +192,28 @@ private void playLastFromHistory() { private void tryPlayAtStart() { boolean play = false; + boolean auto_off = false; + SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext().getApplicationContext()); if (!firstPlayAttempted && PlayerServiceUtil.isServiceBound()) { firstPlayAttempted = true; if (!PlayerServiceUtil.isPlaying()) { - SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext().getApplicationContext()); play = sharedPreferences.getBoolean("auto_play_on_startup", false); } } if (play) { + auto_off = sharedPreferences.getBoolean("auto_off_on_startup", false); + if (auto_off) { + int timeout; + try { + timeout = Integer.parseInt(sharedPreferences.getString("auto_off_timeout", "10")); + } catch(Exception e) { + timeout=10; + } + PlayerServiceUtil.addTimer(timeout * 60); + } playLastFromHistory(); } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b1a5b2ed0..b80d1722e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -145,6 +145,11 @@ Auto-play Play last station on startup Do not play last station on startup + Auto-stop + Use Auto-stop timer with auto-play + Do not use Auto-stop timer with auto-play + Auto-stop timer + Stop playing after %1$s minutes Enable external player Play stations with external player Play stations with RadioDroid diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index b1484971c..5f3e959f3 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -57,6 +57,25 @@ android:summaryOff="@string/settings_auto_play_on_startup_off" android:summaryOn="@string/settings_auto_play_on_startup_on" android:title="@string/settings_auto_play_on_startup" /> + + + + +