diff options
Diffstat (limited to 'subsonic-android/src/github/daneren2005')
3 files changed, 30 insertions, 7 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java index ee6e3885..df501994 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/OfflineMusicService.java @@ -32,6 +32,7 @@ import java.util.Random; import java.util.Set; import android.content.Context; +import android.content.SharedPreferences; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.media.MediaMetadataRetriever; @@ -78,6 +79,10 @@ public class OfflineMusicService extends RESTMusicService { } } + SharedPreferences prefs = Util.getPreferences(context); + String ignoredArticlesString = prefs.getString(Constants.CACHE_KEY_IGNORE, "The El La Los Las Le Les"); + final String[] ignoredArticles = ignoredArticlesString.split(" "); + Collections.sort(artists, new Comparator<Artist>() { public int compare(Artist lhsArtist, Artist rhsArtist) { String lhs = lhsArtist.getName().toLowerCase(); @@ -92,13 +97,15 @@ public class OfflineMusicService extends RESTMusicService { 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); + for(String article: ignoredArticles) { + int index = lhs.indexOf(article.toLowerCase()); + if(index == 0) { + lhs = lhs.substring(article.length() + 1); + } + index = rhs.indexOf(article.toLowerCase()); + if(index == 0) { + rhs = rhs.substring(article.length() + 1); + } } return lhs.compareTo(rhs); diff --git a/subsonic-android/src/github/daneren2005/dsub/service/parser/IndexesParser.java b/subsonic-android/src/github/daneren2005/dsub/service/parser/IndexesParser.java index 4a307812..6196411d 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/parser/IndexesParser.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/parser/IndexesParser.java @@ -25,20 +25,26 @@ import java.util.ArrayList; import org.xmlpull.v1.XmlPullParser; import android.content.Context; +import android.content.SharedPreferences; import github.daneren2005.dsub.R; import github.daneren2005.dsub.domain.Artist; import github.daneren2005.dsub.domain.Indexes; import github.daneren2005.dsub.util.ProgressListener; import android.util.Log; +import github.daneren2005.dsub.util.Constants; +import github.daneren2005.dsub.util.Util; /** * @author Sindre Mehus */ public class IndexesParser extends AbstractParser { private static final String TAG = IndexesParser.class.getSimpleName(); + + private Context context; public IndexesParser(Context context) { super(context); + this.context = context; } public Indexes parse(Reader reader, ProgressListener progressListener) throws Exception { @@ -52,6 +58,7 @@ public class IndexesParser extends AbstractParser { Long lastModified = null; int eventType; String index = "#"; + String ignoredArticles = null; boolean changed = false; do { @@ -61,6 +68,7 @@ public class IndexesParser extends AbstractParser { if ("indexes".equals(name)) { changed = true; lastModified = getLong("lastModified"); + ignoredArticles = get("ignoredArticles"); } else if ("index".equals(name)) { index = get("name"); @@ -90,6 +98,12 @@ public class IndexesParser extends AbstractParser { } while (eventType != XmlPullParser.END_DOCUMENT); validate(); + + if(ignoredArticles != null) { + SharedPreferences.Editor prefs = Util.getPreferences(context).edit(); + prefs.putString(Constants.CACHE_KEY_IGNORE, ignoredArticles); + prefs.commit(); + } if (!changed) { return null; diff --git a/subsonic-android/src/github/daneren2005/dsub/util/Constants.java b/subsonic-android/src/github/daneren2005/dsub/util/Constants.java index 54a61819..03213ce4 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/Constants.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/Constants.java @@ -105,6 +105,8 @@ public final class Constants { public static final String PREFERENCES_KEY_CHAT_REFRESH = "chatRefreshRate"; public static final String PREFERENCES_KEY_CHAT_ENABLED = "chatEnabled"; + public static final String CACHE_KEY_IGNORE = "ignoreArticles"; + public static final String MAIN_BACK_STACK = "backStackIds"; public static final String MAIN_BACK_STACK_SIZE = "backStackIdsSize"; public static final String MAIN_BACK_STACK_TABS = "backStackTabs"; |