[Android] [PATCH 1/2] AudioBrowserFragment: focus related resource improvements

Mik Amchislavsky hailmikhail at gmail.com
Mon Oct 6 05:40:17 CEST 2014


diff --git a/vlc-android/res/drawable/background_header_item.xml b/vlc-android/res/drawable/background_header_item.xml
new file mode 100644
index 0000000..0089988
--- /dev/null
+++ b/vlc-android/res/drawable/background_header_item.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:state_focused="true" android:state_selected="false">
+        <shape android:shape="rectangle">
+            <solid android:color="@color/darkgrey" />
+        </shape>
+    </item>
+    <item android:state_pressed="true">
+        <shape android:shape="rectangle">
+            <solid android:color="@color/orange" />
+        </shape>
+    </item>
+    <item android:state_selected="true">
+        <shape android:shape="rectangle">
+            <solid android:color="@color/darkorange" />
+        </shape>
+    </item>
+    <item android:state_focused="false" android:state_selected="false">
+        <shape android:shape="rectangle">
+            <solid android:color="@color/background_menu" />
+        </shape>
+    </item>    
+</selector>
diff --git a/vlc-android/res/drawable/tab_focused.xml b/vlc-android/res/drawable/tab_focused.xml
new file mode 100644
index 0000000..9e8e05b
--- /dev/null
+++ b/vlc-android/res/drawable/tab_focused.xml
@@ -0,0 +1,27 @@
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item>
+        <shape android:shape="rectangle" >
+            <solid android:color="#FFcccccc" />
+        </shape>
+    </item>
+    <item
+        android:bottom="0dp"
+        android:left="-7dp"
+        android:right="-7dp"
+        android:top="-7dp">
+        <shape android:shape="rectangle" >
+            <padding
+                android:bottom="15dp"
+                android:left="10dp"
+                android:right="10dp"
+                android:top="15dp" />
+            <stroke
+                android:width="6dp"
+                android:color="@color/darkorange" />
+                
+            <solid android:color="#00000000" />
+        </shape>
+    </item>
+
+</layer-list>
diff --git a/vlc-android/res/drawable/tab_indicator.xml b/vlc-android/res/drawable/tab_indicator.xml
index dd89988..a7b5394 100644
--- a/vlc-android/res/drawable/tab_indicator.xml
+++ b/vlc-android/res/drawable/tab_indicator.xml
@@ -4,6 +4,9 @@
     <item android:drawable="@drawable/tab_unselected" android:state_focused="false" android:state_pressed="false" android:state_selected="false"/>
     <item android:drawable="@drawable/tab_selected" android:state_focused="false" android:state_pressed="false" android:state_selected="true"/>
 
+    <!-- Focused state -->
+    <item android:drawable="@drawable/tab_focused" android:state_focused="true"/>
+
     <!-- Pressed -->
     <item android:drawable="@drawable/tab_pressed" android:state_pressed="true" android:state_selected="true"/>
     <item android:drawable="@drawable/tab_pressed" android:state_pressed="true"/>
diff --git a/vlc-android/res/layout/audio_albums_songs.xml b/vlc-android/res/layout/audio_albums_songs.xml
index 1b2916c..9676501 100644
--- a/vlc-android/res/layout/audio_albums_songs.xml
+++ b/vlc-android/res/layout/audio_albums_songs.xml
@@ -34,7 +34,10 @@
                     android:fastScrollEnabled="true"
                     android:paddingBottom="@dimen/listview_bottom_padding"
                     android:paddingLeft="20dp"
-                    android:paddingRight="20dp" />
+                    android:paddingRight="20dp"
+                    android:nextFocusDown="@id/albums"
+                    android:nextFocusLeft="@id/albums"
+                    android:nextFocusRight="@id/albums" />
 
                 <ListView
                     android:id="@+id/songs"
@@ -44,9 +47,12 @@
                     android:fastScrollEnabled="true"
                     android:paddingBottom="@dimen/listview_bottom_padding"
                     android:paddingLeft="20dp"
-                    android:paddingRight="20dp" />
+                    android:paddingRight="20dp"
+                    android:nextFocusDown="@id/songs"
+                    android:nextFocusLeft="@id/songs"
+                    android:nextFocusRight="@id/songs" />
             </org.videolan.vlc.widget.FlingViewGroup>
         </FrameLayout>
     </LinearLayout>
 
-</TabHost>
\ No newline at end of file
+</TabHost>
diff --git a/vlc-android/res/layout/audio_browser.xml b/vlc-android/res/layout/audio_browser.xml
index 68e70af..9a7ea4b 100644
--- a/vlc-android/res/layout/audio_browser.xml
+++ b/vlc-android/res/layout/audio_browser.xml
@@ -13,7 +13,11 @@
 	        android:fadingEdge="none"
 	        android:layout_width="fill_parent"
 	        android:layout_height="wrap_content"
-	        android:background="?attr/background_header">
+	        android:background="@drawable/background_header_item"
+	        android:nextFocusUp="@+id/ml_menu_search"
+	        android:nextFocusDown="@id/header"
+	        android:nextFocusLeft="@id/header"
+	        android:nextFocusRight="@id/header" >
 	        <LinearLayout
 	            android:id="@+id/header_layout"
 	            android:layout_width="wrap_content"
@@ -97,7 +101,12 @@
             android:paddingRight="20dp"
             android:fastScrollEnabled="true"
             android:paddingBottom="@dimen/listview_bottom_padding"
-            android:clipToPadding="false" />
+            android:clipToPadding="false"
+            android:focusable="true"
+            android:nextFocusUp="@id/header"
+            android:nextFocusDown="@id/header"
+            android:nextFocusLeft="@id/artists_list"
+            android:nextFocusRight="@+id/albums_list" />
         <ListView
             android:id="@+id/albums_list"
             android:layout_width="fill_parent"
@@ -106,7 +115,12 @@
             android:paddingRight="20dp"
             android:fastScrollEnabled="true"
             android:paddingBottom="@dimen/listview_bottom_padding"
-            android:clipToPadding="false" />
+            android:clipToPadding="false"
+            android:focusable="true"
+            android:nextFocusUp="@id/header"
+            android:nextFocusDown="@id/header"
+            android:nextFocusLeft="@id/artists_list"
+            android:nextFocusRight="@+id/songs_list" />
        <ListView
             android:id="@+id/songs_list"
             android:layout_width="fill_parent"
@@ -115,7 +129,12 @@
             android:paddingRight="20dp"
             android:fastScrollEnabled="true"
             android:paddingBottom="@dimen/listview_bottom_padding"
-            android:clipToPadding="false" />
+            android:clipToPadding="false"
+            android:focusable="true"
+            android:nextFocusUp="@id/header"
+            android:nextFocusDown="@id/header"
+            android:nextFocusLeft="@id/albums_list"
+            android:nextFocusRight="@+id/genres_list" />
         <ListView
             android:id="@+id/genres_list"
             android:layout_width="fill_parent"
@@ -124,6 +143,11 @@
             android:paddingRight="20dp"
             android:fastScrollEnabled="true"
             android:paddingBottom="@dimen/listview_bottom_padding"
-            android:clipToPadding="false" />
+            android:clipToPadding="false"
+            android:focusable="true"
+            android:nextFocusUp="@id/header"
+            android:nextFocusDown="@id/header"
+            android:nextFocusLeft="@id/songs_list"
+            android:nextFocusRight="@id/genres_list" />
     </org.videolan.vlc.widget.FlingViewGroup>
 </LinearLayout>
-- 
1.7.9.5



More information about the Android mailing list