From 90643ffe79badc378f55630fe559236f5b580aa8 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 6 Feb 2014 18:03:37 -0800 Subject: Fix web commits --- src/github/daneren2005/dsub/service/DownloadFile.java | 12 ++++++------ src/github/daneren2005/dsub/util/Util.java | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/github/daneren2005') diff --git a/src/github/daneren2005/dsub/service/DownloadFile.java b/src/github/daneren2005/dsub/service/DownloadFile.java index cfadced5..fb5122ba 100644 --- a/src/github/daneren2005/dsub/service/DownloadFile.java +++ b/src/github/daneren2005/dsub/service/DownloadFile.java @@ -63,7 +63,7 @@ public class DownloadFile { private boolean saveWhenDone = false; private boolean completeWhenDone = false; private Integer contentLength = null; - private int currentSpeed = 0; + private long currentSpeed = 0; public DownloadFile(Context context, MusicDirectory.Entry song, boolean save) { this.context = context; @@ -111,7 +111,7 @@ public class DownloadFile { return contentLength; } - public int getCurrentSize() { + public long getCurrentSize() { if(partialFile.exists()) { return partialFile.length(); } else { @@ -119,12 +119,12 @@ public class DownloadFile { if(file.exists()) { return file.length(); } else { - return 0; + return 0L; } } } - public int getEstimatedSize() { + public long getEstimatedSize() { if(contentLength != null) { return contentLength; } @@ -135,13 +135,13 @@ public class DownloadFile { } else if(song.getDuration() == null) { return 0; } else { - int br = getBitrate(); + int br = getBitRate(); int duration = song.getDuration(); return br * duration; } } - public int getBytesPerSecond() { + public long getBytesPerSecond() { return currentSpeed; } diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java index fe8b6eae..05dbb1c3 100644 --- a/src/github/daneren2005/dsub/util/Util.java +++ b/src/github/daneren2005/dsub/util/Util.java @@ -1122,7 +1122,7 @@ public final class Util { .setProgress(10, 5, true) .setOngoing(true) .addAction(R.drawable.notification_close, - context.getResources().getString(R.string.common_cancel, + context.getResources().getString(R.string.common_cancel), cancelPI); Intent notificationIntent = new Intent(context, SubsonicFragmentActivity.class); -- cgit v1.2.3 From 47efa0e85266bc390513854ac89fca914fe9f93b Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 6 Feb 2014 19:31:51 -0800 Subject: Fix cancel button --- .../service/DownloadServiceLifecycleSupport.java | 33 +++++++++++++--------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'src/github/daneren2005') diff --git a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java index 65320f84..cd876621 100644 --- a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java +++ b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java @@ -92,8 +92,6 @@ public class DownloadServiceLifecycleSupport { } else if (DownloadServiceImpl.CMD_STOP.equals(action)) { downloadService.pause(); downloadService.seekTo(0); - } else if(DownloadServiceImpl.CANCEL_DOWNLOADS.equals(action)) { - downloadService.clearBackground(); } } }); @@ -204,19 +202,26 @@ public class DownloadServiceLifecycleSupport { } public void onStart(Intent intent) { - if (intent != null && intent.getExtras() != null) { - final KeyEvent event = (KeyEvent) intent.getExtras().get(Intent.EXTRA_KEY_EVENT); - if (event != null) { - eventHandler.post(new Runnable() { - @Override - public void run() { - if(!setup.get()) { - lock.lock(); - lock.unlock(); + if (intent != null) { + if(intent.getExtras() != null) { + final KeyEvent event = (KeyEvent) intent.getExtras().get(Intent.EXTRA_KEY_EVENT); + if (event != null) { + eventHandler.post(new Runnable() { + @Override + public void run() { + if(!setup.get()) { + lock.lock(); + lock.unlock(); + } + handleKeyEvent(event); } - handleKeyEvent(event); - } - }); + }); + } + } else { + String action = intent.getAction(); + if(DownloadServiceImpl.CANCEL_DOWNLOADS.equals(action)) { + downloadService.clearBackground(); + } } } } -- cgit v1.2.3 From 35a56bb221f67d4ae6cfef2eb0e689c00cded96b Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 6 Feb 2014 19:52:17 -0800 Subject: Check if file list is null --- src/github/daneren2005/dsub/util/Util.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/github/daneren2005') diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java index 05dbb1c3..5b79e2f2 100644 --- a/src/github/daneren2005/dsub/util/Util.java +++ b/src/github/daneren2005/dsub/util/Util.java @@ -606,14 +606,17 @@ public final class Util { } public static boolean recursiveDelete(File dir) { if (dir != null && dir.exists()) { - for(File file: dir.listFiles()) { - if(file.isDirectory()) { - if(!recursiveDelete(file)) { - return false; - } - } else if(file.exists()) { - if(!file.delete()) { - return false; + File[] list = dir.listFiles(); + if(list != null) { + for(File file: list) { + if(file.isDirectory()) { + if(!recursiveDelete(file)) { + return false; + } + } else if(file.exists()) { + if(!file.delete()) { + return false; + } } } } -- cgit v1.2.3 From 12c277209fb81ba578d59551e1954ddca73cbaaa Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sat, 8 Feb 2014 18:39:24 -0800 Subject: Add more information to download notification --- res/values/strings.xml | 3 +++ src/github/daneren2005/dsub/service/DownloadFile.java | 2 +- .../daneren2005/dsub/service/DownloadServiceImpl.java | 18 ++++++++++++++++-- src/github/daneren2005/dsub/util/Util.java | 18 +++++++++++++++--- 4 files changed, 35 insertions(+), 6 deletions(-) (limited to 'src/github/daneren2005') diff --git a/res/values/strings.xml b/res/values/strings.xml index f1f4a1ca..7abcbd28 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -193,6 +193,9 @@ Bookmark created Downloading %1$d songs Current: %1$s + Current: %1$s + \nEstimated Size: %2$s + \nAverage Speed: %3$s kbps DSub: New media is available New podcasts: %s diff --git a/src/github/daneren2005/dsub/service/DownloadFile.java b/src/github/daneren2005/dsub/service/DownloadFile.java index fb5122ba..9ecfe0ad 100644 --- a/src/github/daneren2005/dsub/service/DownloadFile.java +++ b/src/github/daneren2005/dsub/service/DownloadFile.java @@ -135,7 +135,7 @@ public class DownloadFile { } else if(song.getDuration() == null) { return 0; } else { - int br = getBitRate(); + int br = (getBitRate() * 1024) / 8; int duration = song.getDuration(); return br * duration; } diff --git a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java index d67d53bf..19e7625c 100644 --- a/src/github/daneren2005/dsub/service/DownloadServiceImpl.java +++ b/src/github/daneren2005/dsub/service/DownloadServiceImpl.java @@ -121,6 +121,7 @@ public class DownloadServiceImpl extends Service implements DownloadService { private int cachedPosition = 0; private long downloadRevision; private boolean downloadOngoing = false; + private DownloadFile lastDownloaded = null; private static boolean equalizerAvailable; private static boolean visualizerAvailable; @@ -1526,13 +1527,26 @@ public class DownloadServiceImpl extends Service implements DownloadService { } } - if(!backgroundDownloadList.isEmpty() && downloadRevision != revision) { - Util.showDownloadingNotification(this, currentDownloading, backgroundDownloadList.size()); + if(!backgroundDownloadList.isEmpty()) { + DownloadFile speedFile = null; + // Updating existing notification + if(downloadOngoing) { + // Changing download, use speed of last DownloadFile + if(revision != downloadRevision && lastDownloaded != null) { + speedFile = lastDownloaded; + } else { + // Updated mid-download + speedFile = currentDownloading; + } + } + Util.showDownloadingNotification(this, currentDownloading, backgroundDownloadList.size(), speedFile); downloadRevision = revision; + lastDownloaded = currentDownloading; downloadOngoing = true; } else if(backgroundDownloadList.isEmpty() && downloadOngoing) { Util.hideDownloadingNotification(this); downloadOngoing = false; + lastDownloaded = null; } // Delete obsolete .partial and .complete files. diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java index 5b79e2f2..e2f2d02f 100644 --- a/src/github/daneren2005/dsub/util/Util.java +++ b/src/github/daneren2005/dsub/util/Util.java @@ -1108,12 +1108,24 @@ public final class Util { DSubWidgetProvider.notifyInstances(context, downloadService, false); } - public static void showDownloadingNotification(final Context context, DownloadFile file, int size) { + public static void showDownloadingNotification(final Context context, DownloadFile file, int size, DownloadFile speedFile) { Intent cancelIntent = new Intent(context, DownloadServiceImpl.class); cancelIntent.setAction(DownloadServiceImpl.CANCEL_DOWNLOADS); PendingIntent cancelPI = PendingIntent.getService(context, 0, cancelIntent, 0); - String currentDownloading = (file != null) ? file.getSong().getTitle() : "none"; + String currentDownloading, currentSize, speed; + if(file != null) { + currentDownloading = file.getSong().getTitle(); + currentSize = Util.formatBytes(file.getEstimatedSize()); + } else { + currentDownloading = "none"; + currentSize = "0"; + } + if(speedFile != null) { + speed = Long.toString(speedFile.getBytesPerSecond() / 1024); + } else { + speed = "0"; + } NotificationCompat.Builder builder; builder = new NotificationCompat.Builder(context) @@ -1121,7 +1133,7 @@ public final class Util { .setContentTitle(context.getResources().getString(R.string.download_downloading_title, size)) .setContentText(context.getResources().getString(R.string.download_downloading_summary, currentDownloading)) .setStyle(new NotificationCompat.BigTextStyle() - .bigText(context.getResources().getString(R.string.download_downloading_summary, currentDownloading))) + .bigText(context.getResources().getString(R.string.download_downloading_summary_expanded, currentDownloading, currentSize, speed))) .setProgress(10, 5, true) .setOngoing(true) .addAction(R.drawable.notification_close, -- cgit v1.2.3 From e696190dcf4ad31476f7018d59ace23eea68d505 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Sat, 8 Feb 2014 18:51:54 -0800 Subject: Updated custom sort message, removed buffer length option --- res/values-es/strings.xml | 1 - res/values-hu/strings.xml | 1 - res/values-ru/strings.xml | 1 - res/values/strings.xml | 3 +-- res/xml/settings.xml | 6 ------ src/github/daneren2005/dsub/activity/SettingsActivity.java | 3 --- src/github/daneren2005/dsub/service/DownloadServiceImpl.java | 9 +-------- src/github/daneren2005/dsub/util/Constants.java | 1 - 8 files changed, 2 insertions(+), 23 deletions(-) (limited to 'src/github/daneren2005') diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index 5dd4cdda..cb245e83 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -308,7 +308,6 @@ Mantener la pantalla encendida durantes las descargas mejora la velocidad de descarga. Listas de reproducción Tamaño aleatorio - Tamaño del buffer (0 = totalmente en caché) Temporizador Duración del temporizador Encendido diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml index c4f50fdd..afe5db36 100644 --- a/res/values-hu/strings.xml +++ b/res/values-hu/strings.xml @@ -325,7 +325,6 @@ Képernyő ébrentartása a letöltés alatt, a magasabb letöltési sebesség érdekében. Lejátszási listák Véletlenszerű lejátszási lista mérete - Pufferméret (0 = teljes gyorsítótárazás) Alvás időzítő Alvás időzítő időtartam Ki diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index 2671a8b6..f53a421c 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -234,7 +234,6 @@ Оставить экран включенным для повышения скорости при скачивании. Списки воспроизведения Размер случайного списка - Размер буфера (0 = кешировать полностью) Таймер сна Продолжительность таймера сна Выключен diff --git a/res/values/strings.xml b/res/values/strings.xml index 7abcbd28..1d4398f5 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -272,7 +272,7 @@ Display Track # Display Track # in front of songs if one exists Custom Sort - Sort directory listings to properly sort by disc number. Interferes with the servers sort albums by year. + Override default server sorting to sort by disc number and by year. Network Max Audio bitrate - Wi-Fi Max Audio bitrate - Mobile @@ -328,7 +328,6 @@ Keeping the screen on while downloading improves download speed. Play Random Size - Buffer Length (0 = when fully cached) Sleep Timer Sleep Timer Duration Off diff --git a/res/xml/settings.xml b/res/xml/settings.xml index 30b2e584..573da94b 100644 --- a/res/xml/settings.xml +++ b/res/xml/settings.xml @@ -277,12 +277,6 @@ - - Date: Sat, 8 Feb 2014 19:02:08 -0800 Subject: Remove unused constants --- src/github/daneren2005/dsub/util/Constants.java | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src/github/daneren2005') diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java index aa4fe62a..5d80a961 100644 --- a/src/github/daneren2005/dsub/util/Constants.java +++ b/src/github/daneren2005/dsub/util/Constants.java @@ -41,7 +41,6 @@ public final class Constants { public static final String INTENT_EXTRA_NAME_ARTIST = "subsonic.artist"; public static final String INTENT_EXTRA_NAME_TITLE = "subsonic.title"; public static final String INTENT_EXTRA_NAME_AUTOPLAY = "subsonic.playall"; - public static final String INTENT_EXTRA_NAME_ERROR = "subsonic.error"; public static final String INTENT_EXTRA_NAME_QUERY = "subsonic.query"; public static final String INTENT_EXTRA_NAME_PLAYLIST_ID = "subsonic.playlist.id"; public static final String INTENT_EXTRA_NAME_PLAYLIST_NAME = "subsonic.playlist.name"; @@ -50,7 +49,6 @@ public final class Constants { public static final String INTENT_EXTRA_NAME_ALBUM_LIST_SIZE = "subsonic.albumlistsize"; public static final String INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET = "subsonic.albumlistoffset"; public static final String INTENT_EXTRA_NAME_SHUFFLE = "subsonic.shuffle"; - public static final String INTENT_EXTRA_NAME_REFRESH = "subsonic.refresh"; public static final String INTENT_EXTRA_REQUEST_SEARCH = "subsonic.requestsearch"; public static final String INTENT_EXTRA_NAME_EXIT = "subsonic.exit" ; public static final String INTENT_EXTRA_NAME_DOWNLOAD = "subsonic.download"; @@ -65,7 +63,6 @@ public final class Constants { // Notification IDs. public static final int NOTIFICATION_ID_PLAYING = 100; - public static final int NOTIFICATION_ID_ERROR = 101; public static final int NOTIFICATION_ID_DOWNLOADING = 102; // Preferences keys. @@ -104,7 +101,6 @@ public final class Constants { public static final String PREFERENCES_KEY_REPEAT_MODE = "repeatMode"; public static final String PREFERENCES_KEY_WIFI_REQUIRED_FOR_DOWNLOAD = "wifiRequiredForDownload"; public static final String PREFERENCES_KEY_RANDOM_SIZE = "randomSize"; - public static final String PREFERENCES_KEY_SLEEP_TIMER = "sleepTimer"; public static final String PREFERENCES_KEY_SLEEP_TIMER_DURATION = "sleepTimerDuration"; public static final String PREFERENCES_KEY_OFFLINE = "offline"; public static final String PREFERENCES_KEY_TEMP_LOSS = "tempLoss"; @@ -153,9 +149,6 @@ public final class Constants { public static final String MAIN_BACK_STACK = "backStackIds"; public static final String MAIN_BACK_STACK_SIZE = "backStackIdsSize"; - public static final String MAIN_BACK_STACK_TABS = "backStackTabs"; - public static final String MAIN_BACK_STACK_POSITION = "backStackPosition"; - public static final String FRAGMENT_ID = "fragmentId"; public static final String FRAGMENT_LIST = "fragmentList"; public static final String FRAGMENT_LIST2 = "fragmentList2"; public static final String FRAGMENT_DOWNLOAD_FLIPPER = "fragmentDownloadFlipper"; -- cgit v1.2.3