From dda3d70b27157641d96008c16bb69994c916de36 Mon Sep 17 00:00:00 2001 From: smitdol Date: Sat, 29 Jan 2022 15:49:08 +0100 Subject: [PATCH] added auto-stop on auto-start --- .../radiodroid2/FragmentPlayerSmall.java | 13 ++++++++++++- app/src/main/res/values/strings.xml | 5 +++++ app/src/main/res/xml/preferences.xml | 18 ++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) 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 2c46fd483..3e898a711 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 6efd28fde..e821a08b6 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -58,6 +58,24 @@ android:summaryOn="@string/settings_auto_play_on_startup_on" android:title="@string/settings_auto_play_on_startup" /> + + + +