diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-06-27 20:56:39 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-06-27 20:56:39 -0700 |
commit | a0e5b6d20d033c31592a66cb0f36741785e664be (patch) | |
tree | 4565347808cd88bfebfb151a112c7e906873eab6 | |
parent | 08ddea6128d2ffeda1a51cc58ca8ae1c2b8a1282 (diff) | |
download | dsub-a0e5b6d20d033c31592a66cb0f36741785e664be.tar.gz dsub-a0e5b6d20d033c31592a66cb0f36741785e664be.tar.bz2 dsub-a0e5b6d20d033c31592a66cb0f36741785e664be.zip |
Fixed up menus for podcasts, took away checks, fixed episodes with status error/skipped
10 files changed, 160 insertions, 35 deletions
diff --git a/subsonic-android/res/menu/select_podcast_episode.xml b/subsonic-android/res/menu/select_podcast_episode.xml new file mode 100644 index 00000000..b6db96aa --- /dev/null +++ b/subsonic-android/res/menu/select_podcast_episode.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:id="@+id/menu_refresh" + android:icon="@drawable/action_refresh" + android:title="@string/menu.refresh" + android:showAsAction="always|withText"/> +</menu> diff --git a/subsonic-android/res/menu/select_podcast_episode_context.xml b/subsonic-android/res/menu/select_podcast_episode_context.xml new file mode 100644 index 00000000..2c0d86ff --- /dev/null +++ b/subsonic-android/res/menu/select_podcast_episode_context.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + + <item + android:id="@+id/song_menu_info" + android:title="@string/common.info" + /> + + <item + android:id="@+id/song_menu_play_now" + android:title="@string/common.play_now" + /> + + <item + android:id="@+id/song_menu_play_last" + android:title="@string/common.play_last" + /> + + <item + android:id="@+id/song_menu_download" + android:title="@string/common.download" + /> + + <item + android:id="@+id/song_menu_delete" + android:title="@string/common.delete"/> + +</menu> diff --git a/subsonic-android/res/menu/select_podcast_episode_context_offline.xml b/subsonic-android/res/menu/select_podcast_episode_context_offline.xml new file mode 100644 index 00000000..38c4569b --- /dev/null +++ b/subsonic-android/res/menu/select_podcast_episode_context_offline.xml @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + + <item + android:id="@+id/song_menu_info" + android:title="@string/common.info" + /> + + <item + android:id="@+id/song_menu_play_now" + android:title="@string/common.play_now" + /> + + <item + android:id="@+id/song_menu_play_last" + android:title="@string/common.play_last" + /> + + <item + android:id="@+id/song_menu_delete" + android:title="@string/common.delete"/> +</menu> diff --git a/subsonic-android/res/menu/select_podcast_episode_offline.xml b/subsonic-android/res/menu/select_podcast_episode_offline.xml new file mode 100644 index 00000000..ce414955 --- /dev/null +++ b/subsonic-android/res/menu/select_podcast_episode_offline.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<menu xmlns:android="http://schemas.android.com/apk/res/android"> + <item + android:id="@+id/menu_refresh" + android:icon="@drawable/action_refresh" + android:title="@string/menu.refresh" + android:showAsAction="always|withText"/> + + <item + android:id="@+id/menu_delete" + android:icon="@drawable/action_remove_all" + android:title="@string/common.delete" + android:showAsAction="ifRoom|withText"/> + + <item + android:id="@+id/menu_play_last" + android:icon="@drawable/action_play_all" + android:title="@string/menu.play_last" + android:showAsAction="ifRoom|withText"/> +</menu> diff --git a/subsonic-android/res/values/strings.xml b/subsonic-android/res/values/strings.xml index d7c0d089..cc638a23 100644 --- a/subsonic-android/res/values/strings.xml +++ b/subsonic-android/res/values/strings.xml @@ -131,6 +131,8 @@ <string name="select_genre.blank">Blank</string>
<string name="select_podcasts.empty">No podcasts found</string>
+ <string name="select_podcasts.error">This podcast had an error while downloading on the server. The server must download it first.</string>
+ <string name="select_podcasts.skipped">This podcast has not been downloaded on the server. The server must download it first.</string>
<string name="select_playlist.empty">No saved playlists on server</string>
@@ -187,6 +189,8 @@ <string name="song_details.all">%1$s %2$s</string>
<string name="song_details.kbps">%d kbps</string>
+ <string name="song_details.error">Error</string>
+ <string name="song_details.skipped">Skipped</string>
<string name="lyrics.nomatch">No lyrics found</string>
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<MusicDirectory.Entry> podcasts = new ArrayList<MusicDirectory.Entry>(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)); } |