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 | |
parent | fa09f6b7371d7e1e5290a9c1fbfd4aee4d93676e (diff) | |
download | dsub-af7238785da4e61dca1bc3abd1a2357726e29f38.tar.gz dsub-af7238785da4e61dca1bc3abd1a2357726e29f38.tar.bz2 dsub-af7238785da4e61dca1bc3abd1a2357726e29f38.zip |
Make large album art optional
-rw-r--r-- | res/layout/album_list_item.xml | 58 | ||||
-rw-r--r-- | res/values/strings.xml | 2 | ||||
-rw-r--r-- | res/xml/settings.xml | 5 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java | 29 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/util/Constants.java | 1 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/view/AlbumView.java | 100 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/view/EntryAdapter.java | 53 |
7 files changed, 219 insertions, 29 deletions
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 @@ +<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@id/drag_handle"
+ android:orientation="horizontal"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+
+ <ImageView
+ android:id="@+id/album_coverart"
+ android:layout_width="@dimen/AlbumArt.Small"
+ android:layout_height="@dimen/AlbumArt.Small"
+ android:layout_gravity="left|center_vertical"/>
+
+ <LinearLayout
+ android:orientation="vertical"
+ android:layout_width="0dip"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:layout_gravity="left|center_vertical"
+ android:paddingLeft="10dip"
+ android:paddingRight="3dip">
+
+ <TextView
+ android:id="@+id/album_title"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:singleLine="true"
+ android:ellipsize="marquee"/>
+
+ <TextView
+ android:id="@+id/album_artist"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textAppearance="?android:attr/textAppearanceSmall"
+ android:singleLine="true"/>
+
+ </LinearLayout>
+
+ <ImageButton
+ android:id="@+id/album_star"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_gravity="right|center_vertical"
+ android:src="@drawable/ic_stat_star"
+ android:background="@android:color/transparent"
+ android:focusable="false"
+ android:visibility="gone"/>
+
+ <ImageView
+ android:id="@+id/album_more"
+ android:src="?attr/download_none"
+ android:layout_width="wrap_content"
+ android:layout_height="fill_parent"
+ android:layout_gravity="right|center_vertical"
+ android:paddingRight="10dip"
+ android:background="@drawable/menubar_button"/>
+</LinearLayout>
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 @@ <string name="settings.drawer_items_title">Drawer Items</string>
<string name="settings.play_now_after">Play Now - After</string>
<string name="settings.play_now_after_summary">Play Now context menu for a song plays everything after selected item (like the Subsonic web GUI)</string>
+ <string name="settings.large_album_art">Large Album Art</string>
+ <string name="settings.large_album_art_summary">Display albums with large album art instead of in a list</string>
<string name="shuffle.title">Shuffle By</string>
<string name="shuffle.startYear">Start Year:</string>
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"/> + <CheckBoxPreference + android:title="@string/settings.large_album_art" + android:summary="@string/settings.large_album_art_summary" + android:key="largeAlbumArt" + android:defaultValue="true"/> </PreferenceCategory> <PreferenceCategory 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; - } + } } |