mirror of
https://github.com/nextcloud/android.git
synced 2024-11-27 09:39:25 +03:00
Download any file just with click on the list of files
This commit is contained in:
parent
b8b60d844f
commit
c6ed18dafa
2 changed files with 53 additions and 35 deletions
|
@ -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 )
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue