diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-01-30 19:57:52 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-01-30 19:57:52 -0800 |
commit | 656dcf8b5816394e68354dd9b9f6c567bec173ad (patch) | |
tree | ce9c58594c97f81ca9eacb89507049185f62a522 | |
parent | 9a3e1a665bdd2e0a8f6fdc7aaa20bf1c63acb29e (diff) | |
parent | 22563edb7c8227fe1aa6de6a9ccb8f83c8c54257 (diff) | |
download | dsub-656dcf8b5816394e68354dd9b9f6c567bec173ad.tar.gz dsub-656dcf8b5816394e68354dd9b9f6c567bec173ad.tar.bz2 dsub-656dcf8b5816394e68354dd9b9f6c567bec173ad.zip |
Merge master into Experimental
10 files changed, 191 insertions, 14 deletions
diff --git a/subsonic-android/AndroidManifest.xml b/subsonic-android/AndroidManifest.xml index 03043c2d..0f915865 100644 --- a/subsonic-android/AndroidManifest.xml +++ b/subsonic-android/AndroidManifest.xml @@ -2,8 +2,8 @@ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="github.daneren2005.dsub"
android:installLocation="internalOnly"
- android:versionCode="31"
- android:versionName="3.7.0">
+ android:versionCode="35"
+ android:versionName="3.7.2">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java index edd9b779..fd2f31d4 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/MainActivity.java @@ -139,6 +139,8 @@ public class MainActivity extends SubsonicTabActivity { // Title: Subsonic setTitle(R.string.common_appname); showInfoDialog(); + + checkUpdates(); } @Override diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java index ff63aae9..d2c61b59 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SubsonicTabActivity.java @@ -47,6 +47,7 @@ import github.daneren2005.dsub.domain.Artist; import github.daneren2005.dsub.domain.MusicDirectory;
import github.daneren2005.dsub.domain.Playlist;
import github.daneren2005.dsub.service.*;
+import github.daneren2005.dsub.updates.Updater;
import github.daneren2005.dsub.util.*;
import java.util.ArrayList;
import java.util.Arrays;
@@ -503,12 +504,11 @@ public class SubsonicTabActivity extends SherlockActivity { }
public void displaySongInfo(final MusicDirectory.Entry song) {
-
String msg = "";
if(!song.isVideo()) {
msg += "Artist: " + song.getArtist() + "\nAlbum: " + song.getAlbum();
}
- if(song.getGenre() != null && !song.getGenre().isEmpty()) {
+ if(song.getGenre() != null && !"".equals(song.getGenre())) {
msg += "\nGenre: " + song.getGenre();
}
if(song.getYear() != null && song.getYear() != 0) {
@@ -529,6 +529,18 @@ public class SubsonicTabActivity extends SherlockActivity { .setMessage(msg)
.show();
}
+
+ public void checkUpdates() {
+ try {
+ String version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
+ int ver = Integer.parseInt(version.replace(".", ""));
+ Updater updater = new Updater(ver);
+ updater.checkUpdates(SubsonicTabActivity.this);
+ }
+ catch(Exception e) {
+
+ }
+ }
private void setUncaughtExceptionHandler() {
Thread.UncaughtExceptionHandler handler = Thread.getDefaultUncaughtExceptionHandler();
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java index 3d8a3881..b4c48bde 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java @@ -77,6 +77,34 @@ public class OfflineMusicService extends RESTMusicService { artists.add(artist); } } + + Collections.sort(artists, new Comparator<Artist>() { + public int compare(Artist lhsArtist, Artist rhsArtist) { + String lhs = lhsArtist.getName().toLowerCase(); + String rhs = rhsArtist.getName().toLowerCase(); + + char lhs1 = lhs.charAt(0); + char rhs1 = rhs.charAt(0); + + if(Character.isDigit(lhs1) && !Character.isDigit(rhs1)) { + return 1; + } else if(Character.isDigit(rhs1) && !Character.isDigit(lhs1)) { + return -1; + } + + int index = lhs.indexOf("The "); + if(index == 0) { + lhs = lhs.substring(4, 0); + } + index = rhs.indexOf("The "); + if(index == 0) { + rhs = rhs.substring(4, 0); + } + + return lhs.compareTo(rhs); + } + }); + return new Indexes(0L, Collections.<Artist>emptyList(), artists); } diff --git a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java index bf22521d..e1f694e6 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java @@ -502,19 +502,19 @@ public class RESTMusicService implements MusicService { names.add("size"); values.add(size); - if (musicFolderId != null && musicFolderId != "") { + if (musicFolderId != null && !"".equals(musicFolderId)) { names.add("musicFolderId"); values.add(musicFolderId); } - if(genre != null && !genre.isEmpty()) { + if(genre != null && !"".equals(genre)) { names.add("genre"); values.add(genre); } - if(startYear != null && !startYear.isEmpty()) { + if(startYear != null && !"".equals(startYear)) { names.add("fromYear"); values.add(startYear); } - if(endYear != null && !endYear.isEmpty()) { + if(endYear != null && !"".equals(endYear)) { names.add("toYear"); values.add(endYear); } diff --git a/subsonic-android/src/github/daneren2005/dsub/service/parser/MusicDirectoryEntryParser.java b/subsonic-android/src/github/daneren2005/dsub/service/parser/MusicDirectoryEntryParser.java index 89d8d52f..818c8235 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/parser/MusicDirectoryEntryParser.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/parser/MusicDirectoryEntryParser.java @@ -54,7 +54,7 @@ public class MusicDirectoryEntryParser extends AbstractParser { entry.setBitRate(getInteger("bitRate")); entry.setPath(get("path")); entry.setVideo(getBoolean("isVideo")); - } else if(!artist.isEmpty()) { + } else if(!"".equals(artist)) { entry.setPath(artist + "/" + entry.getTitle()); } return entry; diff --git a/subsonic-android/src/github/daneren2005/dsub/updates/Updater.java b/subsonic-android/src/github/daneren2005/dsub/updates/Updater.java new file mode 100644 index 00000000..a62920b9 --- /dev/null +++ b/subsonic-android/src/github/daneren2005/dsub/updates/Updater.java @@ -0,0 +1,77 @@ +/*
+ 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 2009 (C) Sindre Mehus
+ */
+package github.daneren2005.dsub.updates;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.os.AsyncTask;
+import android.util.Log;
+import github.daneren2005.dsub.util.Constants;
+import github.daneren2005.dsub.util.Util;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ * @author Scott
+ */
+public class Updater {
+ protected String TAG = Updater.class.getSimpleName();
+ protected int version;
+ protected Context context;
+
+ public Updater(int version) {
+ this.version = version;
+ }
+
+ public void checkUpdates(Context context) {
+ this.context = context;
+ List<Updater> updaters = new ArrayList<Updater>();
+ updaters.add(new Updater373());
+
+ SharedPreferences prefs = Util.getPreferences(context);
+ int lastVersion = prefs.getInt(Constants.LAST_VERSION, 372);
+ if(version > lastVersion) {
+ SharedPreferences.Editor editor = prefs.edit();
+ editor.putInt(Constants.LAST_VERSION, version);
+
+ Log.i(TAG, "Updating from version " + lastVersion + " to " + version);
+ for(Updater updater: updaters) {
+ if(updater.shouldUpdate(lastVersion)) {
+ new BackgroundUpdate().execute(updater);
+ }
+ }
+ }
+ }
+
+ private class BackgroundUpdate extends AsyncTask<Updater, Void, Void> {
+ @Override
+ protected Void doInBackground(Updater... params) {
+ params[0].update(context);
+ return null;
+ }
+ }
+
+ public boolean shouldUpdate(int version) {
+ return this.version > version;
+ }
+ public void update(Context context) {
+
+ }
+}
diff --git a/subsonic-android/src/github/daneren2005/dsub/updates/Updater373.java b/subsonic-android/src/github/daneren2005/dsub/updates/Updater373.java new file mode 100644 index 00000000..4df31580 --- /dev/null +++ b/subsonic-android/src/github/daneren2005/dsub/updates/Updater373.java @@ -0,0 +1,55 @@ +/*
+ 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 2009 (C) Sindre Mehus
+ */
+package github.daneren2005.dsub.updates;
+
+import android.content.Context;
+import android.util.Log;
+import github.daneren2005.dsub.updates.Updater;
+import github.daneren2005.dsub.util.Constants;
+import github.daneren2005.dsub.util.FileUtil;
+import java.io.File;
+
+/**
+ *
+ * @author Scott
+ */
+public class Updater373 extends Updater {
+ public Updater373() {
+ super(373);
+ }
+
+ @Override
+ public void update(Context context) {
+ // Rename cover.jpeg to cover.jpg
+ Log.i(TAG, "Running Updater373: updating cover.jpeg to cover.jpg");
+ File dir = FileUtil.getMusicDirectory(context);
+ moveArt(dir);
+ }
+
+ private void moveArt(File dir) {
+ for(File file: dir.listFiles()) {
+ if(file.isDirectory()) {
+ moveArt(file);
+ } else if("cover.jpeg".equals(file.getName())) {
+ File renamed = new File(dir, Constants.ALBUM_ART_FILE);
+ file.renameTo(renamed);
+ }
+ }
+ }
+}
diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Constants.java b/subsonic-android/src/github/daneren2005/dsub/util/Constants.java index 0490b3d3..c116c484 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/Constants.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/Constants.java @@ -31,6 +31,7 @@ public final class Constants { // Note: Keep it as low as possible to maintain compatibility with older servers. public static final String REST_PROTOCOL_VERSION = "1.2.0"; public static final String REST_CLIENT_ID = "DSub"; + public static final String LAST_VERSION = "subsonic.version"; // Names for intent extras. public static final String INTENT_EXTRA_NAME_ID = "subsonic.id"; @@ -97,7 +98,7 @@ public final class Constants { // URL for project donations. public static final String DONATION_URL = "http://subsonic.org/pages/android-donation.jsp"; - public static final String ALBUM_ART_FILE = "cover.jpeg"; + public static final String ALBUM_ART_FILE = "cover.jpg"; private Constants() { } diff --git a/subsonic-android/src/github/daneren2005/dsub/util/ShufflePlayBuffer.java b/subsonic-android/src/github/daneren2005/dsub/util/ShufflePlayBuffer.java index 51d86f74..6b5d0996 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/ShufflePlayBuffer.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/ShufflePlayBuffer.java @@ -46,7 +46,7 @@ public class ShufflePlayBuffer { private final List<MusicDirectory.Entry> buffer = new ArrayList<MusicDirectory.Entry>(); private Context context; private int currentServer; - private String currentFolder; + private String currentFolder = ""; private String genre = ""; private String startYear = ""; @@ -108,9 +108,11 @@ public class ShufflePlayBuffer { private void clearBufferIfnecessary() { synchronized (buffer) { final SharedPreferences prefs = Util.getPreferences(context); - if (currentServer != Util.getActiveServer(context) || !currentFolder.equals(Util.getSelectedMusicFolderId(context)) - || !genre.equals(prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_GENRE, "")) || !startYear.equals(prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_START_YEAR, "")) - || !endYear.equals(prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_END_YEAR, ""))) { + if (currentServer != Util.getActiveServer(context) + || (currentFolder != null && !currentFolder.equals(Util.getSelectedMusicFolderId(context))) + || (genre != null && !genre.equals(prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_GENRE, ""))) + || (startYear != null && !startYear.equals(prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_START_YEAR, ""))) + || (endYear != null && !endYear.equals(prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_END_YEAR, "")))) { currentServer = Util.getActiveServer(context); currentFolder = Util.getSelectedMusicFolderId(context); genre = prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_GENRE, ""); |