Skip to content

Commit

Permalink
Merge pull request #12053 from nextcloud/feature/use-m3-files-export-…
Browse files Browse the repository at this point in the history
…notification

Remove Extra Info from Files Export Notification
  • Loading branch information
alperozturk96 authored Oct 20, 2023
2 parents 4766d8b + 2f9ef36 commit c3a5c5c
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions app/src/main/java/com/nextcloud/client/jobs/FilesExportWork.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import android.content.ContentResolver
import android.content.Context
import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.graphics.BitmapFactory
import androidx.core.app.NotificationCompat
import androidx.work.Worker
import androidx.work.WorkerParameters
Expand Down Expand Up @@ -69,9 +68,7 @@ class FilesExportWork(

val successfulExports = exportFiles(fileIDs)

// show notification
showSuccessNotification(successfulExports)

return Result.success()
}

Expand Down Expand Up @@ -105,7 +102,13 @@ class FilesExportWork(

@Throws(IllegalStateException::class)
private fun exportFile(ocFile: OCFile) {
FileExportUtils().exportFile(ocFile.fileName, ocFile.mimeType, contentResolver, ocFile, null)
FileExportUtils().exportFile(
ocFile.fileName,
ocFile.mimeType,
contentResolver,
ocFile,
null
)
}

private fun downloadFile(ocFile: OCFile) {
Expand All @@ -119,19 +122,16 @@ class FilesExportWork(
}

private fun showErrorNotification(successfulExports: Int) {
if (successfulExports == 0) {
showNotification(
appContext.resources.getQuantityString(R.plurals.export_failed, successfulExports, successfulExports)
)
val message = if (successfulExports == 0) {
appContext.resources.getQuantityString(R.plurals.export_failed, successfulExports, successfulExports)
} 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) {
Expand All @@ -152,9 +152,7 @@ class FilesExportWork(
NotificationUtils.NOTIFICATION_CHANNEL_DOWNLOAD
)
.setSmallIcon(R.drawable.notification_icon)
.setLargeIcon(BitmapFactory.decodeResource(appContext.resources, R.drawable.notification_icon))
.setSubText(user.accountName)
.setContentText(message)
.setContentTitle(message)
.setAutoCancel(true)

viewThemeUtils.androidx.themeNotificationCompatBuilder(appContext, notificationBuilder)
Expand All @@ -166,7 +164,8 @@ class FilesExportWork(
appContext,
notificationId,
actionIntent,
PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
PendingIntent.FLAG_CANCEL_CURRENT or
PendingIntent.FLAG_IMMUTABLE
)
notificationBuilder.addAction(
NotificationCompat.Action(
Expand All @@ -176,7 +175,8 @@ class FilesExportWork(
)
)

val notificationManager = appContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
val notificationManager = appContext
.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.notify(notificationId, notificationBuilder.build())
}

Expand Down

0 comments on commit c3a5c5c

Please sign in to comment.