diff options
author | Scott Jackson <daneren2005@gmail.com> | 2012-11-10 20:43:57 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2012-11-10 20:43:57 -0800 |
commit | 2ded932e517a1b53f5f61297c5b062fadee30045 (patch) | |
tree | f613496eee9f0ecf4948afab60b84d0155683ddd | |
parent | f2bbdbe89234a0e0ac0991eac323a7fc0b729d59 (diff) | |
download | dsub-2ded932e517a1b53f5f61297c5b062fadee30045.tar.gz dsub-2ded932e517a1b53f5f61297c5b062fadee30045.tar.bz2 dsub-2ded932e517a1b53f5f61297c5b062fadee30045.zip |
Made arrows on artist/albums/playlists clickable to quickly bring up context menus #47
8 files changed, 141 insertions, 77 deletions
diff --git a/subsonic-android/res/layout/album_list_item.xml b/subsonic-android/res/layout/album_list_item.xml index 6bd12fd1..d76f105f 100644 --- a/subsonic-android/res/layout/album_list_item.xml +++ b/subsonic-android/res/layout/album_list_item.xml @@ -44,13 +44,15 @@ android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:src="@drawable/ic_stat_star"
- android:background="@null"
+ android:background="@android:color/transparent"
android:focusable="false"/>
<ImageView
- android:src="@drawable/list_item_more"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="right|center_vertical"
- android:paddingRight="6dip"/>
+ android:id="@+id/album_more"
+ android:src="@drawable/list_item_more"
+ android:layout_width="wrap_content"
+ android:layout_height="fill_parent"
+ android:layout_gravity="right|center_vertical"
+ android:paddingRight="6dip"
+ android:background="@drawable/menubar_button"/>
</LinearLayout>
diff --git a/subsonic-android/res/layout/artist_list_item.xml b/subsonic-android/res/layout/artist_list_item.xml index ed78b543..09ecd802 100644 --- a/subsonic-android/res/layout/artist_list_item.xml +++ b/subsonic-android/res/layout/artist_list_item.xml @@ -21,13 +21,15 @@ android:layout_height="wrap_content" android:layout_gravity="right|center_vertical" android:src="@drawable/ic_stat_star" - android:background="@null" + android:background="@android:color/transparent" android:focusable="false"/> <ImageView + android:id="@+id/artist_more" android:src="@drawable/list_item_more" android:layout_width="wrap_content" - android:layout_height="wrap_content" + android:layout_height="fill_parent" android:layout_gravity="right|center_vertical" - android:paddingRight="6dip"/> + android:paddingRight="6dip" + android:background="@drawable/menubar_button"/> </LinearLayout>
\ No newline at end of file diff --git a/subsonic-android/res/layout/playlist_list_item.xml b/subsonic-android/res/layout/playlist_list_item.xml index 3c99ccbd..1ec5753f 100644 --- a/subsonic-android/res/layout/playlist_list_item.xml +++ b/subsonic-android/res/layout/playlist_list_item.xml @@ -1,12 +1,26 @@ <?xml version="1.0" encoding="utf-8"?> -<TextView xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@android:id/text1" - android:drawableRight="@drawable/list_item_more" - android:drawablePadding="6dip" - android:layout_width="fill_parent" - android:layout_height="wrap_content" - android:textAppearance="?android:attr/textAppearanceMedium" - android:gravity="center_vertical" - android:paddingLeft="6dip" - android:paddingRight="6dip" - android:minHeight="50dip"/>
\ No newline at end of file +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="horizontal" + android:layout_width="fill_parent" + android:layout_height="wrap_content"> + + <TextView + android:id="@+id/playlist_name" + android:layout_width="0dip" + android:layout_height="wrap_content" + android:layout_weight="1" + android:textAppearance="?android:attr/textAppearanceMedium" + android:gravity="left|center_vertical" + android:paddingLeft="6dip" + android:paddingRight="6dip" + android:minHeight="50dip"/> + + <ImageView + android:id="@+id/playlist_more" + android:src="@drawable/list_item_more" + android:layout_width="wrap_content" + android:layout_height="fill_parent" + android:layout_gravity="right|center_vertical" + android:paddingRight="6dip" + android:background="@drawable/menubar_button"/> +</LinearLayout>
\ No newline at end of file diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java index 84a10d08..a88cdcaf 100644 --- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java +++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java @@ -19,6 +19,7 @@ package github.daneren2005.dsub.activity; +import github.daneren2005.dsub.view.PlaylistAdapter; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; diff --git a/subsonic-android/src/github/daneren2005/dsub/view/AlbumView.java b/subsonic-android/src/github/daneren2005/dsub/view/AlbumView.java index 1636776c..6415984f 100644 --- a/subsonic-android/src/github/daneren2005/dsub/view/AlbumView.java +++ b/subsonic-android/src/github/daneren2005/dsub/view/AlbumView.java @@ -22,6 +22,7 @@ import android.content.Context; 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; @@ -41,6 +42,7 @@ public class AlbumView extends UpdateView { private TextView artistView; private View coverArtView; private ImageButton starButton; + private ImageView moreButton; public AlbumView(Context context) { super(context); @@ -50,6 +52,13 @@ public class AlbumView extends UpdateView { artistView = (TextView) findViewById(R.id.album_artist); coverArtView = findViewById(R.id.album_coverart); starButton = (ImageButton) findViewById(R.id.album_star); + + moreButton = (ImageView) findViewById(R.id.album_more); + moreButton.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + v.showContextMenu(); + } + }); } public void setAlbum(MusicDirectory.Entry album, ImageLoader imageLoader) { diff --git a/subsonic-android/src/github/daneren2005/dsub/view/ArtistView.java b/subsonic-android/src/github/daneren2005/dsub/view/ArtistView.java index 8eaca821..86c39d14 100644 --- a/subsonic-android/src/github/daneren2005/dsub/view/ArtistView.java +++ b/subsonic-android/src/github/daneren2005/dsub/view/ArtistView.java @@ -22,10 +22,10 @@ import android.content.Context; 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.Artist;
-import github.daneren2005.dsub.util.ImageLoader;
import github.daneren2005.dsub.util.Util;
/**
@@ -40,6 +40,7 @@ public class ArtistView extends UpdateView { private TextView titleView;
private ImageButton starButton;
+ private ImageView moreButton;
public ArtistView(Context context) {
super(context);
@@ -47,6 +48,12 @@ public class ArtistView extends UpdateView { titleView = (TextView) findViewById(R.id.artist_name);
starButton = (ImageButton) findViewById(R.id.artist_star);
+ moreButton = (ImageView) findViewById(R.id.artist_more);
+ moreButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ v.showContextMenu();
+ }
+ });
}
public void setArtist(Artist artist) {
diff --git a/subsonic-android/src/github/daneren2005/dsub/view/PlaylistAdapter.java b/subsonic-android/src/github/daneren2005/dsub/view/PlaylistAdapter.java index 54379150..c9377721 100644 --- a/subsonic-android/src/github/daneren2005/dsub/view/PlaylistAdapter.java +++ b/subsonic-android/src/github/daneren2005/dsub/view/PlaylistAdapter.java @@ -14,77 +14,46 @@ 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 + Copyright 2010 (C) Sindre Mehus */ package github.daneren2005.dsub.view; -import android.content.Context; -import android.widget.ArrayAdapter; -import android.widget.SectionIndexer; import github.daneren2005.dsub.R; +import java.util.List; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import github.daneren2005.dsub.activity.SubsonicTabActivity; import github.daneren2005.dsub.domain.Playlist; - -import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; /** -* @author Sindre Mehus -* @version $Id$ -*/ -public class PlaylistAdapter extends ArrayAdapter<Playlist> implements SectionIndexer { - - // Both arrays are indexed by section ID. - private final Object[] sections; - private final Integer[] positions; - - /** - * Note: playlists must be sorted alphabetically. - */ - public PlaylistAdapter(Context context, List<Playlist> playlists) { - super(context, R.layout.playlist_list_item, playlists); - - Set<String> sectionSet = new LinkedHashSet<String>(30); - List<Integer> positionList = new ArrayList<Integer>(30); - for (int i = 0; i < playlists.size(); i++) { - Playlist playlist = playlists.get(i); - if (playlist.getName().length() > 0) { - String index = playlist.getName().substring(0, 1).toUpperCase(); - if (!sectionSet.contains(index)) { - sectionSet.add(index); - positionList.add(i); - } - } - } - sections = sectionSet.toArray(new Object[sectionSet.size()]); - positions = positionList.toArray(new Integer[positionList.size()]); - } + * @author Sindre Mehus + */ +public class PlaylistAdapter extends ArrayAdapter<Playlist> { - @Override - public Object[] getSections() { - return sections; - } + private final SubsonicTabActivity activity; - @Override - public int getPositionForSection(int section) { - section = Math.min(section, positions.length - 1); - return positions[section]; + public PlaylistAdapter(SubsonicTabActivity activity, List<Playlist> Playlists) { + super(activity, R.layout.playlist_list_item, Playlists); + this.activity = activity; } @Override - public int getSectionForPosition(int pos) { - for (int i = 0; i < sections.length - 1; i++) { - if (pos < positions[i + 1]) { - return i; - } - } - return sections.length - 1; + public View getView(int position, View convertView, ViewGroup parent) { + Playlist entry = getItem(position); + PlaylistView view; + if (convertView != null && convertView instanceof PlaylistView) { + view = (PlaylistView) convertView; + } else { + view = new PlaylistView(activity); + } + view.setPlaylist(entry); + return view; } - - public static class PlaylistComparator implements Comparator<Playlist> { + + public static class PlaylistComparator implements Comparator<Playlist> { @Override public int compare(Playlist playlist1, Playlist playlist2) { return playlist1.getName().compareToIgnoreCase(playlist2.getName()); diff --git a/subsonic-android/src/github/daneren2005/dsub/view/PlaylistView.java b/subsonic-android/src/github/daneren2005/dsub/view/PlaylistView.java new file mode 100644 index 00000000..d1b9340a --- /dev/null +++ b/subsonic-android/src/github/daneren2005/dsub/view/PlaylistView.java @@ -0,0 +1,60 @@ +/*
+ 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.view.LayoutInflater;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.domain.Playlist;
+
+/**
+ * Used to display albums in a {@code ListView}.
+ *
+ * @author Sindre Mehus
+ */
+public class PlaylistView extends UpdateView {
+ private static final String TAG = ArtistView.class.getSimpleName();
+
+ private Playlist playlist;
+
+ private TextView titleView;
+ private ImageView moreButton;
+
+ public PlaylistView(Context context) {
+ super(context);
+ LayoutInflater.from(context).inflate(R.layout.artist_list_item, this, true);
+
+ titleView = (TextView) findViewById(R.id.artist_name);
+ moreButton = (ImageView) findViewById(R.id.artist_more);
+ moreButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ v.showContextMenu();
+ }
+ });
+ }
+
+ public void setPlaylist(Playlist playlist) {
+ this.playlist = playlist;
+
+ titleView.setText(playlist.getName());
+ }
+}
|