Remove extra info from files export

Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
alperozturk 2023-10-17 12:44:33 +02:00
parent 4ff5a37d56
commit 71706f79c2
No known key found for this signature in database
GPG key ID: 4E577DC593B59BDF

View file

@ -31,6 +31,7 @@ import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.graphics.BitmapFactory import android.graphics.BitmapFactory
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import androidx.work.Worker import androidx.work.Worker
import androidx.work.WorkerParameters import androidx.work.WorkerParameters
import com.nextcloud.client.account.User import com.nextcloud.client.account.User
@ -69,9 +70,7 @@ class FilesExportWork(
val successfulExports = exportFiles(fileIDs) val successfulExports = exportFiles(fileIDs)
// show notification
showSuccessNotification(successfulExports) showSuccessNotification(successfulExports)
return Result.success() return Result.success()
} }
@ -119,19 +118,12 @@ class FilesExportWork(
} }
private fun showErrorNotification(successfulExports: Int) { private fun showErrorNotification(successfulExports: Int) {
if (successfulExports == 0) { val message = if (successfulExports == 0) {
showNotification( appContext.resources.getQuantityString(R.plurals.export_failed, successfulExports, successfulExports)
appContext.resources.getQuantityString(R.plurals.export_failed, successfulExports, successfulExports)
)
} else { } else {
showNotification( appContext.resources.getQuantityString(R.plurals.export_partially_failed, successfulExports, successfulExports)
appContext.resources.getQuantityString(
R.plurals.export_partially_failed,
successfulExports,
successfulExports
)
)
} }
showNotification(message)
} }
private fun showSuccessNotification(successfulExports: Int) { private fun showSuccessNotification(successfulExports: Int) {
@ -147,14 +139,9 @@ class FilesExportWork(
private fun showNotification(message: String) { private fun showNotification(message: String) {
val notificationId = SecureRandom().nextInt() val notificationId = SecureRandom().nextInt()
val notificationBuilder = NotificationCompat.Builder( val notificationBuilder = NotificationCompat.Builder(appContext, NotificationUtils.NOTIFICATION_CHANNEL_DOWNLOAD)
appContext,
NotificationUtils.NOTIFICATION_CHANNEL_DOWNLOAD
)
.setSmallIcon(R.drawable.notification_icon) .setSmallIcon(R.drawable.notification_icon)
.setLargeIcon(BitmapFactory.decodeResource(appContext.resources, R.drawable.notification_icon)) .setContentTitle(message)
.setSubText(user.accountName)
.setContentText(message)
.setAutoCancel(true) .setAutoCancel(true)
viewThemeUtils.androidx.themeNotificationCompatBuilder(appContext, notificationBuilder) viewThemeUtils.androidx.themeNotificationCompatBuilder(appContext, notificationBuilder)