From 58dc3d7d6fdebe1bd3e18f6364ce9cb8ce2f7bd8 Mon Sep 17 00:00:00 2001 From: alperozturk96 Date: Wed, 28 Jan 2026 09:05:04 +0100 Subject: [PATCH 1/2] make media folder detection worker silent Signed-off-by: alperozturk96 --- .../client/jobs/MediaFoldersDetectionWork.kt | 36 ++++++++++++------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/nextcloud/client/jobs/MediaFoldersDetectionWork.kt b/app/src/main/java/com/nextcloud/client/jobs/MediaFoldersDetectionWork.kt index f7c7694ba662..1b36fb0a0ff3 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/MediaFoldersDetectionWork.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/MediaFoldersDetectionWork.kt @@ -21,7 +21,6 @@ import android.content.Context import android.content.Intent import android.content.res.Resources import android.graphics.BitmapFactory -import android.media.RingtoneManager import android.text.TextUtils import androidx.core.app.NotificationCompat import androidx.work.Worker @@ -49,7 +48,7 @@ import com.owncloud.android.utils.theme.ViewThemeUtils import java.util.Random @Suppress("LongParameterList") // dependencies injection -class MediaFoldersDetectionWork constructor( +class MediaFoldersDetectionWork( private val context: Context, params: WorkerParameters, private val resources: Resources, @@ -195,13 +194,15 @@ class MediaFoldersDetectionWork constructor( @Suppress("LongMethod") private fun sendNotification(contentTitle: String, subtitle: String, user: User, path: String, type: Int) { val notificationId = randomIdGenerator.nextInt() - val context = context - val intent = Intent(context, SyncedFoldersActivity::class.java) - intent.putExtra(NOTIFICATION_ID, notificationId) - intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) - intent.putExtra(NotificationWork.KEY_NOTIFICATION_ACCOUNT, user.accountName) - intent.putExtra(KEY_MEDIA_FOLDER_PATH, path) - intent.putExtra(KEY_MEDIA_FOLDER_TYPE, type) + + val intent = Intent(context, SyncedFoldersActivity::class.java).apply { + putExtra(NOTIFICATION_ID, notificationId) + addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) + putExtra(NotificationWork.KEY_NOTIFICATION_ACCOUNT, user.accountName) + putExtra(KEY_MEDIA_FOLDER_PATH, path) + putExtra(KEY_MEDIA_FOLDER_TYPE, type) + } + val pendingIntent = PendingIntent.getActivity( context, 0, @@ -217,21 +218,27 @@ class MediaFoldersDetectionWork constructor( .setSubText(user.accountName) .setContentTitle(contentTitle) .setContentText(subtitle) - .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) .setAutoCancel(true) + .setSound(null) + .setVibrate(null) + .setOnlyAlertOnce(true) + .setSilent(true) .setContentIntent(pendingIntent) viewThemeUtils.androidx.themeNotificationCompatBuilder(context, notificationBuilder) - val disableDetection = Intent(context, NotificationReceiver::class.java) - disableDetection.putExtra(NOTIFICATION_ID, notificationId) - disableDetection.action = DISABLE_DETECTION_CLICK + val disableDetection = Intent(context, NotificationReceiver::class.java).apply { + putExtra(NOTIFICATION_ID, notificationId) + action = DISABLE_DETECTION_CLICK + } + val disableIntent = PendingIntent.getBroadcast( context, notificationId, disableDetection, PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE ) + notificationBuilder.addAction( NotificationCompat.Action( R.drawable.ic_close, @@ -239,12 +246,14 @@ class MediaFoldersDetectionWork constructor( disableIntent ) ) + val configureIntent = PendingIntent.getActivity( context, notificationId, intent, PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE ) + notificationBuilder.addAction( NotificationCompat.Action( R.drawable.ic_settings, @@ -252,6 +261,7 @@ class MediaFoldersDetectionWork constructor( configureIntent ) ) + val notificationManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager notificationManager.notify(notificationId, notificationBuilder.build()) } From f63c79396585ad4fd7fef0d7fcf997b1c95161df Mon Sep 17 00:00:00 2001 From: alperozturk96 Date: Wed, 28 Jan 2026 09:08:21 +0100 Subject: [PATCH 2/2] make media folder detection worker silent Signed-off-by: alperozturk96 --- .../java/com/nextcloud/client/jobs/MediaFoldersDetectionWork.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/java/com/nextcloud/client/jobs/MediaFoldersDetectionWork.kt b/app/src/main/java/com/nextcloud/client/jobs/MediaFoldersDetectionWork.kt index 1b36fb0a0ff3..198d37f18f12 100644 --- a/app/src/main/java/com/nextcloud/client/jobs/MediaFoldersDetectionWork.kt +++ b/app/src/main/java/com/nextcloud/client/jobs/MediaFoldersDetectionWork.kt @@ -221,7 +221,6 @@ class MediaFoldersDetectionWork( .setAutoCancel(true) .setSound(null) .setVibrate(null) - .setOnlyAlertOnce(true) .setSilent(true) .setContentIntent(pendingIntent)