From 1236edf9b079582c9edfd5cd8ba8b049c8853499 Mon Sep 17 00:00:00 2001 From: "David A. Velasco" Date: Thu, 21 Mar 2013 15:49:10 +0100 Subject: [PATCH] Improvementes in full screen video: tap on video shows and hides controls; full screen available in portrait; fade out for controls reduced to 4 seconds --- .../owncloud/android/media/MediaService.java | 2 +- .../ui/preview/PreviewVideoActivity.java | 43 +++++++++++++++---- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/com/owncloud/android/media/MediaService.java b/src/com/owncloud/android/media/MediaService.java index f8e70fe71f..379b404a98 100644 --- a/src/com/owncloud/android/media/MediaService.java +++ b/src/com/owncloud/android/media/MediaService.java @@ -73,7 +73,7 @@ public class MediaService extends Service implements OnCompletionListener, OnPre public static final int OC_MEDIA_ERROR = 0; /** Time To keep the control panel visible when the user does not use it */ - public static final int MEDIA_CONTROL_SHORT_LIFE = 5000; + public static final int MEDIA_CONTROL_SHORT_LIFE = 4000; /** Time To keep the control panel visible when the user does not use it */ public static final int MEDIA_CONTROL_PERMANENT = 0; diff --git a/src/com/owncloud/android/ui/preview/PreviewVideoActivity.java b/src/com/owncloud/android/ui/preview/PreviewVideoActivity.java index 0b12920bb2..38eb634604 100644 --- a/src/com/owncloud/android/ui/preview/PreviewVideoActivity.java +++ b/src/com/owncloud/android/ui/preview/PreviewVideoActivity.java @@ -88,11 +88,19 @@ public class PreviewVideoActivity extends Activity implements OnCompletionListen setContentView(R.layout.video_layout); - Bundle extras = getIntent().getExtras(); - mFile = extras.getParcelable(EXTRA_FILE); - mAccount = extras.getParcelable(EXTRA_ACCOUNT); - mSavedPlaybackPosition = extras.getInt(EXTRA_START_POSITION); - mAutoplay = extras.getBoolean(EXTRA_AUTOPLAY); + if (savedInstanceState == null) { + Bundle extras = getIntent().getExtras(); + mFile = extras.getParcelable(EXTRA_FILE); + mAccount = extras.getParcelable(EXTRA_ACCOUNT); + mSavedPlaybackPosition = extras.getInt(EXTRA_START_POSITION); + mAutoplay = extras.getBoolean(EXTRA_AUTOPLAY); + + } else { + mFile = savedInstanceState.getParcelable(EXTRA_FILE); + mAccount = savedInstanceState.getParcelable(EXTRA_ACCOUNT); + mSavedPlaybackPosition = savedInstanceState.getInt(EXTRA_START_POSITION); + mAutoplay = savedInstanceState.getBoolean(EXTRA_AUTOPLAY); + } mVideoPlayer = (VideoView) findViewById(R.id.videoPlayer); @@ -129,8 +137,22 @@ public class PreviewVideoActivity extends Activity implements OnCompletionListen } + /** + * {@inheritDoc} + */ + @Override + public void onSaveInstanceState(Bundle outState) { + super.onSaveInstanceState(outState); + outState.putParcelable(PreviewVideoActivity.EXTRA_FILE, mFile); + outState.putParcelable(PreviewVideoActivity.EXTRA_ACCOUNT, mAccount); + outState.putInt(PreviewVideoActivity.EXTRA_START_POSITION, mVideoPlayer.getCurrentPosition()); + outState.putBoolean(PreviewVideoActivity.EXTRA_AUTOPLAY , mVideoPlayer.isPlaying()); + } + + @Override public void onBackPressed() { + Log.e(TAG, "onBackPressed"); Intent i = new Intent(); i.putExtra(EXTRA_AUTOPLAY, mVideoPlayer.isPlaying()); i.putExtra(EXTRA_START_POSITION, mVideoPlayer.getCurrentPosition()); @@ -208,12 +230,17 @@ public class PreviewVideoActivity extends Activity implements OnCompletionListen */ @Override public boolean onTouchEvent (MotionEvent ev){ - if (ev.getAction() == MotionEvent.ACTION_DOWN) { - mMediaController.show(MediaService.MEDIA_CONTROL_SHORT_LIFE); + /*if (ev.getAction() == MotionEvent.ACTION_DOWN) { + if (mMediaController.isShowing()) { + mMediaController.hide(); + } else { + mMediaController.show(MediaService.MEDIA_CONTROL_SHORT_LIFE); + } return true; } else { return false; - } + }*/ + return false; }