+ mLastPercent = percent;
+ }
+
+
+ /**
+ * Callback method to update the progress bar in the status notification (old version)
+ */
+ @Override
+ public void onTransferProgress(long progressRate) {
+ // NOTHING TO DO HERE ANYMORE
+ }
+
+
+ /**
+ * Updates the status notification with the result of an upload operation.
+ *
+ * @param uploadResult Result of the upload operation.
+ * @param upload Finished upload operation
+ */
+ private void notifyUploadResult(RemoteOperationResult uploadResult, UploadFileOperation upload) {
+ if (uploadResult.isCancelled()) {
+ /// cancelled operation -> silent removal of progress notification
+ mNotificationManager.cancel(R.string.uploader_upload_in_progress_ticker);
+
+ } else if (uploadResult.isSuccess()) {
+ /// success -> silent update of progress notification to success message
+ mNotification.flags ^= Notification.FLAG_ONGOING_EVENT; // remove the ongoing flag
+ mNotification.flags |= Notification.FLAG_AUTO_CANCEL;
+ mNotification.contentView = mDefaultNotificationContentView;
+
+ /// includes a pending intent in the notification showing the details view of the file
+ Intent showDetailsIntent = new Intent(this, FileDetailActivity.class);
+ showDetailsIntent.putExtra(FileDetailFragment.EXTRA_FILE, upload.getFile());
+ showDetailsIntent.putExtra(FileDetailFragment.EXTRA_ACCOUNT, upload.getAccount());
+ showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ mNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), (int)System.currentTimeMillis(), showDetailsIntent, 0);
+
+ mNotification.setLatestEventInfo( getApplicationContext(),
+ getString(R.string.uploader_upload_succeeded_ticker),
+ String.format(getString(R.string.uploader_upload_succeeded_content_single), (new File(upload.getStoragePath())).getName()),
+ mNotification.contentIntent);
+
+ mNotificationManager.notify(R.string.uploader_upload_in_progress_ticker, mNotification); // NOT AN ERROR; uploader_upload_in_progress_ticker is the target, not a new notification
+
+ /* Notification about multiple uploads: pending of update
+ mNotification.setLatestEventInfo( getApplicationContext(),
+ getString(R.string.uploader_upload_succeeded_ticker),
+ String.format(getString(R.string.uploader_upload_succeeded_content_multiple), mSuccessCounter),
+ mNotification.contentIntent);
+ */
+
+ } else {
+ /// fail -> explicit failure notification
+ mNotificationManager.cancel(R.string.uploader_upload_in_progress_ticker);
+ Notification finalNotification = new Notification(R.drawable.icon, getString(R.string.uploader_upload_failed_ticker), System.currentTimeMillis());
+ finalNotification.flags |= Notification.FLAG_AUTO_CANCEL;
+ // TODO put something smart in the contentIntent below
+ finalNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), (int)System.currentTimeMillis(), new Intent(), 0);
+ finalNotification.setLatestEventInfo( getApplicationContext(),
+ getString(R.string.uploader_upload_failed_ticker),
+ String.format(getString(R.string.uploader_upload_failed_content_single), (new File(upload.getStoragePath())).getName()),
+ finalNotification.contentIntent);
+
+ mNotificationManager.notify(R.string.uploader_upload_failed_ticker, finalNotification);
+
+ /* Notification about multiple uploads failure: pending of update
+ finalNotification.setLatestEventInfo( getApplicationContext(),
+ getString(R.string.uploader_upload_failed_ticker),
+ String.format(getString(R.string.uploader_upload_failed_content_multiple), mSuccessCounter, mTotalFilesToSend),
+ finalNotification.contentIntent);
+ } */
+ }
+