Skip to content

Commit

Permalink
nextcloud#193 add cancel action to upload notification - first stub
Browse files Browse the repository at this point in the history
  • Loading branch information
childnode committed Aug 19, 2016
1 parent c2f3519 commit 93c8c48
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/com/owncloud/android/files/services/FileUploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -981,17 +981,28 @@ private void notifyUploadStart(UploadFileOperation upload) {
.setProgress(100, 0, false)
.setContentText(
String.format(getString(R.string.uploader_upload_in_progress_content), 0, upload.getFileName())
)
.setAutoCancel(false)
.addAction(
R.drawable.ic_action_delete_grey,
getString(R.string.common_cancel),
PendingIntent.getActivity(
this,
(int) System.nanoTime(),
new Intent(this, FileUploader.ServiceHandler.class),
0)
);

/// includes a pending intent in the notification showing the details
Intent showUploadListIntent = new Intent(this, UploadListActivity.class);
showUploadListIntent.putExtra(FileActivity.EXTRA_FILE, upload.getFile());
showUploadListIntent.putExtra(FileActivity.EXTRA_ACCOUNT, upload.getAccount());
showUploadListIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
mNotificationBuilder.setContentIntent(PendingIntent.getActivity(this, (int) System.currentTimeMillis(),
mNotificationBuilder.setContentIntent(PendingIntent.getActivity(this, (int) System.nanoTime(),
showUploadListIntent, 0));

if (!upload.isInstantPicture() && !upload.isInstantVideo()) {
// TODO: should first parameter to notify not be a uniq mId?
mNotificationManager.notify(R.string.uploader_upload_in_progress_ticker, mNotificationBuilder.build());
} // 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
Expand Down

0 comments on commit 93c8c48

Please sign in to comment.