Forráskód Böngészése

Only show total download/upload progress if total count bigger than 0

Signed-off-by: alperozturk <alper_ozturk@proton.me>
alperozturk 1 éve
szülő
commit
2d11376e21

+ 10 - 6
app/src/main/java/com/nextcloud/client/jobs/download/DownloadNotificationManager.kt

@@ -19,19 +19,23 @@ import java.security.SecureRandom
 
 @Suppress("TooManyFunctions")
 class DownloadNotificationManager(
-    private val id: Int,
+    id: Int,
     private val context: Context,
     viewThemeUtils: ViewThemeUtils
 ) : WorkerNotificationManager(id, context, viewThemeUtils, R.string.downloader_download_in_progress_ticker) {
 
     @Suppress("MagicNumber")
     fun prepareForStart(operation: DownloadFileOperation, currentDownloadIndex: Int, totalDownloadSize: Int) {
-        currentOperationTitle = String.format(
-            context.getString(R.string.downloader_notification_manager_download_text),
-            currentDownloadIndex,
-            totalDownloadSize,
+        currentOperationTitle = if (totalDownloadSize > 1) {
+            String.format(
+                context.getString(R.string.downloader_notification_manager_download_text),
+                currentDownloadIndex,
+                totalDownloadSize,
+                File(operation.savePath).name
+            )
+        } else {
             File(operation.savePath).name
-        )
+        }
 
         notificationBuilder.run {
             setContentTitle(currentOperationTitle)

+ 9 - 5
app/src/main/java/com/nextcloud/client/jobs/upload/UploadNotificationManager.kt

@@ -31,12 +31,16 @@ class UploadNotificationManager(private val context: Context, viewThemeUtils: Vi
         currentUploadIndex: Int,
         totalUploadSize: Int
     ) {
-        currentOperationTitle = String.format(
-            context.getString(R.string.upload_notification_manager_start_text),
-            currentUploadIndex,
-            totalUploadSize,
+        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),