[Android] Audio browser: allow to slide up the mini player

Adrien Maglo git at videolan.org
Tue Jan 7 14:39:07 CET 2014


vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Tue Jan  7 14:38:50 2014 +0100| [1454416de0b1205a4d0263b0314afcdd2dc1084e] | committer: Adrien Maglo

Audio browser: allow to slide up the mini player

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

 vlc-android/res/layout/audio_player_mini.xml       |    2 +-
 vlc-android/res/layout/main.xml                    |   80 ++++++++++++--------
 .../src/org/videolan/vlc/gui/MainActivity.java     |   18 +++++
 .../org/videolan/vlc/widget/AudioMiniPlayer.java   |   25 ++----
 4 files changed, 72 insertions(+), 53 deletions(-)

diff --git a/vlc-android/res/layout/audio_player_mini.xml b/vlc-android/res/layout/audio_player_mini.xml
index 87eff5c..0b18ee7 100644
--- a/vlc-android/res/layout/audio_player_mini.xml
+++ b/vlc-android/res/layout/audio_player_mini.xml
@@ -4,7 +4,7 @@
     android:id="@+id/root_node"
     android:orientation="vertical"
     android:layout_width="fill_parent"
-    android:layout_height="wrap_content"
+    android:layout_height="fill_parent"
     android:background="?attr/background_menu">
     <ProgressBar
         style="@android:style/Widget.ProgressBar.Horizontal"
diff --git a/vlc-android/res/layout/main.xml b/vlc-android/res/layout/main.xml
index 06c8b4e..1cf7477 100644
--- a/vlc-android/res/layout/main.xml
+++ b/vlc-android/res/layout/main.xml
@@ -1,39 +1,53 @@
 <?xml version="1.0" encoding="utf-8"?>
-<LinearLayout
-    xmlns:android="http://schemas.android.com/apk/res/android"
-    android:orientation="vertical"
-    android:layout_width="fill_parent"
-    android:layout_height="fill_parent">
-    <FrameLayout android:id="@+id/fragment_placeholder"
-        android:layout_weight="1"
-        android:layout_width="fill_parent"
-        android:layout_height="0dip" />
-    <RelativeLayout
-        android:id="@+id/info_layout"
+<org.videolan.vlc.widget.SlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/pane"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent" >
+
+    <LinearLayout
         android:layout_width="fill_parent"
-        android:layout_height="20dp"
-        android:visibility="gone">
-        <ProgressBar
-            android:id="@+id/info_progress"
-            style="?android:attr/progressBarStyleHorizontal"
+        android:layout_height="fill_parent"
+        android:layout_weight="1"
+        android:orientation="horizontal" >
+
+        <FrameLayout
+            android:id="@+id/fragment_placeholder"
             android:layout_width="fill_parent"
-            android:layout_height="fill_parent"
-            android:progressDrawable="@drawable/progress"/>
-        <TextView
-            android:id="@+id/info_text"
-            android:layout_width="wrap_content"
             android:layout_height="wrap_content"
-            android:layout_marginLeft="5dip"
-            android:layout_marginRight="5dip"
-            android:singleLine="true"
-            android:textColor="#FFFFFFFF"
-            android:shadowColor="#CC000000"
-            android:shadowRadius="1.5"
-            android:shadowDx="1"
-            android:shadowDy="1"/>
-    </RelativeLayout>
+            android:layout_weight="1" />
+
+        <RelativeLayout
+            android:id="@+id/info_layout"
+            android:layout_width="fill_parent"
+            android:layout_height="20dp"
+            android:visibility="gone" >
+
+            <ProgressBar
+                android:id="@+id/info_progress"
+                style="?android:attr/progressBarStyleHorizontal"
+                android:layout_width="fill_parent"
+                android:layout_height="fill_parent"
+                android:progressDrawable="@drawable/progress" />
+
+            <TextView
+                android:id="@+id/info_text"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="5dip"
+                android:layout_marginRight="5dip"
+                android:shadowColor="#CC000000"
+                android:shadowDx="1"
+                android:shadowDy="1"
+                android:shadowRadius="1.5"
+                android:singleLine="true"
+                android:textColor="#FFFFFFFF" />
+        </RelativeLayout>
+    </LinearLayout>
+
     <FrameLayout
         android:id="@+id/audio_mini_player"
-        android:layout_height="wrap_content"
-        android:layout_width="fill_parent"/>
-</LinearLayout>
+        android:layout_width="fill_parent"
+        android:layout_height="fill_parent"
+        android:minHeight="60dp" />
+
+</org.videolan.vlc.widget.SlidingPaneLayout>
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
index c888a83..3c2823c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MainActivity.java
@@ -35,6 +35,7 @@ import org.videolan.vlc.gui.audio.EqualizerFragment;
 import org.videolan.vlc.gui.video.VideoListAdapter;
 import org.videolan.vlc.interfaces.ISortable;
 import org.videolan.vlc.widget.AudioMiniPlayer;
+import org.videolan.vlc.widget.SlidingPaneLayout;
 
 import android.annotation.TargetApi;
 import android.app.AlertDialog;
@@ -101,6 +102,7 @@ public class MainActivity extends SherlockFragmentActivity {
     private SidebarAdapter mSidebarAdapter;
     private AudioMiniPlayer mAudioPlayer;
     private AudioServiceController mAudioController;
+    private SlidingPaneLayout mSlidingPane;
 
     private View mInfoLayout;
     private ProgressBar mInfoProgress;
@@ -176,6 +178,8 @@ public class MainActivity extends SherlockFragmentActivity {
         View v_main = LayoutInflater.from(this).inflate(R.layout.main, null);
         mMenu.setContent(v_main);
 
+        mSlidingPane = (SlidingPaneLayout) v_main.findViewById(R.id.pane);
+
         View sidebar = LayoutInflater.from(this).inflate(R.layout.sidebar, null);
         final ListView listView = (ListView)sidebar.findViewById(android.R.id.list);
         listView.setFooterDividersEnabled(true);
@@ -738,4 +742,18 @@ public class MainActivity extends SherlockFragmentActivity {
     {
         mAudioPlayer.setKeepHidden(k);
     }
+
+    /**
+     * Show the mini player.
+     */
+    public void showMiniPlayer() {
+        mSlidingPane.openPane();
+    }
+
+    /**
+     * Hide the mini player.
+     */
+    public void hideMiniPlayer() {
+        mSlidingPane.openPaneEntirely();
+    }
 }
diff --git a/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java b/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java
index d7930af..59a47a1 100644
--- a/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java
@@ -22,6 +22,7 @@ package org.videolan.vlc.widget;
 
 import android.app.Activity;
 import org.videolan.vlc.R;
+import org.videolan.vlc.gui.MainActivity;
 import org.videolan.vlc.gui.audio.AudioPlayerFragment;
 import org.videolan.vlc.interfaces.IAudioPlayer;
 import org.videolan.vlc.interfaces.IAudioPlayerControl;
@@ -117,11 +118,7 @@ public class AudioMiniPlayer extends Fragment implements IAudioPlayer {
                     mTouchY = event.getRawY();
                     break;
                 case MotionEvent.ACTION_UP:
-                    if(mTouchY - event.getRawY() > root.getHeight()) {
-                        // should show playlist view of AudioPlayerFragment
-                        Toast.makeText(AudioMiniPlayer.this.getActivity(), "AudioMiniPlayer swipe up", Toast.LENGTH_SHORT).show();
-                        return true;
-                    } else if(Math.abs( mTouchY - event.getRawY() ) < 5 && Math.abs( mTouchX - event.getRawX() ) < 5) {
+                    if (Math.abs(mTouchY - event.getRawY()) < 5 && Math.abs(mTouchX - event.getRawX()) < 5) {
                         // effectively a click
                         // should show cover view of AudioPlayerFragment
                         AudioPlayerFragment.start(getActivity());
@@ -227,23 +224,13 @@ public class AudioMiniPlayer extends Fragment implements IAudioPlayer {
     }
 
     public void show() {
-        FragmentTransaction ft = getActivity().getSupportFragmentManager()
-                .beginTransaction();
-        ft.setCustomAnimations(R.anim.anim_enter_bottom, 0);
-        ft.show(this);
-        ft.commit();
+        MainActivity activity = (MainActivity)getActivity();
+        activity.showMiniPlayer();
     }
 
     public void hide() {
-        FragmentTransaction ft = getActivity().getSupportFragmentManager()
-                .beginTransaction();
-        /*
-            The exit animation won't run because of a bug in the compatibility library.
-            See: https://code.google.com/p/android/issues/detail?id=32405
-        */
-        ft.setCustomAnimations(0, R.anim.anim_leave_bottom);
-        ft.hide(this);
-        ft.commit();
+        MainActivity activity = (MainActivity)getActivity();
+        activity.hideMiniPlayer();
     }
 
     private boolean mKeepHidden = false;



More information about the Android mailing list