From de8d45646fbb0b06fb796bd3f0440bd5235506d8 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Wed, 11 Dec 2024 16:19:25 +0100 Subject: [PATCH 1/2] fix Signed-off-by: alperozturk --- .../nextcloud/client/jobs/upload/FileUploadWorker.kt | 9 +++++++-- .../client/jobs/upload/UploadNotificationManager.kt | 11 +---------- app/src/main/res/values/strings.xml | 1 - 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt index d732a63777..bc03d32f8f 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/upload/FileUploadWorker.kt @@ -90,6 +90,7 @@ class FileUploadWorker( } } + private var currentUploadIndex: Int = 1 private var lastPercent = 0 private val notificationManager = UploadNotificationManager(context, viewThemeUtils) private val intents = FileUploaderIntents(context) @@ -167,7 +168,7 @@ class FileUploadWorker( setWorkerState(user.get(), uploadsPerPage) run uploads@{ - uploadsPerPage.forEachIndexed { currentUploadIndex, upload -> + uploadsPerPage.forEach { upload -> if (isStopped) { return@uploads } @@ -181,12 +182,16 @@ class FileUploadWorker( uploadFileOperation, cancelPendingIntent = intents.startIntent(uploadFileOperation), startIntent = intents.notificationStartIntent(uploadFileOperation), - currentUploadIndex = currentUploadIndex + 1, + currentUploadIndex = currentUploadIndex, totalUploadSize = totalUploadSize ) val result = upload(uploadFileOperation, user.get()) + if (result.isSuccess) { + currentUploadIndex += 1 + } + currentUploadFileOperation = null fileUploaderDelegate.sendBroadcastUploadFinished( diff --git a/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt b/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt index bade8ed798..15fb0f9948 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt @@ -32,16 +32,7 @@ class UploadNotificationManager(private val context: Context, viewThemeUtils: Vi currentUploadIndex: Int, totalUploadSize: Int ) { - currentOperationTitle = if (totalUploadSize > 1) { - String.format( - context.getString(R.string.upload_notification_manager_start_text), - currentUploadIndex, - totalUploadSize, - uploadFileOperation.fileName - ) - } else { - uploadFileOperation.fileName - } + currentOperationTitle = "$currentUploadIndex / $totalUploadSize - ${uploadFileOperation.fileName}" val progressText = String.format( context.getString(R.string.upload_notification_manager_upload_in_progress_text), diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f0b93bdd5f..002ac5a95f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -223,7 +223,6 @@ Upload from… Folder name - %1$d / %2$d - %3$s %1$d%% Uploading… From 4385285f687337fc2733cc5e8366e854283900a9 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Wed, 11 Dec 2024 16:33:02 +0100 Subject: [PATCH 2/2] revert translation changes Signed-off-by: alperozturk --- .../client/jobs/upload/UploadNotificationManager.kt | 11 ++++++++++- app/src/main/res/values/strings.xml | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt b/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt index 15fb0f9948..bade8ed798 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt @@ -32,7 +32,16 @@ class UploadNotificationManager(private val context: Context, viewThemeUtils: Vi currentUploadIndex: Int, totalUploadSize: Int ) { - currentOperationTitle = "$currentUploadIndex / $totalUploadSize - ${uploadFileOperation.fileName}" + currentOperationTitle = if (totalUploadSize > 1) { + String.format( + context.getString(R.string.upload_notification_manager_start_text), + currentUploadIndex, + totalUploadSize, + uploadFileOperation.fileName + ) + } else { + uploadFileOperation.fileName + } val progressText = String.format( context.getString(R.string.upload_notification_manager_upload_in_progress_text), diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 002ac5a95f..f0b93bdd5f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -223,6 +223,7 @@ Upload from… Folder name + %1$d / %2$d - %3$s %1$d%% Uploading…