diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-09-07 08:13:53 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-09-07 08:13:53 -0700 |
commit | e79139cd92cf484eff5666237c4d5b39afa2e456 (patch) | |
tree | 3c908c8f6110043790ca3485116de798b37912f9 /app | |
parent | 6bfd1b493f57d344f9effe4555480d3e505a7ef8 (diff) | |
parent | 1f0bbb6a2443b47501a5d3aad9de939a8e377d7b (diff) | |
download | dsub-e79139cd92cf484eff5666237c4d5b39afa2e456.tar.gz dsub-e79139cd92cf484eff5666237c4d5b39afa2e456.tar.bz2 dsub-e79139cd92cf484eff5666237c4d5b39afa2e456.zip |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'app')
7 files changed, 89 insertions, 19 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/domain/Playlist.java b/app/src/main/java/github/daneren2005/dsub/domain/Playlist.java index 99b85ce9..7d480607 100644 --- a/app/src/main/java/github/daneren2005/dsub/domain/Playlist.java +++ b/app/src/main/java/github/daneren2005/dsub/domain/Playlist.java @@ -19,9 +19,13 @@ package github.daneren2005.dsub.domain; import java.io.Serializable; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.Collections; import java.util.Comparator; +import java.util.Date; import java.util.List; +import java.util.Locale; /** * @author Sindre Mehus @@ -33,8 +37,10 @@ public class Playlist implements Serializable { private String owner; private String comment; private String songCount; - private String created; private Boolean pub; + private Date created; + private Date changed; + private Integer duration; public Playlist() { @@ -43,14 +49,16 @@ public class Playlist implements Serializable { this.id = id; this.name = name; } - public Playlist(String id, String name, String owner, String comment, String songCount, String created, String pub) { + public Playlist(String id, String name, String owner, String comment, String songCount, String pub, String created, String changed, Integer duration) { this.id = id; this.name = name; this.owner = (owner == null) ? "" : owner; this.comment = (comment == null) ? "" : comment; this.songCount = (songCount == null) ? "" : songCount; - this.created = (created == null) ? "" : created; this.pub = (pub == null) ? null : (pub.equals("true")); + setCreated(created); + setChanged(changed); + this.duration = duration; } public String getId() { @@ -93,14 +101,6 @@ public class Playlist implements Serializable { this.songCount = songCount; } - public String getCreated() { - return this.created; - } - - public void setCreated(String created) { - this.created = created; - } - public Boolean getPublic() { return this.pub; } @@ -108,6 +108,50 @@ public class Playlist implements Serializable { this.pub = pub; } + public Date getCreated() { + return created; + } + + public void setCreated(String created) { + if (created != null) { + try { + this.created = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH).parse(created); + } catch (ParseException e) { + this.created = null; + } + } else { + this.created = null; + } + } + public void setCreated(Date created) { + this.created = created; + } + + public Date getChanged() { + return changed; + } + public void setChanged(String changed) { + if (changed != null) { + try { + this.changed = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH).parse(changed); + } catch (ParseException e) { + this.changed = null; + } + } else { + this.changed = null; + } + } + public void setChanged(Date changed) { + this.changed = changed; + } + + public Integer getDuration() { + return duration; + } + public void setDuration(Integer duration) { + this.duration = duration; + } + @Override public String toString() { return name; diff --git a/app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java b/app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java index 07a86db4..cb871008 100644 --- a/app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java +++ b/app/src/main/java/github/daneren2005/dsub/domain/ServerInfo.java @@ -210,4 +210,7 @@ public class ServerInfo implements Serializable { public static boolean canAlbumListPerFolder(Context context) { return ServerInfo.checkServerVersion(context, "1.11") && !ServerInfo.isMadsonic(context) && !Util.isTagBrowsing(context); } + public static boolean hasTopSongs(Context context) { + return ServerInfo.isMadsonic(context) || ServerInfo.checkServerVersion(context, "1.13"); + } } diff --git a/app/src/main/java/github/daneren2005/dsub/domain/Version.java b/app/src/main/java/github/daneren2005/dsub/domain/Version.java index 6b82ea99..97246ecf 100644 --- a/app/src/main/java/github/daneren2005/dsub/domain/Version.java +++ b/app/src/main/java/github/daneren2005/dsub/domain/Version.java @@ -90,6 +90,10 @@ public class Version implements Comparable<Version>, Serializable { return "4.9"; case 11: return "5.1"; + case 12: + return "5.2"; + case 13: + return "5.3"; } } return ""; diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index c138b04e..430aaa3c 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -228,7 +228,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section } else if(artist && !showAll) { menuInflater.inflate(R.menu.select_album, menu); - if(!ServerInfo.isMadsonic(context)) { + if(!ServerInfo.hasTopSongs(context)) { menu.removeItem(R.id.menu_top_tracks); } if(!ServerInfo.checkServerVersion(context, "1.11") || (id != null && "root".equals(id))) { @@ -555,7 +555,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Section new LoadTask(refresh) { @Override protected MusicDirectory load(MusicService service) throws Exception { - return service.getTopTrackSongs(name, 20, context, this); + return service.getTopTrackSongs(name, 50, context, this); } }.execute(); } diff --git a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java index a2f1aabd..543dcb26 100644 --- a/app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java +++ b/app/src/main/java/github/daneren2005/dsub/fragments/SelectPlaylistFragment.java @@ -210,6 +210,11 @@ public class SelectPlaylistFragment extends SelectRecyclerFragment<Playlist> { headers.add(R.string.details_song_count); details.add(playlist.getSongCount()); + if(playlist.getDuration() != null) { + headers.add(R.string.details_length); + details.add(Util.formatDuration(playlist.getDuration())); + } + if(playlist.getPublic() != null) { headers.add(R.string.details_public); details.add(Boolean.toString(playlist.getPublic())); @@ -217,7 +222,11 @@ public class SelectPlaylistFragment extends SelectRecyclerFragment<Playlist> { if(playlist.getCreated() != null) { headers.add(R.string.details_created); - details.add(Util.formatDate(context, playlist.getCreated())); + details.add(Util.formatDate(playlist.getCreated())); + } + if(playlist.getChanged() != null) { + headers.add(R.string.details_updated); + details.add(Util.formatDate(playlist.getChanged())); } Util.showDetailsDialog(context, R.string.details_title_playlist, headers, details); diff --git a/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java b/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java index 78a7ec51..b70a2458 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java +++ b/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java @@ -579,8 +579,14 @@ public class RESTMusicService implements MusicService { names.add("toYear"); int decade = Integer.parseInt(extra); - values.add(decade); - values.add(decade + 10); + // Reverse chronological order only supported in 5.3+ + if(ServerInfo.checkServerVersion(context, "1.13", getInstance(context))) { + values.add(decade + 10); + values.add(decade); + } else { + values.add(decade); + values.add(decade + 10); + } } // Add folder if it was set and is non null @@ -1186,7 +1192,8 @@ public class RESTMusicService implements MusicService { parameterNames.add("size"); parameterValues.add(size); - Reader reader = getReader(context, progressListener, "getTopTrackSongs", null, parameterNames, parameterValues); + String method = ServerInfo.isMadsonic(context, getInstance(context)) ? "getTopTrackSongs" : "getTopSongs"; + Reader reader = getReader(context, progressListener, method, null, parameterNames, parameterValues); try { return new RandomSongsParser(context, getInstance(context)).parse(reader, progressListener); } finally { @@ -1867,6 +1874,7 @@ public class RESTMusicService implements MusicService { if(url.indexOf("getCoverArt") == -1 && url.indexOf("stream") == -1 && url.indexOf("getAvatar") == -1) { request.addHeader("Accept-Encoding", "gzip"); } + request.addHeader("User-Agent", Constants.REST_CLIENT_ID); // Set credentials to get through apache proxies that require authentication. int instance = prefs.getInt(Constants.PREFERENCES_KEY_SERVER_INSTANCE, 1); diff --git a/app/src/main/java/github/daneren2005/dsub/service/parser/PlaylistsParser.java b/app/src/main/java/github/daneren2005/dsub/service/parser/PlaylistsParser.java index 69e5af64..71a6b65e 100644 --- a/app/src/main/java/github/daneren2005/dsub/service/parser/PlaylistsParser.java +++ b/app/src/main/java/github/daneren2005/dsub/service/parser/PlaylistsParser.java @@ -52,9 +52,11 @@ public class PlaylistsParser extends AbstractParser { String owner = get("owner"); String comment = get("comment"); String songCount = get("songCount"); - String created = get("created"); String pub = get("public"); - result.add(new Playlist(id, name, owner, comment, songCount, created, pub)); + String created = get("created"); + String changed = get("changed"); + Integer duration = getInteger("duration"); + result.add(new Playlist(id, name, owner, comment, songCount, pub, created, changed, duration)); } else if ("error".equals(tag)) { handleError(); } |