Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Extra Info from Files Export Notification #12053

Merged
merged 5 commits into from
Oct 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading