|
@@ -158,7 +158,6 @@ public class FileUploader extends Service
|
|
|
|
|
|
public static final String KEY_LOCAL_BEHAVIOUR = "BEHAVIOUR";
|
|
|
|
|
|
-
|
|
|
public static final int LOCAL_BEHAVIOUR_COPY = 0;
|
|
|
public static final int LOCAL_BEHAVIOUR_MOVE = 1;
|
|
|
public static final int LOCAL_BEHAVIOUR_FORGET = 2;
|
|
@@ -202,7 +201,6 @@ public class FileUploader extends Service
|
|
|
sendBroadcastUploadStarted(mCurrentUpload);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Helper class providing methods to ease requesting commands to {@link FileUploader} .
|
|
|
*
|
|
@@ -211,7 +209,6 @@ public class FileUploader extends Service
|
|
|
*/
|
|
|
public static class UploadRequester {
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Call to upload several new files
|
|
|
*/
|
|
@@ -239,7 +236,6 @@ public class FileUploader extends Service
|
|
|
intent.putExtra(FileUploader.KEY_WHILE_ON_WIFI_ONLY, requiresWifi);
|
|
|
intent.putExtra(FileUploader.KEY_WHILE_CHARGING_ONLY, requiresCharging);
|
|
|
|
|
|
-
|
|
|
context.startService(intent);
|
|
|
}
|
|
|
|
|
@@ -356,7 +352,6 @@ public class FileUploader extends Service
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Retry a subset of all the stored failed uploads.
|
|
|
*
|
|
@@ -402,10 +397,8 @@ public class FileUploader extends Service
|
|
|
context.startService(i);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Service initialization
|
|
|
*/
|
|
@@ -439,7 +432,6 @@ public class FileUploader extends Service
|
|
|
am.addOnAccountsUpdatedListener(this, null, false);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Service clean-up when restarted after being killed
|
|
|
*/
|
|
@@ -448,7 +440,6 @@ public class FileUploader extends Service
|
|
|
mNotificationManager.cancel(R.string.uploader_upload_in_progress_ticker);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Service clean up
|
|
|
*/
|
|
@@ -468,7 +459,6 @@ public class FileUploader extends Service
|
|
|
super.onDestroy();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Entry point to add one or several files to the queue of uploads.
|
|
|
*
|
|
@@ -525,7 +515,6 @@ public class FileUploader extends Service
|
|
|
mimeTypes = intent.getStringArrayExtra(KEY_MIME_TYPE);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
boolean forceOverwrite = intent.getBooleanExtra(KEY_FORCE_OVERWRITE, false);
|
|
|
int localAction = intent.getIntExtra(KEY_LOCAL_BEHAVIOUR, LOCAL_BEHAVIOUR_FORGET);
|
|
|
|
|
@@ -717,9 +706,8 @@ public class FileUploader extends Service
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Binder to let client components to perform operations on the queue of
|
|
|
- * uploads.
|
|
|
- * <p/>
|
|
|
+ * Binder to let client components to perform operations on the queue of uploads.
|
|
|
+ *
|
|
|
* It provides by itself the available operations.
|
|
|
*/
|
|
|
public class FileUploaderBinder extends Binder implements OnDatatransferProgressListener {
|
|
@@ -728,9 +716,7 @@ public class FileUploader extends Service
|
|
|
* 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>();
|
|
|
-
|
|
|
+ private Map<String, OnDatatransferProgressListener> mBoundListeners = new HashMap<>();
|
|
|
|
|
|
/**
|
|
|
* Cancels a pending or current upload of a remote file.
|
|
@@ -828,7 +814,6 @@ public class FileUploader extends Service
|
|
|
return (mPendingUploads.contains(account.name, file.getRemotePath()));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
public boolean isUploadingNow(OCUpload upload) {
|
|
|
return (
|
|
|
upload != null &&
|
|
@@ -839,7 +824,6 @@ public class FileUploader extends Service
|
|
|
);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Adds a listener interested in the progress of the upload for a concrete file.
|
|
|
*
|
|
@@ -859,7 +843,6 @@ public class FileUploader extends Service
|
|
|
mBoundListeners.put(targetKey, listener);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Adds a listener interested in the progress of the upload for a concrete file.
|
|
|
*
|
|
@@ -877,7 +860,6 @@ public class FileUploader extends Service
|
|
|
mBoundListeners.put(targetKey, listener);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Removes a listener interested in the progress of the upload for a concrete file.
|
|
|
*
|
|
@@ -899,7 +881,6 @@ public class FileUploader extends Service
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Removes a listener interested in the progress of the upload for a concrete file.
|
|
|
*
|
|
@@ -919,7 +900,6 @@ public class FileUploader extends Service
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
public void onTransferProgress(long progressRate, long totalTransferredSoFar,
|
|
|
long totalToTransfer, String fileName) {
|
|
@@ -945,7 +925,7 @@ public class FileUploader extends Service
|
|
|
|
|
|
/**
|
|
|
* Builds a key for the map of listeners.
|
|
|
- * <p/>
|
|
|
+ *
|
|
|
* TODO use method in IndexedForest, or refactor both to a common place
|
|
|
* add to local database) to better policy (add to local database, then upload)
|
|
|
*
|
|
@@ -963,7 +943,7 @@ public class FileUploader extends Service
|
|
|
/**
|
|
|
* Upload worker. Performs the pending uploads in the order they were
|
|
|
* requested.
|
|
|
- * <p/>
|
|
|
+ *
|
|
|
* Created with the Looper of a new thread, started in
|
|
|
* {@link FileUploader#onCreate()}.
|
|
|
*/
|
|
@@ -1058,7 +1038,7 @@ public class FileUploader extends Service
|
|
|
mCurrentAccount.name,
|
|
|
mCurrentUpload.getOldFile().getRemotePath()
|
|
|
);
|
|
|
- /** TODO: grant that name is also updated for mCurrentUpload.getOCUploadId */
|
|
|
+ // TODO: grant that name is also updated for mCurrentUpload.getOCUploadId
|
|
|
|
|
|
} else {
|
|
|
removeResult = mPendingUploads.removePayload(
|
|
@@ -1073,7 +1053,6 @@ public class FileUploader extends Service
|
|
|
notifyUploadResult(mCurrentUpload, uploadResult);
|
|
|
|
|
|
sendBroadcastUploadFinished(mCurrentUpload, uploadResult, removeResult.second);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
// generate new Thumbnail
|
|
@@ -1097,8 +1076,7 @@ public class FileUploader extends Service
|
|
|
private void notifyUploadStart(UploadFileOperation upload) {
|
|
|
// / create status notification with a progress bar
|
|
|
mLastPercent = 0;
|
|
|
- mNotificationBuilder =
|
|
|
- NotificationUtils.newNotificationBuilder(this);
|
|
|
+ mNotificationBuilder = NotificationUtils.newNotificationBuilder(this);
|
|
|
mNotificationBuilder
|
|
|
.setOngoing(true)
|
|
|
.setSmallIcon(R.drawable.notification_icon)
|
|
@@ -1122,7 +1100,6 @@ public class FileUploader extends Service
|
|
|
} // else wait until the upload really start (onTransferProgress is called), so that if it's discarded
|
|
|
// due to lack of Wifi, no notification is shown
|
|
|
// TODO generalize for automated uploads
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1178,9 +1155,7 @@ public class FileUploader extends Service
|
|
|
.setOngoing(false)
|
|
|
.setProgress(0, 0, false);
|
|
|
|
|
|
- content = ErrorMessageAdapter.getErrorCauseMessage(
|
|
|
- uploadResult, upload, getResources()
|
|
|
- );
|
|
|
+ content = ErrorMessageAdapter.getErrorCauseMessage(uploadResult, upload, getResources());
|
|
|
|
|
|
if (needsToUpdateCredentials) {
|
|
|
// let the user update credentials with one click
|
|
@@ -1231,7 +1206,6 @@ public class FileUploader extends Service
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Sends a broadcast in order to the interested activities can update their
|
|
|
* view
|
|
@@ -1245,7 +1219,6 @@ public class FileUploader extends Service
|
|
|
sendStickyBroadcast(start);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Sends a broadcast in order to the interested activities can update their
|
|
|
* view
|
|
@@ -1309,5 +1282,4 @@ public class FileUploader extends Service
|
|
|
mPendingUploads.remove(account.name);
|
|
|
mUploadsStorageManager.removeUploads(account.name);
|
|
|
}
|
|
|
-
|
|
|
}
|