aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-12-23 20:11:52 -0800
committerScott Jackson <daneren2005@gmail.com>2013-12-23 20:11:52 -0800
commit01d29911c7affa298800cf93f7d7015263eb788e (patch)
tree89811eea0266e4e7c1376cb08fa743f3753cef03
parent0193bcb62b62271a00f7bc7a7400948470ea888c (diff)
downloaddsub-01d29911c7affa298800cf93f7d7015263eb788e.tar.gz
dsub-01d29911c7affa298800cf93f7d7015263eb788e.tar.bz2
dsub-01d29911c7affa298800cf93f7d7015263eb788e.zip
#221, #225: Added By Year, default genres to album list if 4.9+
-rw-r--r--res/layout/main_buttons.xml123
-rw-r--r--res/values/strings.xml4
-rw-r--r--res/values/styles.xml23
-rw-r--r--src/github/daneren2005/dsub/fragments/MainFragment.java8
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java4
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectYearFragment.java79
-rw-r--r--src/github/daneren2005/dsub/service/CachedMusicService.java7
-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.java39
-rw-r--r--src/github/daneren2005/dsub/view/AlbumListAdapter.java6
11 files changed, 206 insertions, 94 deletions
diff --git a/res/layout/main_buttons.xml b/res/layout/main_buttons.xml
index 7729315c..d83632c1 100644
--- a/res/layout/main_buttons.xml
+++ b/res/layout/main_buttons.xml
@@ -55,96 +55,43 @@
android:paddingBottom="4dp"
android:minHeight="50dip"/>
- <TextView
- android:id="@+id/main_albums"
- android:text="@string/main.albums_title"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceSmall"
- android:textColor="@color/cyan"
- android:gravity="center_vertical"
- android:paddingLeft="6dp"
- android:textAllCaps="true"
- android:textStyle="bold"
- android:textSize="16sp"/>
+ <TextView
+ android:id="@+id/main_albums"
+ android:text="@string/main.albums_title"
+ style="@style/MainAlbumButtonLabel"/>
- <TextView
- android:id="@+id/main_albums_newest"
- android:text="@string/main.albums_newest"
- android:drawablePadding="6dip"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:gravity="center_vertical"
- android:paddingLeft="6dip"
- android:paddingRight="6dip"
- android:minHeight="50dip"/>
- <TextView
- android:id="@+id/main_albums_recent"
- android:text="@string/main.albums_recent"
- android:drawablePadding="6dip"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:gravity="center_vertical"
- android:paddingLeft="6dip"
- android:paddingRight="6dip"
- android:minHeight="50dip"/>
- <TextView
- android:id="@+id/main_albums_frequent"
- android:text="@string/main.albums_frequent"
- android:drawablePadding="6dip"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:gravity="center_vertical"
- android:paddingLeft="6dip"
- android:paddingRight="6dip"
- android:minHeight="50dip"/>
- <TextView
- android:id="@+id/main_albums_highest"
- android:text="@string/main.albums_highest"
- android:drawablePadding="6dip"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:gravity="center_vertical"
- android:paddingLeft="6dip"
- android:paddingRight="6dip"
- android:minHeight="50dip"/>
- <TextView
- android:id="@+id/main_albums_starred"
- android:text="@string/main.albums_starred"
- android:drawablePadding="6dip"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:gravity="center_vertical"
- android:paddingLeft="6dip"
- android:paddingRight="6dip"
- android:minHeight="50dip"/>
<TextView
- android:id="@+id/main_albums_genres"
- android:text="@string/main.albums_genres"
- android:drawablePadding="6dip"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:gravity="center_vertical"
- android:paddingLeft="6dip"
- android:paddingRight="6dip"
- android:minHeight="50dip"/>
- <TextView
- android:id="@+id/main_albums_random"
- android:text="@string/main.albums_random"
- android:drawablePadding="6dip"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textAppearance="?android:attr/textAppearanceMedium"
- android:gravity="center_vertical"
- android:paddingLeft="6dip"
- android:paddingRight="6dip"
- android:minHeight="50dip"/>
+ android:id="@+id/main_albums_newest"
+ android:text="@string/main.albums_newest"
+ style="@style/MainAlbumButton"/>
+ <TextView
+ android:id="@+id/main_albums_recent"
+ android:text="@string/main.albums_recent"
+ style="@style/MainAlbumButton"/>
+ <TextView
+ android:id="@+id/main_albums_frequent"
+ android:text="@string/main.albums_frequent"
+ style="@style/MainAlbumButton"/>
+ <TextView
+ android:id="@+id/main_albums_highest"
+ android:text="@string/main.albums_highest"
+ style="@style/MainAlbumButton"/>
+ <TextView
+ android:id="@+id/main_albums_starred"
+ android:text="@string/main.albums_starred"
+ style="@style/MainAlbumButton"/>
+ <TextView
+ android:id="@+id/main_albums_genres"
+ android:text="@string/main.albums_genres"
+ style="@style/MainAlbumButton"/>
+ <TextView
+ android:id="@+id/main_albums_year"
+ android:text="@string/main.albums_year"
+ style="@style/MainAlbumButton"/>
+ <TextView
+ android:id="@+id/main_albums_random"
+ android:text="@string/main.albums_random"
+ style="@style/MainAlbumButton"/>
</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 1d2cde0d..677b69cf 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -47,7 +47,7 @@
<string name="main.offline">Go Offline</string>
<string name="main.online">Go Online</string>
<string name="main.settings">Settings</string>
- <string name="main.albums_title">Albums</string>
+ <string name="main.albums_title">Album Lists</string>
<string name="main.albums_newest">Recently added</string>
<string name="main.albums_recent">Recently played</string>
<string name="main.albums_frequent">Most played</string>
@@ -55,6 +55,8 @@
<string name="main.albums_starred">Starred</string>
<string name="main.albums_random">Random</string>
<string name="main.albums_genres">Genres</string>
+ <string name="main.albums_year">Decades</string>
+ <string name="main.songs_genres">@string/main.albums_genres</string>
<string name="main.back_confirm">Press back again to exit</string>
<string name="menu.search">Search</string>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index b1475eb6..e5dfdaf0 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -64,4 +64,27 @@
<item name="remove_mode">flingRemove</item>
<item name="drag_start_mode">onLongPress</item>
</style>
+
+ <style name="MainAlbumButton">
+ <item name="android:drawablePadding">6dip</item>
+ <item name="android:layout_width">fill_parent</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:textAppearance">?android:attr/textAppearanceMedium</item>
+ <item name="android:gravity">center_vertical</item>
+ <item name="android:paddingLeft">6dip</item>
+ <item name="android:paddingRight">6dip</item>
+ <item name="android:minHeight">46dip</item>
+ </style>
+
+ <style name="MainAlbumButtonLabel">
+ <item name="android:layout_width">fill_parent</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
+ <item name="android:textColor">@color/cyan</item>
+ <item name="android:gravity">center_vertical</item>
+ <item name="android:paddingLeft">6dp</item>
+ <item name="android:textAllCaps">true</item>
+ <item name="android:textStyle">bold</item>
+ <item name="android:textSize">16sp</item>
+ </style>
</resources> \ No newline at end of file
diff --git a/src/github/daneren2005/dsub/fragments/MainFragment.java b/src/github/daneren2005/dsub/fragments/MainFragment.java
index a190369d..65924685 100644
--- a/src/github/daneren2005/dsub/fragments/MainFragment.java
+++ b/src/github/daneren2005/dsub/fragments/MainFragment.java
@@ -142,6 +142,7 @@ public class MainFragment extends SubsonicFragment {
final View albumsFrequentButton = buttons.findViewById(R.id.main_albums_frequent);
final View albumsStarredButton = buttons.findViewById(R.id.main_albums_starred);
final View albumsGenresButton = buttons.findViewById(R.id.main_albums_genres);
+ final View albumsYearButton = buttons.findViewById(R.id.main_albums_year);
final View dummyView = rootView.findViewById(R.id.main_dummy);
@@ -158,7 +159,7 @@ public class MainFragment extends SubsonicFragment {
adapter.addView(offlineButton, true);
if (!Util.isOffline(context)) {
adapter.addView(albumsTitle, false);
- adapter.addViews(Arrays.asList(albumsNewestButton, albumsRandomButton, albumsHighestButton, albumsStarredButton, albumsGenresButton, albumsRecentButton, albumsFrequentButton), true);
+ adapter.addViews(Arrays.asList(albumsNewestButton, albumsRandomButton, albumsHighestButton, albumsStarredButton, albumsGenresButton, albumsYearButton, albumsRecentButton, albumsFrequentButton), true);
}
list.setAdapter(adapter);
registerForContextMenu(dummyView);
@@ -184,6 +185,8 @@ public class MainFragment extends SubsonicFragment {
showAlbumList("starred");
} else if(view == albumsGenresButton) {
showAlbumList("genres");
+ } else if(view == albumsYearButton) {
+ showAlbumList("years");
}
}
});
@@ -219,6 +222,9 @@ public class MainFragment extends SubsonicFragment {
if("genres".equals(type)) {
SubsonicFragment fragment = new SelectGenreFragment();
replaceFragment(fragment, R.id.home_layout);
+ } else if("years".equals(type)) {
+ SubsonicFragment fragment = new SelectYearFragment();
+ replaceFragment(fragment, R.id.home_layout);
} else {
SubsonicFragment fragment = new SelectDirectoryFragment();
Bundle args = new Bundle();
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index cce14c31..4ed4123f 100644
--- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -459,7 +459,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
setTitle(R.string.main_albums_frequent);
} else if ("starred".equals(albumListType)) {
setTitle(R.string.main_albums_starred);
- } else if("genres".equals(albumListType)) {
+ } else if("genres".equals(albumListType) || "years".equals(albumListType)) {
setTitle(albumListExtra);
}
@@ -469,6 +469,8 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
MusicDirectory result;
if ("starred".equals(albumListType)) {
result = service.getStarredList(context, this);
+ } else if(("genres".equals(albumListType) && Util.checkServerVersion(context, "1.10.0")) || "years".equals(albumListType)) {
+ result = service.getAlbumList(albumListType, albumListExtra, size, 0, context, this);
} else if("genres".equals(albumListType)) {
result = service.getSongsByGenre(albumListExtra, size, 0, context, this);
} else {
diff --git a/src/github/daneren2005/dsub/fragments/SelectYearFragment.java b/src/github/daneren2005/dsub/fragments/SelectYearFragment.java
new file mode 100644
index 00000000..acd3154a
--- /dev/null
+++ b/src/github/daneren2005/dsub/fragments/SelectYearFragment.java
@@ -0,0 +1,79 @@
+/*
+ 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 2010 (C) Sindre Mehus
+*/
+package github.daneren2005.dsub.fragments;
+
+import android.os.Bundle;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.ListAdapter;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.service.MusicService;
+import github.daneren2005.dsub.util.Constants;
+
+/**
+ * Created by Scott on 12/23/13.
+ */
+public class SelectYearFragment extends SelectListFragment<Integer> {
+
+ @Override
+ public int getOptionsMenu() {
+ return R.menu.empty;
+ }
+
+ @Override
+ public ListAdapter getAdapter(List<Integer> objs) {
+ return new ArrayAdapter<Integer>(context, android.R.layout.simple_list_item_1, objs);
+ }
+
+ @Override
+ public List<Integer> getObjects(MusicService musicService) {
+ List<Integer> decades = new ArrayList<Integer>();
+ for(int i = 2010; i >= 1920; i -= 10) {
+ decades.add(i);
+ }
+
+ return decades;
+ }
+
+ @Override
+ public int getTitleResource() {
+ return R.string.main_albums_year;
+ }
+
+ @Override
+ public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
+ Integer decade = (Integer) parent.getItemAtPosition(position);
+
+ SubsonicFragment fragment = new SelectDirectoryFragment();
+ Bundle args = new Bundle();
+ args.putString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_TYPE, "years");
+ args.putInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 20);
+ args.putInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_OFFSET, 0);
+ args.putString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_EXTRA, Integer.toString(decade));
+ fragment.setArguments(args);
+
+ replaceFragment(fragment, R.id.fragment_list_layout);
+ }
+}
diff --git a/src/github/daneren2005/dsub/service/CachedMusicService.java b/src/github/daneren2005/dsub/service/CachedMusicService.java
index 3704d012..3c6168d2 100644
--- a/src/github/daneren2005/dsub/service/CachedMusicService.java
+++ b/src/github/daneren2005/dsub/service/CachedMusicService.java
@@ -235,7 +235,12 @@ public class CachedMusicService implements MusicService {
return musicService.getAlbumList(type, size, offset, context, progressListener);
}
- @Override
+ @Override
+ public MusicDirectory getAlbumList(String type, String extra, int size, int offset, Context context, ProgressListener progressListener) throws Exception {
+ return musicService.getAlbumList(type, extra, size, offset, context, progressListener);
+ }
+
+ @Override
public MusicDirectory getStarredList(Context context, ProgressListener progressListener) throws Exception {
return musicService.getStarredList(context, progressListener);
}
diff --git a/src/github/daneren2005/dsub/service/MusicService.java b/src/github/daneren2005/dsub/service/MusicService.java
index b5b37354..1fb317ce 100644
--- a/src/github/daneren2005/dsub/service/MusicService.java
+++ b/src/github/daneren2005/dsub/service/MusicService.java
@@ -83,6 +83,8 @@ public interface MusicService {
MusicDirectory getAlbumList(String type, int size, int offset, Context context, ProgressListener progressListener) throws Exception;
+ MusicDirectory getAlbumList(String type, String extra, int size, int offset, Context context, ProgressListener progressListener) throws Exception;
+
MusicDirectory getRandomSongs(int size, String folder, String genre, String startYear, String endYear, Context context, ProgressListener progressListener) throws Exception;
Bitmap getCoverArt(Context context, MusicDirectory.Entry entry, int size, int saveSize, ProgressListener progressListener) throws Exception;
diff --git a/src/github/daneren2005/dsub/service/OfflineMusicService.java b/src/github/daneren2005/dsub/service/OfflineMusicService.java
index 3386af70..0f6f0126 100644
--- a/src/github/daneren2005/dsub/service/OfflineMusicService.java
+++ b/src/github/daneren2005/dsub/service/OfflineMusicService.java
@@ -484,6 +484,11 @@ public class OfflineMusicService extends RESTMusicService {
throw new OfflineException("Album lists not available in offline mode");
}
+ @Override
+ public MusicDirectory getAlbumList(String type, String extra, int size, int offset, Context context, ProgressListener progressListener) throws Exception {
+ throw new OfflineException("Album lists not available in offline mode");
+ }
+
@Override
public String getVideoUrl(int maxBitrate, Context context, String id) {
return null;
diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java
index c96f3569..5da92843 100644
--- a/src/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/src/github/daneren2005/dsub/service/RESTMusicService.java
@@ -513,7 +513,44 @@ public class RESTMusicService implements MusicService {
}
}
- @Override
+ @Override
+ public MusicDirectory getAlbumList(String type, String extra, int size, int offset, Context context, ProgressListener progressListener) throws Exception {
+ List<String> names = new ArrayList<String>();
+ List<Object> values = new ArrayList<Object>();
+
+ names.add("size");
+ names.add("offset");
+
+ values.add(size);
+ values.add(offset);
+
+ if("genres".equals(type)) {
+ names.add("type");
+ values.add("byGenre");
+
+ names.add("genre");
+ values.add(extra);
+ } else if("years".equals(type)) {
+ names.add("type");
+ values.add("byYear");
+
+ names.add("fromYear");
+ names.add("toYear");
+
+ int decade = Integer.parseInt(extra);
+ values.add(decade);
+ values.add(decade + 10);
+ }
+
+ Reader reader = getReader(context, progressListener, "getAlbumList", null, names, values);
+ try {
+ return new AlbumListParser(context).parse(reader, progressListener);
+ } finally {
+ Util.close(reader);
+ }
+ }
+
+ @Override
public MusicDirectory getStarredList(Context context, ProgressListener progressListener) throws Exception {
Reader reader = getReader(context, progressListener, "getStarred", null);
try {
diff --git a/src/github/daneren2005/dsub/view/AlbumListAdapter.java b/src/github/daneren2005/dsub/view/AlbumListAdapter.java
index 3ff8350b..1180b5c8 100644
--- a/src/github/daneren2005/dsub/view/AlbumListAdapter.java
+++ b/src/github/daneren2005/dsub/view/AlbumListAdapter.java
@@ -28,6 +28,8 @@ import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.service.MusicService;
import github.daneren2005.dsub.service.MusicServiceFactory;
+import github.daneren2005.dsub.util.Util;
+
import java.util.List;
public class AlbumListAdapter extends EndlessAdapter {
@@ -53,7 +55,9 @@ public class AlbumListAdapter extends EndlessAdapter {
protected boolean cacheInBackground() throws Exception {
MusicService service = MusicServiceFactory.getMusicService(context);
MusicDirectory result;
- if("genres".equals(type)) {
+ if(("genres".equals(type) && Util.checkServerVersion(context, "1.10.0")) || "years".equals(type)) {
+ result = service.getAlbumList(type, extra, size, offset, context, null);
+ } else if("genres".equals(type)) {
result = service.getSongsByGenre(extra, size, offset, context, null);
} else {
result = service.getAlbumList(type, size, offset, context, null);