|
@@ -3,8 +3,10 @@
|
|
*
|
|
*
|
|
* @author David A. Velasco
|
|
* @author David A. Velasco
|
|
* @author Chris Narkiewicz
|
|
* @author Chris Narkiewicz
|
|
|
|
+ * @author Andy Scherzinger
|
|
* Copyright (C) 2016 ownCloud Inc.
|
|
* Copyright (C) 2016 ownCloud Inc.
|
|
* Copyright (C) 2019 Chris Narkiewicz <hello@ezaquarii.com>
|
|
* Copyright (C) 2019 Chris Narkiewicz <hello@ezaquarii.com>
|
|
|
|
+ * Copyright (C) 2020 Andy Scherzinger
|
|
*
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2,
|
|
* it under the terms of the GNU General Public License version 2,
|
|
@@ -17,7 +19,6 @@
|
|
*
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
- *
|
|
|
|
*/
|
|
*/
|
|
package com.owncloud.android.ui.preview;
|
|
package com.owncloud.android.ui.preview;
|
|
|
|
|
|
@@ -45,11 +46,7 @@ import android.view.MotionEvent;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
import android.view.View.OnTouchListener;
|
|
import android.view.View.OnTouchListener;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
-import android.widget.ImageView;
|
|
|
|
import android.widget.LinearLayout;
|
|
import android.widget.LinearLayout;
|
|
-import android.widget.RelativeLayout;
|
|
|
|
-import android.widget.TextView;
|
|
|
|
-import android.widget.VideoView;
|
|
|
|
|
|
|
|
import com.nextcloud.client.account.User;
|
|
import com.nextcloud.client.account.User;
|
|
import com.nextcloud.client.account.UserAccountManager;
|
|
import com.nextcloud.client.account.UserAccountManager;
|
|
@@ -59,13 +56,13 @@ import com.nextcloud.client.media.ErrorFormat;
|
|
import com.nextcloud.client.media.PlayerServiceConnection;
|
|
import com.nextcloud.client.media.PlayerServiceConnection;
|
|
import com.nextcloud.client.network.ClientFactory;
|
|
import com.nextcloud.client.network.ClientFactory;
|
|
import com.owncloud.android.R;
|
|
import com.owncloud.android.R;
|
|
|
|
+import com.owncloud.android.databinding.FragmentPreviewMediaBinding;
|
|
import com.owncloud.android.datamodel.OCFile;
|
|
import com.owncloud.android.datamodel.OCFile;
|
|
import com.owncloud.android.files.FileMenuFilter;
|
|
import com.owncloud.android.files.FileMenuFilter;
|
|
import com.owncloud.android.files.StreamMediaFileOperation;
|
|
import com.owncloud.android.files.StreamMediaFileOperation;
|
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
|
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
|
|
import com.owncloud.android.lib.common.utils.Log_OC;
|
|
import com.owncloud.android.lib.common.utils.Log_OC;
|
|
-import com.owncloud.android.media.MediaControlView;
|
|
|
|
import com.owncloud.android.ui.activity.DrawerActivity;
|
|
import com.owncloud.android.ui.activity.DrawerActivity;
|
|
import com.owncloud.android.ui.activity.FileActivity;
|
|
import com.owncloud.android.ui.activity.FileActivity;
|
|
import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
|
|
import com.owncloud.android.ui.dialog.ConfirmationDialogFragment;
|
|
@@ -77,7 +74,6 @@ import java.lang.ref.WeakReference;
|
|
|
|
|
|
import javax.inject.Inject;
|
|
import javax.inject.Inject;
|
|
|
|
|
|
-import androidx.annotation.DrawableRes;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.StringRes;
|
|
import androidx.annotation.StringRes;
|
|
import androidx.drawerlayout.widget.DrawerLayout;
|
|
import androidx.drawerlayout.widget.DrawerLayout;
|
|
@@ -107,34 +103,26 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|
private static final String AUTOPLAY = "AUTOPLAY";
|
|
private static final String AUTOPLAY = "AUTOPLAY";
|
|
|
|
|
|
private User user;
|
|
private User user;
|
|
- private ImageView mImagePreview;
|
|
|
|
- private VideoView mVideoPreview;
|
|
|
|
- private int mSavedPlaybackPosition;
|
|
|
|
-
|
|
|
|
- private RelativeLayout mPreviewContainer;
|
|
|
|
-
|
|
|
|
- private LinearLayout mMultiListContainer;
|
|
|
|
- private TextView mMultiListMessage;
|
|
|
|
- private TextView mMultiListHeadline;
|
|
|
|
- private ImageView mMultiListIcon;
|
|
|
|
|
|
+ private int savedPlaybackPosition;
|
|
|
|
|
|
- private MediaControlView mMediaController;
|
|
|
|
- private boolean mAutoplay;
|
|
|
|
- private boolean mPrepared;
|
|
|
|
- private PlayerServiceConnection mMediaPlayerServiceConnection;
|
|
|
|
|
|
+ private boolean autoplay;
|
|
|
|
+ private boolean prepared;
|
|
|
|
+ private PlayerServiceConnection mediaPlayerServiceConnection;
|
|
|
|
|
|
- private Uri mVideoUri;
|
|
|
|
|
|
+ private Uri videoUri;
|
|
@Inject ClientFactory clientFactory;
|
|
@Inject ClientFactory clientFactory;
|
|
@Inject UserAccountManager accountManager;
|
|
@Inject UserAccountManager accountManager;
|
|
@Inject DeviceInfo deviceInfo;
|
|
@Inject DeviceInfo deviceInfo;
|
|
|
|
+ FragmentPreviewMediaBinding binding;
|
|
|
|
+ LinearLayout emptyListView;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Creates a fragment to preview a file.
|
|
* Creates a fragment to preview a file.
|
|
- *
|
|
|
|
- * When 'fileToDetail' or 'ocAccount' are null
|
|
|
|
|
|
+ * <p>
|
|
|
|
+ * When 'fileToDetail' or 'user' are null
|
|
*
|
|
*
|
|
* @param fileToDetail An {@link OCFile} to preview in the fragment
|
|
* @param fileToDetail An {@link OCFile} to preview in the fragment
|
|
- * @param user Currently active user
|
|
|
|
|
|
+ * @param user Currently active user
|
|
*/
|
|
*/
|
|
public static PreviewMediaFragment newInstance(OCFile fileToDetail, User user, int startPlaybackPosition,
|
|
public static PreviewMediaFragment newInstance(OCFile fileToDetail, User user, int startPlaybackPosition,
|
|
boolean autoplay) {
|
|
boolean autoplay) {
|
|
@@ -162,8 +150,8 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|
*/
|
|
*/
|
|
public PreviewMediaFragment() {
|
|
public PreviewMediaFragment() {
|
|
super();
|
|
super();
|
|
- mSavedPlaybackPosition = 0;
|
|
|
|
- mAutoplay = true;
|
|
|
|
|
|
+ savedPlaybackPosition = 0;
|
|
|
|
+ autoplay = true;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -175,9 +163,9 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|
|
|
|
|
setFile(bundle.getParcelable(FILE));
|
|
setFile(bundle.getParcelable(FILE));
|
|
user = bundle.getParcelable(USER);
|
|
user = bundle.getParcelable(USER);
|
|
- mSavedPlaybackPosition = bundle.getInt(PLAYBACK_POSITION);
|
|
|
|
- mAutoplay = bundle.getBoolean(AUTOPLAY);
|
|
|
|
- mMediaPlayerServiceConnection = new PlayerServiceConnection(getContext());
|
|
|
|
|
|
+ savedPlaybackPosition = bundle.getInt(PLAYBACK_POSITION);
|
|
|
|
+ autoplay = bundle.getBoolean(AUTOPLAY);
|
|
|
|
+ mediaPlayerServiceConnection = new PlayerServiceConnection(getContext());
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -185,44 +173,30 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|
super.onCreateView(inflater, container, savedInstanceState);
|
|
super.onCreateView(inflater, container, savedInstanceState);
|
|
Log_OC.v(TAG, "onCreateView");
|
|
Log_OC.v(TAG, "onCreateView");
|
|
|
|
|
|
|
|
+ binding = FragmentPreviewMediaBinding.inflate(inflater, container, false);
|
|
|
|
+ View view = binding.getRoot();
|
|
|
|
|
|
- View view = inflater.inflate(R.layout.file_preview, container, false);
|
|
|
|
-
|
|
|
|
- mPreviewContainer = view.findViewById(R.id.file_preview_container);
|
|
|
|
- mImagePreview = view.findViewById(R.id.image_preview);
|
|
|
|
- mVideoPreview = view.findViewById(R.id.video_preview);
|
|
|
|
- mVideoPreview.setOnTouchListener(this);
|
|
|
|
|
|
+ emptyListView = binding.emptyView.emptyListView;
|
|
|
|
|
|
- mMediaController = view.findViewById(R.id.media_controller);
|
|
|
|
|
|
+ binding.videoPreview.setOnTouchListener(this);
|
|
|
|
|
|
- setupMultiView(view);
|
|
|
|
- setMultiListLoadingMessage();
|
|
|
|
|
|
+ setLoadingView();
|
|
return view;
|
|
return view;
|
|
}
|
|
}
|
|
|
|
|
|
- private void setupMultiView(View view) {
|
|
|
|
- mMultiListContainer = view.findViewById(R.id.empty_list_view);
|
|
|
|
- mMultiListMessage = view.findViewById(R.id.empty_list_view_text);
|
|
|
|
- mMultiListHeadline = view.findViewById(R.id.empty_list_view_headline);
|
|
|
|
- mMultiListIcon = view.findViewById(R.id.empty_list_icon);
|
|
|
|
|
|
+ private void setLoadingView() {
|
|
|
|
+ binding.progress.setVisibility(View.VISIBLE);
|
|
|
|
+ binding.emptyView.emptyListView.setVisibility(View.GONE);
|
|
}
|
|
}
|
|
|
|
|
|
- private void setMultiListLoadingMessage() {
|
|
|
|
- if (mMultiListContainer != null) {
|
|
|
|
- mMultiListHeadline.setText(R.string.file_list_loading);
|
|
|
|
- mMultiListMessage.setText("");
|
|
|
|
- mMultiListIcon.setVisibility(View.GONE);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void setMessageForMultiList(String headline, @StringRes int message, @DrawableRes int icon) {
|
|
|
|
- if (mMultiListContainer != null && mMultiListMessage != null) {
|
|
|
|
- mMultiListHeadline.setText(headline);
|
|
|
|
- mMultiListMessage.setText(message);
|
|
|
|
- mMultiListIcon.setImageResource(icon);
|
|
|
|
- mMultiListMessage.setVisibility(View.VISIBLE);
|
|
|
|
- mMultiListIcon.setVisibility(View.VISIBLE);
|
|
|
|
- }
|
|
|
|
|
|
+ private void setVideoErrorMessage(String headline, @StringRes int message) {
|
|
|
|
+ binding.emptyView.emptyListViewHeadline.setText(headline);
|
|
|
|
+ binding.emptyView.emptyListViewText.setText(message);
|
|
|
|
+ binding.emptyView.emptyListIcon.setImageResource(R.drawable.file_movie);
|
|
|
|
+ binding.emptyView.emptyListViewText.setVisibility(View.VISIBLE);
|
|
|
|
+ binding.emptyView.emptyListIcon.setVisibility(View.VISIBLE);
|
|
|
|
+ binding.progress.setVisibility(View.GONE);
|
|
|
|
+ binding.emptyView.emptyListView.setVisibility(View.VISIBLE);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -242,18 +216,18 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|
file = savedInstanceState.getParcelable(EXTRA_FILE);
|
|
file = savedInstanceState.getParcelable(EXTRA_FILE);
|
|
setFile(file);
|
|
setFile(file);
|
|
user = savedInstanceState.getParcelable(EXTRA_USER);
|
|
user = savedInstanceState.getParcelable(EXTRA_USER);
|
|
- mSavedPlaybackPosition = savedInstanceState.getInt(EXTRA_PLAY_POSITION);
|
|
|
|
- mAutoplay = savedInstanceState.getBoolean(EXTRA_PLAYING);
|
|
|
|
|
|
+ savedPlaybackPosition = savedInstanceState.getInt(EXTRA_PLAY_POSITION);
|
|
|
|
+ autoplay = savedInstanceState.getBoolean(EXTRA_PLAYING);
|
|
}
|
|
}
|
|
|
|
|
|
if (file != null) {
|
|
if (file != null) {
|
|
if (MimeTypeUtil.isVideo(file)) {
|
|
if (MimeTypeUtil.isVideo(file)) {
|
|
- mVideoPreview.setVisibility(View.VISIBLE);
|
|
|
|
- mImagePreview.setVisibility(View.GONE);
|
|
|
|
|
|
+ binding.videoPreview.setVisibility(View.VISIBLE);
|
|
|
|
+ binding.imagePreview.setVisibility(View.GONE);
|
|
prepareVideo();
|
|
prepareVideo();
|
|
} else {
|
|
} else {
|
|
- mVideoPreview.setVisibility(View.GONE);
|
|
|
|
- mImagePreview.setVisibility(View.VISIBLE);
|
|
|
|
|
|
+ binding.videoPreview.setVisibility(View.GONE);
|
|
|
|
+ binding.imagePreview.setVisibility(View.VISIBLE);
|
|
extractAndSetCoverArt(file);
|
|
extractAndSetCoverArt(file);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -273,12 +247,12 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|
byte[] data = mmr.getEmbeddedPicture();
|
|
byte[] data = mmr.getEmbeddedPicture();
|
|
if (data != null) {
|
|
if (data != null) {
|
|
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
|
|
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
|
|
- mImagePreview.setImageBitmap(bitmap); //associated cover art in bitmap
|
|
|
|
|
|
+ binding.imagePreview.setImageBitmap(bitmap); //associated cover art in bitmap
|
|
} else {
|
|
} else {
|
|
- mImagePreview.setImageResource(R.drawable.logo);
|
|
|
|
|
|
+ binding.imagePreview.setImageResource(R.drawable.logo);
|
|
}
|
|
}
|
|
} catch (Throwable t) {
|
|
} catch (Throwable t) {
|
|
- mImagePreview.setImageResource(R.drawable.logo);
|
|
|
|
|
|
+ binding.imagePreview.setImageResource(R.drawable.logo);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -292,15 +266,15 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|
outState.putParcelable(EXTRA_USER, user);
|
|
outState.putParcelable(EXTRA_USER, user);
|
|
|
|
|
|
if (MimeTypeUtil.isVideo(getFile())) {
|
|
if (MimeTypeUtil.isVideo(getFile())) {
|
|
- if (mVideoPreview != null) {
|
|
|
|
- mSavedPlaybackPosition = mVideoPreview.getCurrentPosition();
|
|
|
|
- mAutoplay = mVideoPreview.isPlaying();
|
|
|
|
- outState.putInt(EXTRA_PLAY_POSITION, mSavedPlaybackPosition);
|
|
|
|
- outState.putBoolean(EXTRA_PLAYING, mAutoplay);
|
|
|
|
|
|
+ if (binding.videoPreview != null) {
|
|
|
|
+ savedPlaybackPosition = binding.videoPreview.getCurrentPosition();
|
|
|
|
+ autoplay = binding.videoPreview.isPlaying();
|
|
|
|
+ outState.putInt(EXTRA_PLAY_POSITION, savedPlaybackPosition);
|
|
|
|
+ outState.putBoolean(EXTRA_PLAYING, autoplay);
|
|
}
|
|
}
|
|
- } else if(mMediaPlayerServiceConnection.isConnected()) {
|
|
|
|
- outState.putInt(EXTRA_PLAY_POSITION, mMediaPlayerServiceConnection.getCurrentPosition());
|
|
|
|
- outState.putBoolean(EXTRA_PLAYING, mMediaPlayerServiceConnection.isPlaying());
|
|
|
|
|
|
+ } else if(mediaPlayerServiceConnection.isConnected()) {
|
|
|
|
+ outState.putInt(EXTRA_PLAY_POSITION, mediaPlayerServiceConnection.getCurrentPosition());
|
|
|
|
+ outState.putBoolean(EXTRA_PLAYING, mediaPlayerServiceConnection.isPlaying());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -311,15 +285,16 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|
OCFile file = getFile();
|
|
OCFile file = getFile();
|
|
if (file != null) {
|
|
if (file != null) {
|
|
// bind to any existing player
|
|
// bind to any existing player
|
|
- mMediaPlayerServiceConnection.bind();
|
|
|
|
|
|
+ mediaPlayerServiceConnection.bind();
|
|
|
|
|
|
if (MimeTypeUtil.isAudio(file)) {
|
|
if (MimeTypeUtil.isAudio(file)) {
|
|
- mMediaController.setMediaPlayer(mMediaPlayerServiceConnection);
|
|
|
|
- mMediaPlayerServiceConnection.start(user, file, mAutoplay, mSavedPlaybackPosition);
|
|
|
|
- mMultiListContainer.setVisibility(View.GONE);
|
|
|
|
- mPreviewContainer.setVisibility(View.VISIBLE);
|
|
|
|
|
|
+ binding.mediaController.setMediaPlayer(mediaPlayerServiceConnection);
|
|
|
|
+ mediaPlayerServiceConnection.start(user, file, mAutoplay, mSavedPlaybackPosition);
|
|
|
|
+ binding.emptyView.emptyListView.setVisibility(View.GONE);
|
|
|
|
+ binding.progress.setVisibility(View.GONE);
|
|
|
|
+ binding.filePreviewContainer.setVisibility(View.VISIBLE);
|
|
} else if (MimeTypeUtil.isVideo(file)) {
|
|
} else if (MimeTypeUtil.isVideo(file)) {
|
|
- if (mMediaPlayerServiceConnection.isConnected()) {
|
|
|
|
|
|
+ if (mediaPlayerServiceConnection.isConnected()) {
|
|
// always stop player
|
|
// always stop player
|
|
stopAudio();
|
|
stopAudio();
|
|
}
|
|
}
|
|
@@ -329,7 +304,7 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|
}
|
|
}
|
|
|
|
|
|
private void stopAudio() {
|
|
private void stopAudio() {
|
|
- mMediaPlayerServiceConnection.stop();
|
|
|
|
|
|
+ mediaPlayerServiceConnection.stop();
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -412,31 +387,25 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
- switch (item.getItemId()) {
|
|
|
|
- case R.id.action_send_share_file: {
|
|
|
|
- sendShareFile();
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- case R.id.action_open_file_with: {
|
|
|
|
- openFile();
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- case R.id.action_remove_file: {
|
|
|
|
- RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(getFile());
|
|
|
|
- dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION);
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- case R.id.action_see_details: {
|
|
|
|
- seeDetails();
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- case R.id.action_sync_file: {
|
|
|
|
- containerActivity.getFileOperationsHelper().syncFile(getFile());
|
|
|
|
- return true;
|
|
|
|
- }
|
|
|
|
- default:
|
|
|
|
- return super.onOptionsItemSelected(item);
|
|
|
|
|
|
+ int itemId = item.getItemId();
|
|
|
|
+ if (itemId == R.id.action_send_share_file) {
|
|
|
|
+ sendShareFile();
|
|
|
|
+ return true;
|
|
|
|
+ } else if (itemId == R.id.action_open_file_with) {
|
|
|
|
+ openFile();
|
|
|
|
+ return true;
|
|
|
|
+ } else if (itemId == R.id.action_remove_file) {
|
|
|
|
+ RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(getFile());
|
|
|
|
+ dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION);
|
|
|
|
+ return true;
|
|
|
|
+ } else if (itemId == R.id.action_see_details) {
|
|
|
|
+ seeDetails();
|
|
|
|
+ return true;
|
|
|
|
+ } else if (itemId == R.id.action_sync_file) {
|
|
|
|
+ containerActivity.getFileOperationsHelper().syncFile(getFile());
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
+ return super.onOptionsItemSelected(item);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -461,19 +430,19 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|
private void prepareVideo() {
|
|
private void prepareVideo() {
|
|
// create helper to get more control on the playback
|
|
// create helper to get more control on the playback
|
|
VideoHelper videoHelper = new VideoHelper();
|
|
VideoHelper videoHelper = new VideoHelper();
|
|
- mVideoPreview.setOnPreparedListener(videoHelper);
|
|
|
|
- mVideoPreview.setOnCompletionListener(videoHelper);
|
|
|
|
- mVideoPreview.setOnErrorListener(videoHelper);
|
|
|
|
|
|
+ binding.videoPreview.setOnPreparedListener(videoHelper);
|
|
|
|
+ binding.videoPreview.setOnCompletionListener(videoHelper);
|
|
|
|
+ binding.videoPreview.setOnErrorListener(videoHelper);
|
|
}
|
|
}
|
|
|
|
|
|
private void playVideo() {
|
|
private void playVideo() {
|
|
// create and prepare control panel for the user
|
|
// create and prepare control panel for the user
|
|
- mMediaController.setMediaPlayer(mVideoPreview);
|
|
|
|
|
|
+ binding.mediaController.setMediaPlayer(binding.videoPreview);
|
|
|
|
|
|
// load the video file in the video player
|
|
// load the video file in the video player
|
|
// when done, VideoHelper#onPrepared() will be called
|
|
// when done, VideoHelper#onPrepared() will be called
|
|
if (getFile().isDown()) {
|
|
if (getFile().isDown()) {
|
|
- mVideoPreview.setVideoURI(getFile().getStorageUri());
|
|
|
|
|
|
+ binding.videoPreview.setVideoURI(getFile().getStorageUri());
|
|
} else {
|
|
} else {
|
|
try {
|
|
try {
|
|
OwnCloudClient client = clientFactory.create(user);
|
|
OwnCloudClient client = clientFactory.create(user);
|
|
@@ -512,13 +481,13 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|
final Context context = previewMediaFragment != null ? previewMediaFragment.getContext() : null;
|
|
final Context context = previewMediaFragment != null ? previewMediaFragment.getContext() : null;
|
|
if (previewMediaFragment != null && context != null) {
|
|
if (previewMediaFragment != null && context != null) {
|
|
if (uri != null) {
|
|
if (uri != null) {
|
|
- previewMediaFragment.mVideoUri = uri;
|
|
|
|
- previewMediaFragment.mVideoPreview.setVideoURI(uri);
|
|
|
|
|
|
+ previewMediaFragment.videoUri = uri;
|
|
|
|
+ previewMediaFragment.binding.videoPreview.setVideoURI(uri);
|
|
} else {
|
|
} else {
|
|
- previewMediaFragment.mMultiListContainer.setVisibility(View.VISIBLE);
|
|
|
|
- previewMediaFragment.setMessageForMultiList(
|
|
|
|
|
|
+ previewMediaFragment.emptyListView.setVisibility(View.VISIBLE);
|
|
|
|
+ previewMediaFragment.setVideoErrorMessage(
|
|
previewMediaFragment.getString(R.string.stream_not_possible_headline),
|
|
previewMediaFragment.getString(R.string.stream_not_possible_headline),
|
|
- R.string.stream_not_possible_message, R.drawable.file_movie);
|
|
|
|
|
|
+ R.string.stream_not_possible_message);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
Log_OC.e(TAG, "Error streaming file: no previewMediaFragment!");
|
|
Log_OC.e(TAG, "Error streaming file: no previewMediaFragment!");
|
|
@@ -538,15 +507,16 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|
@Override
|
|
@Override
|
|
public void onPrepared(MediaPlayer vp) {
|
|
public void onPrepared(MediaPlayer vp) {
|
|
Log_OC.v(TAG, "onPrepared");
|
|
Log_OC.v(TAG, "onPrepared");
|
|
- mMultiListContainer.setVisibility(View.GONE);
|
|
|
|
- mPreviewContainer.setVisibility(View.VISIBLE);
|
|
|
|
- mVideoPreview.seekTo(mSavedPlaybackPosition);
|
|
|
|
- if (mAutoplay) {
|
|
|
|
- mVideoPreview.start();
|
|
|
|
|
|
+ binding.emptyView.emptyListView.setVisibility(View.GONE);
|
|
|
|
+ binding.progress.setVisibility(View.GONE);
|
|
|
|
+ binding.filePreviewContainer.setVisibility(View.VISIBLE);
|
|
|
|
+ binding.videoPreview.seekTo(savedPlaybackPosition);
|
|
|
|
+ if (autoplay) {
|
|
|
|
+ binding.videoPreview.start();
|
|
}
|
|
}
|
|
- mMediaController.setEnabled(true);
|
|
|
|
- mMediaController.updatePausePlay();
|
|
|
|
- mPrepared = true;
|
|
|
|
|
|
+ binding.mediaController.setEnabled(true);
|
|
|
|
+ binding.mediaController.updatePausePlay();
|
|
|
|
+ prepared = true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -561,9 +531,9 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|
public void onCompletion(MediaPlayer mp) {
|
|
public void onCompletion(MediaPlayer mp) {
|
|
Log_OC.v(TAG, "completed");
|
|
Log_OC.v(TAG, "completed");
|
|
if (mp != null) {
|
|
if (mp != null) {
|
|
- mVideoPreview.seekTo(0);
|
|
|
|
|
|
+ binding.videoPreview.seekTo(0);
|
|
} // else : called from onError()
|
|
} // else : called from onError()
|
|
- mMediaController.updatePausePlay();
|
|
|
|
|
|
+ binding.mediaController.updatePausePlay();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -576,12 +546,13 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|
@Override
|
|
@Override
|
|
public boolean onError(MediaPlayer mp, int what, int extra) {
|
|
public boolean onError(MediaPlayer mp, int what, int extra) {
|
|
Log_OC.e(TAG, "Error in video playback, what = " + what + ", extra = " + extra);
|
|
Log_OC.e(TAG, "Error in video playback, what = " + what + ", extra = " + extra);
|
|
- mPreviewContainer.setVisibility(View.GONE);
|
|
|
|
|
|
+ binding.filePreviewContainer.setVisibility(View.GONE);
|
|
|
|
+ binding.progress.setVisibility(View.GONE);
|
|
final Context context = getActivity();
|
|
final Context context = getActivity();
|
|
- if (mVideoPreview.getWindowToken() != null && context != null) {
|
|
|
|
|
|
+ if (binding.videoPreview.getWindowToken() != null && context != null) {
|
|
String message = ErrorFormat.toString(context, what, extra);
|
|
String message = ErrorFormat.toString(context, what, extra);
|
|
- mMultiListContainer.setVisibility(View.VISIBLE);
|
|
|
|
- setMessageForMultiList(message, R.string.preview_sorry, R.drawable.file_movie);
|
|
|
|
|
|
+ binding.emptyView.emptyListView.setVisibility(View.VISIBLE);
|
|
|
|
+ setVideoErrorMessage(message, R.string.preview_sorry);
|
|
}
|
|
}
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -606,17 +577,24 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|
super.onDestroy();
|
|
super.onDestroy();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void onDestroyView() {
|
|
|
|
+ Log_OC.v(TAG, "onDestroyView");
|
|
|
|
+ super.onDestroyView();
|
|
|
|
+ binding = null;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void onStop() {
|
|
public void onStop() {
|
|
Log_OC.v(TAG, "onStop");
|
|
Log_OC.v(TAG, "onStop");
|
|
- mMediaPlayerServiceConnection.unbind();
|
|
|
|
|
|
+ mediaPlayerServiceConnection.unbind();
|
|
toggleDrawerLockMode(containerActivity, DrawerLayout.LOCK_MODE_UNLOCKED);
|
|
toggleDrawerLockMode(containerActivity, DrawerLayout.LOCK_MODE_UNLOCKED);
|
|
super.onStop();
|
|
super.onStop();
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public boolean onTouch(View v, MotionEvent event) {
|
|
public boolean onTouch(View v, MotionEvent event) {
|
|
- if (event.getAction() == MotionEvent.ACTION_DOWN && v.equals(mVideoPreview)) {
|
|
|
|
|
|
+ if (event.getAction() == MotionEvent.ACTION_DOWN && v.equals(binding.videoPreview)) {
|
|
// added a margin on the left to avoid interfering with gesture to open navigation drawer
|
|
// added a margin on the left to avoid interfering with gesture to open navigation drawer
|
|
if (event.getX() / Resources.getSystem().getDisplayMetrics().density > MIN_DENSITY_RATIO) {
|
|
if (event.getX() / Resources.getSystem().getDisplayMetrics().density > MIN_DENSITY_RATIO) {
|
|
startFullScreenVideo();
|
|
startFullScreenVideo();
|
|
@@ -627,14 +605,14 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|
}
|
|
}
|
|
|
|
|
|
private void startFullScreenVideo() {
|
|
private void startFullScreenVideo() {
|
|
- Intent i = new Intent(getActivity(), PreviewVideoActivity.class);
|
|
|
|
- i.putExtra(FileActivity.EXTRA_ACCOUNT, user.toPlatformAccount());
|
|
|
|
- i.putExtra(FileActivity.EXTRA_FILE, getFile());
|
|
|
|
- i.putExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, mVideoPreview.isPlaying());
|
|
|
|
- i.putExtra(PreviewVideoActivity.EXTRA_STREAM_URL, mVideoUri);
|
|
|
|
- mVideoPreview.pause();
|
|
|
|
- i.putExtra(PreviewVideoActivity.EXTRA_START_POSITION, mVideoPreview.getCurrentPosition());
|
|
|
|
- startActivityForResult(i, FileActivity.REQUEST_CODE__LAST_SHARED + 1);
|
|
|
|
|
|
+ Intent intent = new Intent(getActivity(), PreviewVideoActivity.class);
|
|
|
|
+ intent.putExtra(FileActivity.EXTRA_ACCOUNT, user.toPlatformAccount());
|
|
|
|
+ intent.putExtra(FileActivity.EXTRA_FILE, getFile());
|
|
|
|
+ intent.putExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, binding.videoPreview.isPlaying());
|
|
|
|
+ intent.putExtra(PreviewVideoActivity.EXTRA_STREAM_URL, videoUri);
|
|
|
|
+ binding.videoPreview.pause();
|
|
|
|
+ intent.putExtra(PreviewVideoActivity.EXTRA_START_POSITION, binding.videoPreview.getCurrentPosition());
|
|
|
|
+ startActivityForResult(intent, FileActivity.REQUEST_CODE__LAST_SHARED + 1);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -648,8 +626,8 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|
Log_OC.v(TAG, "onActivityResult " + this);
|
|
Log_OC.v(TAG, "onActivityResult " + this);
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
if (resultCode == Activity.RESULT_OK) {
|
|
if (resultCode == Activity.RESULT_OK) {
|
|
- mSavedPlaybackPosition = data.getIntExtra(PreviewVideoActivity.EXTRA_START_POSITION, 0);
|
|
|
|
- mAutoplay = data.getBooleanExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, false);
|
|
|
|
|
|
+ savedPlaybackPosition = data.getIntExtra(PreviewVideoActivity.EXTRA_START_POSITION, 0);
|
|
|
|
+ autoplay = data.getBooleanExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -676,9 +654,9 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|
public void stopPreview(boolean stopAudio) {
|
|
public void stopPreview(boolean stopAudio) {
|
|
OCFile file = getFile();
|
|
OCFile file = getFile();
|
|
if (MimeTypeUtil.isAudio(file) && stopAudio) {
|
|
if (MimeTypeUtil.isAudio(file) && stopAudio) {
|
|
- mMediaPlayerServiceConnection.pause();
|
|
|
|
|
|
+ mediaPlayerServiceConnection.pause();
|
|
} else if (MimeTypeUtil.isVideo(file)) {
|
|
} else if (MimeTypeUtil.isVideo(file)) {
|
|
- mVideoPreview.stopPlayback();
|
|
|
|
|
|
+ binding.videoPreview.stopPlayback();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -693,11 +671,11 @@ public class PreviewMediaFragment extends FileFragment implements OnTouchListene
|
|
}
|
|
}
|
|
|
|
|
|
public int getPosition() {
|
|
public int getPosition() {
|
|
- if (mPrepared) {
|
|
|
|
- mSavedPlaybackPosition = mVideoPreview.getCurrentPosition();
|
|
|
|
|
|
+ if (prepared) {
|
|
|
|
+ savedPlaybackPosition = binding.videoPreview.getCurrentPosition();
|
|
}
|
|
}
|
|
- Log_OC.v(TAG, "getting position: " + mSavedPlaybackPosition);
|
|
|
|
- return mSavedPlaybackPosition;
|
|
|
|
|
|
+ Log_OC.v(TAG, "getting position: " + savedPlaybackPosition);
|
|
|
|
+ return savedPlaybackPosition;
|
|
}
|
|
}
|
|
|
|
|
|
private void toggleDrawerLockMode(ContainerActivity containerActivity, int lockMode) {
|
|
private void toggleDrawerLockMode(ContainerActivity containerActivity, int lockMode) {
|