diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index f5ed3470bacc..19da01d7505a 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -239,6 +239,12 @@
android:exported="false"
android:configChanges="orientation|screenLayout|screenSize|keyboardHidden"
android:theme="@style/Theme.ownCloud.Media" />
+
diff --git a/app/src/main/java/com/nextcloud/client/files/downloader/DownloadNotificationManager.kt b/app/src/main/java/com/nextcloud/client/files/downloader/DownloadNotificationManager.kt
index f3c7cb0d5bc5..60ce0c1911b0 100644
--- a/app/src/main/java/com/nextcloud/client/files/downloader/DownloadNotificationManager.kt
+++ b/app/src/main/java/com/nextcloud/client/files/downloader/DownloadNotificationManager.kt
@@ -111,7 +111,7 @@ class DownloadNotificationManager(
@Suppress("MagicNumber")
fun showCompleteNotification(text: String) {
Handler(Looper.getMainLooper()).postDelayed({
- updateNotificationText(null,text, true)
+ updateNotificationText(null, text, true)
dismissNotification()
}, 3000)
}
@@ -156,4 +156,12 @@ class DownloadNotificationManager(
)
)
}
+
+ fun getId(): Int {
+ return id
+ }
+
+ fun getNotification(): Notification {
+ return notificationBuilder.build()
+ }
}
diff --git a/app/src/main/java/com/nextcloud/client/files/downloader/FileDownloadWorker.kt b/app/src/main/java/com/nextcloud/client/files/downloader/FileDownloadWorker.kt
index bf3c165f3df8..b4534cfa0a63 100644
--- a/app/src/main/java/com/nextcloud/client/files/downloader/FileDownloadWorker.kt
+++ b/app/src/main/java/com/nextcloud/client/files/downloader/FileDownloadWorker.kt
@@ -36,8 +36,10 @@ import com.nextcloud.client.account.UserAccountManager
import com.nextcloud.java.util.Optional
import com.nextcloud.model.WorkerState
import com.nextcloud.model.WorkerStateLiveData
+import com.nextcloud.utils.ForegroundServiceHelper
import com.owncloud.android.R
import com.owncloud.android.datamodel.FileDataStorageManager
+import com.owncloud.android.datamodel.ForegroundServiceType
import com.owncloud.android.datamodel.OCFile
import com.owncloud.android.files.services.IndexedForest
import com.owncloud.android.lib.common.OwnCloudAccount
@@ -123,6 +125,14 @@ class FileDownloadWorker(
addAccountUpdateListener()
+ setForegroundAsync(
+ ForegroundServiceHelper.createWorkerForegroundInfo(
+ notificationManager.getId(),
+ notificationManager.getNotification(),
+ ForegroundServiceType.DataSync
+ )
+ )
+
requestDownloads.forEach {
downloadFile(it)
}