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 1 commit
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
27 changes: 7 additions & 20 deletions app/src/main/java/com/nextcloud/client/jobs/FilesExportWork.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.graphics.BitmapFactory
import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import androidx.work.Worker
import androidx.work.WorkerParameters
import com.nextcloud.client.account.User
Expand Down Expand Up @@ -69,9 +70,7 @@

val successfulExports = exportFiles(fileIDs)

// show notification
showSuccessNotification(successfulExports)

return Result.success()
}

Expand Down Expand Up @@ -119,19 +118,12 @@
}

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)

Check notice on line 124 in app/src/main/java/com/nextcloud/client/jobs/FilesExportWork.kt

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

app/src/main/java/com/nextcloud/client/jobs/FilesExportWork.kt#L124

Line detected, which is longer than the defined maximum line length in the code style.
}
showNotification(message)
}

private fun showSuccessNotification(successfulExports: Int) {
Expand All @@ -147,14 +139,9 @@
private fun showNotification(message: String) {
val notificationId = SecureRandom().nextInt()

val notificationBuilder = NotificationCompat.Builder(
appContext,
NotificationUtils.NOTIFICATION_CHANNEL_DOWNLOAD
)
val notificationBuilder = NotificationCompat.Builder(appContext, NotificationUtils.NOTIFICATION_CHANNEL_DOWNLOAD)

Check notice on line 142 in app/src/main/java/com/nextcloud/client/jobs/FilesExportWork.kt

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

app/src/main/java/com/nextcloud/client/jobs/FilesExportWork.kt#L142

Line detected, which is longer than the defined maximum line length in the code style.
.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 Down
Loading