aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-07-22 20:26:21 -0700
committerScott Jackson <daneren2005@gmail.com>2015-07-22 20:26:21 -0700
commitc04ae69ec580c7d86eed872626cc98bdd2769c81 (patch)
tree2e92574ee64fba0b18d8186af730788386c20806 /app/src/main
parentfbd1a68042dfc3601eaa0a9e37b3957bbdd51420 (diff)
downloaddsub-c04ae69ec580c7d86eed872626cc98bdd2769c81.tar.gz
dsub-c04ae69ec580c7d86eed872626cc98bdd2769c81.tar.bz2
dsub-c04ae69ec580c7d86eed872626cc98bdd2769c81.zip
#506 Show sleep time remaining
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/fragments/NowPlayingFragment.java16
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/DownloadService.java6
-rw-r--r--app/src/main/res/values-de/strings.xml1
-rw-r--r--app/src/main/res/values-es/strings.xml1
-rw-r--r--app/src/main/res/values-fr/strings.xml1
-rw-r--r--app/src/main/res/values-hu/strings.xml1
-rw-r--r--app/src/main/res/values-ru/strings.xml3
-rw-r--r--app/src/main/res/values/strings.xml2
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 @@
<string name="download.jukebox_not_authorized">Fernbedienung ist nicht erlaubt. Bitte aktivieren Sie den Jukebox-Modus unter <b>Nutzer &gt; Einstellungen</b> auf Ihrem Subsonic-Server.</string>
<string name="download.timer_length">Timer:</string>
<string name="download.start_timer">Starte Timer</string>
- <string name="download.stop_timer">Stoppe Timer</string>
<string name="download.need_download">Video muss zuerst heruntergeladen werden</string>
<string name="download.no_streaming_player">Stream kann nicht wiedergegeben werden.</string>
<string name="download.playing_out_of">Wiedergabe: %1$d/%2$d</string>
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 @@
<string name="download.jukebox_not_authorized">Control remoto no permitido. Por favor, active el modo jukebox en <b>Users &gt; Settings</b> en su servidor Subsonic.</string>
<string name="download.timer_length">Temporizador</string>
<string name="download.start_timer">Iniciar temporizador</string>
- <string name="download.stop_timer">Detener temporizador</string>
<string name="download.need_download">El vídeo ha de ser descargado antes</string>
<string name="download.no_streaming_player">Ningún reproductor puede reproducir este stream</string>
<string name="download.playing_out_of">%1$d/%2$d</string>
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 @@
<string name="download.jukebox_not_authorized">Mode télécommande non autorisée. Activer le mode jukebox.<b>Users &gt; Settings</b> on your Subsonic server.</string>
<string name="download.timer_length">Minuteur :</string>
<string name="download.start_timer">Démarrer le minuteur</string>
- <string name="download.stop_timer">Arrêter le minuteur</string>
<string name="download.need_download">La vidéo doit d\'abord être téléchargée</string>
<string name="download.no_streaming_player">Aucun lecteur ne peut afficher ce flux</string>
<string name="download.playing_out_of">Lecture : %1$d/%2$d</string>
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 @@
<string name="download.jukebox_not_authorized">A távvezérlés nem lehetséges! Engedélyezze a Jukebox módot a <b>Users &gt; Settings</b> menüben a Subsonic kiszolgálón!</string>
<string name="download.timer_length">Időhossz:</string>
<string name="download.start_timer">Időzítő indítása</string>
- <string name="download.stop_timer">Időzítő megállítása</string>
<string name="download.need_download">A videót először le kell tölteni!</string>
<string name="download.no_streaming_player">Nincs megfelelő lejátszó a stream megjelenítéséhez!</string>
<string name="download.playing_out_of">Lejátszás: %1$d/%2$d</string>
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 @@
<string name="download.jukebox_not_authorized">Удаленное управление запрещено. Пожалуйста, активируйте режим jukebox в разделе <b>Настройки &gt; Проигрыватели</b> на вашем сервере Subsonic.</string>
<string name="download.timer_length">Длительность</string>
<string name="download.start_timer">Запустить таймер</string>
- <string name="download.stop_timer">Остановить таймер</string>
- <string name="download.need_download">Необходимо сначала скачать видео</string>
+ <string name="download.need_download">Необходимо сначала скачать видео</string>
<string name="download.no_streaming_player">Нет плеера для воспроизведения потока</string>
<string name="starring_content_starred">\"%s\" добавлено в закладки</string>
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 @@
<string name="download.jukebox_not_authorized">Remote control is not allowed. Please enable jukebox mode in <b>Users &gt; Settings</b> on your Subsonic server.</string>
<string name="download.timer_length">Timer:</string>
<string name="download.start_timer">Start Timer</string>
- <string name="download.stop_timer">Stop Timer</string>
+ <string name="download.stop_time_remaining">Stop in %1$s</string>
<string name="download.need_download">Video needs to be downloaded first</string>
<string name="download.no_streaming_player">No player can play this stream</string>
<string name="download.playing_out_of">Playing: %1$d/%2$d</string>