|
@@ -93,6 +93,7 @@ public class FileUploader extends Service
|
|
|
|
|
|
private static final String TAG = FileUploader.class.getSimpleName();
|
|
|
|
|
|
+ private static final String UPLOADS_ADDED_MESSAGE = "UPLOADS_ADDED";
|
|
|
private static final String UPLOAD_START_MESSAGE = "UPLOAD_START";
|
|
|
private static final String UPLOAD_FINISH_MESSAGE = "UPLOAD_FINISH";
|
|
|
public static final String EXTRA_UPLOAD_RESULT = "RESULT";
|
|
@@ -126,10 +127,6 @@ public class FileUploader extends Service
|
|
|
*/
|
|
|
public static final String KEY_ACCOUNT = "ACCOUNT";
|
|
|
|
|
|
- /**
|
|
|
- * Set whether single file or multiple files are to be uploaded. SINGLE_FILES = 0, MULTIPLE_FILEs = 1.
|
|
|
- */
|
|
|
- public static final String KEY_UPLOAD_TYPE = "UPLOAD_TYPE";
|
|
|
/**
|
|
|
* Set to true if remote file is to be overwritten. Default action is to upload with different name.
|
|
|
*/
|
|
@@ -174,6 +171,10 @@ public class FileUploader extends Service
|
|
|
private NotificationCompat.Builder mNotificationBuilder;
|
|
|
private int mLastPercent;
|
|
|
|
|
|
+ public static String getUploadsAddedMessage() {
|
|
|
+ return FileUploader.class.getName() + UPLOADS_ADDED_MESSAGE;
|
|
|
+ }
|
|
|
+
|
|
|
public static String getUploadStartMessage() {
|
|
|
return FileUploader.class.getName() + UPLOAD_START_MESSAGE;
|
|
|
}
|
|
@@ -535,6 +536,7 @@ public class FileUploader extends Service
|
|
|
msg.arg1 = startId;
|
|
|
msg.obj = requestedUploads;
|
|
|
mServiceHandler.sendMessage(msg);
|
|
|
+ sendBroadcastUploadsAdded();
|
|
|
}
|
|
|
return Service.START_NOT_STICKY;
|
|
|
}
|
|
@@ -845,6 +847,8 @@ public class FileUploader extends Service
|
|
|
|
|
|
notifyUploadStart(mCurrentUpload);
|
|
|
|
|
|
+ sendBroadcastUploadStarted(mCurrentUpload);
|
|
|
+
|
|
|
RemoteOperationResult uploadResult = null;
|
|
|
|
|
|
try {
|
|
@@ -964,8 +968,6 @@ public class FileUploader extends Service
|
|
|
|
|
|
mNotificationManager.notify(R.string.uploader_upload_in_progress_ticker, mNotificationBuilder.build());
|
|
|
|
|
|
- // TODO really needed?
|
|
|
- sendBroadcastUploadStarted(mCurrentUpload);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1074,10 +1076,26 @@ public class FileUploader extends Service
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* Sends a broadcast in order to the interested activities can update their
|
|
|
* view
|
|
|
*
|
|
|
+ * TODO - no more broadcasts, replace with a callback to subscribed listeners
|
|
|
+ */
|
|
|
+ private void sendBroadcastUploadsAdded() {
|
|
|
+ Intent start = new Intent(getUploadsAddedMessage());
|
|
|
+ // nothing else needed right now
|
|
|
+ sendStickyBroadcast(start);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Sends a broadcast in order to the interested activities can update their
|
|
|
+ * view
|
|
|
+ *
|
|
|
+ * TODO - no more broadcasts, replace with a callback to subscribed listeners
|
|
|
+ *
|
|
|
* @param upload Finished upload operation
|
|
|
*/
|
|
|
private void sendBroadcastUploadStarted(
|
|
@@ -1095,6 +1113,8 @@ public class FileUploader extends Service
|
|
|
* Sends a broadcast in order to the interested activities can update their
|
|
|
* view
|
|
|
*
|
|
|
+ * TODO - no more broadcasts, replace with a callback to subscribed listeners
|
|
|
+ *
|
|
|
* @param upload Finished upload operation
|
|
|
* @param uploadResult Result of the upload operation
|
|
|
* @param unlinkedFromRemotePath Path in the uploads tree where the upload was unlinked from
|