Commit fb8d599a authored by Sébastien Toque's avatar Sébastien Toque

UI: In video player, replace the static header by a sliding panel

parent aeb54c41
......@@ -21,65 +21,6 @@
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" />
<ImageButton
android:id="@+id/player_overlay_audio"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/header_icon_audio" />
<ImageButton
android:id="@+id/player_overlay_subtitle"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/header_icon_subtitle" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<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" />
<TextView
android:id="@+id/player_overlay_battery"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|center_vertical"
android:textColor="#ffffff"
android:textSize="15dip" />
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:id="@+id/player_overlay"
android:layout_width="fill_parent"
......@@ -152,4 +93,103 @@
android:background="@drawable/ic_lock" />
</RelativeLayout>
</FrameLayout>
<SlidingDrawer
android:id="@+id/player_overlay_header"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:content="@+id/header_content"
android:handle="@+id/header_handle"
android:rotation="180"
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>
<LinearLayout
android:id="@id/header_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#AA000000"
android:orientation="vertical"
android:rotation="180" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/header_icon_audio" />
<Spinner
android:id="@+id/player_overlay_audio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/header_icon_subtitle" />
<Spinner
android:id="@+id/player_overlay_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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" />
</LinearLayout>
</SlidingDrawer>
</FrameLayout>
\ No newline at end of file
......@@ -41,11 +41,8 @@ import org.videolan.vlc.widget.PlayerControlWheel;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
......@@ -69,13 +66,22 @@ import android.view.SurfaceView;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnSystemUiVisibilityChangeListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup.LayoutParams;
import android.view.WindowManager;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
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;
import android.widget.Spinner;
import android.widget.TextView;
public class VideoPlayerActivity extends Activity {
......@@ -97,9 +103,10 @@ public class VideoPlayerActivity extends Activity {
private int mCurrentSize = SURFACE_BEST_FIT;
/** Overlay */
private View mOverlayHeader;
private SlidingDrawer mOverlayHeader;
private View mOverlay;
private static final int OVERLAY_TIMEOUT = 4000;
private static final int OVERLAY_INFINITE = 3600000;
private static final int FADE_OUT = 1;
private static final int SHOW_PROGRESS = 2;
private static final int SURFACE_SIZE = 3;
......@@ -116,8 +123,8 @@ public class VideoPlayerActivity extends Activity {
private TextView mLength;
private TextView mInfo;
private IPlayerControl mControls;
private ImageButton mAudio;
private ImageButton mSubtitles;
private Spinner mAudio;
private Spinner mSubtitles;
private ImageButton mLock;
private ImageButton mSize;
......@@ -164,9 +171,42 @@ public class VideoPlayerActivity extends Activity {
);
/** initialize Views an their Events */
mOverlayHeader = findViewById(R.id.player_overlay_header);
mOverlayHeader = (SlidingDrawer) findViewById(R.id.player_overlay_header);
mOverlay = findViewById(R.id.player_overlay);
/* prevent touch event from going through the view */
View headerContent = findViewById(R.id.header_content);
headerContent.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
mOverlayHeader.setOnDrawerScrollListener(new OnDrawerScrollListener() {
@Override
public void onScrollStarted() {
showOverlay(OVERLAY_INFINITE);
}
@Override
public void onScrollEnded() {
showOverlay(mOverlayHeader.isOpened() ? OVERLAY_INFINITE : OVERLAY_TIMEOUT);
}
});
mOverlayHeader.setOnDrawerOpenListener(new OnDrawerOpenListener() {
@Override
public void onDrawerOpened() {
showOverlay(OVERLAY_INFINITE);
}
});
mOverlayHeader.setOnDrawerCloseListener(new OnDrawerCloseListener() {
@Override
public void onDrawerClosed() {
showOverlay(OVERLAY_TIMEOUT);
}
});
/* header */
mTitle = (TextView) findViewById(R.id.player_overlay_title);
mSysTime = (TextView) findViewById(R.id.player_overlay_systime);
......@@ -184,11 +224,8 @@ public class VideoPlayerActivity extends Activity {
FrameLayout mControlContainer = (FrameLayout) findViewById(R.id.player_control);
mControlContainer.addView((View) mControls);
mAudio = (ImageButton) findViewById(R.id.player_overlay_audio);
mAudio.setOnClickListener(mAudioListener);
mSubtitles = (ImageButton) findViewById(R.id.player_overlay_subtitle);
mSubtitles.setOnClickListener(mSubtitlesListener);
mAudio = (Spinner) findViewById(R.id.player_overlay_audio);
mSubtitles = (Spinner) findViewById(R.id.player_overlay_subtitle);
mLock = (ImageButton) findViewById(R.id.player_overlay_lock);
mLock.setOnClickListener(mLockListener);
......@@ -623,7 +660,7 @@ public class VideoPlayerActivity extends Activity {
@Override
public void onStartTrackingTouch(SeekBar seekBar) {
mDragging = true;
showOverlay(3600000);
showOverlay(OVERLAY_INFINITE);
}
@Override
......@@ -648,50 +685,30 @@ public class VideoPlayerActivity extends Activity {
/**
*
*/
private final OnClickListener mAudioListener = new OnClickListener() {
private final OnItemSelectedListener mAudioListener = new OnItemSelectedListener() {
@Override
public void onClick(View v) {
if (mAudioTracks == null || mAudioTracks.length <= 1)
return;
int current = mLibVLC.getAudioTrack() - 1;
Builder builder = new AlertDialog.Builder(VideoPlayerActivity.this);
builder.setSingleChoiceItems(mAudioTracks, current, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
mLibVLC.setAudioTrack(which + 1);
}
});
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
mLibVLC.setAudioTrack(position + 1);
}
builder.show();
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
};
/**
*
*/
private final OnClickListener mSubtitlesListener = new OnClickListener() {
@Override
public void onClick(View v) {
if (mSubtitleTracks == null || mSubtitleTracks.length == 0)
return;
int current = mLibVLC.getSpuTrack();
Builder builder = new AlertDialog.Builder(VideoPlayerActivity.this);
builder.setSingleChoiceItems(mSubtitleTracks, current, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
mLibVLC.setSpuTrack(which);
}
});
private final OnItemSelectedListener mSubtitlesListener = new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
mLibVLC.setSpuTrack(position);
}
builder.show();
}
};
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
};
/**
......@@ -722,7 +739,7 @@ public class VideoPlayerActivity extends Activity {
@Override
public long onWheelStart() {
showOverlay(3600000);
showOverlay(OVERLAY_INFINITE);
return mLibVLC.getTime();
}
......@@ -841,17 +858,35 @@ public class VideoPlayerActivity extends Activity {
}
if (mAudioTracks == null) {
mAudioTracks = mLibVLC.getAudioTrackDescription();
if (mAudioTracks != null && mAudioTracks.length > 1)
mAudio.setVisibility(View.VISIBLE);
else
mAudio.setVisibility(View.GONE);
if (mAudioTracks != null && mAudioTracks.length > 1) {
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mAudioTracks);
mAudio.setAdapter(adapter);
int current = mLibVLC.getAudioTrack() - 1;
mAudio.setSelection(current);
mAudio.setOnItemSelectedListener(mAudioListener);
mAudio.setEnabled(true);
}
else {
mAudio.setEnabled(false);
mAudio.setOnItemSelectedListener(null);
mAudio.setAdapter(null);
}
}
if (mSubtitleTracks == null) {
mSubtitleTracks = mLibVLC.getSpuTrackDescription();
if (mSubtitleTracks != null && mSubtitleTracks.length > 0)
mSubtitles.setVisibility(View.VISIBLE);
else
mSubtitles.setVisibility(View.GONE);
if (mSubtitleTracks != null && mSubtitleTracks.length > 0) {
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mSubtitleTracks);
mSubtitles.setAdapter(adapter);
int current = mLibVLC.getSpuTrack();
mSubtitles.setSelection(current);
mSubtitles.setOnItemSelectedListener(mSubtitlesListener);
mSubtitles.setEnabled(true);
}
else {
mSubtitles.setEnabled(false);
mSubtitles.setOnItemSelectedListener(null);
mSubtitles.setAdapter(null);
}
}
updateOverlayPausePlay();
}
......
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