-
-
Notifications
You must be signed in to change notification settings - Fork 254
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove class level notification property
Signed-off-by: parneet-guraya <[email protected]>
- Loading branch information
1 parent
8cede68
commit c7bf1b2
Showing
2 changed files
with
15 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,9 @@ | |
* Nextcloud Talk application | ||
* | ||
* @author Marcel Hibbe | ||
* @author Parneet Singh | ||
* Copyright (C) 2021-2022 Marcel Hibbe <[email protected]> | ||
* Copyright (C) 2024-2025 Parneet Singh <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -22,7 +24,6 @@ package com.nextcloud.talk.jobs | |
|
||
import android.Manifest | ||
import android.app.Activity | ||
import android.app.Notification | ||
import android.app.NotificationManager | ||
import android.app.PendingIntent | ||
import android.content.Context | ||
|
@@ -85,7 +86,6 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa | |
|
||
private var mNotifyManager: NotificationManager? = null | ||
private var mBuilder: NotificationCompat.Builder? = null | ||
private lateinit var notification: Notification | ||
private var notificationId: Int = 0 | ||
|
||
lateinit var roomToken: String | ||
|
@@ -187,12 +187,12 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa | |
} | ||
|
||
override fun onTransferProgress(percentage: Int) { | ||
notification = mBuilder!! | ||
val progressUpdateNotification = mBuilder!! | ||
.setProgress(HUNDRED_PERCENT, percentage, false) | ||
.setContentText(getNotificationContentText(percentage)) | ||
.build() | ||
|
||
mNotifyManager!!.notify(notificationId, notification) | ||
mNotifyManager!!.notify(notificationId, progressUpdateNotification) | ||
} | ||
|
||
private fun initNotificationSetup() { | ||
|
@@ -205,7 +205,7 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa | |
} | ||
|
||
private fun initNotificationWithPercentage() { | ||
notification = mBuilder!! | ||
val initNotification = mBuilder!! | ||
.setContentTitle(context.resources.getString(R.string.nc_upload_in_progess)) | ||
.setContentText(getNotificationContentText(ZERO_PERCENT)) | ||
.setSmallIcon(R.drawable.upload_white) | ||
|
@@ -216,9 +216,8 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa | |
.setContentIntent(getIntentToOpenConversation()) | ||
.build() | ||
|
||
|
||
notificationId = SystemClock.uptimeMillis().toInt() | ||
mNotifyManager!!.notify(notificationId, notification) | ||
mNotifyManager!!.notify(notificationId, initNotification) | ||
// only need one summary notification but multiple upload worker can call it more than once but it is safe | ||
// because of the same notification object config and id. | ||
makeSummaryNotification() | ||
|
@@ -227,7 +226,8 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa | |
private fun makeSummaryNotification() { | ||
// summary notification encapsulating the group of notifications | ||
val summaryNotification = NotificationCompat.Builder( | ||
context, NotificationUtils.NotificationChannels | ||
context, | ||
NotificationUtils.NotificationChannels | ||
.NOTIFICATION_CHANNEL_UPLOADS.name | ||
).setSmallIcon(R.drawable.upload_white) | ||
.setGroup(NotificationUtils.KEY_UPLOAD_GROUP) | ||
|
@@ -239,7 +239,10 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa | |
|
||
private fun getActiveUploadNotifications(): Int? { | ||
// filter out active notifications that are upload notifications using group | ||
return mNotifyManager?.activeNotifications?.filter { notification.group == NotificationUtils.KEY_UPLOAD_GROUP }?.size | ||
return mNotifyManager?.activeNotifications?.filter { | ||
it.notification.group == NotificationUtils | ||
.KEY_UPLOAD_GROUP | ||
}?.size | ||
} | ||
|
||
private fun cancelNotification() { | ||
|
@@ -295,7 +298,8 @@ class UploadAndShareFilesWorker(val context: Context, workerParameters: WorkerPa | |
fileName | ||
) | ||
val failureNotification = NotificationCompat.Builder( | ||
context, NotificationUtils.NotificationChannels | ||
context, | ||
NotificationUtils.NotificationChannels | ||
.NOTIFICATION_CHANNEL_UPLOADS.name | ||
) | ||
.setContentTitle(failureTitle) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters