[Android] GUI: define style attributes for the shadows.

Adrien Maglo git at videolan.org
Mon Mar 3 10:35:05 CET 2014


vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Mon Mar  3 10:34:59 2014 +0100| [f1d6ae33271e05a13db9c30e602d9805a1085457] | committer: Adrien Maglo

GUI: define style attributes for the shadows.

Do not display shadows for the black theme.

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

 vlc-android/res/values/attrs.xml                            |    3 +++
 vlc-android/res/values/styles.xml                           |    6 ++++++
 vlc-android/src/org/videolan/vlc/gui/MainActivity.java      |    4 +++-
 .../src/org/videolan/vlc/gui/audio/AudioPlaylistView.java   |   11 +++++++++--
 4 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/vlc-android/res/values/attrs.xml b/vlc-android/res/values/attrs.xml
index 04cd2e1..23ef9ec 100644
--- a/vlc-android/res/values/attrs.xml
+++ b/vlc-android/res/values/attrs.xml
@@ -28,6 +28,9 @@
     <attr name="ic_down_style" format="reference" />
     <attr name="ic_up_style" format="reference" />
 
+    <attr name="mini_player_top_shadow" format="reference" />
+    <attr name="audio_playlist_shadow" format="reference" />
+
     <declare-styleable name="SlidingPaneLayout">
         <attr name="overhangSize" format="dimension" />
     </declare-styleable>
diff --git a/vlc-android/res/values/styles.xml b/vlc-android/res/values/styles.xml
index 6170da4..7f3dc3f 100644
--- a/vlc-android/res/values/styles.xml
+++ b/vlc-android/res/values/styles.xml
@@ -37,6 +37,9 @@
         <item name="list_title_last">@color/list_title_last</item>
         <item name="list_title">@color/list_title</item>
         <item name="android:windowBackground">@color/background_common</item>
+
+        <item name="mini_player_top_shadow">@drawable/mini_player_top_shadow</item>
+        <item name="audio_playlist_shadow">@drawable/audio_playlist_shadow</item>
     </style>
 
     <style name="Theme.VLC.Black" parent="Theme.VLC">
@@ -47,6 +50,9 @@
         <item name="background_playlist">@color/font_default</item>
         <item name="list_title">@color/bt_list_title</item>
         <item name="android:windowBackground">@color/font_default</item>
+
+        <item name="mini_player_top_shadow">@null</item>
+        <item name="audio_playlist_shadow">@null</item>
     </style>
 
     <style name="Theme.VLC.List">
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index e6148e7..d27cff6 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -890,7 +890,9 @@ public class MainActivity extends SherlockFragmentActivity {
 
             @Override
             public void onPanelOpened() {
-                mSlidingPane.setShadowResource(R.drawable.mini_player_top_shadow);
+                int resId = Util.getResourceFromAttribute(MainActivity.this, R.attr.mini_player_top_shadow);
+                if (resId != 0)
+                    mSlidingPane.setShadowResource(resId);
                 mAudioPlayer.setHeaderVisibilities(false, false, true, true, true);
                 mMenu.setSlidingEnabled(true);
             }
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistView.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistView.java
index 2a4a2c5..0fb1064 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistView.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistView.java
@@ -21,6 +21,7 @@
 package org.videolan.vlc.gui.audio;
 
 import org.videolan.vlc.R;
+import org.videolan.vlc.Util;
 
 import android.content.Context;
 import android.graphics.Canvas;
@@ -46,6 +47,8 @@ public class AudioPlaylistView extends ListView {
     private OnItemRemovedListener mOnItemRemovedListener;
     private OnItemLongClickListener mOnItemLongClickListener;
 
+    Drawable mShadowDrawable;
+
     public AudioPlaylistView(Context context, AttributeSet attrs) {
         super(context, attrs);
 
@@ -53,6 +56,9 @@ public class AudioPlaylistView extends ListView {
 
         LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
         mDragShadow = inflater.inflate(R.layout.audio_playlist_item_drag_shadow, this, false);
+
+        int resId = Util.getResourceFromAttribute(context, R.attr.audio_playlist_shadow);
+        mShadowDrawable = resId != 0 ? getResources().getDrawable(resId) : null;
     }
 
     @Override
@@ -139,9 +145,10 @@ public class AudioPlaylistView extends ListView {
     public void draw(Canvas c) {
         super.draw(c);
 
-        // Draw the top and bottom list shadows.
-        Drawable mShadowDrawable = getResources().getDrawable(R.drawable.audio_playlist_shadow);
+        if (mShadowDrawable == null)
+            return;
 
+        // Draw the top and bottom list shadows.
         final int shadowHeight = mShadowDrawable.getIntrinsicHeight();
         final int right = getRight();
         final int left = getLeft();



More information about the Android mailing list