Commit d32fe528 authored by Thomas Guillem's avatar Thomas Guillem Committed by Geoffrey Métais

VideoPlayerActivity: Improve overlay timeout handling.

Don't hide ui on gesture or while seeking.
Signed-off-by: default avatarGeoffrey Métais <geoffrey.metais@gmail.com>
parent b2077e21
...@@ -1412,29 +1412,27 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer { ...@@ -1412,29 +1412,27 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
if (mEnableBrightnessGesture && (int)mTouchX < (screen.widthPixels / 2)){ if (mEnableBrightnessGesture && (int)mTouchX < (screen.widthPixels / 2)){
doBrightnessTouch(y_changed); doBrightnessTouch(y_changed);
} }
// Extend the overlay for a little while, so that it doesn't
// disappear on the user if more adjustment is needed. This
// is because on devices with soft navigation (e.g. Galaxy
// Nexus), gestures can't be made without activating the UI.
if(AndroidDevices.hasNavBar())
showOverlay();
} else { } else {
// Seek (Right or Left move) // Seek (Right or Left move)
doSeekTouch(coef, xgesturesize, false); doSeekTouch(coef, xgesturesize, false);
} }
if (mTouchAction != TOUCH_NONE && mOverlayTimeout != OVERLAY_INFINITE)
showOverlayTimeout(OVERLAY_INFINITE);
break; break;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
// Mouse events for the core // Mouse events for the core
LibVLC.sendMouseEvent(MotionEvent.ACTION_UP, 0, xTouch, yTouch); LibVLC.sendMouseEvent(MotionEvent.ACTION_UP, 0, xTouch, yTouch);
// Audio or Brightness if (mTouchAction == TOUCH_NONE) {
if ( mTouchAction == TOUCH_NONE) {
if (!mShowing) { if (!mShowing) {
showOverlay(); showOverlay();
} else { } else {
hideOverlay(true); hideOverlay(true);
} }
} else {
// We were in gesture mode, re-init the overlay timeout
showOverlay(true);
} }
// Seek // Seek
doSeekTouch(coef, xgesturesize, true); doSeekTouch(coef, xgesturesize, true);
...@@ -1452,9 +1450,6 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer { ...@@ -1452,9 +1450,6 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
return; return;
mTouchAction = TOUCH_SEEK; mTouchAction = TOUCH_SEEK;
// Always show seekbar when searching
if (!mShowing) showOverlay();
long length = mLibVLC.getLength(); long length = mLibVLC.getLength();
long time = mLibVLC.getTime(); long time = mLibVLC.getTime();
...@@ -1566,13 +1561,13 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer { ...@@ -1566,13 +1561,13 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
@Override @Override
public void onStartTrackingTouch(SeekBar seekBar) { public void onStartTrackingTouch(SeekBar seekBar) {
mDragging = true; mDragging = true;
showOverlay(OVERLAY_INFINITE); showOverlayTimeout(OVERLAY_INFINITE);
} }
@Override @Override
public void onStopTrackingTouch(SeekBar seekBar) { public void onStopTrackingTouch(SeekBar seekBar) {
mDragging = false; mDragging = false;
showOverlay(); showOverlay(true);
} }
@Override @Override
...@@ -1714,12 +1709,12 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer { ...@@ -1714,12 +1709,12 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
}; };
private final void doPlayPause() { private final void doPlayPause() {
if (mLibVLC.isPlaying()){ if (mLibVLC.isPlaying()) {
pause(); pause();
showOverlay(OVERLAY_INFINITE); showOverlayTimeout(OVERLAY_INFINITE);
} else { } else {
play(); play();
showOverlay(OVERLAY_TIMEOUT); showOverlayTimeout(OVERLAY_TIMEOUT);
} }
} }
...@@ -1870,10 +1865,20 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer { ...@@ -1870,10 +1865,20 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
}; };
/** /**
* show overlay the the default timeout * show overlay
* @param forceCheck: adjust the timeout in function of playing state
*/
private void showOverlay(boolean forceCheck) {
if (forceCheck)
mOverlayTimeout = 0;
showOverlayTimeout(0);
}
/**
* show overlay with the previous timeout value
*/ */
private void showOverlay() { private void showOverlay() {
showOverlay(0); showOverlay(false);
} }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @TargetApi(Build.VERSION_CODES.HONEYCOMB)
...@@ -1887,7 +1892,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer { ...@@ -1887,7 +1892,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
/** /**
* show overlay * show overlay
*/ */
private void showOverlay(int timeout) { private void showOverlayTimeout(int timeout) {
if (timeout != 0) if (timeout != 0)
mOverlayTimeout = timeout; mOverlayTimeout = timeout;
if (mOverlayTimeout == 0) if (mOverlayTimeout == 0)
...@@ -1924,6 +1929,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer { ...@@ -1924,6 +1929,7 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
*/ */
private void hideOverlay(boolean fromUser) { private void hideOverlay(boolean fromUser) {
if (mShowing) { if (mShowing) {
mHandler.removeMessages(FADE_OUT);
mHandler.removeMessages(SHOW_PROGRESS); mHandler.removeMessages(SHOW_PROGRESS);
Log.i(TAG, "remove View!"); Log.i(TAG, "remove View!");
if (mOverlayTips != null) mOverlayTips.setVisibility(View.INVISIBLE); if (mOverlayTips != null) mOverlayTips.setVisibility(View.INVISIBLE);
......
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