Commit 1d87af69 authored by Sébastien Toque's avatar Sébastien Toque

UI: In video player, move the slider to the bottom, replacing the lock button

The new button can be clicked or slided.
the lock/unlock button is still available from inside the slider

PS: the slider icon is just a dummy, until a new icon is made
parent cc262289
......@@ -21,6 +21,35 @@
android:textSize="36dp"
android:visibility="invisible" />
<LinearLayout
android:id="@+id/player_overlay_header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:background="#AA000000"
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="left|center_vertical"
android:text="@string/title"
android:textColor="#ffffff"
android:textSize="15dip" />
<TextView
android:id="@+id/player_overlay_systime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:textColor="#ffffff"
android:textSize="15dip" />
</LinearLayout>
<RelativeLayout
android:id="@+id/player_overlay"
android:layout_width="fill_parent"
......@@ -83,65 +112,39 @@
android:layout_alignParentRight="true"
android:layout_below="@+id/player_overlay_seekbar"
android:background="@drawable/ic_size" />
<ImageButton
android:id="@+id/player_overlay_lock"
android:layout_width="40dip"
android:layout_height="40dip"
android:layout_alignParentLeft="true"
android:layout_below="@+id/player_overlay_seekbar"
android:background="@drawable/ic_lock" />
</RelativeLayout>
<SlidingDrawer
android:id="@+id/player_overlay_header"
<org.videolan.vlc.widget.SlidingPanel
android:id="@+id/player_overlay_slider"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:content="@+id/header_content"
android:handle="@+id/header_handle"
android:rotation="180"
android:content="@+id/slider_content"
android:handle="@+id/slider_handle"
android:visibility="invisible" >
<LinearLayout
android:id="@+id/header_handle"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#AA000000"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:rotation="180" >
<TextView
android:id="@+id/player_overlay_title"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="left|center_vertical"
android:text="@string/title"
android:textColor="#ffffff"
android:textSize="15dip" />
<TextView
android:id="@+id/player_overlay_systime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:textColor="#ffffff"
android:textSize="15dip" />
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/slider_handle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="5dp"
android:paddingLeft="7dp"
android:src="@drawable/ic_seekbar_thumb" />
<LinearLayout
android:id="@id/header_content"
android:id="@+id/slider_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#AA000000"
android:orientation="vertical"
android:rotation="180" >
android:orientation="vertical" >
<TextView
android:id="@+id/player_overlay_battery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="bottom"
android:textColor="#ffffff"
android:textSize="15dip" />
<LinearLayout
android:layout_width="wrap_content"
......@@ -181,15 +184,12 @@
android:layout_gravity="center_vertical" />
</LinearLayout>
<TextView
android:id="@+id/player_overlay_battery"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="right"
android:gravity="bottom"
android:textColor="#ffffff"
android:textSize="15dip" />
<ImageButton
android:id="@+id/player_overlay_lock"
android:layout_width="40dip"
android:layout_height="40dip"
android:background="@drawable/ic_lock" />
</LinearLayout>
</SlidingDrawer>
</org.videolan.vlc.widget.SlidingPanel>
</FrameLayout>
\ No newline at end of file
......@@ -38,6 +38,7 @@ import org.videolan.vlc.interfaces.IPlayerControl;
import org.videolan.vlc.interfaces.OnPlayerControlListener;
import org.videolan.vlc.widget.PlayerControlClassic;
import org.videolan.vlc.widget.PlayerControlWheel;
import org.videolan.vlc.widget.SlidingPanel;
import android.annotation.TargetApi;
import android.app.Activity;
......@@ -77,7 +78,6 @@ import android.widget.FrameLayout;
import android.widget.ImageButton;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.SlidingDrawer;
import android.widget.SlidingDrawer.OnDrawerCloseListener;
import android.widget.SlidingDrawer.OnDrawerOpenListener;
import android.widget.SlidingDrawer.OnDrawerScrollListener;
......@@ -103,8 +103,9 @@ public class VideoPlayerActivity extends Activity {
private int mCurrentSize = SURFACE_BEST_FIT;
/** Overlay */
private SlidingDrawer mOverlayHeader;
private View mOverlayHeader;
private View mOverlay;
private SlidingPanel mOverlaySlider;
private static final int OVERLAY_TIMEOUT = 4000;
private static final int OVERLAY_INFINITE = 3600000;
private static final int FADE_OUT = 1;
......@@ -171,19 +172,20 @@ public class VideoPlayerActivity extends Activity {
);
/** initialize Views an their Events */
mOverlayHeader = (SlidingDrawer) findViewById(R.id.player_overlay_header);
mOverlayHeader = findViewById(R.id.player_overlay_header);
mOverlay = findViewById(R.id.player_overlay);
mOverlaySlider = (SlidingPanel) findViewById(R.id.player_overlay_slider);
/* prevent touch event from going through the view */
View headerContent = findViewById(R.id.header_content);
headerContent.setOnTouchListener(new OnTouchListener() {
/* prevent touch event from going through the slider view */
View sliderContent = findViewById(R.id.slider_content);
sliderContent.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
mOverlayHeader.setOnDrawerScrollListener(new OnDrawerScrollListener() {
mOverlaySlider.setOnDrawerScrollListener(new OnDrawerScrollListener() {
@Override
public void onScrollStarted() {
showOverlay(OVERLAY_INFINITE);
......@@ -191,18 +193,27 @@ public class VideoPlayerActivity extends Activity {
@Override
public void onScrollEnded() {
showOverlay(mOverlayHeader.isOpened() ? OVERLAY_INFINITE : OVERLAY_TIMEOUT);
if (mOverlaySlider.isOpened()) {
mOverlaySlider.ExpandHandle();
showOverlay(OVERLAY_INFINITE);
}
else {
mOverlaySlider.CollapseHandle();
showOverlay(OVERLAY_TIMEOUT);
}
}
});
mOverlayHeader.setOnDrawerOpenListener(new OnDrawerOpenListener() {
mOverlaySlider.setOnDrawerOpenListener(new OnDrawerOpenListener() {
@Override
public void onDrawerOpened() {
mOverlaySlider.ExpandHandle();
showOverlay(OVERLAY_INFINITE);
}
});
mOverlayHeader.setOnDrawerCloseListener(new OnDrawerCloseListener() {
mOverlaySlider.setOnDrawerCloseListener(new OnDrawerCloseListener() {
@Override
public void onDrawerClosed() {
mOverlaySlider.CollapseHandle();
showOverlay(OVERLAY_TIMEOUT);
}
});
......@@ -854,6 +865,7 @@ public class VideoPlayerActivity extends Activity {
mShowing = true;
mOverlayHeader.setVisibility(View.VISIBLE);
mOverlay.setVisibility(View.VISIBLE);
mOverlaySlider.setVisibility(View.VISIBLE);
dimStatusBar(false);
}
Message msg = mHandler.obtainMessage(FADE_OUT);
......@@ -906,9 +918,11 @@ public class VideoPlayerActivity extends Activity {
if (!fromUser) {
mOverlayHeader.startAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));
mOverlay.startAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));
mOverlaySlider.startAnimation(AnimationUtils.loadAnimation(this, android.R.anim.fade_out));
}
mOverlayHeader.setVisibility(View.INVISIBLE);
mOverlay.setVisibility(View.INVISIBLE);
mOverlaySlider.setVisibility(View.INVISIBLE);
mShowing = false;
dimStatusBar(true);
}
......
/*****************************************************************************
* SlidingPanel.java
*****************************************************************************
* Copyright © 2012 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
package org.videolan.vlc.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.SlidingDrawer;
public class SlidingPanel extends SlidingDrawer {
public SlidingPanel(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
View handle = getHandle();
handle.layout(0, handle.getTop(), handle.getWidth(), handle.getBottom());
}
public void CollapseHandle() {
View handle = getHandle();
LayoutParams lp = handle.getLayoutParams();
if (lp.width == LayoutParams.WRAP_CONTENT)
return;
lp.width = LayoutParams.WRAP_CONTENT;
handle.setLayoutParams(lp);
}
public void ExpandHandle() {
View handle = getHandle();
LayoutParams lp = handle.getLayoutParams();
if (lp.width == LayoutParams.MATCH_PARENT)
return;
lp.width = LayoutParams.MATCH_PARENT;
handle.setLayoutParams(lp);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment