[Android] [PATCH 2/2] Use action bar menu for action and with any Android version

Geoffrey Métais geoffrey.metais at gmail.com
Wed Oct 29 15:11:34 CET 2014


---
 .../res/layout-land/player_remote_control.xml      |  55 +-----
 vlc-android/res/layout-v15/player.xml              |  75 ++------
 .../res/layout-v17/player_overlay_header.xml       |   5 -
 .../player_remote_control_overlay_header.xml       |   5 -
 vlc-android/res/layout/adv_view.xml                |   9 +
 vlc-android/res/layout/player.xml                  |  46 +----
 vlc-android/res/layout/player_action_bar.xml       |  36 ++++
 vlc-android/res/layout/player_overlay_header.xml   |  40 -----
 vlc-android/res/layout/player_remote_control.xml   |  47 +----
 .../player_remote_control_overlay_header.xml       |  44 -----
 vlc-android/res/menu/video_player.xml              |  19 ++
 vlc-android/res/values-sw600dp/dimens.xml          |   5 +-
 vlc-android/res/values-v17/styles.xml              |   2 +-
 vlc-android/res/values-v19/styles.xml              |   2 +-
 vlc-android/res/values/dimens.xml                  |   4 +-
 vlc-android/res/values/strings.xml                 |   2 +
 vlc-android/res/values/styles.xml                  |   4 +-
 .../vlc/gui/video/VideoPlayerActivity.java         | 200 +++++++++------------
 18 files changed, 186 insertions(+), 414 deletions(-)
 delete mode 100644 vlc-android/res/layout-v17/player_overlay_header.xml
 delete mode 100644 vlc-android/res/layout-v17/player_remote_control_overlay_header.xml
 create mode 100644 vlc-android/res/layout/adv_view.xml
 create mode 100644 vlc-android/res/layout/player_action_bar.xml
 delete mode 100644 vlc-android/res/layout/player_overlay_header.xml
 delete mode 100644 vlc-android/res/layout/player_remote_control_overlay_header.xml
 create mode 100644 vlc-android/res/menu/video_player.xml

diff --git a/vlc-android/res/layout-land/player_remote_control.xml b/vlc-android/res/layout-land/player_remote_control.xml
index 91a762c..fda70d7 100644
--- a/vlc-android/res/layout-land/player_remote_control.xml
+++ b/vlc-android/res/layout-land/player_remote_control.xml
@@ -63,13 +63,11 @@
             android:text="@string/please_wait"
             android:textSize="20sp" />
 
-        <include layout="@layout/player_remote_control_overlay_header" />
-
         <TextView
             android:id="@+id/player_overlay_info"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_below="@+id/player_overlay_header"
+            android:layout_below="@+id/player_overlay_loading_text"
             android:layout_centerHorizontal="true"
             android:padding="5dp"
             android:textColor="#ffffff"
@@ -90,54 +88,11 @@
                 android:layout_height="wrap_content"
                 android:background="@drawable/ic_pause_circle_big_o" />
 
-            <RelativeLayout
-                android:id="@+id/option_overlay"
+            <ImageButton
+                android:id="@+id/player_overlay_size"
                 android:layout_width="wrap_content"
-                android:layout_height="wrap_content" >
-
-                <LinearLayout
-                    android:id="@+id/option_nodvd_overlay"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_centerHorizontal="true"
-                    android:gravity="center_vertical"
-                    android:orientation="horizontal" >
-
-                    <ImageButton
-                        android:id="@+id/player_overlay_subtitle"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:background="@drawable/ic_subtitle_circle_o" />
-
-                    <ImageButton
-                        android:id="@+id/player_overlay_audio"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:background="@drawable/ic_audio_circle_o" />
-
-                    <ImageButton
-                        android:id="@+id/player_overlay_size"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:background="@drawable/ic_crop_circle_o" />
-
-                    <ImageButton
-                        android:id="@+id/player_overlay_adv_function"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:background="@drawable/ic_dots_circle_o"
-                        android:onClick="showAdvancedOptions" />
-                </LinearLayout>
-
-                <ImageButton
-                    android:id="@+id/player_overlay_navmenu"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_below="@+id/option_nodvd_overlay"
-                    android:layout_centerHorizontal="true"
-                    android:background="@drawable/ic_navmenu_circle_o"
-                    android:visibility="gone" />
-            </RelativeLayout>
+                android:layout_height="wrap_content"
+                android:background="@drawable/ic_crop_circle_o" />
         </LinearLayout>
 
         <RelativeLayout
diff --git a/vlc-android/res/layout-v15/player.xml b/vlc-android/res/layout-v15/player.xml
index 048cf5a..6fa572f 100644
--- a/vlc-android/res/layout-v15/player.xml
+++ b/vlc-android/res/layout-v15/player.xml
@@ -37,8 +37,6 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:fitsSystemWindows="true" >
-
-	    <include layout="@layout/player_overlay_header" />
 	
 	    <include
 	        android:id="@+id/player_overlay_tips"
@@ -79,7 +77,7 @@
 	    <RelativeLayout
 	        android:id="@+id/progress_overlay"
 	        android:layout_width="@dimen/overlay_width"
-	        android:layout_height="@dimen/overlay_height"
+	        android:layout_height="wrap_content"
 	        android:layout_alignParentBottom="true"
 	        android:layout_centerHorizontal="true"
 	        android:layout_marginBottom="@dimen/overlay_margin_bottom"
@@ -130,12 +128,21 @@
 	            android:id="@+id/media_controls"
 	            android:layout_width="wrap_content"
 	            android:layout_height="wrap_content"
+	            android:layout_below="@id/player_overlay_progress"
 	            android:layout_centerHorizontal="true"
 	            android:layout_centerVertical="true"
 	            android:layout_marginTop="@dimen/media_ctrl_margin_top"
 	            android:orientation="horizontal" >
 	
 	            <ImageButton
+	                android:id="@+id/lock_overlay_button"
+	                android:layout_width="wrap_content"
+	                android:layout_height="wrap_content"
+	                android:layout_marginRight="@dimen/options_margin"
+	                android:layout_gravity="center_vertical"
+	                android:background="@drawable/ic_lock" />
+
+	            <ImageButton
 	                android:id="@+id/player_overlay_backward"
 	                android:layout_width="wrap_content"
 	                android:layout_height="wrap_content"
@@ -149,8 +156,8 @@
 	                android:layout_width="wrap_content"
 	                android:layout_height="wrap_content"
 	                android:layout_gravity="center_vertical"
-	                android:layout_marginLeft="20dp"
-	                android:layout_marginRight="20dp"
+	                android:layout_marginLeft="@dimen/playpause_margin"
+	                android:layout_marginRight="@dimen/playpause_margin"
 	                android:clickable="true"
 	                android:onClick="onClick"
 	            	android:background="@drawable/ic_pause_circle"/>
@@ -163,68 +170,14 @@
 	                android:clickable="true"
 	                android:onClick="onClick"
 	                android:background="@drawable/ic_forward_normal_w" />
-	        </LinearLayout>
-	
-	        <LinearLayout
-	            android:id="@+id/option_overlay"
-	            android:layout_width="wrap_content"
-	            android:layout_height="wrap_content"
-	            android:layout_below="@+id/media_controls"
-	            android:layout_alignParentBottom="true"
-	            android:layout_alignParentRight="true"
-	            android:layout_alignParentEnd="true"
-	            android:orientation="horizontal"
-	            android:visibility="invisible" >
-	
-	            <ImageButton
-	                android:id="@+id/lock_overlay_button"
-	                android:layout_width="wrap_content"
-	                android:layout_height="wrap_content"
-	                android:layout_marginRight="@dimen/options_margin"
-	                android:layout_gravity="center_vertical"
-	                android:background="@drawable/ic_lock" />
-	
-	            <ImageButton
-	                android:id="@+id/player_overlay_subtitle"
-	                android:layout_width="wrap_content"
-	                android:layout_height="wrap_content"
-	                android:layout_marginRight="@dimen/options_margin"
-	                android:layout_gravity="center_vertical"
-	                android:background="@drawable/ic_subtitle_circle" />
-	
-	            <ImageButton
-	                android:id="@+id/player_overlay_audio"
-	                android:layout_width="wrap_content"
-	                android:layout_height="wrap_content"
-	                android:layout_marginRight="@dimen/options_margin"
-	                android:layout_gravity="center_vertical"
-	                android:background="@drawable/ic_audio_circle" />
-	
-	            <ImageButton
-	                android:id="@+id/player_overlay_navmenu"
-	                android:layout_width="wrap_content"
-	                android:layout_height="wrap_content"
-	                android:layout_marginRight="@dimen/options_margin"
-	                android:layout_gravity="center_vertical"
-	                android:background="@drawable/ic_navmenu_circle"
-	                android:visibility="visible" />
-	
+
 	            <ImageButton
 	                android:id="@+id/player_overlay_size"
 	                android:layout_width="wrap_content"
 	                android:layout_height="wrap_content"
-	                android:layout_marginRight="@dimen/options_margin"
+	                android:layout_marginLeft="@dimen/options_margin"
 	                android:layout_gravity="center_vertical"
 	                android:background="@drawable/ic_crop_circle" />
-	
-	            <ImageButton
-	                android:id="@+id/player_overlay_adv_function"
-	                android:layout_width="wrap_content"
-	                android:layout_height="wrap_content"
-	                android:layout_marginRight="@dimen/options_margin"
-	                android:layout_gravity="center_vertical"
-	                android:background="@drawable/dots"
-	                android:onClick="showAdvancedOptions" />
 	        </LinearLayout>
 	    </RelativeLayout>
     </RelativeLayout>
diff --git a/vlc-android/res/layout-v17/player_overlay_header.xml b/vlc-android/res/layout-v17/player_overlay_header.xml
deleted file mode 100644
index f91d4b3..0000000
--- a/vlc-android/res/layout-v17/player_overlay_header.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<merge xmlns:android="http://schemas.android.com/apk/res/android">
-    <!-- no Layout here: custom overlay_header is deactivated after api v17, as
-         StatusBar and ActionBar are used -->
-</merge>
diff --git a/vlc-android/res/layout-v17/player_remote_control_overlay_header.xml b/vlc-android/res/layout-v17/player_remote_control_overlay_header.xml
deleted file mode 100644
index f91d4b3..0000000
--- a/vlc-android/res/layout-v17/player_remote_control_overlay_header.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<merge xmlns:android="http://schemas.android.com/apk/res/android">
-    <!-- no Layout here: custom overlay_header is deactivated after api v17, as
-         StatusBar and ActionBar are used -->
-</merge>
diff --git a/vlc-android/res/layout/adv_view.xml b/vlc-android/res/layout/adv_view.xml
new file mode 100644
index 0000000..b01e99c
--- /dev/null
+++ b/vlc-android/res/layout/adv_view.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ImageButton xmlns:android="http://schemas.android.com/apk/res/android"
+	                android:id="@+id/player_overlay_adv_function"
+	                android:layout_width="wrap_content"
+	                android:layout_height="wrap_content"
+	                android:layout_marginRight="@dimen/options_margin"
+	                android:layout_gravity="center_vertical"
+	                android:background="@drawable/dots"
+	                android:onClick="showAdvancedOptions" />
\ No newline at end of file
diff --git a/vlc-android/res/layout/player.xml b/vlc-android/res/layout/player.xml
index 0c279d3..80fb9f1 100644
--- a/vlc-android/res/layout/player.xml
+++ b/vlc-android/res/layout/player.xml
@@ -79,44 +79,7 @@
             android:textSize="36sp"
             android:visibility="invisible" />
 
-        <include layout="@layout/player_overlay_header" />
-
-        <LinearLayout
-            android:id="@+id/option_overlay"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_above="@+id/progress_overlay"
-            android:layout_alignParentRight="true"
-            android:layout_below="@+id/player_overlay_header"
-            android:gravity="bottom|right"
-            android:orientation="vertical"
-            android:visibility="invisible" >
-
-            <ImageButton
-                android:id="@+id/player_overlay_subtitle"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:background="@drawable/ic_subtitle_circle" />
-
-            <ImageButton
-                android:id="@+id/player_overlay_audio"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:background="@drawable/ic_audio_circle" />
-
-            <ImageButton
-                android:id="@+id/player_overlay_navmenu"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:background="@drawable/ic_navmenu_circle"
-                android:visibility="visible" />
-
-            <ImageButton
-                android:id="@+id/player_overlay_size"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:background="@drawable/ic_crop_circle" />
-        </LinearLayout>
+        <!-- <include layout="@layout/player_overlay_header" /> -->
 
         <RelativeLayout
             android:id="@+id/progress_overlay"
@@ -190,18 +153,17 @@
                 android:layout_height="40dip"
                 android:layout_centerVertical="true"
                 android:layout_marginLeft="5dp"
-                android:layout_toLeftOf="@+id/player_overlay_adv_function"
+                android:layout_toLeftOf="@+id/player_overlay_size"
                 android:background="@drawable/ic_forward_w" />
 
             <ImageButton
-                android:id="@+id/player_overlay_adv_function"
+                android:id="@+id/player_overlay_size"
                 android:layout_width="wrap_content"
                 android:layout_height="wrap_content"
                 android:layout_alignParentRight="true"
                 android:layout_centerVertical="true"
                 android:layout_marginLeft="5dp"
-                android:background="@drawable/dots"
-                android:onClick="showAdvancedOptions" />
+                android:background="@drawable/ic_crop_circle" />
         </RelativeLayout>
     </RelativeLayout>
 
diff --git a/vlc-android/res/layout/player_action_bar.xml b/vlc-android/res/layout/player_action_bar.xml
new file mode 100644
index 0000000..01175ae
--- /dev/null
+++ b/vlc-android/res/layout/player_action_bar.xml
@@ -0,0 +1,36 @@
+<?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:layout_alignParentTop="true"
+    android:layout_gravity="top"
+    android:background="?attr/video_player_overlay"
+    android:layout_marginTop="10dp"
+    android:paddingLeft="5dp"
+    android:paddingRight="5dp" >
+
+    <TextView
+        android:id="@+id/player_overlay_title"
+        android:layout_width="0dp"
+        android:layout_height="fill_parent"
+        android:layout_weight="1"
+        android:gravity="center_horizontal"
+        android:text="@string/title"
+        android:textColor="#ffffff"
+        android:textSize="15sp" />
+
+    <TextView
+        android:id="@+id/player_overlay_battery"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginRight="5dp"
+        android:textColor="#ffffff"
+        android:textSize="15sp" />
+
+    <TextView
+        android:id="@+id/player_overlay_systime"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:textColor="#ffffff"
+        android:textSize="15sp" />
+</LinearLayout>
diff --git a/vlc-android/res/layout/player_overlay_header.xml b/vlc-android/res/layout/player_overlay_header.xml
deleted file mode 100644
index 5a9a462..0000000
--- a/vlc-android/res/layout/player_overlay_header.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<merge xmlns:android="http://schemas.android.com/apk/res/android">
-    <LinearLayout
-        android:id="@+id/player_overlay_header"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:layout_alignParentTop="true"
-        android:layout_gravity="top"
-        android:background="?attr/video_player_overlay"
-        android:layout_marginTop="10dp"
-        android:paddingLeft="5dp"
-        android:paddingRight="5dp"
-        android:visibility="invisible" >
-
-        <TextView
-            android:id="@+id/player_overlay_title"
-            android:layout_width="0dp"
-            android:layout_height="fill_parent"
-            android:layout_weight="1"
-            android:gravity="center_horizontal"
-            android:text="@string/title"
-            android:textColor="#ffffff"
-            android:textSize="15sp" />
-
-        <TextView
-            android:id="@+id/player_overlay_battery"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_marginRight="5dp"
-            android:textColor="#ffffff"
-            android:textSize="15sp" />
-
-        <TextView
-            android:id="@+id/player_overlay_systime"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:textColor="#ffffff"
-            android:textSize="15sp" />
-    </LinearLayout>
-</merge>
diff --git a/vlc-android/res/layout/player_remote_control.xml b/vlc-android/res/layout/player_remote_control.xml
index 95d0570..b90f7bd 100644
--- a/vlc-android/res/layout/player_remote_control.xml
+++ b/vlc-android/res/layout/player_remote_control.xml
@@ -40,13 +40,11 @@
         android:background="@color/background_remote"
         android:fitsSystemWindows="true" >
 
-        <include layout="@layout/player_remote_control_overlay_header" />
-
         <TextView
             android:id="@+id/player_overlay_info"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_below="@+id/player_overlay_header"
+            android:layout_alignParentTop="true"
             android:layout_centerHorizontal="true"
             android:padding="5dp"
             android:textColor="#ffffff"
@@ -79,48 +77,13 @@
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content" >
 
-                <LinearLayout
-                    android:id="@+id/option_nodvd_overlay"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_centerHorizontal="true"
-                    android:gravity="center_vertical"
-                    android:orientation="horizontal" >
-
-                    <ImageButton
-                        android:id="@+id/player_overlay_subtitle"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:background="@drawable/ic_subtitle_circle_o" />
-
-                    <ImageButton
-                        android:id="@+id/player_overlay_audio"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:background="@drawable/ic_audio_circle_o" />
-
-                    <ImageButton
-                        android:id="@+id/player_overlay_size"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:background="@drawable/ic_crop_circle_o" />
-
-                    <ImageButton
-                        android:id="@+id/player_overlay_adv_function"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:background="@drawable/ic_dots_circle_o"
-                        android:onClick="showAdvancedOptions" />
-                </LinearLayout>
-
                 <ImageButton
-                    android:id="@+id/player_overlay_navmenu"
+                    android:id="@+id/player_overlay_size"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:layout_alignLeft="@+id/option_nodvd_overlay"
-                    android:layout_below="@+id/option_nodvd_overlay"
-                    android:background="@drawable/ic_navmenu_circle_o"
-                    android:visibility="gone" />
+	                android:layout_centerHorizontal="true"
+	                android:gravity="center_vertical"
+                    android:background="@drawable/ic_crop_circle_o" />
             </RelativeLayout>
         </LinearLayout>
 
diff --git a/vlc-android/res/layout/player_remote_control_overlay_header.xml b/vlc-android/res/layout/player_remote_control_overlay_header.xml
deleted file mode 100644
index 7d6fe48..0000000
--- a/vlc-android/res/layout/player_remote_control_overlay_header.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<merge xmlns:android="http://schemas.android.com/apk/res/android">
-    <LinearLayout
-        android:id="@+id/player_overlay_header"
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        android:layout_alignParentTop="true"
-        android:orientation="vertical"
-        android:paddingLeft="5dp"
-        android:paddingRight="5dp" >
-
-        <LinearLayout
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_gravity="right"
-            android:orientation="horizontal" >
-
-            <TextView
-                android:id="@+id/player_overlay_battery"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_marginRight="5dp"
-                android:text="bat"
-                android:textColor="#ffffff"
-                android:textSize="15sp" />
-
-            <TextView
-                android:id="@+id/player_overlay_systime"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="time"
-                android:textColor="#ffffff"
-                android:textSize="15sp" />
-        </LinearLayout>
-
-        <TextView
-            android:id="@+id/player_overlay_title"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:text="@string/title"
-            android:textColor="#ffffff"
-            android:textSize="30sp" />
-    </LinearLayout>
-</merge>
diff --git a/vlc-android/res/menu/video_player.xml b/vlc-android/res/menu/video_player.xml
new file mode 100644
index 0000000..cad2b2d
--- /dev/null
+++ b/vlc-android/res/menu/video_player.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+    <item
+        android:id="@+id/pl_menu_audiotrack"
+        android:icon="@drawable/ic_audio_circle"
+        android:title="@string/track_audio" />
+    <item
+        android:id="@+id/pl_menu_subtitle"
+        android:icon="@drawable/ic_subtitle_circle"
+        android:title="@string/subtitles" />
+    <item
+        android:id="@+id/pl_menu_nav"
+        android:icon="@drawable/ic_navmenu_circle"
+        android:title="@string/navmenu" />
+    <item
+        android:id="@+id/pl_menu_adv"
+        android:icon="@drawable/dots"
+        android:title="@string/advanced" />
+</menu>
diff --git a/vlc-android/res/values-sw600dp/dimens.xml b/vlc-android/res/values-sw600dp/dimens.xml
index ded8585..a90810f 100644
--- a/vlc-android/res/values-sw600dp/dimens.xml
+++ b/vlc-android/res/values-sw600dp/dimens.xml
@@ -1,4 +1,7 @@
 <resources>
     <!-- Video Player -->
-    <dimen name="overlay_height">250dp</dimen>
+    <dimen name="overlay_padding_sides">30dip</dimen>
+    <dimen name="options_margin">100dp</dimen>
+    <dimen name="playpause_margin">20dp</dimen>
+    <dimen name="media_ctrl_margin_top">30dp</dimen>
 </resources>
\ No newline at end of file
diff --git a/vlc-android/res/values-v17/styles.xml b/vlc-android/res/values-v17/styles.xml
index 151b5a8..0edb8cd 100644
--- a/vlc-android/res/values-v17/styles.xml
+++ b/vlc-android/res/values-v17/styles.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <resources xmlns:android="http://schemas.android.com/apk/res/android">
-    <style name="Theme.VLC.Player" parent="android:Theme.Holo">
+    <style name="Theme.VLC.Player" parent="Theme.AppCompat">
         <item name="android:windowBackground">@color/black</item>
         <item name="android:windowActionBarOverlay">true</item>
 
diff --git a/vlc-android/res/values-v19/styles.xml b/vlc-android/res/values-v19/styles.xml
index 6f1046f..1695498 100644
--- a/vlc-android/res/values-v19/styles.xml
+++ b/vlc-android/res/values-v19/styles.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <resources xmlns:android="http://schemas.android.com/apk/res/android">
-    <style name="Theme.VLC.Player" parent="android:Theme.Holo">
+    <style name="Theme.VLC.Player" parent="Theme.AppCompat">
         <item name="android:windowBackground">@color/black</item>
         <item name="android:windowActionBarOverlay">true</item>
         <item name="android:windowTranslucentStatus">true</item>
diff --git a/vlc-android/res/values/dimens.xml b/vlc-android/res/values/dimens.xml
index bde3575..bf69d06 100644
--- a/vlc-android/res/values/dimens.xml
+++ b/vlc-android/res/values/dimens.xml
@@ -6,15 +6,15 @@
 
     <!-- Video Player -->
     <dimen name="overlay_width">800dp</dimen>
-    <dimen name="overlay_height">200dp</dimen>
     <dimen name="overlay_margin_bottom">10dip</dimen>
     <dimen name="overlay_padding_bottom">10dip</dimen>
     <dimen name="overlay_padding_top">20dip</dimen>
-    <dimen name="overlay_padding_sides">30dip</dimen>
+    <dimen name="overlay_padding_sides">20dip</dimen>
 
     <dimen name="seekbar_height">3dip</dimen>
     <dimen name="seekbar_padding_sides">20dp</dimen>
 
     <dimen name="media_ctrl_margin_top">20dp</dimen>
     <dimen name="options_margin">10dp</dimen>
+    <dimen name="playpause_margin">10dp</dimen>
 </resources>
\ No newline at end of file
diff --git a/vlc-android/res/values/strings.xml b/vlc-android/res/values/strings.xml
index bf6e2d4..941b699 100644
--- a/vlc-android/res/values/strings.xml
+++ b/vlc-android/res/values/strings.xml
@@ -116,6 +116,8 @@
     <string name="sound_on">Sound On</string>
     <string name="sound_off">Sound Off</string>
     <string name="brightness">Brightness</string>
+    <string name="navmenu">navigation menu</string>
+    <string name="advanced">advanced options</string>
 
     <plurals name="track_channels_info_quantity">
         <item quantity="one">1 channel\n</item>
diff --git a/vlc-android/res/values/styles.xml b/vlc-android/res/values/styles.xml
index 6325889..4c7a828 100644
--- a/vlc-android/res/values/styles.xml
+++ b/vlc-android/res/values/styles.xml
@@ -151,10 +151,12 @@
         <item name="android:windowBackground">@color/background_common</item>
     </style>
 
-    <style name="Theme.VLC.Player" parent="android:Theme.NoTitleBar.Fullscreen">
+    <style name="Theme.VLC.Player" parent="Theme.AppCompat">
         <item name="android:windowBackground">@color/black</item>
+        <item name="windowActionBarOverlay">true</item>
         <!-- item name="video_player_overlay">@color/transparent_gray</item-->
         <item name="video_player_overlay">@android:color/transparent</item>
+        <item name="status_bar_overlay">@android:color/transparent</item>
 
         <item name="advanced_options_style">@style/Theme.VLC.AdvancedOptionsBlack</item>
     </style>
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 3c174ea..d4623c9 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -58,8 +58,6 @@ import org.videolan.vlc.util.VLCInstance;
 import org.videolan.vlc.util.WeakHandler;
 
 import android.annotation.TargetApi;
-import android.app.ActionBar;
-import android.app.Activity;
 import android.app.AlertDialog;
 import android.app.KeyguardManager;
 import android.app.Presentation;
@@ -88,12 +86,17 @@ import android.os.Message;
 import android.preference.PreferenceManager;
 import android.provider.MediaStore;
 import android.provider.Settings.SettingNotFoundException;
+import android.support.v4.view.MenuItemCompat;
+import android.support.v7.app.ActionBar;
+import android.support.v7.app.ActionBarActivity;
 import android.text.format.DateFormat;
 import android.util.DisplayMetrics;
 import android.util.Log;
 import android.view.Display;
 import android.view.InputDevice;
 import android.view.KeyEvent;
+import android.view.Menu;
+import android.view.MenuItem;
 import android.view.MotionEvent;
 import android.view.Surface;
 import android.view.SurfaceHolder;
@@ -118,7 +121,7 @@ import android.widget.SeekBar;
 import android.widget.SeekBar.OnSeekBarChangeListener;
 import android.widget.TextView;
 
-public class VideoPlayerActivity extends Activity implements IVideoPlayer {
+public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlayer {
 
 	public final static String TAG = "VLC/VideoPlayerActivity";
 
@@ -150,9 +153,6 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
 
     /** Overlay */
     private ActionBar mActionBar;
-    private boolean mOverlayUseStatusBar;
-    private View mOverlayHeader;
-    private View mOverlayOption;
     private View mOverlayProgress;
     private View mOverlayBackground;
     private static final int OVERLAY_TIMEOUT = 4000;
@@ -184,11 +184,8 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
     private boolean mDisplayRemainingTime = false;
     private int mScreenOrientation;
     private int mScreenOrientationLock;
-    private ImageButton mAudioTrack;
-    private ImageButton mSubtitle;
     private ImageButton mLock;
     private ImageButton mSize;
-    private ImageButton mMenu;
     private boolean mIsLocked = false;
     private int mLastAudioTrack = -1;
     private int mLastSpuTrack = -2;
@@ -254,7 +251,6 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
     private static final String PREF_TIPS_SHOWN = "video_player_tips_shown";
 
     // Navigation handling (DVD, Blu-Ray...)
-    private ImageButton mNavMenu;
     private boolean mHasMenu = false;
     private boolean mIsNavMenu = false;
 
@@ -274,9 +270,6 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
                 }
             };
             Log.d(TAG, "MediaRouter information : " + mMediaRouter  .toString());
-            mOverlayUseStatusBar = true;
-        } else {
-            mOverlayUseStatusBar = false;
         }
 
         mSettings = PreferenceManager.getDefaultSharedPreferences(this);
@@ -306,33 +299,25 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
             );
 
         /** initialize Views an their Events */
-        if (mOverlayUseStatusBar) {
-            mActionBar = getActionBar();
-            mActionBar.setDisplayShowHomeEnabled(false);
-            mActionBar.setDisplayShowTitleEnabled(false);
-            mActionBar.setBackgroundDrawable(null);
-            mActionBar.setDisplayShowCustomEnabled(true);
-            mActionBar.setCustomView(R.layout.player_action_bar);
-
-            ViewGroup view = (ViewGroup) mActionBar.getCustomView();
-            /* Dispatch ActionBar touch events to the Activity */
-            view.setOnTouchListener(new View.OnTouchListener() {
-                @Override
-                public boolean onTouch(View v, MotionEvent event) {
-                    onTouchEvent(event);
-                    return true;
-                }
-            });
-            mTitle = (TextView) view.findViewById(R.id.player_overlay_title);
-            mOverlayHeader = mSysTime = mBattery = null;
-        } else {
-            mOverlayHeader = findViewById(R.id.player_overlay_header);
-            /* header */
-            mTitle = (TextView) findViewById(R.id.player_overlay_title);
-            mSysTime = (TextView) findViewById(R.id.player_overlay_systime);
-            mBattery = (TextView) findViewById(R.id.player_overlay_battery);
-        }
-        mOverlayOption = findViewById(R.id.option_overlay);
+        mActionBar = getSupportActionBar();
+        mActionBar.setDisplayShowHomeEnabled(false);
+        mActionBar.setDisplayShowTitleEnabled(false);
+        mActionBar.setBackgroundDrawable(null);
+        mActionBar.setDisplayShowCustomEnabled(true);
+        mActionBar.setCustomView(R.layout.player_action_bar);
+
+        ViewGroup view = (ViewGroup) mActionBar.getCustomView();
+        /* Dispatch ActionBar touch events to the Activity */
+        view.setOnTouchListener(new View.OnTouchListener() {
+            @Override
+            public boolean onTouch(View v, MotionEvent event) {
+                onTouchEvent(event);
+                return true;
+            }
+        });
+        mTitle = (TextView) view.findViewById(R.id.player_overlay_title);
+        mSysTime = (TextView) findViewById(R.id.player_overlay_systime);
+        mBattery = (TextView) findViewById(R.id.player_overlay_battery);
         mOverlayProgress = findViewById(R.id.progress_overlay);
         mOverlayBackground = findViewById(R.id.player_overlay_background);
 
@@ -357,19 +342,11 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
         mForward = (ImageButton) findViewById(R.id.player_overlay_forward);
         mForward.setOnClickListener(mForwardListener);
 
-        mAudioTrack = (ImageButton) findViewById(R.id.player_overlay_audio);
-        mAudioTrack.setVisibility(View.GONE);
-        mSubtitle = (ImageButton) findViewById(R.id.player_overlay_subtitle);
-        mSubtitle.setVisibility(View.GONE);
-        mNavMenu = (ImageButton) findViewById(R.id.player_overlay_navmenu);
-        mNavMenu.setVisibility(View.GONE);
-
         mLock = (ImageButton) findViewById(R.id.lock_overlay_button);
         mLock.setOnClickListener(mLockListener);
 
         mSize = (ImageButton) findViewById(R.id.player_overlay_size);
         mSize.setOnClickListener(mSizeListener);
-        mMenu = (ImageButton) findViewById(R.id.player_overlay_adv_function);
 
         try {
             mLibVLC = VLCInstance.getLibVlcInstance();
@@ -422,7 +399,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
         editor.commit();
 
         IntentFilter filter = new IntentFilter();
-        if (!mOverlayUseStatusBar)
+        if (mBattery != null)
             filter.addAction(Intent.ACTION_BATTERY_CHANGED);
         filter.addAction(VLCApplication.SLEEP_INTENT);
         registerReceiver(mReceiver, filter);
@@ -464,6 +441,49 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
         updateNavStatus();
     }
 
+    public boolean onCreateOptionsMenu(Menu menu){
+        getMenuInflater().inflate(R.menu.video_player, menu);
+        return super.onCreateOptionsMenu(menu);
+    }
+
+    public boolean onPrepareOptionsMenu(Menu menu){
+        MenuItem item;
+        item = menu.findItem(R.id.pl_menu_subtitle);
+        item.setVisible(mLibVLC.getSpuTracksCount() > 0);
+        MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
+
+        item = menu.findItem(R.id.pl_menu_audiotrack);
+        item.setVisible(mLibVLC.getAudioTracksCount() > 2);
+        MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
+
+        item = menu.findItem(R.id.pl_menu_nav);
+        item.setVisible(mLibVLC.getChapterCountForTitle(0) > 1 && mLibVLC.getTitleCount() > 1 && mLibVLC.getTitle() != 0);
+        MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
+
+        item = menu.findItem(R.id.pl_menu_adv);
+        MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_IF_ROOM);
+        MenuItemCompat.setActionView(item, R.layout.adv_view);//we set this view as custom to have its coordinates to display popup at the right place.
+        return super.onPrepareOptionsMenu(menu);
+    }
+
+    public boolean onOptionsItemSelected(MenuItem item){
+        switch (item.getItemId()) {
+            case R.id.pl_menu_subtitle:
+                selectSubtitles();
+                return true;
+            case R.id.pl_menu_audiotrack:
+                selectAudioTrack();
+                return true;
+            case R.id.pl_menu_nav:
+                showNavMenu();
+                return true;
+            case R.id.pl_menu_adv:
+                showAdvancedOptions(item.getActionView());
+                return true;
+            default:
+                return super.onOptionsItemSelected(item);
+        }
+    }
     @Override
     protected void onPause() {
         super.onPause();
@@ -776,7 +796,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
             showNavMenu();
             return true;
         case KeyEvent.KEYCODE_O:
-            showAdvancedOptions(mMenu);
+            showAdvancedOptions(null);
             return true;
         case KeyEvent.KEYCODE_A:
             resizeVideo();
@@ -841,6 +861,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
         mTime.setEnabled(false);
         mSeekbar.setEnabled(false);
         mLength.setEnabled(false);
+        mSize.setEnabled(false);
         hideOverlay(true);
     }
 
@@ -855,6 +876,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
         mTime.setEnabled(true);
         mSeekbar.setEnabled(true);
         mLength.setEnabled(true);
+        mSize.setEnabled(true);
         mShowing = false;
         showOverlay();
     }
@@ -1533,16 +1555,6 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
         }
     };
 
-    /**
-    *
-    */
-    private final OnClickListener mAudioTrackListener = new OnClickListener() {
-        @Override
-        public void onClick(View v) {
-            selectAudioTrack();
-        }
-    };
-
     private void selectAudioTrack() {
     	if (mAudioTracksList == null) return;
 
@@ -1585,16 +1597,6 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
         dialog.show();
     }
 
-    /**
-    *
-    */
-    private final OnClickListener mSubtitlesListener = new OnClickListener() {
-        @Override
-        public void onClick(View v) {
-            selectSubtitles();
-        }
-    };
-
     private void selectSubtitles() {
         final String[] arrList = new String[mSubtitleTracksList.size()];
         int i = 0;
@@ -1636,13 +1638,6 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
         dialog.show();
     }
 
-    private final OnClickListener mNavMenuListener = new OnClickListener() {
-        @Override
-        public void onClick(View v) {
-            showNavMenu();
-        }
-    };
-
     private void showNavMenu() {
         /* Try to return to the menu. */
         /* FIXME: not working correctly in all cases */
@@ -1838,15 +1833,10 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
         if (!mShowing) {
             mShowing = true;
             if (!mIsLocked) {
-                if (mOverlayUseStatusBar)
-                    setActionBarVisibility(true);
-                else if (mOverlayHeader != null)
-                    mOverlayHeader.setVisibility(View.VISIBLE);
-                mOverlayOption.setVisibility(View.VISIBLE);
+                setActionBarVisibility(true);
                 mPlayPause.setVisibility(View.VISIBLE);
                 mBackward.setVisibility(View.VISIBLE);
                 mForward.setVisibility(View.VISIBLE);
-                mMenu.setVisibility(View.VISIBLE);
                 dimStatusBar(false);
             }
             mOverlayProgress.setVisibility(View.VISIBLE);
@@ -1870,29 +1860,20 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
             Log.i(TAG, "remove View!");
             if (mOverlayTips != null) mOverlayTips.setVisibility(View.INVISIBLE);
             if (!fromUser && !mIsLocked) {
-                if (mOverlayHeader != null)
-                    mOverlayHeader.startAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));
-                mOverlayOption.startAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));
                 mOverlayProgress.startAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));
                 mPlayPause.startAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));
                 mBackward.startAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));
                 mForward.startAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));
-                mMenu.startAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));
             }
             if (mPresentation != null) {
                 mOverlayBackground.startAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));
                 mOverlayBackground.setVisibility(View.INVISIBLE);
             }
-            if (mOverlayUseStatusBar)
-                setActionBarVisibility(false);
-            else if (mOverlayHeader != null)
-                mOverlayHeader.setVisibility(View.INVISIBLE);
-            mOverlayOption.setVisibility(View.INVISIBLE);
+            setActionBarVisibility(false);
             mOverlayProgress.setVisibility(View.INVISIBLE);
             mPlayPause.setVisibility(View.INVISIBLE);
             mBackward.setVisibility(View.INVISIBLE);
             mForward.setVisibility(View.INVISIBLE);
-            mMenu.setVisibility(View.INVISIBLE);
             mShowing = false;
             dimStatusBar(true);
         } else if (!fromUser) {
@@ -1916,16 +1897,14 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
         int layout = 0;
         if (!AndroidDevices.hasCombBar() && LibVlcUtil.isJellyBeanOrLater())
             layout = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
-        if (mOverlayUseStatusBar)
-            layout |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
+        layout |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
 
         int visibility = layout;
         if (dim) {
             visibility |= View.SYSTEM_UI_FLAG_LOW_PROFILE;
             if (!AndroidDevices.hasCombBar()) {
                 visibility |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
-                if (mOverlayUseStatusBar)
-                    visibility |= View.SYSTEM_UI_FLAG_FULLSCREEN;
+                visibility |= View.SYSTEM_UI_FLAG_FULLSCREEN;
             }
         } else {
             visibility |= View.SYSTEM_UI_FLAG_VISIBLE;
@@ -1991,24 +1970,11 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
         if(mAudioTracksList == null || force) {
             if (mLibVLC.getAudioTracksCount() > 2) {
                 mAudioTracksList = mLibVLC.getAudioTrackDescription();
-                mAudioTrack.setOnClickListener(mAudioTrackListener);
-                mAudioTrack.setVisibility(View.VISIBLE);
-            }
-            else {
-                mAudioTrack.setVisibility(View.GONE);
-                mAudioTrack.setOnClickListener(null);
             }
         }
         if (mSubtitleTracksList == null || force) {
-            if (mLibVLC.getSpuTracksCount() > 0) {
+            if (mLibVLC.getSpuTracksCount() > 0)
                 mSubtitleTracksList = mLibVLC.getSpuTrackDescription();
-                mSubtitle.setOnClickListener(mSubtitlesListener);
-                mSubtitle.setVisibility(View.VISIBLE);
-            }
-            else {
-                mSubtitle.setVisibility(View.GONE);
-                mSubtitle.setOnClickListener(null);
-            }
         }
     }
 
@@ -2389,8 +2355,8 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
 
         public SecondaryDisplay(Context context, Display display) {
             super(context, display);
-            if (context instanceof Activity) {
-                setOwnerActivity((Activity) context);
+            if (context instanceof ActionBarActivity) {
+                setOwnerActivity((ActionBarActivity) context);
             }
             try {
                 mLibVLC = VLCInstance.getLibVlcInstance();
@@ -2494,13 +2460,9 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
         else if (mHasMenu) {
             setESTrackLists(true);
             setESTracks();
-
-            /* Show the return to menu button. */
-            mNavMenu.setVisibility(View.VISIBLE);
-            mNavMenu.setOnClickListener(mNavMenuListener);
         }
-        else
-            mNavMenu.setVisibility(View.GONE);
+        invalidateOptionsMenu();
+
 
     }
 }
-- 
1.9.1




More information about the Android mailing list