[Android] Audio player: make the layout of the playlist items correspond to the design

Adrien Maglo git at videolan.org
Mon Jan 20 15:35:17 CET 2014


vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Mon Jan 20 15:35:08 2014 +0100| [92c29a3a015d074ab17f41b19a45d44e0900c78e] | committer: Adrien Maglo

Audio player: make the layout of the playlist items correspond to the design

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=92c29a3a015d074ab17f41b19a45d44e0900c78e
---

 vlc-android/res/drawable/ic_move_media.png         |  Bin 0 -> 3178 bytes
 vlc-android/res/layout/audio_playlist_item.xml     |   75 ++++++++++++++++++++
 vlc-android/res/values-v11/styles.xml              |    2 +
 vlc-android/res/values/attrs.xml                   |    1 +
 vlc-android/res/values/colors.xml                  |    1 +
 vlc-android/res/values/styles.xml                  |    3 +
 .../videolan/vlc/gui/audio/AudioListAdapter.java   |   27 ++++---
 7 files changed, 95 insertions(+), 14 deletions(-)

diff --git a/vlc-android/res/drawable/ic_move_media.png b/vlc-android/res/drawable/ic_move_media.png
new file mode 100644
index 0000000..2418c26
Binary files /dev/null and b/vlc-android/res/drawable/ic_move_media.png differ
diff --git a/vlc-android/res/layout/audio_playlist_item.xml b/vlc-android/res/layout/audio_playlist_item.xml
new file mode 100644
index 0000000..e45090e
--- /dev/null
+++ b/vlc-android/res/layout/audio_playlist_item.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="wrap_content"
+    android:descendantFocusability="blocksDescendants"
+    android:orientation="vertical" >
+
+    <LinearLayout
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="10dp"
+        android:layout_weight="1"
+        android:orientation="horizontal" >
+
+        <LinearLayout
+            android:layout_width="0dip"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            android:gravity="center_vertical"
+            android:orientation="vertical" >
+
+            <TextView
+                android:id="@+id/title"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="5dip"
+                android:layout_marginRight="5dip"
+                android:layout_marginTop="5dip"
+                android:singleLine="true"
+                android:text="@string/title"
+                android:textColor="@color/list_title"
+                android:textSize="16sp" />
+
+            <TextView
+                android:id="@+id/artist"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginBottom="5dip"
+                android:layout_marginLeft="5dip"
+                android:layout_marginRight="5dip"
+                android:singleLine="true"
+                android:text="@string/artist"
+                android:textColor="@color/list_subtitle"
+                android:textSize="11sp" />
+        </LinearLayout>
+
+        <View
+            android:layout_width="1dp"
+            android:layout_height="match_parent"
+            android:layout_gravity="center"
+            android:layout_marginBottom="8dp"
+            android:layout_marginTop="8dp"
+            android:background="?attr/playlist_item_footer" />
+
+        <ImageButton
+            android:id="@+id/move"
+            android:layout_width="30dp"
+            android:layout_height="30dp"
+            android:layout_gravity="center"
+            android:layout_marginLeft="5dp"
+            android:layout_marginRight="5dp"
+            android:background="#00000000"
+            android:scaleType="fitXY"
+            android:src="@drawable/ic_move_media" />
+    </LinearLayout>
+
+    <View
+        android:layout_width="match_parent"
+        android:layout_height="1dp"
+        android:layout_gravity="center"
+        android:layout_marginLeft="10dp"
+        android:layout_marginRight="10dp"
+        android:background="?attr/playlist_item_footer" />
+
+</LinearLayout>
\ No newline at end of file
diff --git a/vlc-android/res/values-v11/styles.xml b/vlc-android/res/values-v11/styles.xml
index 83dd859..4a29da3 100644
--- a/vlc-android/res/values-v11/styles.xml
+++ b/vlc-android/res/values-v11/styles.xml
@@ -13,6 +13,8 @@
         <item name="item_divider">@color/item_divider</item>
         <item name="item_common_pressed">@color/item_common_pressed</item>
         <item name="item_common_selected">@color/item_common_selected</item>
+        <item name="item_footer">@color/item_footer</item>
+        <item name="playlist_item_footer">@color/playlist_item_footer</item>
         <item name="background_menu_divider">@color/background_menu_divider</item>
         <item name="background_menu">@color/background_menu</item>
         <item name="background_player">@color/background_player</item>
diff --git a/vlc-android/res/values/attrs.xml b/vlc-android/res/values/attrs.xml
index 2ca445f..6d85d27 100644
--- a/vlc-android/res/values/attrs.xml
+++ b/vlc-android/res/values/attrs.xml
@@ -5,6 +5,7 @@
     <attr name="item_common_pressed" format="reference|color" />
     <attr name="item_common_selected" format="reference|color" />
     <attr name="item_footer" format="reference|color" />
+    <attr name="playlist_item_footer" format="reference|color" />
     <attr name="background_menu_divider" format="reference|color" />
     <attr name="background_menu" format="reference|color" />
     <attr name="background_player" format="reference|color" />
diff --git a/vlc-android/res/values/colors.xml b/vlc-android/res/values/colors.xml
index fa9760f..446dc9d 100644
--- a/vlc-android/res/values/colors.xml
+++ b/vlc-android/res/values/colors.xml
@@ -5,6 +5,7 @@
     <color name="item_common_pressed">#e0e0e0</color>
     <color name="item_common_selected">#5e5e5e</color>
     <color name="item_footer">#e0e0e0</color>
+    <color name="playlist_item_footer">#d0d0d0</color>
     <color name="background_common">#f2f1f0</color>
     <color name="background_player">#fafaf9</color>
     <color name="background_menu_divider">#d0d0d0</color>
diff --git a/vlc-android/res/values/styles.xml b/vlc-android/res/values/styles.xml
index 5750c6d..3100a32 100644
--- a/vlc-android/res/values/styles.xml
+++ b/vlc-android/res/values/styles.xml
@@ -20,6 +20,7 @@
         <item name="item_common_pressed">@color/item_common_pressed</item>
         <item name="item_common_selected">@color/item_common_selected</item>
         <item name="item_footer">@color/item_footer</item>
+        <item name="playlist_item_footer">@color/playlist_item_footer</item>
         <item name="background_menu_divider">@color/background_menu_divider</item>
         <item name="background_menu">@color/background_menu</item>
         <item name="background_player">@color/background_player</item>
@@ -53,8 +54,10 @@
         <item name="item_common_pressed">@color/item_common_pressed</item>
         <item name="item_common_selected">@color/item_common_selected</item>
         <item name="item_footer">@color/item_footer</item>
+        <item name="playlist_item_footer">@color/playlist_item_footer</item>
         <item name="background_menu_divider">@color/background_menu_divider</item>
         <item name="background_menu">@color/background_menu</item>
+        <item name="background_player">@color/background_player</item>
         <item name="font_default">@color/font_default</item>
         <item name="font_light">@color/font_light</item>
         <item name="orange">@color/orange</item>
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioListAdapter.java
index ddaeddb..5070da0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioListAdapter.java
@@ -24,17 +24,16 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.videolan.libvlc.Media;
-import org.videolan.vlc.BitmapCache;
 import org.videolan.vlc.R;
 
 import android.content.Context;
 import android.content.res.ColorStateList;
-import android.graphics.Bitmap;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.View.OnClickListener;
 import android.view.ViewGroup;
 import android.widget.ArrayAdapter;
-import android.widget.ImageView;
+import android.widget.ImageButton;
 import android.widget.TextView;
 
 public class AudioListAdapter extends ArrayAdapter<Media> {
@@ -76,30 +75,31 @@ public class AudioListAdapter extends ArrayAdapter<Media> {
         View v = convertView;
         if (v == null) {
             LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-            v = inflater.inflate(R.layout.audio_browser_item, parent, false);
+            v = inflater.inflate(R.layout.audio_playlist_item, parent, false);
             holder = new ViewHolder();
-            holder.layout = v.findViewById(R.id.layout_item);
-            holder.cover = (ImageView) v.findViewById(R.id.cover);
             holder.title = (TextView) v.findViewById(R.id.title);
             holder.artist = (TextView) v.findViewById(R.id.artist);
+            holder.moveButton = (ImageButton) v.findViewById(R.id.move);
             v.setTag(holder);
         } else
             holder = (ViewHolder) v.getTag();
 
         Media media = getItem(position);
 
-        Bitmap cover = AudioUtil.getCover(v.getContext(), media, 64);
-        if (cover == null)
-            cover = BitmapCache.GetFromResource(v, R.drawable.icon);
-
-        holder.cover.setImageBitmap(cover);
-
         holder.title.setText(media.getTitle());
         ColorStateList titleColor = v.getResources().getColorStateList(mCurrentIndex == position
                 ? R.color.list_title_last
                 : R.color.list_title);
         holder.title.setTextColor(titleColor);
         holder.artist.setText(media.getSubtitle());
+
+        holder.moveButton.setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                // TODO Start dragging.
+            }
+        });
+
         return v;
     }
 
@@ -119,9 +119,8 @@ public class AudioListAdapter extends ArrayAdapter<Media> {
     }
 
     static class ViewHolder {
-        View layout;
-        ImageView cover;
         TextView title;
         TextView artist;
+        ImageButton moveButton;
     }
 }



More information about the Android mailing list