aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-07-02 22:51:24 -0700
committerScott Jackson <daneren2005@gmail.com>2013-07-02 22:51:24 -0700
commit5d4d0d4d6da34b810e59aa55f9fab0ad3445db9d (patch)
tree382dc97023a977fb1510a6e4fce3101c4e1e318d
parent6f1c5cd259e871b72f41f21138b07bbd30f45c4f (diff)
downloaddsub-5d4d0d4d6da34b810e59aa55f9fab0ad3445db9d.tar.gz
dsub-5d4d0d4d6da34b810e59aa55f9fab0ad3445db9d.tar.bz2
dsub-5d4d0d4d6da34b810e59aa55f9fab0ad3445db9d.zip
Added download/delete menus to podcasts episodes, podcast refresh button
-rw-r--r--subsonic-android/res/menu/select_podcast_episode.xml5
-rw-r--r--subsonic-android/res/menu/select_podcast_episode_context.xml7
-rw-r--r--subsonic-android/res/menu/select_podcast_episode_offline.xml9
-rw-r--r--subsonic-android/res/menu/select_podcasts.xml5
-rw-r--r--subsonic-android/res/values/strings.xml8
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java62
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java29
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java25
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/MusicService.java10
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java25
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java50
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/view/SongView.java2
12 files changed, 227 insertions, 10 deletions
diff --git a/subsonic-android/res/menu/select_podcast_episode.xml b/subsonic-android/res/menu/select_podcast_episode.xml
index b6db96aa..ff5898e2 100644
--- a/subsonic-android/res/menu/select_podcast_episode.xml
+++ b/subsonic-android/res/menu/select_podcast_episode.xml
@@ -5,4 +5,9 @@
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"/>
</menu>
diff --git a/subsonic-android/res/menu/select_podcast_episode_context.xml b/subsonic-android/res/menu/select_podcast_episode_context.xml
index 2c0d86ff..25c83989 100644
--- a/subsonic-android/res/menu/select_podcast_episode_context.xml
+++ b/subsonic-android/res/menu/select_podcast_episode_context.xml
@@ -25,4 +25,11 @@
android:id="@+id/song_menu_delete"
android:title="@string/common.delete"/>
+ <item
+ android:id="@+id/song_menu_server_download"
+ android:title="@string/select_podcasts.server_download"/>
+
+ <item
+ android:id="@+id/song_menu_server_delete"
+ android:title="@string/select_podcasts.server_delete"/>
</menu>
diff --git a/subsonic-android/res/menu/select_podcast_episode_offline.xml b/subsonic-android/res/menu/select_podcast_episode_offline.xml
index ce414955..9bbc2d92 100644
--- a/subsonic-android/res/menu/select_podcast_episode_offline.xml
+++ b/subsonic-android/res/menu/select_podcast_episode_offline.xml
@@ -9,12 +9,5 @@
<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"/>
+ android:title="@string/common.delete"/>
</menu>
diff --git a/subsonic-android/res/menu/select_podcasts.xml b/subsonic-android/res/menu/select_podcasts.xml
index e0f9a718..eea03827 100644
--- a/subsonic-android/res/menu/select_podcasts.xml
+++ b/subsonic-android/res/menu/select_podcasts.xml
@@ -7,6 +7,11 @@
android:showAsAction="always|withText"/>
<item
+ android:id="@+id/menu_check"
+ android:icon="@drawable/action_refresh"
+ android:title="@string/menu.check_podcasts"/>
+
+ <item
android:id="@+id/menu_settings"
android:icon="@drawable/action_settings"
android:title="@string/menu.settings"/>
diff --git a/subsonic-android/res/values/strings.xml b/subsonic-android/res/values/strings.xml
index fa672f82..f67dd9fe 100644
--- a/subsonic-android/res/values/strings.xml
+++ b/subsonic-android/res/values/strings.xml
@@ -21,7 +21,7 @@
<string name="common.play_external">Play Video</string>
<string name="common.stream_external">Stream Video</string>
<string name="common.confirm">Confirm</string>
- <string name="common.confirm_message">Do you want to %1$s %2$s</string>
+ <string name="common.confirm_message">Do you want to %1$s %2$s?</string>
<string name="button_bar.home">Home</string>
<string name="button_bar.browse">Library</string>
@@ -71,6 +71,7 @@
<string name="menu.deleted_playlist_error">Failed to delete playlist %s</string>
<string name="menu.log">Send Log</string>
<string name="menu.set_timer">Set Timer</string>
+ <string name="menu.check_podcasts">Request Server Refresh</string>
<string name="playlist.label">Playlists</string>
<string name="playlist.update_info">Update Information</string>
@@ -134,6 +135,10 @@
<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_podcasts.server_download">Download on server</string>
+ <string name="select_podcasts.server_delete">Delete from server</string>
+ <string name="select_podcasts.downloading">Now downloading %s on the server</string>
+ <string name="select_podcasts.refreshing">The server is checking for new podcasts now</string>
<string name="select_playlist.empty">No saved playlists on server</string>
@@ -191,6 +196,7 @@
<string name="song_details.kbps">%d kbps</string>
<string name="song_details.error">Error</string>
<string name="song_details.skipped">Skipped</string>
+ <string name="song_details.downloading">Downloading</string>
<string name="lyrics.nomatch">No lyrics found</string>
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index 4d9ebafd..547eb0f3 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -224,6 +224,12 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
if(!entry.isVideo() && !Util.isOffline(context) && playlistId == null && podcastId != null) {
menu.removeItem(R.id.song_menu_remove_playlist);
}
+ if(podcastId != null) {
+ String status = ((PodcastEpisode)entry).getStatus();
+ if("completed".equals(status)) {
+ menu.removeItem(R.id.song_menu_server_download);
+ }
+ }
}
@Override
@@ -243,6 +249,12 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
case R.id.song_menu_remove_playlist:
removeFromPlaylist(playlistId, playlistName, Arrays.<Integer>asList(info.position - 1));
break;
+ case R.id.song_menu_server_download:
+ downloadPodcastEpisode((PodcastEpisode)selectedItem);
+ break;
+ case R.id.song_menu_server_delete:
+ deletePodcastEpisode((PodcastEpisode)selectedItem);
+ break;
}
return true;
@@ -279,7 +291,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
if("error".equals(status)) {
Util.toast(context, R.string.select_podcasts_error);
return;
- } else if("skipped".equals(status)) {
+ } else if(!"completed".equals(status)) {
Util.toast(context, R.string.select_podcasts_skipped);
return;
}
@@ -633,6 +645,54 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
}
}.execute();
}
+
+ public void downloadPodcastEpisode(final PodcastEpisode episode) {
+ new LoadingTask<Void>(context, true) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ MusicService musicService = MusicServiceFactory.getMusicService(context);
+ musicService.downloadPodcastEpisode(episode.getEpisodeId(), context, null);
+ return null;
+ }
+
+ @Override
+ protected void done(Void result) {
+ Util.toast(context, context.getResources().getString(R.string.select_podcasts_downloading, episode.getTitle()));
+ }
+
+ @Override
+ protected void error(Throwable error) {
+ Util.toast(context, getErrorMessage(error), false);
+ }
+ }.execute();
+ }
+
+ public void deletePodcastEpisode(final PodcastEpisode episode) {
+ Util.confirmDialog(context, R.string.common_delete, episode.getTitle(), new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ new LoadingTask<Void>(context, true) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ MusicService musicService = MusicServiceFactory.getMusicService(context);
+ musicService.deletePodcastEpisode(episode.getEpisodeId(), context, null);
+ return null;
+ }
+
+ @Override
+ protected void done(Void result) {
+ entries.remove(episode);
+ entryAdapter.notifyDataSetChanged();
+ }
+
+ @Override
+ protected void error(Throwable error) {
+ Util.toast(context, getErrorMessage(error), false);
+ }
+ }.execute();
+ }
+ });
+ }
private void checkLicenseAndTrialPeriod(Runnable onValid) {
if (licenseValid) {
diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java
index 3c9ba7c7..dc563135 100644
--- a/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java
+++ b/subsonic-android/src/github/daneren2005/dsub/fragments/SelectPodcastsFragment.java
@@ -34,7 +34,9 @@ import github.daneren2005.dsub.service.MusicService;
import github.daneren2005.dsub.service.MusicServiceFactory;
import github.daneren2005.dsub.util.BackgroundTask;
import github.daneren2005.dsub.util.Constants;
+import github.daneren2005.dsub.util.SilentBackgroundTask;
import github.daneren2005.dsub.util.TabBackgroundTask;
+import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.view.PodcastChannelAdapter;
import java.util.ArrayList;
import java.util.List;
@@ -80,6 +82,12 @@ public class SelectPodcastsFragment extends SubsonicFragment implements AdapterV
if(super.onOptionsItemSelected(item)) {
return true;
}
+
+ switch (item.getItemId()) {
+ case R.id.menu_check:
+ refreshPodcasts();
+ break;
+ }
return false;
}
@@ -130,4 +138,25 @@ public class SelectPodcastsFragment extends SubsonicFragment implements AdapterV
replaceFragment(fragment, R.id.select_podcasts_layout);
}
+
+ public void refreshPodcasts() {
+ new SilentBackgroundTask<Void>(context) {
+ @Override
+ protected Void doInBackground() throws Throwable {
+ MusicService musicService = MusicServiceFactory.getMusicService(context);
+ musicService.refreshPodcasts(context, null);
+ return null;
+ }
+
+ @Override
+ protected void done(Void result) {
+ Util.toast(context, R.string.select_podcasts_refreshing);
+ }
+
+ @Override
+ protected void error(Throwable error) {
+ Util.toast(context, getErrorMessage(error), false);
+ }
+ }.execute();
+ }
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java
index e06f3372..0074e29b 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java
@@ -323,6 +323,31 @@ public class CachedMusicService implements MusicService {
}
@Override
+ public void refreshPodcasts(Context context, ProgressListener progressListener) throws Exception {
+ musicService.refreshPodcasts(context, progressListener);
+ }
+
+ @Override
+ public void createPodcastChannel(String url, Context context, ProgressListener progressListener) throws Exception{
+ musicService.createPodcastChannel(url, context, progressListener);
+ }
+
+ @Override
+ public void deletePodcastChannel(String id, Context context, ProgressListener progressListener) throws Exception{
+ musicService.deletePodcastChannel(id, context, progressListener);
+ }
+
+ @Override
+ public void downloadPodcastEpisode(String id, Context context, ProgressListener progressListener) throws Exception{
+ musicService.downloadPodcastEpisode(id, context, progressListener);
+ }
+
+ @Override
+ public void deletePodcastEpisode(String id, Context context, ProgressListener progressListener) throws Exception{
+ musicService.deletePodcastEpisode(id, context, progressListener);
+ }
+
+ @Override
public int processOfflineSyncs(final Context context, final ProgressListener progressListener) throws Exception{
return musicService.processOfflineSyncs(context, progressListener);
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java
index 57deff8f..537ee2c2 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java
@@ -124,5 +124,15 @@ public interface MusicService {
MusicDirectory getPodcastEpisodes(String id, Context context, ProgressListener progressListener) throws Exception;
+ void refreshPodcasts(Context context, ProgressListener progressListener) throws Exception;
+
+ void createPodcastChannel(String url, Context context, ProgressListener progressListener) throws Exception;
+
+ void deletePodcastChannel(String id, Context context, ProgressListener progressListener) throws Exception;
+
+ void downloadPodcastEpisode(String id, Context context, ProgressListener progressListener) throws Exception;
+
+ void deletePodcastEpisode(String id, Context context, ProgressListener progressListener) throws Exception;
+
int processOfflineSyncs(final Context context, final ProgressListener progressListener) throws Exception;
} \ No newline at end of file
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java
index 395ad6b6..f72f83c4 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java
@@ -607,6 +607,31 @@ public class OfflineMusicService extends RESTMusicService {
public MusicDirectory getPodcastEpisodes(String id, Context context, ProgressListener progressListener) throws Exception {
throw new OfflineException("Getting Podcasts not available in offline mode");
}
+
+ @Override
+ public void refreshPodcasts(Context context, ProgressListener progressListener) throws Exception {
+ throw new OfflineException("Getting Podcasts not available in offline mode");
+ }
+
+ @Override
+ public void createPodcastChannel(String url, Context context, ProgressListener progressListener) throws Exception{
+ throw new OfflineException("Getting Podcasts not available in offline mode");
+ }
+
+ @Override
+ public void deletePodcastChannel(String id, Context context, ProgressListener progressListener) throws Exception{
+ throw new OfflineException("Getting Podcasts not available in offline mode");
+ }
+
+ @Override
+ public void downloadPodcastEpisode(String id, Context context, ProgressListener progressListener) throws Exception{
+ throw new OfflineException("Getting Podcasts not available in offline mode");
+ }
+
+ @Override
+ public void deletePodcastEpisode(String id, Context context, ProgressListener progressListener) throws Exception{
+ throw new OfflineException("Getting Podcasts not available in offline mode");
+ }
@Override
public int processOfflineSyncs(final Context context, final ProgressListener progressListener) throws Exception{
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
index 22e7f8e9..2cd45335 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
@@ -907,6 +907,56 @@ public class RESTMusicService implements MusicService {
}
@Override
+ public void refreshPodcasts(Context context, ProgressListener progressListener) throws Exception {
+ Reader reader = getReader(context, progressListener, "refreshPodcasts", null);
+ try {
+ new ErrorParser(context).parse(reader);
+ } finally {
+ Util.close(reader);
+ }
+ }
+
+ @Override
+ public void createPodcastChannel(String url, Context context, ProgressListener progressListener) throws Exception{
+ Reader reader = getReader(context, progressListener, "createPodcastChannel", null, "url", url);
+ try {
+ new ErrorParser(context).parse(reader);
+ } finally {
+ Util.close(reader);
+ }
+ }
+
+ @Override
+ public void deletePodcastChannel(String id, Context context, ProgressListener progressListener) throws Exception{
+ Reader reader = getReader(context, progressListener, "deletePodcastChannel", null, "id", id);
+ try {
+ new ErrorParser(context).parse(reader);
+ } finally {
+ Util.close(reader);
+ }
+ }
+
+ @Override
+ public void downloadPodcastEpisode(String id, Context context, ProgressListener progressListener) throws Exception{
+ Reader reader = getReader(context, progressListener, "downloadPodcastEpisode", null, "id", id);
+ try {
+ new ErrorParser(context).parse(reader);
+ } finally {
+ Util.close(reader);
+ }
+ }
+
+ @Override
+ public void deletePodcastEpisode(String id, Context context, ProgressListener progressListener) throws Exception{
+ Reader reader = getReader(context, progressListener, "deletePodcastEpisode", null, "id", id);
+ try {
+ new ErrorParser(context).parse(reader);
+ } finally {
+ Util.close(reader);
+ }
+ }
+
+ @Override
public int processOfflineSyncs(final Context context, final ProgressListener progressListener) throws Exception{
return processOfflineScrobbles(context, progressListener) + processOfflineStars(context, progressListener);
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/view/SongView.java b/subsonic-android/src/github/daneren2005/dsub/view/SongView.java
index 130663b5..7c7f5ae6 100644
--- a/subsonic-android/src/github/daneren2005/dsub/view/SongView.java
+++ b/subsonic-android/src/github/daneren2005/dsub/view/SongView.java
@@ -103,6 +103,8 @@ public class SongView extends UpdateView implements Checkable {
artist.append(getContext().getString(R.string.song_details_error));
} else if("skipped".equals(status)) {
artist.append(getContext().getString(R.string.song_details_skipped));
+ } else if("downloading".equals(status)) {
+ artist.append(getContext().getString(R.string.song_details_downloading));
} else {
artist.append(String.format(getContext().getString(R.string.song_details_all), bitRate == null ? "" : bitRate, fileFormat));
}