From 0fc6ac2cfa1ab6e9b8269e4b0a01c40f7e111ef8 Mon Sep 17 00:00:00 2001
From: WirelessAlien <121420261+WirelessAlien@users.noreply.github.com>
Date: Fri, 3 Jan 2025 13:57:30 +0530
Subject: [PATCH] update notification progress- copy/move action
---
.../zipxtract/service/CopyMoveService.kt | 25 +++++++++++++------
app/src/main/res/values/strings.xml | 8 +++---
2 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/app/src/main/java/com/wirelessalien/zipxtract/service/CopyMoveService.kt b/app/src/main/java/com/wirelessalien/zipxtract/service/CopyMoveService.kt
index eafaf05..979cac2 100644
--- a/app/src/main/java/com/wirelessalien/zipxtract/service/CopyMoveService.kt
+++ b/app/src/main/java/com/wirelessalien/zipxtract/service/CopyMoveService.kt
@@ -49,7 +49,7 @@ class CopyMoveService : Service() {
val isCopyAction = intent.getBooleanExtra(EXTRA_IS_COPY_ACTION, true)
createNotificationChannel()
- startForeground(NOTIFICATION_ID, createNotification(0, filesToCopyMove.size))
+ startForeground(NOTIFICATION_ID, createNotification(0, filesToCopyMove.size, isCopyAction))
CoroutineScope(Dispatchers.IO).launch {
copyMoveFiles(filesToCopyMove, destinationPath, isCopyAction)
@@ -84,7 +84,7 @@ class CopyMoveService : Service() {
file.moveTo(destination, overwrite = true)
}
processedFilesCount++
- updateNotification(processedFilesCount, totalFilesCount)
+ updateNotification(processedFilesCount, totalFilesCount, isCopyAction)
}
}
@@ -120,18 +120,29 @@ class CopyMoveService : Service() {
}
}
- private fun createNotification(progress: Int, total: Int): Notification {
+ private fun createNotification(progress: Int, total: Int, isCopyAction: Boolean): Notification {
+ val title = if (isCopyAction) {
+ getString(R.string.copying_files)
+ } else {
+ getString(R.string.moving_files)
+ }
+ val contentText = if (isCopyAction) {
+ getString(R.string.copying_files_progress, progress, total)
+ } else {
+ getString(R.string.moving_files_progress, progress, total)
+ }
+
return NotificationCompat.Builder(this, COPY_MOVE_NOTIFICATION_CHANNEL_ID)
- .setContentTitle(getString(R.string.copying_moving_files))
- .setContentText(getString(R.string.copying_moving_files_progress, progress, total))
+ .setContentTitle(title)
+ .setContentText(contentText)
.setSmallIcon(R.drawable.ic_notification_icon)
.setProgress(total, progress, false)
.setOngoing(true)
.build()
}
- private fun updateNotification(progress: Int, total: Int) {
- val notification = createNotification(progress, total)
+ private fun updateNotification(progress: Int, total: Int, isCopyAction: Boolean) {
+ val notification = createNotification(progress, total, isCopyAction)
val notificationManager = getSystemService(NotificationManager::class.java)
notificationManager.notify(NOTIFICATION_ID, notification)
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 1be06a6..83290c7 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -173,8 +173,10 @@
The file doesn\'t exist: %1$s
Delete File
Deleting files: %1$d/%2$d
- Deleting...
+ Deleting…
Copy/Move Files
- Progress...
- Progress %1$d/%2$d
+ Copying files: %1$d/%2$d
+ Moving files: %1$d/%2$d
+ Copying…
+ Moving…
\ No newline at end of file