aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKoen <koen@koenvh.nl>2018-08-24 13:06:33 +0200
committerGitHub <noreply@github.com>2018-08-24 13:06:33 +0200
commit259b7fd27bfd33bc03ca5d6d9cb11eacf17208e0 (patch)
tree7c278ef0f85e585d1b760b6839378a0ee76a8366
parent32a1cfa82165a5af8ec8b8013b4b41c13b6b47d9 (diff)
parent96b8676e0f435e73459c048cf9c53a5639b9dfac (diff)
downloaddsub-259b7fd27bfd33bc03ca5d6d9cb11eacf17208e0.tar.gz
dsub-259b7fd27bfd33bc03ca5d6d9cb11eacf17208e0.tar.bz2
dsub-259b7fd27bfd33bc03ca5d6d9cb11eacf17208e0.zip
Merge pull request #2 from daneren2005/edge
5.4.2
-rw-r--r--DSub.iml2
-rw-r--r--app/build.gradle4
-rw-r--r--app/src/main/java/github/daneren2005/dsub/domain/MusicDirectory.java41
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/AutoMediaBrowserService.java108
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java11
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/Constants.java1
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/Notifications.java14
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java8
-rw-r--r--app/src/main/res/xml/changelog.xml5
9 files changed, 139 insertions, 55 deletions
diff --git a/DSub.iml b/DSub.iml
index 786f4b16..ef018f42 100644
--- a/DSub.iml
+++ b/DSub.iml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<module external.linked.project.id="DSub" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
+<module external.linked.project.id="DSub" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="java-gradle" name="Java-Gradle">
<configuration>
diff --git a/app/build.gradle b/app/build.gradle
index 3c8e5f45..4c492eaa 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -8,8 +8,8 @@ android {
applicationId "github.daneren2005.dsub"
minSdkVersion 14
targetSdkVersion 26
- versionCode 198
- versionName '5.4.1'
+ versionCode 199
+ versionName '5.4.2'
setProperty("archivesBaseName", "DSub $versionName")
resConfigs "de", "es", "fr", "hu", "nl", "pt-rPT", "ru", "sv"
}
diff --git a/app/src/main/java/github/daneren2005/dsub/domain/MusicDirectory.java b/app/src/main/java/github/daneren2005/dsub/domain/MusicDirectory.java
index 5f7b2412..bd7928fd 100644
--- a/app/src/main/java/github/daneren2005/dsub/domain/MusicDirectory.java
+++ b/app/src/main/java/github/daneren2005/dsub/domain/MusicDirectory.java
@@ -25,6 +25,13 @@ import android.media.MediaMetadataRetriever;
import android.os.Build;
import android.util.Log;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Iterator;
@@ -628,6 +635,40 @@ public class MusicDirectory implements Serializable {
public String toString() {
return title;
}
+
+ public byte[] toByteArray() throws IOException {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ ObjectOutput out = null;
+ try {
+ out = new ObjectOutputStream(bos);
+ out.writeObject(this);
+ out.flush();
+ return bos.toByteArray();
+ } finally {
+ try {
+ bos.close();
+ } catch (IOException ex) {
+ // ignore close exception
+ }
+ }
+ }
+
+ public static Entry fromByteArray(byte[] byteArray) throws IOException, ClassNotFoundException {
+ ByteArrayInputStream bis = new ByteArrayInputStream(byteArray);
+ ObjectInput in = null;
+ try {
+ in = new ObjectInputStream(bis);
+ return (Entry) in.readObject();
+ } finally {
+ try {
+ if (in != null) {
+ in.close();
+ }
+ } catch (IOException ex) {
+ // ignore close exception
+ }
+ }
+ }
}
public static class EntryComparator implements Comparator<Entry> {
diff --git a/app/src/main/java/github/daneren2005/dsub/service/AutoMediaBrowserService.java b/app/src/main/java/github/daneren2005/dsub/service/AutoMediaBrowserService.java
index 88cfe559..d4e544c6 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/AutoMediaBrowserService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/AutoMediaBrowserService.java
@@ -30,6 +30,7 @@ import android.service.media.MediaBrowserService;
import android.support.annotation.Nullable;
import android.util.Log;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -279,18 +280,22 @@ public class AutoMediaBrowserService extends MediaBrowserService {
// music files
for(Entry entry: indexes.getEntries()) {
- entry.setBookmark(null); // don't resume from a bookmark in a browse listing
- Bundle extras = new Bundle();
- extras.putSerializable(Constants.INTENT_EXTRA_ENTRY, entry);
- extras.putString(Constants.INTENT_EXTRA_NAME_CHILD_ID, entry.getId());
+ try {
+ entry.setBookmark(null); // don't resume from a bookmark in a browse listing
+ Bundle extras = new Bundle();
+ extras.putByteArray(Constants.INTENT_EXTRA_ENTRY_BYTES, entry.toByteArray());
+ extras.putString(Constants.INTENT_EXTRA_NAME_CHILD_ID, entry.getId());
- MediaDescription description = new MediaDescription.Builder()
- .setTitle(entry.getTitle())
- .setMediaId(entry.getId())
- .setExtras(extras)
- .build();
+ MediaDescription description = new MediaDescription.Builder()
+ .setTitle(entry.getTitle())
+ .setMediaId(entry.getId())
+ .setExtras(extras)
+ .build();
- mediaItems.add(new MediaBrowser.MediaItem(description, MediaBrowser.MediaItem.FLAG_PLAYABLE));
+ mediaItems.add(new MediaBrowser.MediaItem(description, MediaBrowser.MediaItem.FLAG_PLAYABLE));
+ } catch(IOException e) {
+ Log.e(TAG, "Failed to add entry", e);
+ }
}
result.sendResult(mediaItems);
@@ -324,21 +329,24 @@ public class AutoMediaBrowserService extends MediaBrowserService {
mediaItems.add(new MediaBrowser.MediaItem(description, MediaBrowser.MediaItem.FLAG_BROWSABLE));
} else {
- // mark individual songs as directly playable
- entry.setBookmark(null); // don't resume from a bookmark in a browse listing
- Bundle extras = new Bundle();
- extras.putSerializable(Constants.INTENT_EXTRA_ENTRY, entry);
- extras.putString(Constants.INTENT_EXTRA_NAME_CHILD_ID, entry.getId());
-
- description = new MediaDescription.Builder()
- .setTitle(entry.getTitle())
- .setMediaId(entry.getId())
- .setExtras(extras)
- .build();
-
- mediaItems.add(new MediaBrowser.MediaItem(description, MediaBrowser.MediaItem.FLAG_PLAYABLE));
+ try {
+ // mark individual songs as directly playable
+ entry.setBookmark(null); // don't resume from a bookmark in a browse listing
+ Bundle extras = new Bundle();
+ extras.putByteArray(Constants.INTENT_EXTRA_ENTRY_BYTES, entry.toByteArray());
+ extras.putString(Constants.INTENT_EXTRA_NAME_CHILD_ID, entry.getId());
+
+ description = new MediaDescription.Builder()
+ .setTitle(entry.getTitle())
+ .setMediaId(entry.getId())
+ .setExtras(extras)
+ .build();
+
+ mediaItems.add(new MediaBrowser.MediaItem(description, MediaBrowser.MediaItem.FLAG_PLAYABLE));
+ } catch (IOException e) {
+ Log.e(TAG, "Failed to add entry", e);
+ }
}
-
}
result.sendResult(mediaItems);
}
@@ -412,19 +420,23 @@ public class AutoMediaBrowserService extends MediaBrowserService {
List<MediaBrowser.MediaItem> mediaItems = new ArrayList<>();
for(Entry entry: podcasts.getChildren(false, true)) {
- PodcastEpisode podcast = (PodcastEpisode) entry;
- Bundle podcastExtras = new Bundle();
- podcastExtras.putSerializable(Constants.INTENT_EXTRA_ENTRY, podcast);
- podcastExtras.putString(Constants.INTENT_EXTRA_NAME_PODCAST_ID, podcast.getId());
-
- MediaDescription description = new MediaDescription.Builder()
- .setTitle(podcast.getTitle())
- .setSubtitle(Util.formatDate(downloadService, podcast.getDate(), false))
- .setMediaId(PODCAST_PREFIX + podcast.getId())
- .setExtras(podcastExtras)
- .build();
+ try {
+ PodcastEpisode podcast = (PodcastEpisode) entry;
+ Bundle podcastExtras = new Bundle();
+ podcastExtras.putByteArray(Constants.INTENT_EXTRA_ENTRY_BYTES, podcast.toByteArray());
+ podcastExtras.putString(Constants.INTENT_EXTRA_NAME_PODCAST_ID, podcast.getId());
+
+ MediaDescription description = new MediaDescription.Builder()
+ .setTitle(podcast.getTitle())
+ .setSubtitle(Util.formatDate(downloadService, podcast.getDate(), false))
+ .setMediaId(PODCAST_PREFIX + podcast.getId())
+ .setExtras(podcastExtras)
+ .build();
- mediaItems.add(new MediaBrowser.MediaItem(description, MediaBrowser.MediaItem.FLAG_PLAYABLE));
+ mediaItems.add(new MediaBrowser.MediaItem(description, MediaBrowser.MediaItem.FLAG_PLAYABLE));
+ } catch(IOException e) {
+ Log.e(TAG, "Failed to add podcast", e);
+ }
}
result.sendResult(mediaItems);
@@ -446,18 +458,22 @@ public class AutoMediaBrowserService extends MediaBrowserService {
List<MediaBrowser.MediaItem> mediaItems = new ArrayList<>();
for(Entry entry: bookmarkList.getChildren(false, true)) {
- Bundle extras = new Bundle();
- extras.putSerializable(Constants.INTENT_EXTRA_ENTRY, entry);
- extras.putString(Constants.INTENT_EXTRA_NAME_CHILD_ID, entry.getId());
+ try {
+ Bundle extras = new Bundle();
+ extras.putByteArray(Constants.INTENT_EXTRA_ENTRY_BYTES, entry.toByteArray());
+ extras.putString(Constants.INTENT_EXTRA_NAME_CHILD_ID, entry.getId());
- MediaDescription description = new MediaDescription.Builder()
- .setTitle(entry.getTitle())
- .setSubtitle(Util.formatDuration(entry.getBookmark().getPosition() / 1000))
- .setMediaId(entry.getId())
- .setExtras(extras)
- .build();
+ MediaDescription description = new MediaDescription.Builder()
+ .setTitle(entry.getTitle())
+ .setSubtitle(Util.formatDuration(entry.getBookmark().getPosition() / 1000))
+ .setMediaId(entry.getId())
+ .setExtras(extras)
+ .build();
- mediaItems.add(new MediaBrowser.MediaItem(description, MediaBrowser.MediaItem.FLAG_PLAYABLE));
+ mediaItems.add(new MediaBrowser.MediaItem(description, MediaBrowser.MediaItem.FLAG_PLAYABLE));
+ } catch(IOException e) {
+ Log.e(TAG, "Failed to add entry", e);
+ }
}
result.sendResult(mediaItems);
diff --git a/app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java b/app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java
index 9fd26fe5..1e91a61e 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/CachedMusicService.java
@@ -148,7 +148,11 @@ public class CachedMusicService implements MusicService {
cachedIndexes.clear();
cachedMusicFolders.clear();
}
- Indexes result = cachedIndexes.get();
+ Indexes result = null;
+ if(Util.equals(musicFolderId, this.musicFolderId)) {
+ result = cachedIndexes.get();
+ }
+
if (result == null) {
String name = Util.isTagBrowsing(context, musicService.getInstance(context)) ? "artists" : "indexes";
name = getCacheName(context, name, musicFolderId);
@@ -160,7 +164,10 @@ public class CachedMusicService implements MusicService {
result = musicService.getIndexes(musicFolderId, refresh, context, progressListener);
FileUtil.serialize(context, result, name);
}
- cachedIndexes.set(result);
+
+ if(Util.equals(musicFolderId, this.musicFolderId)) {
+ cachedIndexes.set(result);
+ }
}
return result;
}
diff --git a/app/src/main/java/github/daneren2005/dsub/util/Constants.java b/app/src/main/java/github/daneren2005/dsub/util/Constants.java
index e0a1e164..7f5ff3f1 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/Constants.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/Constants.java
@@ -68,6 +68,7 @@ public final class Constants {
public static final String INTENT_EXTRA_SHOW_ALL = "showAll";
public static final String INTENT_EXTRA_PLAY_LAST = "playLast";
public static final String INTENT_EXTRA_ENTRY = "passedEntry";
+ public static final String INTENT_EXTRA_ENTRY_BYTES = "passedEntryBytes";
// Preferences keys.
public static final String PREFERENCES_KEY_SERVER_KEY = "server";
diff --git a/app/src/main/java/github/daneren2005/dsub/util/Notifications.java b/app/src/main/java/github/daneren2005/dsub/util/Notifications.java
index 428c33e0..f0bd6766 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/Notifications.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/Notifications.java
@@ -216,13 +216,13 @@ public final class Notifications {
// Create actions for media buttons
int previous = 0, pause = 0, next = 0, close = 0, rewind = 0, fastForward = 0;
if (expanded) {
+ pause = R.id.control_pause;
+
if (shouldFastForward) {
rewind = R.id.control_previous;
- pause = R.id.control_pause;
fastForward = R.id.control_next;
} else {
previous = R.id.control_previous;
- pause = R.id.control_pause;
next = R.id.control_next;
}
@@ -240,9 +240,15 @@ public final class Notifications {
}
close = R.id.control_next;
} else {
- rewind = R.id.control_previous;
+ if (shouldFastForward) {
+ rewind = R.id.control_previous;
+ fastForward = R.id.control_next;
+ } else {
+ previous = R.id.control_previous;
+ next = R.id.control_next;
+ }
+
pause = R.id.control_pause;
- fastForward = R.id.control_next;
}
}
diff --git a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java
index 816a071d..9f1d5ebd 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/compat/RemoteControlClientLP.java
@@ -39,6 +39,7 @@ import android.support.v7.media.MediaRouter;
import android.util.Log;
import android.view.KeyEvent;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -584,6 +585,13 @@ public class RemoteControlClientLP extends RemoteControlClientBase {
boolean shuffle = extras.getBoolean(Constants.INTENT_EXTRA_NAME_SHUFFLE, false);
boolean playLast = extras.getBoolean(Constants.INTENT_EXTRA_PLAY_LAST, false);
Entry entry = (Entry) extras.getSerializable(Constants.INTENT_EXTRA_ENTRY);
+ if(extras.containsKey(Constants.INTENT_EXTRA_ENTRY_BYTES)) {
+ try {
+ entry = Entry.fromByteArray(extras.getByteArray(Constants.INTENT_EXTRA_ENTRY_BYTES));
+ } catch(Exception e) {
+ Log.e(TAG, "Failed to deserialize from entry: ", e);
+ }
+ }
String playlistId = extras.getString(Constants.INTENT_EXTRA_NAME_PLAYLIST_ID, null);
if(playlistId != null) {
diff --git a/app/src/main/res/xml/changelog.xml b/app/src/main/res/xml/changelog.xml
index 8aa15153..516ab142 100644
--- a/app/src/main/res/xml/changelog.xml
+++ b/app/src/main/res/xml/changelog.xml
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<changelog>
+ <release version="5.4.2" versioncode="199" releasedate="08/23/2018">
+ <change>Implement notification channels</change>
+ <change>Fix lockscreen back/forward controls rewinding/fast forwarding instead</change>
+ <change>Fix Android Auto compatibility</change>
+ </release>
<release version="5.4.1" versioncode="198" releasedate="07/29/2018">
<change>Fix Android Auto compatibility</change>
</release>