From c04ae69ec580c7d86eed872626cc98bdd2769c81 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 22 Jul 2015 20:26:21 -0700 Subject: #506 Show sleep time remaining --- .../daneren2005/dsub/fragments/NowPlayingFragment.java | 16 ++++++++++++---- .../github/daneren2005/dsub/service/DownloadService.java | 6 ++++++ app/src/main/res/values-de/strings.xml | 1 - app/src/main/res/values-es/strings.xml | 1 - app/src/main/res/values-fr/strings.xml | 1 - app/src/main/res/values-hu/strings.xml | 1 - app/src/main/res/values-ru/strings.xml | 3 +-- app/src/main/res/values/strings.xml | 2 +- 8 files changed, 20 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java index bec43a22..c754f370 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java @@ -131,6 +131,7 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis private boolean scrollWhenLoaded = false; private int lastY = 0; private int currentPlayingSize = 0; + private MenuItem timerMenu; /** * Called when the activity is first created. @@ -525,10 +526,11 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis menuInflater.inflate(R.menu.nowplaying_offline, menu); } else { menuInflater.inflate(R.menu.nowplaying, menu); - - if(downloadService != null && downloadService.getSleepTimer()) { - menu.findItem(R.id.menu_toggle_timer).setTitle(R.string.download_stop_timer); - } + } + if(downloadService != null && downloadService.getSleepTimer()) { + int timeRemaining = downloadService.getSleepTimeRemaining(); + timerMenu = menu.findItem(R.id.menu_toggle_timer); + timerMenu.setTitle(context.getResources().getString(R.string.download_stop_time_remaining, Util.formatDuration(timeRemaining))); } if(downloadService != null && downloadService.getKeepScreenOn()) { menu.findItem(R.id.menu_screen_on_off).setChecked(true); @@ -1380,6 +1382,12 @@ public class NowPlayingFragment extends SubsonicFragment implements OnGestureLis progressBar.setProgress(0); progressBar.setEnabled(false); } + + DownloadService downloadService = getDownloadService(); + if(downloadService.getSleepTimer() && timerMenu != null) { + int timeRemaining = downloadService.getSleepTimeRemaining(); + timerMenu.setTitle(context.getResources().getString(R.string.download_stop_time_remaining, Util.formatDuration(timeRemaining))); + } } @Override diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java index ab757c59..a9f82919 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadService.java @@ -157,6 +157,7 @@ public class DownloadService extends Service { private Timer sleepTimer; private int timerDuration; + private long timerStart; private boolean autoPlayStart = false; private MediaRouteManager mediaRouter; @@ -1808,6 +1809,11 @@ public class DownloadService extends Service { } }, timerDuration * 60 * 1000); + timerStart = System.currentTimeMillis(); + } + + public int getSleepTimeRemaining() { + return (int) (timerStart + (timerDuration * 60 * 1000) - System.currentTimeMillis()) / 1000; } public void stopSleepTimer() { diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index d4a239a6..c370c77c 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -206,7 +206,6 @@ Fernbedienung ist nicht erlaubt. Bitte aktivieren Sie den Jukebox-Modus unter Nutzer > Einstellungen auf Ihrem Subsonic-Server. Timer: Starte Timer - Stoppe Timer Video muss zuerst heruntergeladen werden Stream kann nicht wiedergegeben werden. Wiedergabe: %1$d/%2$d diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index e4d80211..f56e939e 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -191,7 +191,6 @@ Control remoto no permitido. Por favor, active el modo jukebox en Users > Settings en su servidor Subsonic. Temporizador Iniciar temporizador - Detener temporizador El vídeo ha de ser descargado antes Ningún reproductor puede reproducir este stream %1$d/%2$d diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 84e3dd75..4674ca32 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -191,7 +191,6 @@ Mode télécommande non autorisée. Activer le mode jukebox.Users > Settings on your Subsonic server. Minuteur : Démarrer le minuteur - Arrêter le minuteur La vidéo doit d\'abord être téléchargée Aucun lecteur ne peut afficher ce flux Lecture : %1$d/%2$d diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index 481a4c99..91cdf202 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -202,7 +202,6 @@ A távvezérlés nem lehetséges! Engedélyezze a Jukebox módot a Users > Settings menüben a Subsonic kiszolgálón! Időhossz: Időzítő indítása - Időzítő megállítása A videót először le kell tölteni! Nincs megfelelő lejátszó a stream megjelenítéséhez! Lejátszás: %1$d/%2$d diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 15c79a69..ffbb0485 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -123,8 +123,7 @@ Удаленное управление запрещено. Пожалуйста, активируйте режим jukebox в разделе Настройки > Проигрыватели на вашем сервере Subsonic. Длительность Запустить таймер - Остановить таймер - Необходимо сначала скачать видео + Необходимо сначала скачать видео Нет плеера для воспроизведения потока \"%s\" добавлено в закладки diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 74d69e5e..b783f0b9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -207,7 +207,7 @@ Remote control is not allowed. Please enable jukebox mode in Users > Settings on your Subsonic server. Timer: Start Timer - Stop Timer + Stop in %1$s Video needs to be downloaded first No player can play this stream Playing: %1$d/%2$d -- cgit v1.2.3