aboutsummaryrefslogtreecommitdiff
path: root/src/github/daneren2005
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-02-10 09:09:35 -0800
committerScott Jackson <daneren2005@gmail.com>2015-02-10 09:09:35 -0800
commit50d19a361880a2867193f19c460531514dec7f9a (patch)
treeab792055092997d6d64d95a106a470775cd057ce /src/github/daneren2005
parent91bfd2f1813458cab64f6c40b3f5c22d32b802f7 (diff)
downloaddsub-50d19a361880a2867193f19c460531514dec7f9a.tar.gz
dsub-50d19a361880a2867193f19c460531514dec7f9a.tar.bz2
dsub-50d19a361880a2867193f19c460531514dec7f9a.zip
#443 Add a checkbox to browse album lists on a per folder basis
Diffstat (limited to 'src/github/daneren2005')
-rw-r--r--src/github/daneren2005/dsub/fragments/MainFragment.java14
-rw-r--r--src/github/daneren2005/dsub/service/RESTMusicService.java37
-rw-r--r--src/github/daneren2005/dsub/util/Constants.java1
-rw-r--r--src/github/daneren2005/dsub/util/Util.java15
4 files changed, 63 insertions, 4 deletions
diff --git a/src/github/daneren2005/dsub/fragments/MainFragment.java b/src/github/daneren2005/dsub/fragments/MainFragment.java
index f6f7875c..911fd757 100644
--- a/src/github/daneren2005/dsub/fragments/MainFragment.java
+++ b/src/github/daneren2005/dsub/fragments/MainFragment.java
@@ -18,6 +18,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.CheckBox;
+import android.widget.CompoundButton;
import android.widget.ListView;
import android.widget.TextView;
import github.daneren2005.dsub.R;
@@ -165,6 +166,19 @@ public class MainFragment extends SubsonicFragment {
final View dummyView = rootView.findViewById(R.id.main_dummy);
+ final CheckBox albumsPerFolderCheckbox = (CheckBox) buttons.findViewById(R.id.main_albums_per_folder);
+ if(!Util.isOffline(context) && ServerInfo.checkServerVersion(context, "1.11")) {
+ albumsPerFolderCheckbox.setChecked(Util.getAlbumListsPerFolder(context));
+ albumsPerFolderCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ Util.setAlbumListsPerFolder(context, isChecked);
+ }
+ });
+ } else {
+ albumsPerFolderCheckbox.setVisibility(View.GONE);
+ }
+
int instance = Util.getActiveServer(context);
String name = Util.getServerName(context, instance);
serverTextView.setText(name);
diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java
index a56b04f1..8db42677 100644
--- a/src/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/src/github/daneren2005/dsub/service/RESTMusicService.java
@@ -65,7 +65,6 @@ import android.graphics.Bitmap;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Looper;
-import android.support.v4.text.TextUtilsCompat;
import android.util.Log;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.*;
@@ -493,8 +492,28 @@ public class RESTMusicService implements MusicService {
@Override
public MusicDirectory getAlbumList(String type, int size, int offset, Context context, ProgressListener progressListener) throws Exception {
+ List<String> names = new ArrayList<String>();
+ List<Object> values = new ArrayList<Object>();
+
+ names.add("type");
+ values.add(type);
+ names.add("size");
+ values.add(size);
+ names.add("offset");
+ values.add(offset);
+
+ // Add folder if it was set and is non null
+ int instance = getInstance(context);
+ if(Util.getAlbumListsPerFolder(context, instance)) {
+ String folderId = Util.getSelectedMusicFolderId(context, instance);
+ if(folderId != null) {
+ names.add("musicFolderId");
+ values.add(folderId);
+ }
+ }
+
Reader reader = getReader(context, progressListener, Util.isTagBrowsing(context, getInstance(context)) ? "getAlbumList2" : "getAlbumList",
- null, Arrays.asList("type", "size", "offset"), Arrays.<Object>asList(type, size, offset));
+ null, names, values);
try {
return new AlbumListParser(context, getInstance(context)).parse(reader, progressListener);
} finally {
@@ -533,9 +552,19 @@ public class RESTMusicService implements MusicService {
values.add(decade + 10);
}
- Reader reader = getReader(context, progressListener, Util.isTagBrowsing(context, getInstance(context)) ? "getAlbumList2" : "getAlbumList", null, names, values);
+ // Add folder if it was set and is non null
+ int instance = getInstance(context);
+ if(Util.getAlbumListsPerFolder(context, instance)) {
+ String folderId = Util.getSelectedMusicFolderId(context, instance);
+ if(folderId != null) {
+ names.add("musicFolderId");
+ values.add(folderId);
+ }
+ }
+
+ Reader reader = getReader(context, progressListener, Util.isTagBrowsing(context, instance) ? "getAlbumList2" : "getAlbumList", null, names, values);
try {
- return new AlbumListParser(context, getInstance(context)).parse(reader, progressListener);
+ return new AlbumListParser(context, instance).parse(reader, progressListener);
} finally {
Util.close(reader);
}
diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java
index 35f7b7a1..50070d6f 100644
--- a/src/github/daneren2005/dsub/util/Constants.java
+++ b/src/github/daneren2005/dsub/util/Constants.java
@@ -150,6 +150,7 @@ public final class Constants {
public static final String PREFERENCES_KEY_REPLAY_GAIN_BUMP = "replayGainBump2";
public static final String PREFERENCES_KEY_REPLAY_GAIN_UNTAGGED = "replayGainUntagged2";
public static final String PREFERENCES_KEY_REPLAY_GAIN_TYPE= "replayGainType";
+ public static final String PREFERENCES_KEY_ALBUMS_PER_FOLDER = "albumsPerFolder";
public static final String OFFLINE_SCROBBLE_COUNT = "scrobbleCount";
public static final String OFFLINE_SCROBBLE_ID = "scrobbleID";
diff --git a/src/github/daneren2005/dsub/util/Util.java b/src/github/daneren2005/dsub/util/Util.java
index aa12f941..c90548b9 100644
--- a/src/github/daneren2005/dsub/util/Util.java
+++ b/src/github/daneren2005/dsub/util/Util.java
@@ -225,6 +225,21 @@ public final class Util {
return prefs.getString(Constants.PREFERENCES_KEY_MUSIC_FOLDER_ID + instance, null);
}
+ public static boolean getAlbumListsPerFolder(Context context) {
+ return getAlbumListsPerFolder(context, getActiveServer(context));
+ }
+ public static boolean getAlbumListsPerFolder(Context context, int instance) {
+ SharedPreferences prefs = getPreferences(context);
+ return prefs.getBoolean(Constants.PREFERENCES_KEY_ALBUMS_PER_FOLDER + instance, false);
+ }
+ public static void setAlbumListsPerFolder(Context context, boolean perFolder) {
+ int instance = getActiveServer(context);
+ SharedPreferences prefs = getPreferences(context);
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putBoolean(Constants.PREFERENCES_KEY_ALBUMS_PER_FOLDER + instance, perFolder);
+ editor.commit();
+ }
+
public static String getTheme(Context context) {
SharedPreferences prefs = getPreferences(context);
return prefs.getString(Constants.PREFERENCES_KEY_THEME, null);