From: David A. Velasco Date: Mon, 27 May 2013 12:07:33 +0000 (+0200) Subject: Download any file just with click on the list of files X-Git-Tag: oc-android-1.4.3~21^2~11 X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/commitdiff_plain/c6ed18dafa21b5de150ab40e3c8f78b706a73751?ds=inline Download any file just with click on the list of files --- diff --git a/src/com/owncloud/android/ui/activity/FileDetailActivity.java b/src/com/owncloud/android/ui/activity/FileDetailActivity.java index 545e579d..81e4fa9b 100644 --- a/src/com/owncloud/android/ui/activity/FileDetailActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDetailActivity.java @@ -127,19 +127,23 @@ public class FileDetailActivity extends FileActivity implements FileFragment.Con Fragment newFragment = null; OCFile file = getFile(); Account account = getAccount(); - if (PreviewMediaFragment.canBePreviewed(file) && mode == MODE_PREVIEW) { - if (file.isDown()) { + if (mode == MODE_DETAILS) { + newFragment = new FileDetailFragment(file, account); + + } else if (file.isDown()) { + if (PreviewMediaFragment.canBePreviewed(file)) { int startPlaybackPosition = getIntent().getIntExtra(PreviewVideoActivity.EXTRA_START_POSITION, 0); boolean autoplay = getIntent().getBooleanExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, true); newFragment = new PreviewMediaFragment(file, account, startPlaybackPosition, autoplay); } else { newFragment = new FileDetailFragment(file, account); - mWaitingToPreview = true; + // TODO open with } } else { newFragment = new FileDetailFragment(file, account); + mWaitingToPreview = true; // download will requested } FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.replace(R.id.fragment, newFragment, FileDetailFragment.FTAG); @@ -450,15 +454,18 @@ public class FileDetailActivity extends FileActivity implements FileFragment.Con // refresh the details fragment if (success && mWaitingToPreview) { setFile(mStorageManager.getFileById(getFile().getFileId())); // update the file from database, for the local storage path - FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); - transaction.replace(R.id.fragment, new PreviewMediaFragment(getFile(), getAccount(), 0, true), FileDetailFragment.FTAG); - transaction.commit(); + if (PreviewMediaFragment.canBePreviewed(getFile())) { + FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); + transaction.replace(R.id.fragment, new PreviewMediaFragment(getFile(), getAccount(), 0, true), FileDetailFragment.FTAG); + transaction.commit(); + } else { + detailsFragment.updateFileDetails(false, (success)); + } mWaitingToPreview = false; - + } else { detailsFragment.updateFileDetails(false, (success)); - // TODO error message if !success ¿? - } + } } } // TODO else if (fragment != null && fragment ) diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index c62a28d5..a6baf2f0 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -828,9 +828,15 @@ public class FileDisplayActivity extends FileActivity implements // update the right panel if (success && waitedPreview) { mWaitingToPreview = mStorageManager.getFileById(mWaitingToPreview.getFileId()); // update the file from database, for the local storage path - FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); - transaction.replace(R.id.file_details_container, new PreviewMediaFragment(mWaitingToPreview, getAccount(), 0, true), FileDetailFragment.FTAG); - transaction.commit(); + if (PreviewMediaFragment.canBePreviewed(mWaitingToPreview)) { + FragmentTransaction transaction = getSupportFragmentManager().beginTransaction(); + transaction.replace(R.id.file_details_container, new PreviewMediaFragment(mWaitingToPreview, getAccount(), 0, true), FileDetailFragment.FTAG); + transaction.commit(); + } else { + // file cannot be previewed + detailsFragment.updateFileDetails(false, (success)); + + } mWaitingToPreview = null; } else { @@ -876,35 +882,40 @@ public class FileDisplayActivity extends FileActivity implements */ @Override public void onFileClick(OCFile file, boolean onOrientationChange) { - if (file != null && PreviewImageFragment.canBePreviewed(file)) { - // preview image - it handles the download, if needed - startPreviewImage(file); - - } else if (file != null && PreviewMediaFragment.canBePreviewed(file)) { - if (file.isDown()) { - // general preview - if (!onOrientationChange) { - startMediaPreview(file, 0, true, onOrientationChange); - } else { - int startPlaybackPosition = 0; - boolean autoplay = true; - Fragment fragment = getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG); - if (fragment != null && file.isVideo()) { - PreviewMediaFragment videoFragment = (PreviewMediaFragment)fragment; - startPlaybackPosition = videoFragment.getPosition(); - autoplay = videoFragment.isPlaying(); + if (file != null) { + if (PreviewImageFragment.canBePreviewed(file)) { + // preview image - it handles the download, if needed + startPreviewImage(file); + + } else if (PreviewMediaFragment.canBePreviewed(file)) { + if (file.isDown()) { + // general preview + if (!onOrientationChange) { + startMediaPreview(file, 0, true, onOrientationChange); + } else { + int startPlaybackPosition = 0; + boolean autoplay = true; + Fragment fragment = getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG); + if (fragment != null && file.isVideo()) { + PreviewMediaFragment videoFragment = (PreviewMediaFragment)fragment; + startPlaybackPosition = videoFragment.getPosition(); + autoplay = videoFragment.isPlaying(); + } + startMediaPreview(file, startPlaybackPosition, autoplay, onOrientationChange); } - startMediaPreview(file, startPlaybackPosition, autoplay, onOrientationChange); + + } else { + // automatic download, preview on finish + startDownloadForPreview(file, onOrientationChange); + } + } else if (file.isDown()) { + // details view + startDetails(file, onOrientationChange); } else { - // automatic download, preview on finish startDownloadForPreview(file, onOrientationChange); - } - } else { - // details view - startDetails(file, onOrientationChange); } }