Skip to content

Commit 93c8c48

Browse files
committed
nextcloud#193 add cancel action to upload notification - first stub
1 parent c2f3519 commit 93c8c48

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/com/owncloud/android/files/services/FileUploader.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,17 +981,28 @@ private void notifyUploadStart(UploadFileOperation upload) {
981981
.setProgress(100, 0, false)
982982
.setContentText(
983983
String.format(getString(R.string.uploader_upload_in_progress_content), 0, upload.getFileName())
984+
)
985+
.setAutoCancel(false)
986+
.addAction(
987+
R.drawable.ic_action_delete_grey,
988+
getString(R.string.common_cancel),
989+
PendingIntent.getActivity(
990+
this,
991+
(int) System.nanoTime(),
992+
new Intent(this, FileUploader.ServiceHandler.class),
993+
0)
984994
);
985995

986996
/// includes a pending intent in the notification showing the details
987997
Intent showUploadListIntent = new Intent(this, UploadListActivity.class);
988998
showUploadListIntent.putExtra(FileActivity.EXTRA_FILE, upload.getFile());
989999
showUploadListIntent.putExtra(FileActivity.EXTRA_ACCOUNT, upload.getAccount());
9901000
showUploadListIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
991-
mNotificationBuilder.setContentIntent(PendingIntent.getActivity(this, (int) System.currentTimeMillis(),
1001+
mNotificationBuilder.setContentIntent(PendingIntent.getActivity(this, (int) System.nanoTime(),
9921002
showUploadListIntent, 0));
9931003

9941004
if (!upload.isInstantPicture() && !upload.isInstantVideo()) {
1005+
// TODO: should first parameter to notify not be a uniq mId?
9951006
mNotificationManager.notify(R.string.uploader_upload_in_progress_ticker, mNotificationBuilder.build());
9961007
} // else wait until the upload really start (onTransferProgress is called), so that if it's discarded
9971008
// due to lack of Wifi, no notification is shown

0 commit comments

Comments
 (0)