-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Re-use the existing foreground notification for FileUploader progress notifications #6997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -255,7 +255,7 @@ public void onCreate() { | |
| */ | ||
| private void resurrection() { | ||
| // remove stucked notification | ||
| mNotificationManager.cancel(R.string.uploader_upload_in_progress_ticker); | ||
| mNotificationManager.cancel(FOREGROUND_SERVICE_ID); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -269,6 +269,9 @@ public void onDestroy() { | |
| mServiceHandler = null; | ||
| mServiceLooper.quit(); | ||
| mServiceLooper = null; | ||
| if (mNotificationManager != null) { | ||
| mNotificationManager.cancel(FOREGROUND_SERVICE_ID); | ||
| } | ||
| mNotificationManager = null; | ||
|
|
||
| // remove AccountsUpdatedListener | ||
|
|
@@ -705,7 +708,7 @@ private void notifyUploadStart(UploadFileOperation upload) { | |
| mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); | ||
| } | ||
|
|
||
| mNotificationManager.notify(R.string.uploader_upload_in_progress_ticker, mNotificationBuilder.build()); | ||
| mNotificationManager.notify(FOREGROUND_SERVICE_ID, 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 | ||
| // TODO generalize for automated uploads | ||
|
|
@@ -730,7 +733,7 @@ public void onTransferProgress( | |
| if (mNotificationManager == null) { | ||
| mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); | ||
| } | ||
| mNotificationManager.notify(R.string.uploader_upload_in_progress_ticker, mNotificationBuilder.build()); | ||
| mNotificationManager.notify(FOREGROUND_SERVICE_ID, mNotificationBuilder.build()); | ||
| } | ||
| mLastPercent = percent; | ||
| } | ||
|
|
@@ -748,8 +751,6 @@ private void notifyUploadResult(UploadFileOperation upload, RemoteOperationResul | |
| mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); | ||
| } | ||
|
|
||
| mNotificationManager.cancel(R.string.uploader_upload_in_progress_ticker); | ||
|
|
||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. First, I was replacing the progress notification with the general foreground service notification here ( |
||
| // Only notify if the upload fails | ||
| if (!uploadResult.isCancelled() && | ||
| !uploadResult.isSuccess() && | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not seem to be necessary anymore as we now cancel the notification when the service is destroyed.
Was this maybe a relic from before using a foreground service or did you still see that the service was killed without calling
onDestroy()?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is to prevent edge cases like
At least I remember something like that. Maybe it is already better handled by newer Android versions…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably safer to leave it in then. I re-added it back.