diff --git a/app/src/main/java/org/linphone/core/CoreFileTransferService.kt b/app/src/main/java/org/linphone/core/CoreFileTransferService.kt index 3db350b29..7beb494e0 100644 --- a/app/src/main/java/org/linphone/core/CoreFileTransferService.kt +++ b/app/src/main/java/org/linphone/core/CoreFileTransferService.kt @@ -20,6 +20,7 @@ package org.linphone.core import android.Manifest +import android.app.PendingIntent import android.content.Intent import android.content.pm.PackageManager import android.os.IBinder @@ -33,6 +34,7 @@ import org.linphone.LinphoneApplication.Companion.coreContext import org.linphone.R import org.linphone.core.tools.Log import org.linphone.core.tools.service.FileTransferService +import org.linphone.ui.main.MainActivity @MainThread class CoreFileTransferService : FileTransferService() { @@ -80,6 +82,17 @@ class CoreFileTransferService : FileTransferService() { } override fun createServiceNotification() { + Log.i("$TAG Creating notification") + + val intent = Intent(applicationContext, MainActivity::class.java) + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + val pendingIntent = PendingIntent.getActivity( + applicationContext, + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) + mServiceNotification = builder.setContentTitle( getString(R.string.notification_file_transfer_title) ) @@ -92,6 +105,7 @@ class CoreFileTransferService : FileTransferService() { .setShowWhen(false) .setOngoing(true) .setProgress(0, 0, true) + .setContentIntent(pendingIntent) .build() postNotification() @@ -130,7 +144,7 @@ class CoreFileTransferService : FileTransferService() { } else if (uploadingFilesCount > 0) { uploadText } else { - getString(R.string.notification_file_transfer_title) + getString(R.string.notification_file_transfer_startup_message) } mServiceNotification = builder.setContentText(message).build() @@ -146,6 +160,7 @@ class CoreFileTransferService : FileTransferService() { ) == PackageManager.PERMISSION_GRANTED ) { if (mServiceNotification != null) { + Log.i("$TAG Sending notification to manager") notificationsManager.notify(SERVICE_NOTIF_ID, mServiceNotification) } else { Log.e("$TAG Notification content hasn't been computed yet!") diff --git a/app/src/main/java/org/linphone/core/CorePushService.kt b/app/src/main/java/org/linphone/core/CorePushService.kt index 152dbd55a..0c6e67cdc 100644 --- a/app/src/main/java/org/linphone/core/CorePushService.kt +++ b/app/src/main/java/org/linphone/core/CorePushService.kt @@ -19,6 +19,7 @@ */ package org.linphone.core +import android.app.PendingIntent import android.content.Intent import android.os.IBinder import androidx.annotation.MainThread @@ -26,6 +27,7 @@ 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.ui.main.MainActivity @MainThread class CorePushService : PushService() { @@ -58,6 +60,17 @@ class CorePushService : PushService() { } override fun createServiceNotification() { + Log.i("$TAG Creating notification") + + val intent = Intent(applicationContext, MainActivity::class.java) + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + val pendingIntent = PendingIntent.getActivity( + applicationContext, + 0, + intent, + PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE + ) + mServiceNotification = NotificationCompat.Builder( this, SERVICE_NOTIFICATION_CHANNEL_ID @@ -71,6 +84,7 @@ class CorePushService : PushService() { .setWhen(System.currentTimeMillis()) .setShowWhen(false) .setOngoing(true) + .setContentIntent(pendingIntent) .build() } }