Commit 5bdafb46 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Remove touch input mgmt from video player activity

parent 89bfb4dc
......@@ -53,14 +53,10 @@ import android.os.Message;
import android.os.PowerManager;
import android.preference.PreferenceManager;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.view.GestureDetectorCompat;
import android.support.v4.view.ScaleGestureDetectorCompat;
import android.support.v4.view.ViewCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
......@@ -75,13 +71,11 @@ import android.util.DisplayMetrics;
import android.util.Log;
import android.util.Rational;
import android.view.Display;
import android.view.GestureDetector;
import android.view.InputDevice;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.Surface;
import android.view.SurfaceView;
import android.view.View;
......@@ -171,9 +165,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
private final static int RESULT_CONNECTION_FAILED = RESULT_FIRST_USER + 1;
private final static int RESULT_PLAYBACK_ERROR = RESULT_FIRST_USER + 2;
private final static int RESULT_VIDEO_TRACK_LOST = RESULT_FIRST_USER + 3;
private static final float DEFAULT_FOV = 80f;
private static final float MIN_FOV = 20f;
private static final float MAX_FOV = 150f;
static final float DEFAULT_FOV = 80f;
private final PlaybackServiceActivity.Helper mHelper = new PlaybackServiceActivity.Helper(this, this);
protected PlaybackService mService;
......@@ -186,29 +178,23 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
private Uri mUri;
private boolean mAskResume = true;
private boolean mIsRtl;
private ScaleGestureDetector mScaleGestureDetector;
private GestureDetectorCompat mDetector = null;
private ImageView mPlaylistToggle;
private RecyclerView mPlaylist;
private PlaylistAdapter mPlaylistAdapter;
private static final int SURFACE_BEST_FIT = 0;
private static final int SURFACE_FIT_SCREEN = 1;
static final int SURFACE_FIT_SCREEN = 1;
private static final int SURFACE_FILL = 2;
private static final int SURFACE_16_9 = 3;
private static final int SURFACE_4_3 = 4;
private static final int SURFACE_ORIGINAL = 5;
private static final int SURFACE_SIZE_COUNT = 6;
private int mCurrentSize;
private SharedPreferences mSettings;
private static final int TOUCH_FLAG_AUDIO_VOLUME = 1;
private static final int TOUCH_FLAG_BRIGHTNESS = 1 << 1;
private static final int TOUCH_FLAG_SEEK = 1 << 2;
private int mTouchControls = 0;
/** Overlay */
private ActionBar mActionBar;
private ViewGroup mActionBarView;
......@@ -223,8 +209,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
private static final int RESET_BACK_LOCK = 6;
private static final int CHECK_VIDEO_TRACKS = 7;
private static final int LOADING_ANIMATION = 8;
private static final int SHOW_INFO = 9;
private static final int HIDE_INFO = 10;
static final int SHOW_INFO = 9;
static final int HIDE_INFO = 10;
private static final int LOADING_ANIMATION_DELAY = 1000;
......@@ -269,6 +255,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
private long mSavedTime = -1;
private float mSavedRate = 1.f;
private float mSavedBrightness = -1f;
/**
* For uninterrupted switching between audio and video mode
*/
......@@ -294,25 +282,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
private float mOriginalVol;
private Toast warningToast;
//Touch Events
private static final int TOUCH_NONE = 0;
private static final int TOUCH_VOLUME = 1;
private static final int TOUCH_BRIGHTNESS = 2;
private static final int TOUCH_MOVE = 3;
private static final int TOUCH_SEEK = 4;
private static final int TOUCH_IGNORE = 5;
private int mTouchAction = TOUCH_NONE;
private int mSurfaceYDisplayRange, mSurfaceXDisplayRange;
private float mFov;
private float mInitTouchY, mTouchY =-1f, mTouchX=-1f;
//stick event
private static final int JOYSTICK_INPUT_DELAY = 300;
private long mLastMove;
// Brightness
private boolean mIsFirstBrightnessGesture = true;
private float mRestoreAutoBrightness = -1f;
private VideoTouchDelegate mTouchDelegate;
// Tracks & Subtitles
private MediaPlayer.TrackDescription[] mAudioTracksList;
......@@ -362,12 +333,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
mSettings = PreferenceManager.getDefaultSharedPreferences(this);
if (!VLCApplication.showTvUi()) {
mTouchControls = (mSettings.getBoolean("enable_volume_gesture", true) ? TOUCH_FLAG_AUDIO_VOLUME : 0)
+ (mSettings.getBoolean("enable_brightness_gesture", true) ? TOUCH_FLAG_BRIGHTNESS : 0)
+ (mSettings.getBoolean("enable_double_tap_seek", true) ? TOUCH_FLAG_SEEK : 0);
}
/* Services and miscellaneous */
mAudioManager = (AudioManager) getApplicationContext().getSystemService(AUDIO_SERVICE);
mAudioMax = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
......@@ -396,24 +361,24 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
if (v instanceof TextView) mBattery = (TextView) v;
}
mPlaylistToggle = (ImageView) findViewById(R.id.playlist_toggle);
mPlaylist = (RecyclerView) findViewById(R.id.video_playlist);
mPlaylistToggle = findViewById(R.id.playlist_toggle);
mPlaylist = findViewById(R.id.video_playlist);
mScreenOrientation = Integer.valueOf(
mSettings.getString("screen_orientation", "99" /*SCREEN ORIENTATION SENSOR*/));
mSurfaceView = (SurfaceView) findViewById(R.id.player_surface);
mSubtitlesSurfaceView = (SurfaceView) findViewById(R.id.subtitles_surface);
mSurfaceView = findViewById(R.id.player_surface);
mSubtitlesSurfaceView = findViewById(R.id.subtitles_surface);
mSubtitlesSurfaceView.setZOrderMediaOverlay(true);
mSubtitlesSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
mSurfaceFrame = (FrameLayout) findViewById(R.id.player_surface_frame);
mSurfaceFrame = findViewById(R.id.player_surface_frame);
/* Loading view */
mLoading = (ImageView) findViewById(R.id.player_overlay_loading);
mLoading = findViewById(R.id.player_overlay_loading);
dimStatusBar(true);
mHandler.sendEmptyMessageDelayed(LOADING_ANIMATION, LOADING_ANIMATION_DELAY);
......@@ -434,8 +399,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
editor.apply();
final IntentFilter filter = new IntentFilter();
if (mBattery != null)
filter.addAction(Intent.ACTION_BATTERY_CHANGED);
if (mBattery != null) filter.addAction(Intent.ACTION_BATTERY_CHANGED);
filter.addAction(VLCApplication.SLEEP_INTENT);
registerReceiver(mReceiver, filter);
......@@ -457,7 +421,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
int hm = getResources().getDimensionPixelSize(R.dimen.tv_overscan_horizontal);
int vm = getResources().getDimensionPixelSize(R.dimen.tv_overscan_vertical);
final RelativeLayout uiContainer = (RelativeLayout) findViewById(R.id.player_ui_container);
final RelativeLayout uiContainer = findViewById(R.id.player_ui_container);
final RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) uiContainer.getLayoutParams();
lp.setMargins(hm, 0, hm, vm);
uiContainer.setLayoutParams(lp);
......@@ -468,10 +432,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
}
}
getWindowManager().getDefaultDisplay().getMetrics(mScreen);
mSurfaceYDisplayRange = Math.min(mScreen.widthPixels, mScreen.heightPixels);
mSurfaceXDisplayRange = Math.max(mScreen.widthPixels, mScreen.heightPixels);
mCurrentScreenOrientation = getResources().getConfiguration().orientation;
if (mIsBenchmark) {
mCurrentSize = SURFACE_FIT_SCREEN;
} else {
......@@ -479,6 +440,21 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
}
mMedialibrary = VLCApplication.getMLInstance();
mIsRtl = AndroidUtil.isJellyBeanMR1OrLater && TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()) == View.LAYOUT_DIRECTION_RTL;
final int touch;
if (!VLCApplication.showTvUi()) {
touch = (mSettings.getBoolean("enable_volume_gesture", true) ? VideoTouchDelegateKt.TOUCH_FLAG_AUDIO_VOLUME : 0)
+ (mSettings.getBoolean("enable_brightness_gesture", true) ? VideoTouchDelegateKt.TOUCH_FLAG_BRIGHTNESS : 0)
+ (mSettings.getBoolean("enable_double_tap_seek", true) ? VideoTouchDelegateKt.TOUCH_FLAG_SEEK : 0);
} else touch = 0;
mCurrentScreenOrientation = getResources().getConfiguration().orientation;
if (touch != 0) {
final DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int yRange = Math.min(dm.widthPixels, dm.heightPixels);
int xRange = Math.max(dm.widthPixels, dm.heightPixels);
final ScreenConfig sc = new ScreenConfig(dm, xRange, yRange, mCurrentScreenOrientation);
mTouchDelegate = new VideoTouchDelegate(this, touch, sc, mIsRtl);
}
}
@Override
......@@ -518,7 +494,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
}
mUri = uri;
mTitle.setText(mService.getCurrentMediaWrapper().getTitle());
if (mPlaylist.getVisibility() == View.VISIBLE) {
if (isPlaylistVisible()) {
mPlaylistAdapter.setCurrentIndex(mService.getCurrentMediaPosition());
mPlaylist.setVisibility(View.GONE);
}
......@@ -606,10 +582,16 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
getWindowManager().getDefaultDisplay().getMetrics(mScreen);
mCurrentScreenOrientation = newConfig.orientation;
mSurfaceYDisplayRange = Math.min(mScreen.widthPixels, mScreen.heightPixels);
mSurfaceXDisplayRange = Math.max(mScreen.widthPixels, mScreen.heightPixels);
if (mTouchDelegate != null) {
final DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
final ScreenConfig sc = new ScreenConfig(dm,
Math.max(dm.widthPixels, dm.heightPixels),
Math.min(dm.widthPixels, dm.heightPixels),
mCurrentScreenOrientation);
mTouchDelegate.setScreenConfig(sc);
}
resetHudLayout();
}
......@@ -700,14 +682,15 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
}
private void restoreBrightness() {
if (mRestoreAutoBrightness != -1f) {
int brightness = (int) (mRestoreAutoBrightness*255f);
if (mSavedBrightness != -1f) {
int brightness = (int) (mSavedBrightness *255f);
Settings.System.putInt(getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS,
brightness);
Settings.System.putInt(getContentResolver(),
Settings.System.SCREEN_BRIGHTNESS_MODE,
Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
mSavedBrightness = -1f;
}
// Save brightness if user wants to
if (mSettings.getBoolean("save_brightness", false)) {
......@@ -895,11 +878,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
if (mRootView != null) mRootView.setKeepScreenOn(false);
if (mDetector != null) {
mDetector.setOnDoubleTapListener(null);
mDetector = null;
}
/* Stop listening for changes to media routes. */
mDisplayManager.mediaRouterAddCallback(false);
......@@ -1011,59 +989,13 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
@Override
public boolean onTrackballEvent(MotionEvent event) {
if (mIsLoading)
return false;
if (mIsLoading) return false;
showOverlay();
return true;
}
@TargetApi(12) //only active for Android 3.1+
public boolean dispatchGenericMotionEvent(MotionEvent event){
if (mIsLoading)
return false;
//Check for a joystick event
if ((event.getSource() & InputDevice.SOURCE_JOYSTICK) !=
InputDevice.SOURCE_JOYSTICK ||
event.getAction() != MotionEvent.ACTION_MOVE)
return false;
InputDevice mInputDevice = event.getDevice();
float dpadx = event.getAxisValue(MotionEvent.AXIS_HAT_X);
float dpady = event.getAxisValue(MotionEvent.AXIS_HAT_Y);
if (mInputDevice == null || Math.abs(dpadx) == 1.0f || Math.abs(dpady) == 1.0f)
return false;
float x = AndroidDevices.getCenteredAxis(event, mInputDevice,
MotionEvent.AXIS_X);
float y = AndroidDevices.getCenteredAxis(event, mInputDevice,
MotionEvent.AXIS_Y);
float rz = AndroidDevices.getCenteredAxis(event, mInputDevice,
MotionEvent.AXIS_RZ);
if (System.currentTimeMillis() - mLastMove > JOYSTICK_INPUT_DELAY){
if (Math.abs(x) > 0.3){
if (VLCApplication.showTvUi()) {
navigateDvdMenu(x > 0.0f ? KeyEvent.KEYCODE_DPAD_RIGHT : KeyEvent.KEYCODE_DPAD_LEFT);
} else
seekDelta(x > 0.0f ? 10000 : -10000);
} else if (Math.abs(y) > 0.3){
if (VLCApplication.showTvUi())
navigateDvdMenu(x > 0.0f ? KeyEvent.KEYCODE_DPAD_UP : KeyEvent.KEYCODE_DPAD_DOWN);
else {
if (mIsFirstBrightnessGesture)
initBrightnessTouch();
changeBrightness(-y / 10f);
}
} else if (Math.abs(rz) > 0.3){
mVol = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
int delta = -(int) ((rz / 7) * mAudioMax);
int vol = (int) Math.min(Math.max(mVol + delta, 0), mAudioMax);
setAudioVolume(vol);
}
mLastMove = System.currentTimeMillis();
}
return true;
public boolean dispatchGenericMotionEvent(MotionEvent event) {
return !mIsLoading && mTouchDelegate.dispatchGenericMotionEvent(event);
}
@Override
......@@ -1072,9 +1004,9 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
mLockBackButton = false;
mHandler.sendEmptyMessageDelayed(RESET_BACK_LOCK, 2000);
Toast.makeText(getApplicationContext(), getString(R.string.back_quit_lock), Toast.LENGTH_SHORT).show();
} else if(mPlaylist.getVisibility() == View.VISIBLE) {
} else if(isPlaylistVisible()) {
togglePlaylist();
} else if (mPlaybackSetting != DelayState.OFF){
} else if (isPlaybackSettingActive()){
endPlaybackSetting();
} else if (VLCApplication.showTvUi() && mShowing && !mIsLocked) {
hideOverlay(true);
......@@ -1088,7 +1020,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (mService == null || keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_BUTTON_B)
return super.onKeyDown(keyCode, event);
if (mPlaybackSetting != DelayState.OFF)
if (isPlaybackSettingActive())
return false;
if (mIsLoading) {
switch (keyCode) {
......@@ -1268,6 +1200,38 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
return super.onKeyDown(keyCode, event);
}
void setSavedBrightness(float brightness) {
mSavedBrightness = brightness;
}
int getAudioMax() {
return mAudioMax;
}
AudioManager getAudiomanager() {
return mAudioManager;
}
float getVolume() {
return mVol;
}
void setVolume(float vol) {
mVol = vol;
}
float getOriginalVol() {
return mOriginalVol;
}
void setOriginalVol(float vol) {
mOriginalVol = vol;
}
boolean isAudioBoostEnabled() {
return audioBoostEnabled;
}
private void volumeUp() {
if (mMute) {
updateMute();
......@@ -1293,7 +1257,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
setAudioVolume(vol);
}
private boolean navigateDvdMenu(int keyCode) {
boolean navigateDvdMenu(int keyCode) {
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_UP:
mService.navigate(MediaPlayer.Navigate.Up);
......@@ -1331,13 +1295,13 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
}
public void showDelayControls(){
mTouchAction = TOUCH_NONE;
mTouchDelegate.clearTouchAction();
if (!mDisplayManager.isPrimary()) showOverlayTimeout(OVERLAY_INFINITE);
ViewStubCompat vsc = (ViewStubCompat) findViewById(R.id.player_overlay_settings_stub);
ViewStubCompat vsc = findViewById(R.id.player_overlay_settings_stub);
if (vsc != null) {
vsc.inflate();
mPlaybackSettingPlus = (ImageView) findViewById(R.id.player_delay_plus);
mPlaybackSettingMinus = (ImageView) findViewById(R.id.player_delay_minus);
mPlaybackSettingPlus = findViewById(R.id.player_delay_plus);
mPlaybackSettingMinus = findViewById(R.id.player_delay_minus);
}
mPlaybackSettingMinus.setOnClickListener(this);
......@@ -1350,6 +1314,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
initPlaybackSettingInfo();
}
private void initPlaybackSettingInfo() {
initInfoOverlay();
UiTools.setViewVisibility(mVerticalBar, View.GONE);
......@@ -1370,7 +1335,6 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
@Override
public void endPlaybackSetting() {
mTouchAction = TOUCH_NONE;
mService.saveMediaMeta();
if (mPlaybackSetting == DelayState.AUDIO
&& (mAudioManager.isBluetoothA2dpOn() || mAudioManager.isBluetoothScoOn())) {
......@@ -1402,19 +1366,23 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
mService.setAudioDelay(delay);
mInfo.setText(getString(R.string.audio_delay)+"\n"+(delay/1000L)+" ms");
mAudioDelay = delay;
if (mPlaybackSetting == DelayState.OFF) {
if (!isPlaybackSettingActive()) {
mPlaybackSetting = DelayState.AUDIO;
initPlaybackSettingInfo();
}
}
boolean isPlaybackSettingActive() {
return mPlaybackSetting != DelayState.OFF;
}
public void delaySubs(long delta) {
initInfoOverlay();
long delay = mService.getSpuDelay()+delta;
mService.setSpuDelay(delay);
mInfo.setText(getString(R.string.spu_delay) + "\n" + (delay / 1000L) + " ms");
mSpuDelay = delay;
if (mPlaybackSetting == DelayState.OFF) {
if (!isPlaybackSettingActive()) {
mPlaybackSetting = DelayState.SUBS;
initPlaybackSettingInfo();
}
......@@ -1502,7 +1470,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
* @param text
* @param duration
*/
private void showInfo(String text, int duration) {
void showInfo(String text, int duration) {
initInfoOverlay();
UiTools.setViewVisibility(mVerticalBar, View.GONE);
UiTools.setViewVisibility(mOverlayInfo, View.VISIBLE);
......@@ -1512,11 +1480,11 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
}
private void initInfoOverlay() {
ViewStubCompat vsc = (ViewStubCompat) findViewById(R.id.player_info_stub);
ViewStubCompat vsc = findViewById(R.id.player_info_stub);
if (vsc != null) {
vsc.inflate();
// the info textView is not on the overlay
mInfo = (TextView) findViewById(R.id.player_overlay_textinfo);
mInfo = findViewById(R.id.player_overlay_textinfo);
mOverlayInfo = findViewById(R.id.player_overlay_info);
mVerticalBar = findViewById(R.id.verticalbar);
mVerticalBarProgress = findViewById(R.id.verticalbar_progress);
......@@ -1524,7 +1492,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
}
}
private void showInfo(int textid, int duration) {
void showInfo(int textid, int duration) {
initInfoOverlay();
UiTools.setViewVisibility(mVerticalBar, View.GONE);
UiTools.setViewVisibility(mOverlayInfo, View.VISIBLE);
......@@ -1659,22 +1627,23 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
if (event.getBuffering() == 100f)
stopLoading();
else if (!mHandler.hasMessages(LOADING_ANIMATION) && !mIsLoading
&& mTouchAction != TOUCH_SEEK && !mDragging)
&& !mTouchDelegate.isSeeking() && !mDragging)
mHandler.sendEmptyMessageDelayed(LOADING_ANIMATION, LOADING_ANIMATION_DELAY);
break;
}
}
public Handler getHandler() {
return mHandler;
}
/**
* Handle resize of the surface and the overlay
*/
private final Handler mHandler = new Handler(Looper.getMainLooper(), new Handler.Callback() {
private final Handler mHandler = new Handler(Looper.getMainLooper()) {
@Override
public boolean handleMessage(Message msg) {
if (mService == null)
return true;
switch (msg.what) {
public void handleMessage(Message msg) {
if (mService != null) switch (msg.what) {
case FADE_OUT:
hideOverlay(false);
break;
......@@ -1712,9 +1681,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
showOverlay();
break;
}
return true;
}
});
};
private boolean canShowProgress() {
return !mDragging && mShowing && mService != null && mService.isPlaying();
......@@ -2021,9 +1989,8 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
subtitlesSurface.invalidate();
}
private void sendMouseEvent(int action, int x, int y) {
if (mService == null)
return;
void sendMouseEvent(int action, int x, int y) {
if (mService == null) return;
final IVLCVout vlcVout = mService.getVout();
vlcVout.sendMouseEvent(action, 0, x, y);
}
......@@ -2034,205 +2001,36 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
@Override
public boolean onTouchEvent(MotionEvent event) {
if (mService == null) return false;
if (mDetector == null) {
mDetector = new GestureDetectorCompat(this, mGestureListener);
mDetector.setOnDoubleTapListener(mGestureListener);
}
if (mScaleGestureDetector == null) {
mScaleGestureDetector = new ScaleGestureDetector(this, mScaleListener);
ScaleGestureDetectorCompat.setQuickScaleEnabled(mScaleGestureDetector, false);
}
if (mPlaybackSetting != DelayState.OFF) {
if (event.getAction() == MotionEvent.ACTION_UP) endPlaybackSetting();
return true;
} else if (mPlaylist.getVisibility() == View.VISIBLE) {
mTouchAction = TOUCH_IGNORE;
togglePlaylist();
return true;
}
if (mTouchControls == 0 || mIsLocked) {
// locked or swipe disabled, only handle show/hide & ignore all actions
if (event.getAction() == MotionEvent.ACTION_UP) {
if (!mShowing) {
showOverlay();
} else {
hideOverlay(true);
}
}
return false;
}
mScaleGestureDetector.onTouchEvent(event);
if ((mScaleGestureDetector != null && mScaleGestureDetector.isInProgress()) ||
(mDetector != null && mDetector.onTouchEvent(event))) {
mTouchAction = TOUCH_IGNORE;
return true;
}
final float x_changed = mTouchX != -1f && mTouchY != -1f ? event.getRawX() - mTouchX : 0f;
final float y_changed = x_changed != 0f ? event.getRawY()