aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/layout/main_buttons.xml12
-rw-r--r--res/values/strings.xml1
-rw-r--r--src/github/daneren2005/dsub/fragments/MainFragment.java12
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectVideoFragment.java82
-rw-r--r--src/github/daneren2005/dsub/service/CachedMusicService.java5
-rw-r--r--src/github/daneren2005/dsub/service/MusicService.java2
-rw-r--r--src/github/daneren2005/dsub/service/OfflineMusicService.java5
-rw-r--r--src/github/daneren2005/dsub/service/RESTMusicService.java11
-rw-r--r--src/github/daneren2005/dsub/service/parser/VideosParser.java53
9 files changed, 183 insertions, 0 deletions
diff --git a/res/layout/main_buttons.xml b/res/layout/main_buttons.xml
index 29f2acdb..e18589d9 100644
--- a/res/layout/main_buttons.xml
+++ b/res/layout/main_buttons.xml
@@ -77,6 +77,13 @@
android:layout_gravity="right"/>
</LinearLayout>
+ <TextView
+ android:id="@+id/main_video_section"
+ android:text="@string/main.videos"
+ style="@style/MainAlbumButtonLabel"
+ android:layout_width="0dp"
+ android:layout_weight="1"
+ android:layout_height="fill_parent"/>
<LinearLayout
android:id="@+id/main_albums_newest"
@@ -141,5 +148,10 @@
android:text="@string/main.albums_alphabetical"
style="@style/MainAlbumButton"/>
+ <TextView
+ android:id="@+id/main_videos"
+ android:text="@string/main.videos"
+ style="@style/MainAlbumButton"/>
+
</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 99dd17b3..fb780817 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -73,6 +73,7 @@
<string name="main.albums_genres">Genres</string>
<string name="main.albums_year">Decades</string>
<string name="main.albums_alphabetical">Alphabetically</string>
+ <string name="main.videos">Videos</string>
<string name="main.songs_genres">@string/main.albums_genres</string>
<string name="main.back_confirm">Press back again to exit</string>
<string name="main.scan_complete">Completed scan of Server</string>
diff --git a/src/github/daneren2005/dsub/fragments/MainFragment.java b/src/github/daneren2005/dsub/fragments/MainFragment.java
index ac29b274..7225f551 100644
--- a/src/github/daneren2005/dsub/fragments/MainFragment.java
+++ b/src/github/daneren2005/dsub/fragments/MainFragment.java
@@ -154,6 +154,7 @@ public class MainFragment extends SubsonicFragment {
offlineButton.setText(Util.isOffline(context) ? R.string.main_online : R.string.main_offline);
final View albumsTitle = buttons.findViewById(R.id.main_albums);
+ final View videoTitle = buttons.findViewById(R.id.main_video_section);
final View albumsNewestButton = buttons.findViewById(R.id.main_albums_newest);
countView = (TextView) buttons.findViewById(R.id.main_albums_recent_count);
final View albumsRandomButton = buttons.findViewById(R.id.main_albums_random);
@@ -164,6 +165,7 @@ public class MainFragment extends SubsonicFragment {
final View albumsGenresButton = buttons.findViewById(R.id.main_albums_genres);
final View albumsYearButton = buttons.findViewById(R.id.main_albums_year);
final View albumsAlphabeticalButton = buttons.findViewById(R.id.main_albums_alphabetical);
+ final View videosButton = buttons.findViewById(R.id.main_videos);
final View dummyView = rootView.findViewById(R.id.main_dummy);
@@ -201,6 +203,10 @@ public class MainFragment extends SubsonicFragment {
adapter.addView(albumsHighestButton, true);
}
adapter.addViews(Arrays.asList(albumsStarredButton, albumsGenresButton, albumsYearButton, albumsRecentButton, albumsFrequentButton), true);
+ if(ServerInfo.checkServerVersion(context, "1.8") && !Util.isTagBrowsing(context)) {
+ adapter.addView(videoTitle, false);
+ adapter.addView(videosButton, true);
+ }
}
list.setAdapter(adapter);
registerForContextMenu(dummyView);
@@ -230,6 +236,8 @@ public class MainFragment extends SubsonicFragment {
showAlbumList("years");
} else if(view == albumsAlphabeticalButton) {
showAlbumList("alphabeticalByName");
+ } else if(view == videosButton) {
+ showVideos();
}
}
});
@@ -301,6 +309,10 @@ public class MainFragment extends SubsonicFragment {
replaceFragment(fragment);
}
}
+ private void showVideos() {
+ SubsonicFragment fragment = new SelectVideoFragment();
+ replaceFragment(fragment);
+ }
private void showOfflineSyncDialog(final int scrobbleCount, final int starsCount) {
String syncDefault = Util.getSyncDefault(context);
diff --git a/src/github/daneren2005/dsub/fragments/SelectVideoFragment.java b/src/github/daneren2005/dsub/fragments/SelectVideoFragment.java
new file mode 100644
index 00000000..0c8519e8
--- /dev/null
+++ b/src/github/daneren2005/dsub/fragments/SelectVideoFragment.java
@@ -0,0 +1,82 @@
+/*
+ This file is part of Subsonic.
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+ Copyright 2015 (C) Scott Jackson
+*/
+
+package github.daneren2005.dsub.fragments;
+
+import android.view.ContextMenu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+
+import java.util.List;
+
+import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.domain.MusicDirectory;
+import github.daneren2005.dsub.service.MusicService;
+import github.daneren2005.dsub.util.ProgressListener;
+import github.daneren2005.dsub.view.EntryAdapter;
+
+public class SelectVideoFragment extends SelectListFragment<MusicDirectory.Entry> {
+ @Override
+ public int getOptionsMenu() {
+ return R.menu.empty;
+ }
+
+ @Override
+ public ArrayAdapter getAdapter(List<MusicDirectory.Entry> objs) {
+ return new EntryAdapter(context, null, objs, false);
+ }
+
+ @Override
+ public List<MusicDirectory.Entry> getObjects(MusicService musicService, boolean refresh, ProgressListener listener) throws Exception {
+ MusicDirectory dir = musicService.getVideos(refresh, context, listener);
+ return dir.getChildren();
+ }
+
+ @Override
+ public int getTitleResource() {
+ return R.string.main_videos;
+ }
+
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ MusicDirectory.Entry entry = (MusicDirectory.Entry) parent.getItemAtPosition(position);
+ playVideo(entry);
+ }
+
+ @Override
+ public void onCreateContextMenu(ContextMenu menu, View view, ContextMenu.ContextMenuInfo menuInfo) {
+ super.onCreateContextMenu(menu, view, menuInfo);
+
+ AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
+ Object entry = listView.getItemAtPosition(info.position);
+
+ onCreateContextMenu(menu, view, menuInfo, entry);
+ recreateContextMenu(menu);
+ }
+
+ @Override
+ public boolean onContextItemSelected(MenuItem menuItem) {
+ if (menuItem.getGroupId() != getSupportTag()) {
+ return false;
+ }
+
+ AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuItem.getMenuInfo();
+ Object entry = listView.getItemAtPosition(info.position);
+
+ return onContextItemSelected(menuItem, entry);
+ }
+}
diff --git a/src/github/daneren2005/dsub/service/CachedMusicService.java b/src/github/daneren2005/dsub/service/CachedMusicService.java
index dec3c665..79399483 100644
--- a/src/github/daneren2005/dsub/service/CachedMusicService.java
+++ b/src/github/daneren2005/dsub/service/CachedMusicService.java
@@ -919,6 +919,11 @@ public class CachedMusicService implements MusicService {
}
@Override
+ public MusicDirectory getVideos(boolean refresh, Context context, ProgressListener progressListener) throws Exception {
+ return musicService.getVideos(refresh, context, progressListener);
+ }
+
+ @Override
public int processOfflineSyncs(final Context context, final ProgressListener progressListener) throws Exception{
return musicService.processOfflineSyncs(context, progressListener);
}
diff --git a/src/github/daneren2005/dsub/service/MusicService.java b/src/github/daneren2005/dsub/service/MusicService.java
index 2c5a7f2a..b4b99911 100644
--- a/src/github/daneren2005/dsub/service/MusicService.java
+++ b/src/github/daneren2005/dsub/service/MusicService.java
@@ -183,6 +183,8 @@ public interface MusicService {
ArtistInfo getArtistInfo(String id, boolean refresh, Context context, ProgressListener progressListener) throws Exception;
Bitmap getBitmap(String url, int size, Context context, ProgressListener progressListener, SilentBackgroundTask task) throws Exception;
+
+ MusicDirectory getVideos(boolean refresh, Context context, ProgressListener progressListener) throws Exception;
int processOfflineSyncs(final Context context, final ProgressListener progressListener) throws Exception;
diff --git a/src/github/daneren2005/dsub/service/OfflineMusicService.java b/src/github/daneren2005/dsub/service/OfflineMusicService.java
index c0fc89fe..c66ba598 100644
--- a/src/github/daneren2005/dsub/service/OfflineMusicService.java
+++ b/src/github/daneren2005/dsub/service/OfflineMusicService.java
@@ -799,6 +799,11 @@ public class OfflineMusicService implements MusicService {
}
@Override
+ public MusicDirectory getVideos(boolean refresh, Context context, ProgressListener progressListener) throws Exception {
+ throw new OfflineException(ERRORMSG);
+ }
+
+ @Override
public int processOfflineSyncs(final Context context, final ProgressListener progressListener) throws Exception{
throw new OfflineException(ERRORMSG);
}
diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java
index 40a2f849..036cb0ca 100644
--- a/src/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/src/github/daneren2005/dsub/service/RESTMusicService.java
@@ -92,6 +92,7 @@ import github.daneren2005.dsub.service.parser.SearchResultParser;
import github.daneren2005.dsub.service.parser.ShareParser;
import github.daneren2005.dsub.service.parser.StarredListParser;
import github.daneren2005.dsub.service.parser.UserParser;
+import github.daneren2005.dsub.service.parser.VideosParser;
import github.daneren2005.dsub.service.ssl.SSLSocketFactory;
import github.daneren2005.dsub.service.ssl.TrustSelfSignedStrategy;
import github.daneren2005.dsub.util.BackgroundTask;
@@ -1526,6 +1527,16 @@ public class RESTMusicService implements MusicService {
}
@Override
+ public MusicDirectory getVideos(boolean refresh, Context context, ProgressListener progressListener) throws Exception {
+ Reader reader = getReader(context, progressListener, "getVideos", null);
+ try {
+ return new VideosParser(context, getInstance(context)).parse(reader, progressListener);
+ } 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/src/github/daneren2005/dsub/service/parser/VideosParser.java b/src/github/daneren2005/dsub/service/parser/VideosParser.java
new file mode 100644
index 00000000..f22c4a4a
--- /dev/null
+++ b/src/github/daneren2005/dsub/service/parser/VideosParser.java
@@ -0,0 +1,53 @@
+/*
+ This file is part of Subsonic.
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+ Copyright 2015 (C) Scott Jackson
+*/
+
+package github.daneren2005.dsub.service.parser;
+
+import android.content.Context;
+
+import org.xmlpull.v1.XmlPullParser;
+
+import java.io.Reader;
+
+import github.daneren2005.dsub.domain.MusicDirectory;
+import github.daneren2005.dsub.util.ProgressListener;
+
+public class VideosParser extends MusicDirectoryEntryParser {
+ public VideosParser(Context context, int instance) {
+ super(context, instance);
+ }
+
+ public MusicDirectory parse(Reader reader, ProgressListener progressListener) throws Exception {
+ init(reader);
+
+ MusicDirectory dir = new MusicDirectory();
+ int eventType;
+ do {
+ eventType = nextParseEvent();
+ if (eventType == XmlPullParser.START_TAG) {
+ String name = getElementName();
+ if ("video".equals(name)) {
+ MusicDirectory.Entry entry = parseEntry("");
+ dir.addChild(entry);
+ } else if ("error".equals(name)) {
+ handleError();
+ }
+ }
+ } while (eventType != XmlPullParser.END_DOCUMENT);
+
+ validate();
+ return dir;
+ }
+}