Skip to content

Commit

Permalink
Merge branch 'release/1_07_rc3'
Browse files Browse the repository at this point in the history
Conflicts:
	MPDroid/src/main/res/values-de/strings.xml
  • Loading branch information
abarisain committed Nov 20, 2014
2 parents 57ec514 + 72669e6 commit 182bf4a
Show file tree
Hide file tree
Showing 35 changed files with 789 additions and 726 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android:
# - tools

# The BuildTools version used by your project.
- build-tools-21.0.2
- build-tools-21.1.1

# The SDK version used to compile your project.
- android-21
Expand Down
2 changes: 1 addition & 1 deletion JMPDComm/backends/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'

android {
compileSdkVersion 21
buildToolsVersion "21.0.2"
buildToolsVersion "21.1.1"

lintOptions {
abortOnError false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public Album(final Album otherAlbum) {
super(otherAlbum);
}

public Album(final Album otherAlbum, final Artist artist, final boolean hasAlbumArtist) {
super(otherAlbum, artist, hasAlbumArtist);
}

public Album(final String name, final Artist artist) {
super(name, artist, false, 0L, 0L, 0L, null);
}
Expand Down
32 changes: 16 additions & 16 deletions JMPDComm/backends/android/src/main/java/org/a0z/mpd/item/Music.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected Music(final Music music) {
super(music);
}

protected Music(final String album, final String artist, final String albumArtist,
Music(final String album, final String artist, final String albumArtist,
final String composer, final String fullPath, final int disc, final long date,
final String genre, final long time, final String title, final int totalTracks,
final int track, final int songId, final int songPos, final String name) {
Expand All @@ -84,20 +84,20 @@ public int describeContents() {

@Override
public void writeToParcel(final Parcel dest, final int flags) {
dest.writeString(getAlbum());
dest.writeString(getArtist());
dest.writeString(getAlbumArtist());
dest.writeString(getComposer());
dest.writeString(getFullPath());
dest.writeInt(getDisc());
dest.writeLong(getDate());
dest.writeString(getGenre());
dest.writeLong(getTime());
dest.writeString(getTitle());
dest.writeInt(getTotalTracks());
dest.writeInt(getTrack());
dest.writeInt(getSongId());
dest.writeInt(getPos());
dest.writeString(getName());
dest.writeString(mAlbum);
dest.writeString(mArtist);
dest.writeString(mAlbumArtist);
dest.writeString(mComposer);
dest.writeString(mFullPath);
dest.writeInt(mDisc);
dest.writeLong(mDate);
dest.writeString(mGenre);
dest.writeLong(mTime);
dest.writeString(mTitle);
dest.writeInt(mTotalTracks);
dest.writeInt(mTrack);
dest.writeInt(mSongId);
dest.writeInt(mSongPos);
dest.writeString(mName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public Album(final Album otherAlbum) {
super(otherAlbum);
}

public Album(final Album otherAlbum, final Artist artist, final boolean hasAlbumArtist) {
super(otherAlbum, artist, hasAlbumArtist);
}

public Album(final String name, final Artist artist) {
super(name, artist, false, 0L, 0L, 0L, null);
}
Expand Down
8 changes: 8 additions & 0 deletions JMPDComm/src/main/java/org/a0z/mpd/CommandQueue.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ void clear() {
mCommandQueue.clear();
}

public boolean isEmpty() {
return mCommandQueue.isEmpty();
}

/** Reverse the command queue order, useful for removing playlist entries. */
void reverse() {
Collections.reverse(mCommandQueue);
Expand Down Expand Up @@ -215,6 +219,10 @@ public List<String[]> sendSeparated(final MPDConnection mpdConnection)
return separatedQueueResults(send(mpdConnection, true));
}

public int size() {
return mCommandQueue.size();
}

/**
* Returns the command queue in {@code String} format.
*
Expand Down
81 changes: 33 additions & 48 deletions JMPDComm/src/main/java/org/a0z/mpd/MPD.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,28 +187,6 @@ private static MPDCommand nextCommand() {
return new MPDCommand(MPDCommand.MPD_CMD_NEXT);
}

/**
* Parse the response from tag list command for album artists.
*
* @param response The album artist list response from the MPD server database.
* @param substring The substring from the response to remove.
* @param sortInsensitive Whether to sort insensitively.
* @return Returns a parsed album artist list.
*/
private static List<String> parseResponse(final Collection<String> response,
final String substring, final boolean sortInsensitive) {
final List<String> result = new ArrayList<>(response.size());
for (final String line : response) {
result.add(line.substring((substring + ": ").length()));
}
if (sortInsensitive) {
Collections.sort(result, String.CASE_INSENSITIVE_ORDER);
} else {
Collections.sort(result);
}
return result;
}

private static MPDCommand skipToPositionCommand(final int position) {
return new MPDCommand(MPDCommand.MPD_CMD_PLAY, Integer.toString(position));
}
Expand Down Expand Up @@ -352,7 +330,13 @@ public void add(final CommandQueue commandQueue, final boolean replace,

}

commandQueue.send(mConnection);
/**
* It's rare, but possible to make it through the add()
* methods without adding to the command queue.
*/
if (!commandQueue.isEmpty()) {
commandQueue.send(mConnection);
}
}

/**
Expand Down Expand Up @@ -388,16 +372,12 @@ public void add(final PlaylistFile databasePlaylist, final boolean replace, fina
add(commandQueue, replace, play);
}

protected void addAlbumPaths(final List<Album> albums) {
protected void addAlbumPaths(final List<Album> albums) throws IOException, MPDException {
if (albums != null && !albums.isEmpty()) {
for (final Album album : albums) {
try {
final List<Music> songs = getFirstTrack(album);
if (!songs.isEmpty()) {
album.setPath(songs.get(0).getPath());
}
} catch (final IOException | MPDException e) {
Log.error(TAG, "Failed to add an album path.", e);
final List<Music> songs = getFirstTrack(album);
if (!songs.isEmpty()) {
album.setPath(songs.get(0).getPath());
}
}
}
Expand Down Expand Up @@ -611,13 +591,14 @@ protected void fixAlbumArtists(final List<Album> albums) {
.isEmpty()) { // one albumartist, fix this
// album
final Artist artist = new Artist(aartists[0]);
albums.set(i, album.setAlbumArtist(artist));
final Album newAlbum = new Album(album, artist, true);
albums.set(i, newAlbum);
} // do nothing if albumartist is ""
if (aartists.length > 1) { // it's more than one album, insert
for (int n = 1; n < aartists.length; n++) {
final Album newalbum =
new Album(album.getName(), new Artist(aartists[n]), true);
splitAlbums.add(newalbum);
final Artist artist = new Artist(aartists[n]);
final Album newAlbum = new Album(album, artist, true);
splitAlbums.add(newAlbum);
}
}
}
Expand Down Expand Up @@ -1109,8 +1090,7 @@ public List<String> listAlbumArtists(final boolean sortInsensitive)
throws IOException, MPDException {
final List<String> response = mConnection.sendCommand(MPDCommand.MPD_CMD_LIST_TAG,
MPDCommand.MPD_TAG_ALBUM_ARTIST);

return parseResponse(response, "albumartist", sortInsensitive);
return Tools.parseResponse(response, "AlbumArtist", sortInsensitive);
}

public List<String> listAlbumArtists(final Genre genre) throws IOException, MPDException {
Expand All @@ -1130,7 +1110,7 @@ public List<String> listAlbumArtists(final Genre genre, final boolean sortInsens
MPDCommand.MPD_CMD_LIST_TAG, MPDCommand.MPD_TAG_ALBUM_ARTIST,
MPDCommand.MPD_TAG_GENRE, genre.getName());

return parseResponse(response, MPDCommand.MPD_TAG_ALBUM_ARTIST, sortInsensitive);
return Tools.parseResponse(response, "AlbumArtist", sortInsensitive);
}

public List<String[]> listAlbumArtists(final List<Album> albums)
Expand Down Expand Up @@ -1290,7 +1270,7 @@ public List<Album> listAllAlbumsGrouped(final boolean useAlbumArtist,
final List<String> response =
mConnection.sendCommand(listAllAlbumsGroupedCommand(useAlbumArtist));
final List<Album> result = new ArrayList<>(response.size() / 2);
Album currentAlbum = null;
String currentAlbum = null;

if (useAlbumArtist) {
artistResponse = "AlbumArtist";
Expand All @@ -1299,17 +1279,22 @@ public List<Album> listAllAlbumsGrouped(final boolean useAlbumArtist,
}

for (final String[] pair : Tools.splitResponse(response)) {

if (artistResponse.equals(pair[KEY])) {
// Don't make the check with the other so we don't waste time doing string
// comparisons for nothing.
if (currentAlbum != null) {
currentAlbum.setAlbumArtist(new Artist(pair[VALUE]));
final Artist artist = new Artist(pair[VALUE]);
result.add(new Album(currentAlbum, artist, useAlbumArtist));

currentAlbum = null;
}
} else if (albumResponse.equals(pair[KEY])) {
if (currentAlbum != null) {
/** There was no artist in this response, add the album alone */
result.add(new Album(currentAlbum, null));
}

if (!pair[VALUE].isEmpty() || includeUnknownAlbum) {
currentAlbum = new Album(pair[VALUE], null);
currentAlbum.setHasAlbumArtist(useAlbumArtist);
result.add(currentAlbum);
currentAlbum = pair[VALUE];
} else {
currentAlbum = null;
}
Expand Down Expand Up @@ -1359,7 +1344,7 @@ public List<String> listArtists(final boolean sortInsensitive)
final List<String> response = mConnection.sendCommand(MPDCommand.MPD_CMD_LIST_TAG,
MPDCommand.MPD_TAG_ARTIST);

return parseResponse(response, "Artist", sortInsensitive);
return Tools.parseResponse(response, "Artist", sortInsensitive);
}

/**
Expand Down Expand Up @@ -1435,7 +1420,7 @@ public List<String> listArtists(final String genre, final boolean sortInsensitiv
final List<String> response = mConnection.sendCommand(MPDCommand.MPD_CMD_LIST_TAG,
MPDCommand.MPD_TAG_ARTIST, MPDCommand.MPD_TAG_GENRE, genre);

return parseResponse(response, "Artist", sortInsensitive);
return Tools.parseResponse(response, "Artist", sortInsensitive);
}

private List<String[]> listArtistsCommand(final Iterable<Album> albums,
Expand Down Expand Up @@ -1489,7 +1474,7 @@ public List<String> listGenres(final boolean sortInsensitive) throws IOException
final List<String> response = mConnection.sendCommand(MPDCommand.MPD_CMD_LIST_TAG,
MPDCommand.MPD_TAG_GENRE);

return parseResponse(response, "Genre", sortInsensitive);
return Tools.parseResponse(response, "Genre", sortInsensitive);
}

public void movePlaylistSong(final String playlistName, final int from, final int to)
Expand Down
Loading

0 comments on commit 182bf4a

Please sign in to comment.