diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-04-30 21:30:57 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-04-30 21:30:57 -0700 |
commit | af7238785da4e61dca1bc3abd1a2357726e29f38 (patch) | |
tree | d1b0470a331e0777ec9aca7c1848d57af8198c11 /src/github | |
parent | fa09f6b7371d7e1e5290a9c1fbfd4aee4d93676e (diff) | |
download | dsub-af7238785da4e61dca1bc3abd1a2357726e29f38.tar.gz dsub-af7238785da4e61dca1bc3abd1a2357726e29f38.tar.bz2 dsub-af7238785da4e61dca1bc3abd1a2357726e29f38.zip |
Make large album art optional
Diffstat (limited to 'src/github')
4 files changed, 154 insertions, 29 deletions
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index 3754409f..bcb93115 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -77,6 +77,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter boolean showAll = false;
boolean restoredInstance = false;
boolean lookupParent = false;
+ boolean largeAlbums = false;
public SelectDirectoryFragment() {
super();
@@ -139,7 +140,11 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter entryList.setOnItemClickListener(this);
setupScrollList(entryList);
- if(albumListType == null || "starred".equals(albumListType)) {
+ if(Util.getPreferences(context).getBoolean(Constants.PREFERENCES_KEY_LARGE_ALBUM_ART, true)) {
+ largeAlbums = true;
+ }
+
+ if(albumListType == null || "starred".equals(albumListType) || !largeAlbums) {
albumList = (GridView) inflater.inflate(R.layout.unscrollable_grid_view, entryList, false);
entryList.addHeaderView(albumList);
} else {
@@ -611,8 +616,13 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter @Override
protected void done(Pair<MusicDirectory, Boolean> result) {
- albums = result.getFirst().getChildren(true, false);
- entries = result.getFirst().getChildren(false, true);
+ if(largeAlbums) {
+ albums = result.getFirst().getChildren(true, false);
+ entries = result.getFirst().getChildren(false, true);
+ } else {
+ albums = new ArrayList<MusicDirectory.Entry>();
+ entries = result.getFirst().getChildren();
+ }
licenseValid = result.getSecond();
finishLoading();
}
@@ -647,17 +657,18 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter entryList.setAdapter(entryAdapter);
if("genres-songs".equals(albumListType)) {
ViewGroup rootGroup = (ViewGroup) rootView.findViewById(R.id.select_album_layout);
- if(rootGroup.findViewById(R.id.gridview) != null) {
+ if(rootGroup.findViewById(R.id.gridview) != null && largeAlbums) {
rootGroup.removeView(albumList);
rootGroup.addView(entryList);
}
entryList.setAdapter(new AlbumListAdapter(context, entryAdapter, albumListType, albumListExtra, albumListSize));
- }
- else if(albumListType == null || "starred".equals(albumListType)) {
- albumList.setAdapter(new AlbumGridAdapter(context, getImageLoader(), albums, !artist));
- } else {
- albumList.setAdapter(new AlbumListAdapter(context, new AlbumGridAdapter(context, getImageLoader(), albums, true), albumListType, albumListExtra, albumListSize));
+ } else if(largeAlbums) {
+ if(albumListType == null || "starred".equals(albumListType)) {
+ albumList.setAdapter(new AlbumGridAdapter(context, getImageLoader(), albums, !artist));
+ } else {
+ albumList.setAdapter(new AlbumListAdapter(context, new AlbumGridAdapter(context, getImageLoader(), albums, true), albumListType, albumListExtra, albumListSize));
+ }
}
entryList.setVisibility(View.VISIBLE);
context.supportInvalidateOptionsMenu();
diff --git a/src/github/daneren2005/dsub/util/Constants.java b/src/github/daneren2005/dsub/util/Constants.java index 874579a5..ab57bcd0 100644 --- a/src/github/daneren2005/dsub/util/Constants.java +++ b/src/github/daneren2005/dsub/util/Constants.java @@ -139,6 +139,7 @@ public final class Constants { public static final String PREFERENCES_KEY_OPEN_TO_LIBRARY = "openToLibrary"; public static final String PREFERENCES_KEY_OVERRIDE_SYSTEM_LANGUAGE = "overrideSystemLanguage"; public static final String PREFERENCES_KEY_PLAY_NOW_AFTER = "playNowAfter"; + public static final String PREFERENCES_KEY_LARGE_ALBUM_ART = "largeAlbumArt"; public static final String OFFLINE_SCROBBLE_COUNT = "scrobbleCount"; public static final String OFFLINE_SCROBBLE_ID = "scrobbleID"; diff --git a/src/github/daneren2005/dsub/view/AlbumView.java b/src/github/daneren2005/dsub/view/AlbumView.java new file mode 100644 index 00000000..910cac07 --- /dev/null +++ b/src/github/daneren2005/dsub/view/AlbumView.java @@ -0,0 +1,100 @@ +/*
+ 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.view;
+
+import android.content.Context;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.TextView;
+import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.domain.MusicDirectory;
+import github.daneren2005.dsub.util.FileUtil;
+import github.daneren2005.dsub.util.ImageLoader;
+import github.daneren2005.dsub.util.Util;
+import java.io.File;
+import java.util.List;
+
+/**
+ * Used to display albums in a {@code ListView}.
+ *
+ * @author Sindre Mehus
+ */
+public class AlbumView extends UpdateView {
+ private static final String TAG = AlbumView.class.getSimpleName();
+
+ private Context context;
+ private MusicDirectory.Entry album;
+ private File file;
+
+ private TextView titleView;
+ private TextView artistView;
+ private View coverArtView;
+
+ public AlbumView(Context context) {
+ super(context);
+ this.context = context;
+ LayoutInflater.from(context).inflate(R.layout.album_list_item, this, true);
+
+ titleView = (TextView) findViewById(R.id.album_title);
+ artistView = (TextView) findViewById(R.id.album_artist);
+ coverArtView = findViewById(R.id.album_coverart);
+ starButton = (ImageButton) findViewById(R.id.album_star);
+ starButton.setFocusable(false);
+
+ moreButton = (ImageView) findViewById(R.id.album_more);
+ moreButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ v.showContextMenu();
+ }
+ });
+ }
+
+ protected void setObjectImpl(Object obj1, Object obj2) {
+ this.album = (MusicDirectory.Entry) obj1;
+ if(album.getAlbum() == null) {
+ titleView.setText(album.getTitle());
+ } else {
+ titleView.setText(album.getAlbum());
+ }
+ String artist = album.getArtist();
+ if(artist == null) {
+ artist = "";
+ }
+ if(album.getYear() != null) {
+ artist += " - " + album.getYear();
+ }
+ artistView.setText(artist);
+ artistView.setVisibility(album.getArtist() == null ? View.GONE : View.VISIBLE);
+ ((ImageLoader)obj2).loadImage(coverArtView, album, false, true);
+ file = null;
+ }
+
+ @Override
+ protected void updateBackground() {
+ if(file == null) {
+ file = FileUtil.getAlbumDirectory(context, album);
+ }
+
+ exists = file.exists();
+ isStarred = album.isStarred();
+ }
+}
diff --git a/src/github/daneren2005/dsub/view/EntryAdapter.java b/src/github/daneren2005/dsub/view/EntryAdapter.java index 7da6e5a1..2dc14e1b 100644 --- a/src/github/daneren2005/dsub/view/EntryAdapter.java +++ b/src/github/daneren2005/dsub/view/EntryAdapter.java @@ -33,34 +33,47 @@ import github.daneren2005.dsub.util.ImageLoader; */ public class EntryAdapter extends ArrayAdapter<MusicDirectory.Entry> { private final static String TAG = EntryAdapter.class.getSimpleName(); - private final Context activity; - private final ImageLoader imageLoader; - private final boolean checkable; + private final Context activity; + private final ImageLoader imageLoader; + private final boolean checkable; private List<MusicDirectory.Entry> entries; - public EntryAdapter(Context activity, ImageLoader imageLoader, List<MusicDirectory.Entry> entries, boolean checkable) { - super(activity, android.R.layout.simple_list_item_1, entries); + public EntryAdapter(Context activity, ImageLoader imageLoader, List<MusicDirectory.Entry> entries, boolean checkable) { + super(activity, android.R.layout.simple_list_item_1, entries); this.entries = entries; - this.activity = activity; - this.imageLoader = imageLoader; - this.checkable = checkable; - } - + this.activity = activity; + this.imageLoader = imageLoader; + this.checkable = checkable; + } + public void removeAt(int position) { entries.remove(position); } - @Override - public View getView(int position, View convertView, ViewGroup parent) { - MusicDirectory.Entry entry = getItem(position); + @Override + public View getView(int position, View convertView, ViewGroup parent) { + MusicDirectory.Entry entry = getItem(position); - SongView view; - if (convertView != null && convertView instanceof SongView) { - view = (SongView) convertView; + if (entry.isDirectory()) { + if(entry.getArtist() != null || entry.getParent() != null) { + AlbumView view; + view = new AlbumView(activity); + view.setObject(entry, imageLoader); + return view; + } else { + ArtistEntryView view = new ArtistEntryView(activity); + view.setObject(entry); + return view; + } } else { - view = new SongView(activity); + SongView view; + if (convertView != null && convertView instanceof SongView) { + view = (SongView) convertView; + } else { + view = new SongView(activity); + } + view.setObject(entry, checkable); + return view; } - view.setObject(entry, checkable); - return view; - } + } } |