Commit c1ed9b25 authored by Geoffrey Métais's avatar Geoffrey Métais

Use action bar menu for action and with any Android version

parent 09fe54a6
......@@ -62,13 +62,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"
......@@ -89,54 +87,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
......
......@@ -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,11 +128,20 @@
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"
......@@ -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>
......
<?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>
<?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>
<?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"/>
\ No newline at end of file
......@@ -78,44 +78,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"
......@@ -189,18 +152,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/ic_more_normal_w"
android:onClick="showAdvancedOptions" />
android:background="@drawable/ic_more_normal_w" />
</RelativeLayout>
</RelativeLayout>
......
<?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>
<?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>
......@@ -39,13 +39,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"
......@@ -78,48 +76,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>
......
<?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>
<?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>
......@@ -6,5 +6,8 @@
<dimen name="grid_card_subtitle_text_size">12sp</dimen>
<dimen name="grid_card_vertical_spacing">10dp</dimen>
<!-- 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
......@@ -14,15 +14,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
......@@ -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>
......
......@@ -158,10 +158,13 @@
</style>
<style name="Theme.VLC.Player" parent="Theme.AppCompat">
<item name="android:windowBackground">@color/black</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="windowActionBar">false</item>
<item name="video_player_overlay">@color/transparent_gray</item>
<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>
......
......@@ -58,7 +58,6 @@ import org.videolan.vlc.util.VLCInstance;
import org.videolan.vlc.util.WeakHandler;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.KeyguardManager;
import android.app.Presentation;
......@@ -89,6 +88,7 @@ import android.preference.PreferenceManager;
import android.provider.MediaStore;
import android.provider.Settings;
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;
......@@ -97,6 +97,8 @@ 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;
......@@ -156,9 +158,6 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
/** 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;
......@@ -191,11 +190,8 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
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;
......@@ -264,7 +260,6 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
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;
......@@ -286,9 +281,6 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
}
};
Log.d(TAG, "MediaRouter information : " + mMediaRouter .toString());
mOverlayUseStatusBar = true;
} else {
mOverlayUseStatusBar = false;
}
mSettings = PreferenceManager.getDefaultSharedPreferences(this);
......@@ -317,33 +309,25 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
);
/** initialize Views an their Events */
if (mOverlayUseStatusBar) {
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);
mOverlayHeader = mSysTime = mBattery = null;
} else {
mOverlayHeader = findViewById(R.id.player_overlay_header);