mirror of
https://github.com/nextcloud/android.git
synced 2024-11-24 22:25:44 +03:00
added click action for UploadListActivity
This commit is contained in:
parent
e0e9a7c6ce
commit
8f768d8224
3 changed files with 48 additions and 1 deletions
|
@ -184,6 +184,7 @@ public class FileUploadService extends IntentService {
|
|||
* is being uploaded to {@link UploadFileOperation}.
|
||||
*/
|
||||
private ConcurrentMap<String, UploadDbObject> mPendingUploads = new ConcurrentHashMap<String, UploadDbObject>();
|
||||
|
||||
/**
|
||||
* {@link UploadFileOperation} object of ongoing upload. Can be null. Note: There can only be one concurrent upload!
|
||||
*/
|
||||
|
|
|
@ -2,17 +2,23 @@ package com.owncloud.android.ui.activity;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuInflater;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.authentication.AccountUtils;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.db.UploadDbHandler;
|
||||
import com.owncloud.android.db.UploadDbObject;
|
||||
import com.owncloud.android.db.UploadDbHandler.UploadStatus;
|
||||
import com.owncloud.android.files.services.FileUploadService;
|
||||
import com.owncloud.android.lib.common.utils.Log_OC;
|
||||
import com.owncloud.android.ui.errorhandling.ExceptionHandler;
|
||||
import com.owncloud.android.ui.fragment.UploadListFragment;
|
||||
import com.owncloud.android.utils.FileStorageUtils;
|
||||
|
||||
/**
|
||||
* Activity listing pending, active, and completed uploads. User can delete
|
||||
|
@ -36,9 +42,39 @@ public class UploadListActivity extends FileActivity implements UploadListFragme
|
|||
// ////////////////////////////////////////
|
||||
// UploadListFragment.ContainerActivity
|
||||
// ////////////////////////////////////////
|
||||
/**
|
||||
* TODO Without a menu this is a little un-intuitive.
|
||||
*/
|
||||
@Override
|
||||
public void onUploadItemClick(UploadDbObject file) {
|
||||
// TODO Auto-generated method stub
|
||||
OCFile ocFile = FileStorageUtils.fillOCFile(file);
|
||||
switch (file.getUploadStatus()) {
|
||||
case UPLOAD_IN_PROGRESS:
|
||||
if (ocFile != null) {
|
||||
getFileOperationsHelper().cancelTransference(ocFile);
|
||||
} else {
|
||||
Log_OC.e(TAG, "Could not get OCFile for " + file.getRemotePath() + ". Cannot cancel.");
|
||||
}
|
||||
break;
|
||||
case UPLOAD_SUCCEEDED:
|
||||
Intent showDetailsIntent = new Intent(this, FileDisplayActivity.class);
|
||||
showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, ocFile);
|
||||
showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, file.getAccount(this));
|
||||
startActivity(showDetailsIntent);
|
||||
break;
|
||||
case UPLOAD_CANCELLED:
|
||||
case UPLOAD_PAUSED:
|
||||
UploadDbHandler db = UploadDbHandler.getInstance(this.getBaseContext());
|
||||
file.setUploadStatus(UploadStatus.UPLOAD_LATER);
|
||||
db.updateUpload(file);
|
||||
// no break; to start upload immediately.
|
||||
case UPLOAD_LATER:
|
||||
case UPLOAD_FAILED_RETRY:
|
||||
FileUploadService.retry(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.File;
|
|||
import com.owncloud.android.MainApp;
|
||||
import com.owncloud.android.R;
|
||||
import com.owncloud.android.datamodel.OCFile;
|
||||
import com.owncloud.android.db.UploadDbObject;
|
||||
import com.owncloud.android.lib.resources.files.RemoteFile;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
|
@ -135,6 +136,15 @@ public class FileStorageUtils {
|
|||
return file;
|
||||
}
|
||||
|
||||
public static OCFile fillOCFile(UploadDbObject o) {
|
||||
OCFile file = new OCFile(o.getRemotePath());
|
||||
File localFile = new File(o.getLocalPath());
|
||||
file.setFileLength(localFile.length());
|
||||
file.setMimetype(o.getMimeType());
|
||||
file.setStoragePath(o.getLocalPath());
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and populates a new {@link RemoteFile} object with the data read from an {@link OCFile}.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue