From af7238785da4e61dca1bc3abd1a2357726e29f38 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Wed, 30 Apr 2014 21:30:57 -0700 Subject: Make large album art optional --- res/layout/album_list_item.xml | 58 ++++++++++++ res/values/strings.xml | 2 + res/xml/settings.xml | 5 ++ .../dsub/fragments/SelectDirectoryFragment.java | 29 ++++-- src/github/daneren2005/dsub/util/Constants.java | 1 + src/github/daneren2005/dsub/view/AlbumView.java | 100 +++++++++++++++++++++ src/github/daneren2005/dsub/view/EntryAdapter.java | 53 ++++++----- 7 files changed, 219 insertions(+), 29 deletions(-) create mode 100644 res/layout/album_list_item.xml create mode 100644 src/github/daneren2005/dsub/view/AlbumView.java diff --git a/res/layout/album_list_item.xml b/res/layout/album_list_item.xml new file mode 100644 index 00000000..a98f0e04 --- /dev/null +++ b/res/layout/album_list_item.xml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + diff --git a/res/values/strings.xml b/res/values/strings.xml index 0cbb9330..638df57a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -402,6 +402,8 @@ Drawer Items Play Now - After Play Now context menu for a song plays everything after selected item (like the Subsonic web GUI) + Large Album Art + Display albums with large album art instead of in a list Shuffle By Start Year: diff --git a/res/xml/settings.xml b/res/xml/settings.xml index 734621b5..9f1b5b67 100644 --- a/res/xml/settings.xml +++ b/res/xml/settings.xml @@ -67,6 +67,11 @@ android:key="overrideSystemLanguage" android:defaultValue="false"/> + 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(); + 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 . + + 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 { 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 entries; - public EntryAdapter(Context activity, ImageLoader imageLoader, List entries, boolean checkable) { - super(activity, android.R.layout.simple_list_item_1, entries); + public EntryAdapter(Context activity, ImageLoader imageLoader, List 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; - } + } } -- cgit v1.2.3