fix: app launch on notification click

closes #504
This commit is contained in:
Zane Schepke 2024-12-19 11:33:00 -05:00
parent 40dd14ca16
commit 9f1af0140f
2 changed files with 6 additions and 3 deletions

View File

@ -19,7 +19,7 @@ interface NotificationService {
onlyAlertOnce: Boolean = true, onlyAlertOnce: Boolean = true,
): Notification ): Notification
fun createNotificationAction(action: NotificationAction): NotificationCompat.Action fun createNotificationAction(notificationAction: NotificationAction): NotificationCompat.Action
fun remove(notificationId: Int) fun remove(notificationId: Int)

View File

@ -14,6 +14,7 @@ import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat import androidx.core.app.NotificationManagerCompat
import com.zaneschepke.wireguardautotunnel.R import com.zaneschepke.wireguardautotunnel.R
import com.zaneschepke.wireguardautotunnel.receiver.NotificationActionReceiver import com.zaneschepke.wireguardautotunnel.receiver.NotificationActionReceiver
import com.zaneschepke.wireguardautotunnel.ui.MainActivity
import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject import javax.inject.Inject
@ -46,6 +47,8 @@ constructor(
addAction(it) addAction(it)
} }
setContentTitle(title) setContentTitle(title)
setContentIntent(PendingIntent.getActivity(context, 0,
Intent(context, MainActivity::class.java), PendingIntent.FLAG_UPDATE_CURRENT))
setContentText(description) setContentText(description)
setOnlyAlertOnce(onlyAlertOnce) setOnlyAlertOnce(onlyAlertOnce)
setOngoing(onGoing) setOngoing(onGoing)
@ -84,7 +87,7 @@ constructor(
} }
} }
fun NotificationChannels.asBuilder(): NotificationCompat.Builder { private fun NotificationChannels.asBuilder(): NotificationCompat.Builder {
return when (this) { return when (this) {
NotificationChannels.AUTO_TUNNEL -> { NotificationChannels.AUTO_TUNNEL -> {
NotificationCompat.Builder( NotificationCompat.Builder(
@ -101,7 +104,7 @@ constructor(
} }
} }
fun NotificationChannels.asChannel(): NotificationChannel { private fun NotificationChannels.asChannel(): NotificationChannel {
return when (this) { return when (this) {
NotificationChannels.VPN -> { NotificationChannels.VPN -> {
NotificationChannel( NotificationChannel(