aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-01-11 13:13:40 -0800
committerScott Jackson <daneren2005@gmail.com>2014-01-11 13:13:40 -0800
commit5a3424ca5e919f1f0f10435c8a3caff0113d6f01 (patch)
treed247799fdba669072d305472b6049b63c80b3bba /src
parentac3b53f6fd64a00a121dfa19c489fe251f141362 (diff)
downloaddsub-5a3424ca5e919f1f0f10435c8a3caff0113d6f01.tar.gz
dsub-5a3424ca5e919f1f0f10435c8a3caff0113d6f01.tar.bz2
dsub-5a3424ca5e919f1f0f10435c8a3caff0113d6f01.zip
#46 Start of browse by tags
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/activity/SettingsActivity.java8
-rw-r--r--src/github/daneren2005/dsub/service/RESTMusicService.java19
-rw-r--r--src/github/daneren2005/dsub/service/parser/AlbumListParser.java4
-rw-r--r--src/github/daneren2005/dsub/service/parser/StarredListParser.java8
-rw-r--r--src/github/daneren2005/dsub/util/Constants.java1
-rw-r--r--src/github/daneren2005/dsub/util/Util.java10
6 files changed, 40 insertions, 10 deletions
diff --git a/src/github/daneren2005/dsub/activity/SettingsActivity.java b/src/github/daneren2005/dsub/activity/SettingsActivity.java
index a1a58758..55415725 100644
--- a/src/github/daneren2005/dsub/activity/SettingsActivity.java
+++ b/src/github/daneren2005/dsub/activity/SettingsActivity.java
@@ -28,6 +28,7 @@ import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
+import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
@@ -339,6 +340,12 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
serverPasswordPreference.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
serverPasswordPreference.setSummary("***");
serverPasswordPreference.setTitle(R.string.settings_server_password);
+
+ final CheckBoxPreference serverTagPreference = new CheckBoxPreference(this);
+ serverTagPreference.setKey(Constants.PREFERENCES_KEY_BROWSE_TAGS + instance);
+ serverTagPreference.setChecked(Util.isTagBrowsing(this, instance));
+ serverTagPreference.setSummary(R.string.settings_browse_by_tags_summary);
+ serverTagPreference.setTitle(R.string.settings_browse_by_tags);
final Preference serverOpenBrowser = new Preference(this);
serverOpenBrowser.setKey(Constants.PREFERENCES_KEY_OPEN_BROWSER);
@@ -405,6 +412,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
screen.addPreference(serverInternalUrlPreference);
screen.addPreference(serverUsernamePreference);
screen.addPreference(serverPasswordPreference);
+ screen.addPreference(serverTagPreference);
screen.addPreference(serverRemoveServerPreference);
screen.addPreference(serverTestConnectionPreference);
screen.addPreference(serverOpenBrowser);
diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java
index e220bf59..1927dc93 100644
--- a/src/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/src/github/daneren2005/dsub/service/RESTMusicService.java
@@ -219,7 +219,7 @@ public class RESTMusicService implements MusicService {
parameterValues.add(musicFolderId);
}
- Reader reader = getReader(context, progressListener, "getIndexes", null, parameterNames, parameterValues);
+ Reader reader = getReader(context, progressListener, Util.isTagBrowsing(context, getInstance(context)) ? "getArtists" : "getIndexes", null, parameterNames, parameterValues);
try {
Indexes indexes = new IndexesParser(context).parse(reader, progressListener);
if (indexes != null) {
@@ -307,7 +307,7 @@ public class RESTMusicService implements MusicService {
List<String> parameterNames = Arrays.asList("query", "artistCount", "albumCount", "songCount");
List<Object> parameterValues = Arrays.<Object>asList(critera.getQuery(), critera.getArtistCount(),
critera.getAlbumCount(), critera.getSongCount());
- Reader reader = getReader(context, progressListener, "search2", null, parameterNames, parameterValues);
+ Reader reader = getReader(context, progressListener, Util.isTagBrowsing(context, getInstance(context)) ? "search3" : "search2", null, parameterNames, parameterValues);
try {
return new SearchResult2Parser(context).parse(reader, progressListener);
} finally {
@@ -505,7 +505,7 @@ public class RESTMusicService implements MusicService {
@Override
public MusicDirectory getAlbumList(String type, int size, int offset, Context context, ProgressListener progressListener) throws Exception {
- Reader reader = getReader(context, progressListener, "getAlbumList",
+ Reader reader = getReader(context, progressListener, Util.isTagBrowsing(context, getInstance(context)) ? "getAlbumList2" : "getAlbumList",
null, Arrays.asList("type", "size", "offset"), Arrays.<Object>asList(type, size, offset));
try {
return new AlbumListParser(context).parse(reader, progressListener);
@@ -545,7 +545,7 @@ public class RESTMusicService implements MusicService {
values.add(decade + 10);
}
- Reader reader = getReader(context, progressListener, "getAlbumList", null, names, values);
+ Reader reader = getReader(context, progressListener, Util.isTagBrowsing(context, getInstance(context)) ? "getAlbumList2" : "getAlbumList", null, names, values);
try {
return new AlbumListParser(context).parse(reader, progressListener);
} finally {
@@ -555,7 +555,7 @@ public class RESTMusicService implements MusicService {
@Override
public MusicDirectory getStarredList(Context context, ProgressListener progressListener) throws Exception {
- Reader reader = getReader(context, progressListener, "getStarred", null);
+ Reader reader = getReader(context, progressListener, Util.isTagBrowsing(context, getInstance(context)) ? "getStarred2" : "getStarred", null);
try {
return new StarredListParser(context).parse(reader, progressListener);
} finally {
@@ -1440,7 +1440,14 @@ public class RESTMusicService implements MusicService {
NetworkInfo networkInfo = manager.getActiveNetworkInfo();
return networkInfo == null ? -1 : networkInfo.getType();
}
-
+
+ private int getInstance(Context context) {
+ if(instance == null) {
+ return Util.getActiveServer(context);
+ } else {
+ return instance;
+ }
+ }
public String getRestUrl(Context context, String method) {
return getRestUrl(context, method, true);
}
diff --git a/src/github/daneren2005/dsub/service/parser/AlbumListParser.java b/src/github/daneren2005/dsub/service/parser/AlbumListParser.java
index 64145d67..9cf064e6 100644
--- a/src/github/daneren2005/dsub/service/parser/AlbumListParser.java
+++ b/src/github/daneren2005/dsub/service/parser/AlbumListParser.java
@@ -47,7 +47,9 @@ public class AlbumListParser extends MusicDirectoryEntryParser {
if (eventType == XmlPullParser.START_TAG) {
String name = getElementName();
if ("album".equals(name)) {
- dir.addChild(parseEntry(""));
+ MusicDirectory.Entry entry = parseEntry("");
+ entry.setDirectory(true);
+ dir.addChild(entry);
} else if ("error".equals(name)) {
handleError();
}
diff --git a/src/github/daneren2005/dsub/service/parser/StarredListParser.java b/src/github/daneren2005/dsub/service/parser/StarredListParser.java
index fc4cd175..54e419d3 100644
--- a/src/github/daneren2005/dsub/service/parser/StarredListParser.java
+++ b/src/github/daneren2005/dsub/service/parser/StarredListParser.java
@@ -47,9 +47,13 @@ public class StarredListParser extends MusicDirectoryEntryParser {
if (eventType == XmlPullParser.START_TAG) {
String name = getElementName();
if ("album".equals(name) || "song".equals(name)) {
- dir.addChild(parseEntry(""));
+ MusicDirectory.Entry entry = parseEntry("");
+ entry.setDirectory(true);
+ dir.addChild(entry);
} else if("artist".equals(name)) {
- dir.addChild(parseArtist());
+ MusicDirectory.Entry entry = parseArtist();
+ entry.setDirectory(true);
+ dir.addChild(entry);
} else if ("error".equals(name)) {
handleError();
}
diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java
index 6eb859a8..8865c4fa 100644
--- a/src/github/daneren2005/dsub/util/Constants.java
+++ b/src/github/daneren2005/dsub/util/Constants.java
@@ -137,6 +137,7 @@ public final class Constants {
public static final String PREFERENCES_KEY_MENU_STAR = "showStar";
public static final String PREFERENCES_KEY_MENU_SHARED = "showShared";
public static final String PREFERENCES_KEY_SHARED_ENABLED = "sharedEnabled";
+ public static final String PREFERENCES_KEY_BROWSE_TAGS = "browseTags";
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 51e64686..ceeb6ade 100644
--- a/src/github/daneren2005/dsub/util/Util.java
+++ b/src/github/daneren2005/dsub/util/Util.java
@@ -383,9 +383,17 @@ public final class Util {
return builder.toString();
}
+
+ public static boolean isTagBrowsing(Context context) {
+ return isTagBrowsing(context, Util.getActiveServer(context));
+ }
+ public static boolean isTagBrowsing(Context context, int instance) {
+ SharedPreferences prefs = getPreferences(context);
+ return prefs.getBoolean(Constants.PREFERENCES_KEY_BROWSE_TAGS + instance, false);
+ }
public static String getVideoPlayerType(Context context) {
- SharedPreferences prefs = getPreferences(context);
+ SharedPreferences prefs = getPreferences(context);
return prefs.getString(Constants.PREFERENCES_KEY_VIDEO_PLAYER, "raw");
}