From db1d58205c29d93143f852ba84c69d7585f8800f Mon Sep 17 00:00:00 2001 From: alperozturk Date: Fri, 5 Jan 2024 11:23:47 +0100 Subject: [PATCH] Fix tracking current download status Signed-off-by: alperozturk --- .../files/downloader/DownloadNotificationManager.kt | 4 ++++ .../client/files/downloader/FileDownloadWorker.kt | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/nextcloud/client/files/downloader/DownloadNotificationManager.kt b/app/src/main/java/com/nextcloud/client/files/downloader/DownloadNotificationManager.kt index eddfed9f31..176bd9ac71 100644 --- a/app/src/main/java/com/nextcloud/client/files/downloader/DownloadNotificationManager.kt +++ b/app/src/main/java/com/nextcloud/client/files/downloader/DownloadNotificationManager.kt @@ -196,6 +196,10 @@ class DownloadNotificationManager(private val context: Context, private val view notificationManager.cancel(R.string.downloader_download_in_progress_ticker) } + fun dismissAll() { + notificationManager.cancelAll() + } + fun setCredentialContentIntent(user: User) { val intent = Intent(context, AuthenticatorActivity::class.java).apply { putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, user.toPlatformAccount()) diff --git a/app/src/main/java/com/nextcloud/client/files/downloader/FileDownloadWorker.kt b/app/src/main/java/com/nextcloud/client/files/downloader/FileDownloadWorker.kt index 8705a6a3b2..f38273488f 100644 --- a/app/src/main/java/com/nextcloud/client/files/downloader/FileDownloadWorker.kt +++ b/app/src/main/java/com/nextcloud/client/files/downloader/FileDownloadWorker.kt @@ -128,11 +128,11 @@ class FileDownloadWorker( downloadFile(it) } - setIdleWorkerState() folder?.let { notifyForFolderResult(it) } + setIdleWorkerState() Log_OC.e(TAG, "FilesDownloadWorker successfully completed") Result.success() } catch (t: Throwable) { @@ -144,9 +144,9 @@ class FileDownloadWorker( override fun onStopped() { Log_OC.e(TAG, "FilesDownloadWorker stopped") - cancelAllDownloads() - notificationManager.dismissDownloadInProgressNotification() removePendingDownload(currentDownload?.user?.accountName) + cancelAllDownloads() + notificationManager.dismissAll() setIdleWorkerState() super.onStopped() @@ -157,6 +157,8 @@ class FileDownloadWorker( } private fun setIdleWorkerState() { + pendingDownloads.all.clear() + currentDownload = null WorkerStateLiveData.instance().setWorkState(WorkerState.Idle) } @@ -219,8 +221,6 @@ class FileDownloadWorker( pendingDownloads.all.forEach { it.value.payload?.cancel() } - pendingDownloads.all.clear() - currentDownload = null } private fun setUser() {