diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 54b7aceb5..9f2aacbca 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -162,6 +162,13 @@
android:stopWithTask="false"
android:label="@string/app_name" />
+
+
diff --git a/app/src/main/java/org/linphone/core/CoreFileTransferService.kt b/app/src/main/java/org/linphone/core/CoreFileTransferService.kt
new file mode 100644
index 000000000..947a207fc
--- /dev/null
+++ b/app/src/main/java/org/linphone/core/CoreFileTransferService.kt
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2010-2024 Belledonne Communications SARL.
+ *
+ * This file is part of linphone-android
+ * (see https://www.linphone.org).
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package org.linphone.core
+
+import android.Manifest
+import android.content.Intent
+import android.content.pm.PackageManager
+import android.os.IBinder
+import androidx.annotation.MainThread
+import androidx.annotation.WorkerThread
+import androidx.core.app.ActivityCompat
+import androidx.core.app.NotificationCompat
+import androidx.core.app.NotificationManagerCompat
+import org.linphone.LinphoneApplication.Companion.coreContext
+import org.linphone.R
+import org.linphone.core.tools.Log
+import org.linphone.core.tools.service.FileTransferService
+
+@MainThread
+class CoreFileTransferService : FileTransferService() {
+ companion object {
+ private const val TAG = "[Core File Transfer Service]"
+ }
+
+ var builder = NotificationCompat.Builder(this, SERVICE_NOTIFICATION_CHANNEL_ID)
+
+ private val coreListener = object : CoreListenerStub() {
+ @WorkerThread
+ override fun onRemainingNumberOfFileTransferChanged(
+ core: Core,
+ downloadCount: Int,
+ uploadCount: Int
+ ) {
+ updateNotificationContent(downloadCount, uploadCount)
+ }
+ }
+
+ override fun onCreate() {
+ super.onCreate()
+ coreContext.core.addListener(coreListener)
+ Log.i("$TAG Created")
+ }
+
+ override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
+ Log.i("$TAG onStartCommand")
+ return super.onStartCommand(intent, flags, startId)
+ }
+
+ override fun onTaskRemoved(rootIntent: Intent?) {
+ Log.i("$TAG Task removed, doing nothing")
+ super.onTaskRemoved(rootIntent)
+ }
+
+ override fun onDestroy() {
+ Log.i("$TAG onDestroy")
+ coreContext.core.removeListener(coreListener)
+ super.onDestroy()
+ }
+
+ override fun onBind(p0: Intent?): IBinder? {
+ return null
+ }
+
+ override fun createServiceNotification() {
+ mServiceNotification = builder.setContentTitle(
+ getString(R.string.notification_file_transfer_title)
+ )
+ .setContentText(getString(R.string.notification_file_transfer_startup_message))
+ .setSmallIcon(R.drawable.linphone_notification)
+ .setAutoCancel(false)
+ .setCategory(NotificationCompat.CATEGORY_SERVICE)
+ .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
+ .setWhen(System.currentTimeMillis())
+ .setShowWhen(false)
+ .setOngoing(true)
+ .setProgress(0, 0, true)
+ .build()
+
+ coreContext.postOnCoreThread { core ->
+ val downloadingFilesCount = core.remainingDownloadFileCount
+ val uploadingFilesCount = core.remainingUploadFileCount
+ updateNotificationContent(downloadingFilesCount, uploadingFilesCount)
+ }
+ }
+
+ @WorkerThread
+ private fun updateNotificationContent(downloadingFilesCount: Int, uploadingFilesCount: Int) {
+ Log.i(
+ "$TAG [$downloadingFilesCount] file(s) being downloaded, [$uploadingFilesCount] file(s) being uploaded"
+ )
+
+ val downloadText = resources.getQuantityString(
+ R.plurals.notification_file_transfer_download,
+ downloadingFilesCount,
+ "$downloadingFilesCount"
+ )
+ val uploadText = resources.getQuantityString(
+ R.plurals.notification_file_transfer_upload,
+ uploadingFilesCount,
+ "$uploadingFilesCount"
+ )
+
+ val message = if (downloadingFilesCount > 0 && uploadingFilesCount > 0) {
+ getString(
+ R.string.notification_file_transfer_upload_download_message,
+ downloadText,
+ uploadText
+ )
+ } else if (downloadingFilesCount > 0) {
+ downloadText
+ } else if (uploadingFilesCount > 0) {
+ uploadText
+ } else {
+ ""
+ }
+
+ mServiceNotification = builder.setContentText(message).build()
+ val notificationsManager = NotificationManagerCompat.from(this)
+ if (ActivityCompat.checkSelfPermission(
+ this,
+ Manifest.permission.POST_NOTIFICATIONS
+ ) == PackageManager.PERMISSION_GRANTED
+ ) {
+ notificationsManager.notify(SERVICE_NOTIF_ID, mServiceNotification)
+ } else {
+ Log.e("$TAG POST_NOTIFICATIONS permission wasn't granted!")
+ }
+ }
+}
diff --git a/app/src/main/java/org/linphone/core/CorePushService.kt b/app/src/main/java/org/linphone/core/CorePushService.kt
index a0e7642bd..152dbd55a 100644
--- a/app/src/main/java/org/linphone/core/CorePushService.kt
+++ b/app/src/main/java/org/linphone/core/CorePushService.kt
@@ -26,7 +26,6 @@ import androidx.core.app.NotificationCompat
import org.linphone.R
import org.linphone.core.tools.Log
import org.linphone.core.tools.service.PushService
-import org.linphone.notifications.NotificationsManager
@MainThread
class CorePushService : PushService() {
@@ -68,8 +67,7 @@ class CorePushService : PushService() {
.setSmallIcon(R.drawable.linphone_notification)
.setAutoCancel(false)
.setCategory(NotificationCompat.CATEGORY_SERVICE)
- .setGroup(NotificationsManager.CHAT_NOTIFICATIONS_GROUP)
- .setVisibility(NotificationCompat.VISIBILITY_SECRET)
+ .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setWhen(System.currentTimeMillis())
.setShowWhen(false)
.setOngoing(true)
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index b73c15468..4de7b54bd 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -57,6 +57,16 @@
Appel manqué
&appName;
Recherche de nouveaux messages
+ &appName;
+ Transfert de fichier(s) en cours
+
+ - %s fichier en cours d\'envoi
+ - %s fichiers en cours d\'envoi
+
+
+ - %s fichier en cours de réception
+ - %s fichiers en cours de réception
+
Bienvenue
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index a432d5655..50a36cc21 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -93,6 +93,17 @@
Missed call
&appName;
Searching for new messages
+ &appName;
+ File(s) transfer in progress
+
+ - %s file being uploaded
+ - %s files being uploaded
+
+
+ - %s file being downloaded
+ - %s files being downloaded
+
+ %s, %s
Welcome