aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/values/strings.xml2
-rw-r--r--src/github/daneren2005/dsub/activity/SettingsActivity.java7
-rw-r--r--src/github/daneren2005/dsub/fragments/SearchFragment.java1
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectArtistFragment.java5
-rw-r--r--src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java25
-rw-r--r--src/github/daneren2005/dsub/fragments/SubsonicFragment.java12
-rw-r--r--src/github/daneren2005/dsub/service/CachedMusicService.java61
-rw-r--r--src/github/daneren2005/dsub/service/MusicService.java6
-rw-r--r--src/github/daneren2005/dsub/service/OfflineMusicService.java14
-rw-r--r--src/github/daneren2005/dsub/service/RESTMusicService.java68
-rw-r--r--src/github/daneren2005/dsub/service/parser/AlbumListParser.java4
-rw-r--r--src/github/daneren2005/dsub/service/parser/IndexesParser.java2
-rw-r--r--src/github/daneren2005/dsub/service/parser/MusicDirectoryEntryParser.java3
-rw-r--r--src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java12
-rw-r--r--src/github/daneren2005/dsub/service/parser/SearchResult2Parser.java4
-rw-r--r--src/github/daneren2005/dsub/service/parser/StarredListParser.java10
-rw-r--r--src/github/daneren2005/dsub/util/Constants.java1
-rw-r--r--src/github/daneren2005/dsub/util/Util.java10
-rw-r--r--src/github/daneren2005/dsub/util/compat/RemoteControlClientKK.java2
19 files changed, 203 insertions, 46 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index b1fbb3c3..5c2a4614 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -394,6 +394,8 @@
<string name="settings.menu_options.play_last_summary">Show Play last in menus</string>
<string name="settings.menu_options.star_summary">Show Star in menus</string>
<string name="settings.menu_options.shared_summary">Show Share in menus</string>
+ <string name="settings.browse_by_tags">Browse By Tags</string>
+ <string name="settings.browse_by_tags_summary">Browse by tags instead of by folder structure. Requires Subsonic 4.7+</string>
<string name="shuffle.title">Shuffle By</string>
<string name="shuffle.startYear">Start Year:</string>
diff --git a/src/github/daneren2005/dsub/activity/SettingsActivity.java b/src/github/daneren2005/dsub/activity/SettingsActivity.java
index 8ec90367..375e8505 100644
--- a/src/github/daneren2005/dsub/activity/SettingsActivity.java
+++ b/src/github/daneren2005/dsub/activity/SettingsActivity.java
@@ -384,6 +384,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);
serverPasswordPreference.setDialogTitle(R.string.settings_server_password);
final Preference serverOpenBrowser = new Preference(this);
@@ -452,6 +458,7 @@ public class SettingsActivity extends PreferenceActivity implements SharedPrefer
screen.addPreference(serverLocalNetworkSSIDPreference);
screen.addPreference(serverUsernamePreference);
screen.addPreference(serverPasswordPreference);
+ screen.addPreference(serverTagPreference);
screen.addPreference(serverTestConnectionPreference);
screen.addPreference(serverOpenBrowser);
screen.addPreference(serverRemoveServerPreference);
diff --git a/src/github/daneren2005/dsub/fragments/SearchFragment.java b/src/github/daneren2005/dsub/fragments/SearchFragment.java
index b77df12b..86f31041 100644
--- a/src/github/daneren2005/dsub/fragments/SearchFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SearchFragment.java
@@ -298,6 +298,7 @@ public class SearchFragment extends SubsonicFragment {
if(autoplay) {
args.putBoolean(Constants.INTENT_EXTRA_NAME_AUTOPLAY, true);
}
+ args.putBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, true);
fragment.setArguments(args);
replaceFragment(fragment, R.id.fragment_list_layout);
diff --git a/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java b/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java
index 5b46b40c..df4e2d95 100644
--- a/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectArtistFragment.java
@@ -171,6 +171,7 @@ public class SelectArtistFragment extends SubsonicFragment implements AdapterVie
if("root".equals(artist.getId())) {
args.putSerializable(Constants.FRAGMENT_LIST, (Serializable) entries);
}
+ args.putBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, true);
fragment.setArguments(args);
replaceFragment(fragment, R.id.fragment_list_layout);
@@ -185,7 +186,7 @@ public class SelectArtistFragment extends SubsonicFragment implements AdapterVie
private void load(final boolean refresh) {
setTitle(R.string.button_bar_browse);
- if (Util.isOffline(context)) {
+ if (Util.isOffline(context) || Util.isTagBrowsing(context)) {
folderButton.setVisibility(View.GONE);
} else {
folderButton.setVisibility(View.VISIBLE);
@@ -196,7 +197,7 @@ public class SelectArtistFragment extends SubsonicFragment implements AdapterVie
@Override
protected Indexes doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(context);
- if (!Util.isOffline(context)) {
+ if (!Util.isOffline(context) && !Util.isTagBrowsing(context)) {
musicFolders = musicService.getMusicFolders(refresh, context, this);
}
String musicFolderId = Util.getSelectedMusicFolderId(context);
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
index 93558a03..0b58c618 100644
--- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java
@@ -68,6 +68,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
int albumListSize;
boolean refreshListing = false;
boolean showAll = false;
+ boolean artist = false;
public SelectDirectoryFragment() {
@@ -136,6 +137,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
albumListExtra = args.getString(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_EXTRA);
albumListSize = args.getInt(Constants.INTENT_EXTRA_NAME_ALBUM_LIST_SIZE, 0);
refreshListing = args.getBoolean(Constants.INTENT_EXTRA_REFRESH_LISTINGS);
+ artist = args.getBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, false);
if(entries == null) {
entries = (List<MusicDirectory.Entry>) args.getSerializable(Constants.FRAGMENT_LIST);
}
@@ -320,6 +322,9 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
if ("newest".equals(albumListType)) {
args.putBoolean(Constants.INTENT_EXTRA_REFRESH_LISTINGS, true);
}
+ if(entry.getArtist() == null && entry.getParent() == null) {
+ args.putBoolean(Constants.INTENT_EXTRA_NAME_ARTIST, true);
+ }
fragment.setArguments(args);
replaceFragment(fragment, rootId, true);
@@ -390,7 +395,15 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
new LoadTask() {
@Override
protected MusicDirectory load(MusicService service) throws Exception {
- return service.getMusicDirectory(id, name, refresh, context, this);
+ if(Util.isTagBrowsing(context) && !Util.isOffline(context)) {
+ if(artist) {
+ return service.getArtist(id, name, refresh, context, this);
+ } else {
+ return service.getAlbum(id, name, refresh, context, this);
+ }
+ } else {
+ return service.getMusicDirectory(id, name, refresh, context, this);
+ }
}
@Override
@@ -409,7 +422,15 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter
protected MusicDirectory load(MusicService service) throws Exception {
MusicDirectory root;
if(share == null) {
- root = service.getMusicDirectory(id, name, refresh, context, this);
+ if(Util.isTagBrowsing(context) && !Util.isOffline(context)) {
+ if(artist) {
+ root = service.getArtist(id, name, refresh, context, this);
+ } else {
+ root = service.getAlbum(id, name, refresh, context, this);
+ }
+ } else {
+ root = service.getMusicDirectory(id, name, refresh, context, this);
+ }
} else {
root = share.getMusicDirectory();
}
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
index 4bba4e89..8907a534 100644
--- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
+++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java
@@ -588,7 +588,11 @@ public class SubsonicFragment extends Fragment {
@Override
protected Void doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(context);
- musicService.setStarred(entry.getId(), starred, context, null);
+ if(entry.isDirectory() && Util.isTagBrowsing(context) && !Util.isOffline(context)) {
+ musicService.setStarred(null, null, entry.getId(), starred, context, null);
+ } else {
+ musicService.setStarred(entry.getId(), null, null, starred, context, null);
+ }
// Make sure to clear parent cache
String s = Util.getRestUrl(context, null) + entry.getParent();
@@ -627,7 +631,11 @@ public class SubsonicFragment extends Fragment {
@Override
protected Void doInBackground() throws Throwable {
MusicService musicService = MusicServiceFactory.getMusicService(context);
- musicService.setStarred(entry.getId(), starred, context, null);
+ if(Util.isTagBrowsing(context) && !Util.isOffline(context)) {
+ musicService.setStarred(null, entry.getId(), null, starred, context, null);
+ } else {
+ musicService.setStarred(entry.getId(), null, null, starred, context, null);
+ }
return null;
}
diff --git a/src/github/daneren2005/dsub/service/CachedMusicService.java b/src/github/daneren2005/dsub/service/CachedMusicService.java
index 4da3aec2..99f21d6e 100644
--- a/src/github/daneren2005/dsub/service/CachedMusicService.java
+++ b/src/github/daneren2005/dsub/service/CachedMusicService.java
@@ -66,6 +66,7 @@ public class CachedMusicService implements MusicService {
private final TimeLimitedCache<List<MusicFolder>> cachedMusicFolders = new TimeLimitedCache<List<MusicFolder>>(10 * 3600, TimeUnit.SECONDS);
private final TimeLimitedCache<List<PodcastChannel>> cachedPodcastChannels = new TimeLimitedCache<List<PodcastChannel>>(10 * 3600, TimeUnit.SECONDS);
private String restUrl;
+ private boolean isTagBrowsing = false;
public CachedMusicService(RESTMusicService musicService) {
this.musicService = musicService;
@@ -135,21 +136,53 @@ public class CachedMusicService implements MusicService {
@Override
public MusicDirectory getMusicDirectory(String id, String name, boolean refresh, Context context, ProgressListener progressListener) throws Exception {
- MusicDirectory dir = null;
+ MusicDirectory dir = null;
- if(!refresh) {
- dir = FileUtil.deserialize(context, getCacheName(context, "directory", id), MusicDirectory.class);
- }
+ if(!refresh) {
+ dir = FileUtil.deserialize(context, getCacheName(context, "directory", id), MusicDirectory.class);
+ }
- if(dir == null) {
- dir = musicService.getMusicDirectory(id, name, refresh, context, progressListener);
- FileUtil.serialize(context, dir, getCacheName(context, "directory", id));
- }
+ if(dir == null) {
+ dir = musicService.getMusicDirectory(id, name, refresh, context, progressListener);
+ FileUtil.serialize(context, dir, getCacheName(context, "directory", id));
+ }
- return dir;
+ return dir;
}
- @Override
+ @Override
+ public MusicDirectory getArtist(String id, String name, boolean refresh, Context context, ProgressListener progressListener) throws Exception {
+ MusicDirectory dir = null;
+
+ if(!refresh) {
+ dir = FileUtil.deserialize(context, getCacheName(context, "artist", id), MusicDirectory.class);
+ }
+
+ if(dir == null) {
+ dir = musicService.getArtist(id, name, refresh, context, progressListener);
+ FileUtil.serialize(context, dir, getCacheName(context, "artist", id));
+ }
+
+ return dir;
+ }
+
+ @Override
+ public MusicDirectory getAlbum(String id, String name, boolean refresh, Context context, ProgressListener progressListener) throws Exception {
+ MusicDirectory dir = null;
+
+ if(!refresh) {
+ dir = FileUtil.deserialize(context, getCacheName(context, "album", id), MusicDirectory.class);
+ }
+
+ if(dir == null) {
+ dir = musicService.getAlbum(id, name, refresh, context, progressListener);
+ FileUtil.serialize(context, dir, getCacheName(context, "album", id));
+ }
+
+ return dir;
+ }
+
+ @Override
public SearchResult search(SearchCritera criteria, Context context, ProgressListener progressListener) throws Exception {
return musicService.search(criteria, context, progressListener);
}
@@ -318,8 +351,8 @@ public class CachedMusicService implements MusicService {
}
@Override
- public void setStarred(String id, boolean starred, Context context, ProgressListener progressListener) throws Exception {
- musicService.setStarred(id, starred, context, progressListener);
+ public void setStarred(String id, String artistId, String albumId, boolean starred, Context context, ProgressListener progressListener) throws Exception {
+ musicService.setStarred(id, artistId, albumId, starred, context, progressListener);
}
@Override
@@ -480,13 +513,15 @@ public class CachedMusicService implements MusicService {
private void checkSettingsChanged(Context context) {
String newUrl = musicService.getRestUrl(context, null, false);
- if (!Util.equals(newUrl, restUrl)) {
+ boolean newIsTagBrowsing = Util.isTagBrowsing(context);
+ if (!Util.equals(newUrl, restUrl) || isTagBrowsing != newIsTagBrowsing) {
cachedMusicFolders.clear();
cachedLicenseValid.clear();
cachedIndexes.clear();
cachedPlaylists.clear();
cachedPodcastChannels.clear();
restUrl = newUrl;
+ isTagBrowsing = newIsTagBrowsing;
}
}
}
diff --git a/src/github/daneren2005/dsub/service/MusicService.java b/src/github/daneren2005/dsub/service/MusicService.java
index 0946c4f7..28fc2036 100644
--- a/src/github/daneren2005/dsub/service/MusicService.java
+++ b/src/github/daneren2005/dsub/service/MusicService.java
@@ -57,6 +57,10 @@ public interface MusicService {
MusicDirectory getMusicDirectory(String id, String name, boolean refresh, Context context, ProgressListener progressListener) throws Exception;
+ MusicDirectory getArtist(String id, String name, boolean refresh, Context context, ProgressListener progressListener) throws Exception;
+
+ MusicDirectory getAlbum(String id, String name, boolean refresh, Context context, ProgressListener progressListener) throws Exception;
+
SearchResult search(SearchCritera criteria, Context context, ProgressListener progressListener) throws Exception;
MusicDirectory getStarredList(Context context, ProgressListener progressListener) throws Exception;
@@ -113,7 +117,7 @@ public interface MusicService {
RemoteStatus setJukeboxGain(float gain, Context context, ProgressListener progressListener) throws Exception;
- void setStarred(String id, boolean starred, Context context, ProgressListener progressListener) throws Exception;
+ void setStarred(String id, String artistId, String albumId, boolean starred, Context context, ProgressListener progressListener) throws Exception;
List<Share> getShares(Context context, ProgressListener progressListener) throws Exception;
diff --git a/src/github/daneren2005/dsub/service/OfflineMusicService.java b/src/github/daneren2005/dsub/service/OfflineMusicService.java
index fdeb373c..c5803728 100644
--- a/src/github/daneren2005/dsub/service/OfflineMusicService.java
+++ b/src/github/daneren2005/dsub/service/OfflineMusicService.java
@@ -137,7 +137,17 @@ public class OfflineMusicService extends RESTMusicService {
return result;
}
- private String getName(File file) {
+ @Override
+ public MusicDirectory getArtist(String id, String name, boolean refresh, Context context, ProgressListener progressListener) throws Exception {
+ throw new OfflineException("Artist by tags not available in offline mode");
+ }
+
+ @Override
+ public MusicDirectory getAlbum(String id, String name, boolean refresh, Context context, ProgressListener progressListener) throws Exception {
+ throw new OfflineException("Album by tags not available in offline mode");
+ }
+
+ private String getName(File file) {
String name = file.getName();
if (file.isDirectory()) {
return name;
@@ -549,7 +559,7 @@ public class OfflineMusicService extends RESTMusicService {
}
@Override
- public void setStarred(String id, boolean starred, Context context, ProgressListener progressListener) throws Exception {
+ public void setStarred(String id, String artistId, String albumId, boolean starred, Context context, ProgressListener progressListener) throws Exception {
SharedPreferences prefs = Util.getPreferences(context);
String cacheLocn = prefs.getString(Constants.PREFERENCES_KEY_CACHE_LOCATION, null);
diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java
index e220bf59..f9fcc604 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) {
@@ -248,7 +248,7 @@ public class RESTMusicService implements MusicService {
private String getCachedIndexesFilename(Context context, String musicFolderId) {
String s = getRestUrl(context, null) + musicFolderId;
- return "indexes-" + Math.abs(s.hashCode()) + ".ser";
+ return (Util.isTagBrowsing(context, getInstance(context)) ? "artists-" : "indexes-") + Math.abs(s.hashCode()) + ".ser";
}
@Override
@@ -274,7 +274,27 @@ public class RESTMusicService implements MusicService {
}
}
- @Override
+ @Override
+ public MusicDirectory getArtist(String id, String name, boolean refresh, Context context, ProgressListener progressListener) throws Exception {
+ Reader reader = getReader(context, progressListener, "getArtist", null, "id", id);
+ try {
+ return new MusicDirectoryParser(context).parse(name, reader, progressListener);
+ } finally {
+ Util.close(reader);
+ }
+ }
+
+ @Override
+ public MusicDirectory getAlbum(String id, String name, boolean refresh, Context context, ProgressListener progressListener) throws Exception {
+ Reader reader = getReader(context, progressListener, "getAlbum", null, "id", id);
+ try {
+ return new MusicDirectoryParser(context).parse(name, reader, progressListener);
+ } finally {
+ Util.close(reader);
+ }
+ }
+
+ @Override
public SearchResult search(SearchCritera critera, Context context, ProgressListener progressListener) throws Exception {
try {
return searchNew(critera, context, progressListener);
@@ -307,7 +327,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 +525,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 +565,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 +575,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 {
@@ -802,11 +822,24 @@ public class RESTMusicService implements MusicService {
}
@Override
- public void setStarred(String id, boolean starred, Context context, ProgressListener progressListener) throws Exception {
+ public void setStarred(String id, String artistId, String albumId, boolean starred, Context context, ProgressListener progressListener) throws Exception {
checkServerVersion(context, "1.8", "Starring is not supported.");
- id = getOfflineSongId(id, context, progressListener);
+
+ List<String> names = new ArrayList<String>();
+ List<Object> values = new ArrayList<Object>();
+
+ if(id != null) {
+ names.add("id");
+ values.add(getOfflineSongId(id, context, progressListener));
+ } else if(artistId != null) {
+ names.add("artistId");
+ values.add(artistId);
+ } else if(albumId != null) {
+ names.add("albumId");
+ values.add(albumId);
+ }
- Reader reader = getReader(context, progressListener, starred ? "star" : "unstar", null, "id", id);
+ Reader reader = getReader(context, progressListener, starred ? "star" : "unstar", null, names, values);
try {
new ErrorParser(context).parse(reader);
} finally {
@@ -1183,7 +1216,7 @@ public class RESTMusicService implements MusicService {
String id = offline.getString(Constants.OFFLINE_STAR_ID + i, null);
boolean starred = offline.getBoolean(Constants.OFFLINE_STAR_SETTING + i, false);
if(id != null) {
- setStarred(id, starred, context, progressListener);
+ setStarred(id, null, null, starred, context, progressListener);
} else {
String search = offline.getString(Constants.OFFLINE_STAR_SEARCH + i, "");
try{
@@ -1191,10 +1224,10 @@ public class RESTMusicService implements MusicService {
SearchResult result = searchNew(critera, context, progressListener);
if(result.getSongs().size() == 1){
Log.i(TAG, "Query '" + search + "' returned song " + result.getSongs().get(0).getTitle() + " by " + result.getSongs().get(0).getArtist() + " with id " + result.getSongs().get(0).getId());
- setStarred(result.getSongs().get(0).getId(), starred, context, progressListener);
+ setStarred(result.getSongs().get(0).getId(), null, null, starred, context, progressListener);
} else if(result.getAlbums().size() == 1){
Log.i(TAG, "Query '" + search + "' returned song " + result.getAlbums().get(0).getTitle() + " by " + result.getAlbums().get(0).getArtist() + " with id " + result.getAlbums().get(0).getId());
- setStarred(result.getAlbums().get(0).getId(), starred, context, progressListener);
+ setStarred(result.getAlbums().get(0).getId(), null, null, starred, context, progressListener);
}
else{
throw new Exception("Song not found on server");
@@ -1440,7 +1473,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/IndexesParser.java b/src/github/daneren2005/dsub/service/parser/IndexesParser.java
index bf5bd8b1..30ea190b 100644
--- a/src/github/daneren2005/dsub/service/parser/IndexesParser.java
+++ b/src/github/daneren2005/dsub/service/parser/IndexesParser.java
@@ -67,7 +67,7 @@ public class IndexesParser extends MusicDirectoryEntryParser {
eventType = nextParseEvent();
if (eventType == XmlPullParser.START_TAG) {
String name = getElementName();
- if ("indexes".equals(name)) {
+ if ("indexes".equals(name) || "artists".equals(name)) {
changed = true;
lastModified = getLong("lastModified");
ignoredArticles = get("ignoredArticles");
diff --git a/src/github/daneren2005/dsub/service/parser/MusicDirectoryEntryParser.java b/src/github/daneren2005/dsub/service/parser/MusicDirectoryEntryParser.java
index 3c12dfd4..e58427f5 100644
--- a/src/github/daneren2005/dsub/service/parser/MusicDirectoryEntryParser.java
+++ b/src/github/daneren2005/dsub/service/parser/MusicDirectoryEntryParser.java
@@ -34,6 +34,9 @@ public class MusicDirectoryEntryParser extends AbstractParser {
entry.setId(get("id"));
entry.setParent(get("parent"));
entry.setTitle(get("title"));
+ if(entry.getTitle() == null) {
+ entry.setTitle(get("name"));
+ }
entry.setDirectory(getBoolean("isDir"));
entry.setCoverArt(get("coverArt"));
entry.setArtist(get("artist"));
diff --git a/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java b/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java
index 7a49cfa5..75f878be 100644
--- a/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java
+++ b/src/github/daneren2005/dsub/service/parser/MusicDirectoryParser.java
@@ -49,19 +49,25 @@ public class MusicDirectoryParser extends MusicDirectoryEntryParser {
MusicDirectory dir = new MusicDirectory();
int eventType;
+ boolean isArtist = false;
do {
eventType = nextParseEvent();
if (eventType == XmlPullParser.START_TAG) {
String name = getElementName();
- if ("child".equals(name)) {
+ if ("child".equals(name) || "song".equals(name) || "video".equals(name)) {
MusicDirectory.Entry entry = parseEntry(artist);
entry.setGrandParent(dir.getParent());
dir.addChild(entry);
- } else if ("directory".equals(name)) {
+ } else if ("directory".equals(name) || "artist".equals(name) || ("album".equals(name) && !isArtist)) {
dir.setName(get("name"));
dir.setId(get("id"));
dir.setParent(get("parent"));
- } else if ("error".equals(name)) {
+ isArtist = true;
+ } else if("album".equals(name)) {
+ MusicDirectory.Entry entry = parseEntry(artist);
+ entry.setDirectory(true);
+ dir.addChild(entry);
+ } else if ("error".equals(name)) {
handleError();
}
}
diff --git a/src/github/daneren2005/dsub/service/parser/SearchResult2Parser.java b/src/github/daneren2005/dsub/service/parser/SearchResult2Parser.java
index a0be07ac..abf96d7f 100644
--- a/src/github/daneren2005/dsub/service/parser/SearchResult2Parser.java
+++ b/src/github/daneren2005/dsub/service/parser/SearchResult2Parser.java
@@ -57,7 +57,9 @@ public class SearchResult2Parser extends MusicDirectoryEntryParser {
artist.setName(get("name"));
artists.add(artist);
} else if ("album".equals(name)) {
- albums.add(parseEntry(""));
+ MusicDirectory.Entry entry = parseEntry("");
+ entry.setDirectory(true);
+ albums.add(entry);
} else if ("song".equals(name)) {
songs.add(parseEntry(""));
} else if ("error".equals(name)) {
diff --git a/src/github/daneren2005/dsub/service/parser/StarredListParser.java b/src/github/daneren2005/dsub/service/parser/StarredListParser.java
index fc4cd175..bd2a7888 100644
--- a/src/github/daneren2005/dsub/service/parser/StarredListParser.java
+++ b/src/github/daneren2005/dsub/service/parser/StarredListParser.java
@@ -47,9 +47,15 @@ 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("");
+ if("album".equals(name)) {
+ 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 1e56fbd4..651f043e 100644
--- a/src/github/daneren2005/dsub/util/Constants.java
+++ b/src/github/daneren2005/dsub/util/Constants.java
@@ -138,6 +138,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 e944f125..5dd639c4 100644
--- a/src/github/daneren2005/dsub/util/Util.java
+++ b/src/github/daneren2005/dsub/util/Util.java
@@ -388,9 +388,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");
}
diff --git a/src/github/daneren2005/dsub/util/compat/RemoteControlClientKK.java b/src/github/daneren2005/dsub/util/compat/RemoteControlClientKK.java
index e88b4122..2c041d71 100644
--- a/src/github/daneren2005/dsub/util/compat/RemoteControlClientKK.java
+++ b/src/github/daneren2005/dsub/util/compat/RemoteControlClientKK.java
@@ -64,7 +64,7 @@ public class RemoteControlClientKK extends RemoteControlClientJB {
protected Void doInBackground(Void... params) {
try {
MusicService musicService = MusicServiceFactory.getMusicService(downloadService);
- musicService.setStarred(entry.getId(), starred, downloadService, null);
+ musicService.setStarred(entry.getId(), null, null, starred, downloadService, null);
// Make sure to clear parent cache
String s = Util.getRestUrl(downloadService, null) + entry.getParent();