[Android] Repair the mini player context menu

Ludovic Fauvet git at videolan.org
Sat Jun 23 17:11:05 CEST 2012


android | branch: master | Ludovic Fauvet <etix at videolan.org> | Sat Jun 23 16:26:00 2012 +0200| [0e97430e3e8abecf757546a556c0f7e5438c07f8] | committer: Ludovic Fauvet

Repair the mini player context menu

Also remove the possibility to hide the player because it's confusing
from a user perspective.

> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=0e97430e3e8abecf757546a556c0f7e5438c07f8
---

 vlc-android/res/menu/audio_player_mini.xml         |    6 ----
 .../org/videolan/vlc/widget/AudioMiniPlayer.java   |   30 +++++++++-----------
 2 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/vlc-android/res/menu/audio_player_mini.xml b/vlc-android/res/menu/audio_player_mini.xml
index 3b21b8e..48722b7 100644
--- a/vlc-android/res/menu/audio_player_mini.xml
+++ b/vlc-android/res/menu/audio_player_mini.xml
@@ -1,12 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <menu xmlns:android="http://schemas.android.com/apk/res/android">
     <item
-        android:id="@+id/show_player"
-        android:title="@string/show_player" />
-    <item
         android:id="@+id/play_pause"
         android:title="@string/play" />
-    <item
-        android:id="@+id/hide_mini_player"
-        android:title="@string/hide_mini_player" />
 </menu>
diff --git a/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java b/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java
index 12cb8bf..e74cd32 100644
--- a/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java
@@ -115,24 +115,11 @@ public class AudioMiniPlayer extends Fragment implements IAudioPlayer {
             }
         });
 
-        root.setOnLongClickListener(new OnLongClickListener() {
-            @Override
-            public boolean onLongClick(View arg0) {
-                //FIXME getActivity().openContextMenu(getView());
-                return true;
-            }
-        });
-
+        registerForContextMenu(v);
         return v;
     }
 
     @Override
-    public void onActivityCreated(Bundle savedInstanceState) {
-        super.onActivityCreated(savedInstanceState);
-        //FIXME registerForContextMenu(getView());
-    }
-
-    @Override
     public void onCreateContextMenu(ContextMenu menu, View v,
             ContextMenuInfo menuInfo) {
         super.onCreateContextMenu(menu, v, menuInfo);
@@ -140,16 +127,27 @@ public class AudioMiniPlayer extends Fragment implements IAudioPlayer {
         MenuInflater inflater = getActivity().getMenuInflater();
         inflater.inflate(R.menu.audio_player_mini, menu);
 
-        MenuItem hmi = menu.findItem(R.id.hide_mini_player);
         MenuItem pp = menu.findItem(R.id.play_pause);
         if (mAudioPlayerControl.isPlaying()) {
-            hmi.setVisible(false);
             pp.setTitle(R.string.pause);
         } else {
             pp.setTitle(R.string.play);
         }
     }
 
+    @Override
+    public boolean onContextItemSelected(MenuItem item) {
+        switch (item.getItemId()) {
+            case R.id.play_pause:
+                if (mAudioPlayerControl.isPlaying())
+                    mAudioPlayerControl.pause();
+                else
+                    mAudioPlayerControl.play();
+                return true;
+        }
+        return super.onContextItemSelected(item);
+    }
+
     public void setAudioPlayerControl(IAudioPlayerControl control) {
         mAudioPlayerControl = control;
     }



More information about the Android mailing list