From a0e5b6d20d033c31592a66cb0f36741785e664be Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Thu, 27 Jun 2013 20:56:39 -0700 Subject: Fixed up menus for podcasts, took away checks, fixed episodes with status error/skipped --- .../daneren2005/dsub/domain/PodcastEpisode.java | 8 ---- .../dsub/fragments/SelectDirectoryFragment.java | 51 ++++++++++++++++------ .../dsub/fragments/SubsonicFragment.java | 26 +++++++---- .../dsub/service/parser/PodcastEntryParser.java | 7 +++ .../src/github/daneren2005/dsub/view/SongView.java | 21 ++++++--- 5 files changed, 78 insertions(+), 35 deletions(-) (limited to 'subsonic-android/src/github/daneren2005') diff --git a/subsonic-android/src/github/daneren2005/dsub/domain/PodcastEpisode.java b/subsonic-android/src/github/daneren2005/dsub/domain/PodcastEpisode.java index d85e8325..01821072 100644 --- a/subsonic-android/src/github/daneren2005/dsub/domain/PodcastEpisode.java +++ b/subsonic-android/src/github/daneren2005/dsub/domain/PodcastEpisode.java @@ -24,7 +24,6 @@ package github.daneren2005.dsub.domain; */ public class PodcastEpisode extends MusicDirectory.Entry { private String episodeId; - private String description; private String date; private String status; @@ -39,13 +38,6 @@ public class PodcastEpisode extends MusicDirectory.Entry { this.episodeId = episodeId; } - public String getDescription() { - return description; - } - public void setDescription(String description) { - this.description = description; - } - public String getDate() { return date; } diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index 5b007e6f..f4f7aa0a 100644 --- a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -22,6 +22,7 @@ import java.util.List; import com.mobeta.android.dslv.*; import github.daneren2005.dsub.activity.DownloadActivity; import github.daneren2005.dsub.activity.SearchActivity; +import github.daneren2005.dsub.domain.PodcastEpisode; import github.daneren2005.dsub.service.MusicService; import github.daneren2005.dsub.service.MusicServiceFactory; import github.daneren2005.dsub.service.OfflineException; @@ -134,14 +135,23 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter menuInflater.inflate(R.menu.select_album, menu); } } else { - if(Util.isOffline(context)) { - menuInflater.inflate(R.menu.select_song_offline, menu); - } - else { - menuInflater.inflate(R.menu.select_song, menu); + if(podcastId == null) { + if(Util.isOffline(context)) { + menuInflater.inflate(R.menu.select_song_offline, menu); + } + else { + menuInflater.inflate(R.menu.select_song, menu); - if(playlistId == null) { - menu.removeItem(R.id.menu_remove_playlist); + if(playlistId == null) { + menu.removeItem(R.id.menu_remove_playlist); + } + } + } else { + if(Util.isOffline(context)) { + menuInflater.inflate(R.menu.select_podcast_episode_offline, menu); + } + else { + menuInflater.inflate(R.menu.select_podcast_episode, menu); } } } @@ -196,7 +206,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter MusicDirectory.Entry entry = (MusicDirectory.Entry) entryList.getItemAtPosition(info.position); onCreateContextMenu(menu, view, menuInfo, entry); - if(!entry.isVideo() && !Util.isOffline(context) && playlistId == null) { + if(!entry.isVideo() && !Util.isOffline(context) && playlistId == null && podcastId != null) { menu.removeItem(R.id.song_menu_remove_playlist); } } @@ -247,6 +257,21 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter replaceFragment(fragment, R.id.select_album_layout); } else if (entry.isVideo()) { playVideo(entry); + } else if(entry instanceof PodcastEpisode) { + String status = ((PodcastEpisode)entry).getStatus(); + if("error".equals(status)) { + Util.toast(context, R.string.select_podcasts_error); + return; + } else if("skipped".equals(status)) { + Util.toast(context, R.string.select_podcasts_skipped); + return; + } + + getDownloadService().clear(); + List podcasts = new ArrayList(1); + podcasts.add(entry); + getDownloadService().download(podcasts, false, true, true, false); + Util.startActivityWithoutTransition(context, DownloadActivity.class); } } } @@ -390,7 +415,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter } emptyView.setVisibility(entries.isEmpty() ? View.VISIBLE : View.GONE); - entryAdapter = new EntryAdapter(context, getImageLoader(), entries, true); + entryAdapter = new EntryAdapter(context, getImageLoader(), entries, (podcastId == null) ? true : false); if(albumListType == null || "starred".equals(albumListType)) { entryList.setAdapter(entryAdapter); } else { @@ -692,13 +717,13 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter } TextView artistView = (TextView) header.findViewById(R.id.select_album_artist); - if (artists.size() == 1) { - artistView.setText(artists.iterator().next()); - artistView.setVisibility(View.VISIBLE); - } else if(podcastDescription != null) { + if(podcastDescription != null) { artistView.setText(podcastDescription); artistView.setSingleLine(false); artistView.setLines(5); + } else if (artists.size() == 1) { + artistView.setText(artists.iterator().next()); + artistView.setVisibility(View.VISIBLE); } else { artistView.setVisibility(View.GONE); } diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index 8eb9e926..e9dc843c 100644 --- a/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -50,7 +50,7 @@ import github.daneren2005.dsub.domain.Artist; import github.daneren2005.dsub.domain.Genre; import github.daneren2005.dsub.domain.MusicDirectory; import github.daneren2005.dsub.domain.Playlist; -import github.daneren2005.dsub.domain.Version; +import github.daneren2005.dsub.domain.PodcastEpisode; import github.daneren2005.dsub.service.DownloadFile; import github.daneren2005.dsub.service.DownloadService; import github.daneren2005.dsub.service.DownloadServiceImpl; @@ -144,13 +144,22 @@ public class SubsonicFragment extends SherlockFragment { if(selected instanceof MusicDirectory.Entry) { MusicDirectory.Entry entry = (MusicDirectory.Entry) selected; - if (entry.isDirectory()) { + if(entry instanceof PodcastEpisode) { + if(Util.isOffline(context)) { + inflater.inflate(R.menu.select_podcast_episode_context_offline, menu); + } + else { + inflater.inflate(R.menu.select_podcast_episode_context, menu); + } + } + else if (entry.isDirectory()) { if(Util.isOffline(context)) { inflater.inflate(R.menu.select_album_context_offline, menu); } else { inflater.inflate(R.menu.select_album_context, menu); } + menu.findItem(entry.isDirectory() ? R.id.album_menu_star : R.id.song_menu_star).setTitle(entry.isStarred() ? R.string.common_unstar : R.string.common_star); } else if(!entry.isVideo()) { if(Util.isOffline(context)) { inflater.inflate(R.menu.select_song_context_offline, menu); @@ -158,6 +167,7 @@ public class SubsonicFragment extends SherlockFragment { else { inflater.inflate(R.menu.select_song_context, menu); } + menu.findItem(entry.isDirectory() ? R.id.album_menu_star : R.id.song_menu_star).setTitle(entry.isStarred() ? R.string.common_unstar : R.string.common_star); } else { if(Util.isOffline(context)) { inflater.inflate(R.menu.select_video_context_offline, menu); @@ -166,10 +176,6 @@ public class SubsonicFragment extends SherlockFragment { inflater.inflate(R.menu.select_video_context, menu); } } - - if (!entry.isVideo()) { - menu.findItem(entry.isDirectory() ? R.id.album_menu_star : R.id.song_menu_star).setTitle(entry.isStarred() ? R.string.common_unstar : R.string.common_star); - } } else if(selected instanceof Artist) { if(Util.isOffline(context)) { inflater.inflate(R.menu.select_artist_context_offline, menu); @@ -822,7 +828,11 @@ public class SubsonicFragment extends SherlockFragment { String msg = ""; if(!song.isVideo()) { - msg += "Artist: " + song.getArtist() + "\nAlbum: " + song.getAlbum(); + if(song instanceof PodcastEpisode) { + msg += "Podcast: " + song.getArtist() + "\nStatus: " + ((PodcastEpisode)song).getStatus(); + } else { + msg += "Artist: " + song.getArtist() + "\nAlbum: " + song.getAlbum(); + } } if(song.getTrack() != null && song.getTrack() != 0) { msg += "\nTrack: " + song.getTrack(); @@ -833,7 +843,7 @@ public class SubsonicFragment extends SherlockFragment { if(song.getYear() != null && song.getYear() != 0) { msg += "\nYear: " + song.getYear(); } - if(!Util.isOffline(context)) { + if(!Util.isOffline(context) && song.getSuffix() != null) { msg += "\nServer Format: " + song.getSuffix(); if(song.getBitRate() != null && song.getBitRate() != 0) { msg += "\nServer Bitrate: " + song.getBitRate() + " kpbs"; diff --git a/subsonic-android/src/github/daneren2005/dsub/service/parser/PodcastEntryParser.java b/subsonic-android/src/github/daneren2005/dsub/service/parser/PodcastEntryParser.java index 8ef667f4..2af3b970 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/parser/PodcastEntryParser.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/parser/PodcastEntryParser.java @@ -33,6 +33,8 @@ import org.xmlpull.v1.XmlPullParser; * @author Scott */ public class PodcastEntryParser extends AbstractParser { + private static int bogusId = -1; + public PodcastEntryParser(Context context) { super(context); } @@ -74,6 +76,11 @@ public class PodcastEntryParser extends AbstractParser { episode.setDuration(getInteger("duration")); episode.setBitRate(getInteger("bitRate")); episode.setPath(get("path")); + + if("error".equals(episode.getStatus()) || "skipped".equals(episode.getStatus())) { + episode.setId(String.valueOf(bogusId)); + bogusId--; + } episodes.addChild(episode); } else if ("error".equals(name)) { handleError(); diff --git a/subsonic-android/src/github/daneren2005/dsub/view/SongView.java b/subsonic-android/src/github/daneren2005/dsub/view/SongView.java index dfdd814e..130663b5 100644 --- a/subsonic-android/src/github/daneren2005/dsub/view/SongView.java +++ b/subsonic-android/src/github/daneren2005/dsub/view/SongView.java @@ -88,16 +88,25 @@ public class SongView extends UpdateView implements Checkable { } if(!song.isVideo()) { - if(song.getArtist() != null) { - artist.append(song.getArtist()); - } else if(song instanceof PodcastEpisode) { + if(song instanceof PodcastEpisode) { String date = ((PodcastEpisode)song).getDate(); int index = date.indexOf(" "); artist.append(date.substring(0, index != -1 ? index : date.length())); } - artist.append(" (") - .append(String.format(getContext().getString(R.string.song_details_all), bitRate == null ? "" : bitRate, fileFormat)) - .append(")"); + else if(song.getArtist() != null) { + artist.append(song.getArtist()); + } + + String status = (song instanceof PodcastEpisode) ? ((PodcastEpisode)song).getStatus() : ""; + artist.append(" ("); + if("error".equals(status)) { + artist.append(getContext().getString(R.string.song_details_error)); + } else if("skipped".equals(status)) { + artist.append(getContext().getString(R.string.song_details_skipped)); + } else { + artist.append(String.format(getContext().getString(R.string.song_details_all), bitRate == null ? "" : bitRate, fileFormat)); + } + artist.append(")"); } else { artist.append(String.format(getContext().getString(R.string.song_details_all), bitRate == null ? "" : bitRate, fileFormat)); } -- cgit v1.2.3