import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.InstantUploadBroadcastReceiver;
-import com.owncloud.android.files.services.FileDownloader.FileDownloaderBinder;
import com.owncloud.android.operations.ChunkedUploadFileOperation;
-import com.owncloud.android.operations.DownloadFileOperation;
import com.owncloud.android.operations.RemoteOperationResult;
import com.owncloud.android.operations.UploadFileOperation;
import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.ui.activity.FileDetailActivity;
import com.owncloud.android.ui.fragment.FileDetailFragment;
+import com.owncloud.android.ui.preview.PreviewImageActivity;
+import com.owncloud.android.ui.preview.PreviewImageFragment;
import com.owncloud.android.utils.OwnCloudVersion;
import eu.alefzero.webdav.OnDatatransferProgressListener;
/**
* Builds a key for mPendingUploads from the account and file to upload
*
- * @param account Account where the file to download is stored
- * @param file File to download
+ * @param account Account where the file to upload is stored
+ * @param file File to upload
*/
private String buildRemoteName(Account account, OCFile file) {
return account.name + file.getRemotePath();
*/
@Override
public boolean onUnbind(Intent intent) {
- ((FileDownloaderBinder)mBinder).clearListeners();
+ ((FileUploaderBinder)mBinder).clearListeners();
return false; // not accepting rebinding (default behaviour)
}
public class FileUploaderBinder extends Binder implements OnDatatransferProgressListener {
/**
- * Map of listeners that will be reported about progress of uploads from a {@link FileDownloaderBinder} instance
+ * Map of listeners that will be reported about progress of uploads from a {@link FileUploaderBinder} instance
*/
private Map<String, OnDatatransferProgressListener> mBoundListeners = new HashMap<String, OnDatatransferProgressListener>();
/**
* Returns True when the file described by 'file' is being uploaded to the ownCloud account 'account' or waiting for it
*
- * If 'file' is a directory, returns 'true' if some of its descendant files is downloading or waiting to download.
+ * If 'file' is a directory, returns 'true' if some of its descendant files is uploading or waiting to upload.
*
* @param account Owncloud account where the remote file will be stored.
* @param file A file that could be in the queue of pending uploads
String targetKey = buildRemoteName(account, file);
synchronized (mPendingUploads) {
if (file.isDirectory()) {
- // this can be slow if there are many downloads :(
+ // this can be slow if there are many uploads :(
Iterator<String> it = mPendingUploads.keySet().iterator();
boolean found = false;
while (it.hasNext() && !found) {
/**
- * Adds a listener interested in the progress of the download for a concrete file.
+ * Adds a listener interested in the progress of the upload for a concrete file.
*
* @param listener Object to notify about progress of transfer.
* @param account ownCloud account holding the file of interest.
/**
- * Removes a listener interested in the progress of the download for a concrete file.
+ * Removes a listener interested in the progress of the upload for a concrete file.
*
* @param listener Object to notify about progress of transfer.
* @param account ownCloud account holding the file of interest.
file.setMimetype(we.contentType());
file.setModificationTimestamp(we.modifiedTimestamp());
file.setModificationTimestampAtLastSyncForData(we.modifiedTimestamp());
- // file.setEtag(mCurrentDownload.getEtag()); // TODO Etag, where available
+ // file.setEtag(mCurrentUpload.getEtag()); // TODO Etag, where available
}
mNotification.contentView.setImageViewResource(R.id.status_icon, R.drawable.icon);
/// includes a pending intent in the notification showing the details view of the file
- Intent showDetailsIntent = new Intent(this, FileDetailActivity.class);
+ Intent showDetailsIntent = null;
+ if (PreviewImageFragment.canBePreviewed(upload.getFile())) {
+ showDetailsIntent = new Intent(this, PreviewImageActivity.class);
+ } else {
+ showDetailsIntent = new Intent(this, FileDetailActivity.class);
+ showDetailsIntent.putExtra(FileDetailActivity.EXTRA_MODE, FileDetailActivity.MODE_DETAILS);
+ }
showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, upload.getFile());
showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, upload.getAccount());
- showDetailsIntent.putExtra(FileDetailActivity.EXTRA_MODE, FileDetailActivity.MODE_DETAILS);
showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
mNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), (int)System.currentTimeMillis(), showDetailsIntent, 0);
mNotification.contentView = mDefaultNotificationContentView;
/// includes a pending intent in the notification showing the details view of the file
- Intent showDetailsIntent = new Intent(this, FileDetailActivity.class);
+ Intent showDetailsIntent = null;
+ if (PreviewImageFragment.canBePreviewed(upload.getFile())) {
+ showDetailsIntent = new Intent(this, PreviewImageActivity.class);
+ } else {
+ showDetailsIntent = new Intent(this, FileDetailActivity.class);
+ showDetailsIntent.putExtra(FileDetailActivity.EXTRA_MODE, FileDetailActivity.MODE_DETAILS);
+ }
showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, upload.getFile());
showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, upload.getAccount());
- showDetailsIntent.putExtra(FileDetailActivity.EXTRA_MODE, FileDetailActivity.MODE_DETAILS);
showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
mNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), (int)System.currentTimeMillis(), showDetailsIntent, 0);