view images in uploads tab and do everything in UploadListActivity

Signed-off-by: Jonas Mayer <jonas.a.mayer@gmx.net>
This commit is contained in:
Jonas Mayer 2023-11-14 12:40:52 +01:00 committed by Jonas Mayer
parent c79205a465
commit ceeba26608
2 changed files with 20 additions and 15 deletions

View file

@ -347,17 +347,6 @@ public class UploadListActivity extends FileActivity {
} }
} }
/**
* Switches to FileDisplayActivity and shows file (eg. image preview).
*/
public void openFile(String remotePath) {
Intent intent = new Intent(this, FileDisplayActivity.class);
intent.setAction(Intent.ACTION_VIEW);
intent.putExtra(FileDisplayActivity.KEY_FILE_PATH, remotePath);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
/** /**
* Once the file upload has changed its status -> update uploads list view * Once the file upload has changed its status -> update uploads list view
*/ */

View file

@ -62,7 +62,8 @@ import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.operations.RefreshFolderOperation; import com.owncloud.android.operations.RefreshFolderOperation;
import com.owncloud.android.ui.activity.ConflictsResolveActivity; import com.owncloud.android.ui.activity.ConflictsResolveActivity;
import com.owncloud.android.ui.activity.FileActivity; import com.owncloud.android.ui.activity.FileActivity;
import com.owncloud.android.ui.activity.UploadListActivity; import com.owncloud.android.ui.activity.FileDisplayActivity;
import com.owncloud.android.ui.preview.PreviewImageFragment;
import com.owncloud.android.utils.DisplayUtils; import com.owncloud.android.utils.DisplayUtils;
import com.owncloud.android.utils.MimeTypeUtil; import com.owncloud.android.utils.MimeTypeUtil;
import com.owncloud.android.utils.theme.ViewThemeUtils; import com.owncloud.android.utils.theme.ViewThemeUtils;
@ -760,9 +761,24 @@ public class UploadListAdapter extends SectionedRecyclerViewAdapter<SectionedVie
/** /**
* Open remote file. * Open remote file.
*/ */
private void onUploadedItemClick(OCUpload file) { private void onUploadedItemClick(OCUpload upload) {
if (parentActivity instanceof UploadListActivity uploadListActivity) { final OCFile file = parentActivity.getStorageManager().getFileByEncryptedRemotePath(upload.getRemotePath());
uploadListActivity.openFile(file.getRemotePath()); if (file == null){
DisplayUtils.showSnackMessage(parentActivity, R.string.error_retrieving_file);
Log_OC.i(TAG, "Could not find uploaded file on remote.");
return;
}
if (PreviewImageFragment.canBePreviewed(file)){
//show image preview and stay in uploads tab
Intent intent = FileDisplayActivity.openFileIntent(parentActivity, parentActivity.getUser().get(), file);
parentActivity.startActivity(intent);
}else{
Intent intent = new Intent(parentActivity, FileDisplayActivity.class);
intent.setAction(Intent.ACTION_VIEW);
intent.putExtra(FileDisplayActivity.KEY_FILE_PATH, upload.getRemotePath());
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
parentActivity.startActivity(intent);
} }
} }