[Android] AudioPlayer Header: focus related improvement for R.id.header_play_pause

Mik Amchislavsky git at videolan.org
Thu Oct 16 12:13:35 CEST 2014


vlc-ports/android | branch: tv | Mik Amchislavsky <hailmikhail at gmail.com> | Mon Oct 13 04:03:17 2014 -0700| [f4fc742060fad70d4c2e0bd589e523ac5aa6897d] | committer: Geoffrey Métais

AudioPlayer Header: focus related improvement for R.id.header_play_pause

Signed-off-by: Geoffrey Métais <geoffrey.metais at gmail.com>

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

 vlc-android/res/drawable/ic_pause_for_header_play_pause.xml   |    7 +++++++
 vlc-android/res/drawable/ic_pause_for_header_play_pause_w.xml |    7 +++++++
 vlc-android/res/drawable/ic_play_for_header_play_pause.xml    |    7 +++++++
 vlc-android/res/drawable/ic_play_for_header_play_pause_w.xml  |    7 +++++++
 vlc-android/res/layout/audio_player.xml                       |    9 +++++++--
 vlc-android/res/values/attrs.xml                              |    4 +++-
 vlc-android/res/values/styles.xml                             |    4 ++++
 vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java   |    4 ++--
 8 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/vlc-android/res/drawable/ic_pause_for_header_play_pause.xml b/vlc-android/res/drawable/ic_pause_for_header_play_pause.xml
new file mode 100644
index 0000000..4b857ed
--- /dev/null
+++ b/vlc-android/res/drawable/ic_pause_for_header_play_pause.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">  
+    <item android:drawable="@drawable/ic_pause_pressed_w" android:state_focused="true" android:state_pressed="false"/>
+    <item android:drawable="@drawable/ic_pause_pressed" android:state_focused="true" android:state_pressed="true"/>
+    <item android:drawable="@drawable/ic_pause_pressed" android:state_focused="false" android:state_pressed="true"/>
+    <item android:drawable="@drawable/ic_pause_normal"/>    
+</selector>
diff --git a/vlc-android/res/drawable/ic_pause_for_header_play_pause_w.xml b/vlc-android/res/drawable/ic_pause_for_header_play_pause_w.xml
new file mode 100644
index 0000000..0ef436d
--- /dev/null
+++ b/vlc-android/res/drawable/ic_pause_for_header_play_pause_w.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">  
+    <item android:drawable="@drawable/ic_pause_pressed" android:state_focused="true" android:state_pressed="false"/>
+    <item android:drawable="@drawable/ic_pause_pressed_w" android:state_focused="true" android:state_pressed="true"/>
+    <item android:drawable="@drawable/ic_pause_pressed_w" android:state_focused="false" android:state_pressed="true"/>
+    <item android:drawable="@drawable/ic_pause_normal_w"/>    
+</selector>
diff --git a/vlc-android/res/drawable/ic_play_for_header_play_pause.xml b/vlc-android/res/drawable/ic_play_for_header_play_pause.xml
new file mode 100644
index 0000000..5f7458b
--- /dev/null
+++ b/vlc-android/res/drawable/ic_play_for_header_play_pause.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">  
+    <item android:drawable="@drawable/ic_play_pressed_w" android:state_focused="true" android:state_pressed="false"/>
+    <item android:drawable="@drawable/ic_play_pressed" android:state_focused="true" android:state_pressed="true"/>
+    <item android:drawable="@drawable/ic_play_pressed" android:state_focused="false" android:state_pressed="true"/>
+    <item android:drawable="@drawable/ic_play_normal"/>    
+</selector>
diff --git a/vlc-android/res/drawable/ic_play_for_header_play_pause_w.xml b/vlc-android/res/drawable/ic_play_for_header_play_pause_w.xml
new file mode 100644
index 0000000..c7f14ac
--- /dev/null
+++ b/vlc-android/res/drawable/ic_play_for_header_play_pause_w.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">  
+    <item android:drawable="@drawable/ic_play_pressed" android:state_focused="true" android:state_pressed="false"/>
+    <item android:drawable="@drawable/ic_play_pressed_w" android:state_focused="true" android:state_pressed="true"/>
+    <item android:drawable="@drawable/ic_play_pressed_w" android:state_focused="false" android:state_pressed="true"/>
+    <item android:drawable="@drawable/ic_play_normal_w"/>    
+</selector>
diff --git a/vlc-android/res/layout/audio_player.xml b/vlc-android/res/layout/audio_player.xml
index cfffd5d..e98caf6 100644
--- a/vlc-android/res/layout/audio_player.xml
+++ b/vlc-android/res/layout/audio_player.xml
@@ -76,7 +76,12 @@
             android:contentDescription="@string/pause"
             android:focusable="true"
             android:scaleType="fitXY"
-            android:src="?attr/ic_pause" />
+            android:src="?attr/ic_pause_for_header_play_pause"
+            android:nextFocusForward="@+id/header_play_pause"
+            android:nextFocusUp="@+id/ml_menu_search"
+            android:nextFocusDown="@id/header_play_pause"
+            android:nextFocusLeft="@id/header_play_pause"
+            android:nextFocusRight="@id/header_play_pause" />
 
         <View
             android:layout_width="10dp"
@@ -213,4 +218,4 @@
             android:src="?attr/ic_previous" />
     </RelativeLayout>
 
-</LinearLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/vlc-android/res/values/attrs.xml b/vlc-android/res/values/attrs.xml
index cf6a7ee..ea9d657 100644
--- a/vlc-android/res/values/attrs.xml
+++ b/vlc-android/res/values/attrs.xml
@@ -39,6 +39,8 @@
     <attr name="ic_audio_player_dots" format="reference" />
     <attr name="ic_play" format="reference" />
     <attr name="ic_pause" format="reference" />
+    <attr name="ic_play_for_header_play_pause" format="reference" />
+    <attr name="ic_pause_for_header_play_pause" format="reference" />
     <attr name="ic_previous" format="reference" />
     <attr name="ic_next" format="reference" />
     <attr name="ic_menu_video" format="reference" />
@@ -60,4 +62,4 @@
 
     <attr name="marginTopContent" format="dimension" />
 
-</resources>
\ No newline at end of file
+</resources>
diff --git a/vlc-android/res/values/styles.xml b/vlc-android/res/values/styles.xml
index 6d69293..ca844a0 100644
--- a/vlc-android/res/values/styles.xml
+++ b/vlc-android/res/values/styles.xml
@@ -58,6 +58,8 @@
         <item name="ic_audio_player_dots">@drawable/dots_dark</item>
         <item name="ic_play">@drawable/ic_play</item>
         <item name="ic_pause">@drawable/ic_pause</item>
+        <item name="ic_play_for_header_play_pause">@drawable/ic_play_for_header_play_pause</item>
+        <item name="ic_pause_for_header_play_pause">@drawable/ic_pause_for_header_play_pause</item>
         <item name="ic_previous">@drawable/ic_previous</item>
         <item name="ic_next">@drawable/ic_next</item>
         <item name="ic_menu_video">@drawable/ic_menu_video</item>
@@ -119,6 +121,8 @@
         <item name="ic_audio_player_dots">@drawable/dots</item>
         <item name="ic_play">@drawable/ic_play_w</item>
         <item name="ic_pause">@drawable/ic_pause_w</item>
+        <item name="ic_play_for_header_play_pause">@drawable/ic_play_for_header_play_pause_w</item>
+        <item name="ic_pause_for_header_play_pause">@drawable/ic_pause_for_header_play_pause_w</item>
         <item name="ic_previous">@drawable/ic_previous_w</item>
         <item name="ic_next">@drawable/ic_next_w</item>
         <item name="ic_menu_video">@drawable/ic_menu_video_w</item>
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
index 8748107..fb2f931 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlayer.java
@@ -327,12 +327,12 @@ public class AudioPlayer extends Fragment implements IAudioPlayer {
         if (mAudioController.isPlaying()) {
             mPlayPause.setImageResource(Util.getResourceFromAttribute(act, R.attr.ic_pause));
             mPlayPause.setContentDescription(getString(R.string.pause));
-            mHeaderPlayPause.setImageResource(Util.getResourceFromAttribute(act, R.attr.ic_pause));
+            mHeaderPlayPause.setImageResource(Util.getResourceFromAttribute(act, R.attr.ic_pause_for_header_play_pause));
             mHeaderPlayPause.setContentDescription(getString(R.string.pause));
         } else {
             mPlayPause.setImageResource(Util.getResourceFromAttribute(act, R.attr.ic_play));
             mPlayPause.setContentDescription(getString(R.string.play));
-            mHeaderPlayPause.setImageResource(Util.getResourceFromAttribute(act, R.attr.ic_play));
+            mHeaderPlayPause.setImageResource(Util.getResourceFromAttribute(act, R.attr.ic_play_for_header_play_pause));
             mHeaderPlayPause.setContentDescription(getString(R.string.play));
         }
         if (mAudioController.isShuffling()) {



More information about the Android mailing list