aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/org/pacien/tincapp/context/AppNotificationManager.kt7
-rw-r--r--app/src/main/java/org/pacien/tincapp/service/ConfigurationAccessService.kt6
-rw-r--r--app/src/main/java/org/pacien/tincapp/utils/PendingIntentUtils.kt35
3 files changed, 41 insertions, 7 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/context/AppNotificationManager.kt b/app/src/main/java/org/pacien/tincapp/context/AppNotificationManager.kt
index 9d731a5..5b01a54 100644
--- a/app/src/main/java/org/pacien/tincapp/context/AppNotificationManager.kt
+++ b/app/src/main/java/org/pacien/tincapp/context/AppNotificationManager.kt
@@ -1,6 +1,6 @@
1/* 1/*
2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon 2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon
3 * Copyright (C) 2017-2020 Pacien TRAN-GIRARD 3 * Copyright (C) 2017-2023 Pacien TRAN-GIRARD
4 * 4 *
5 * This program is free software: you can redistribute it and/or modify 5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -18,10 +18,8 @@
18 18
19package org.pacien.tincapp.context 19package org.pacien.tincapp.context
20 20
21import android.app.Notification
22import android.app.NotificationChannel 21import android.app.NotificationChannel
23import android.app.NotificationManager 22import android.app.NotificationManager
24import android.app.PendingIntent
25import android.content.Context 23import android.content.Context
26import android.content.Intent 24import android.content.Intent
27import android.net.Uri 25import android.net.Uri
@@ -30,6 +28,7 @@ import androidx.annotation.RequiresApi
30import androidx.core.app.NotificationCompat 28import androidx.core.app.NotificationCompat
31import androidx.core.app.NotificationManagerCompat 29import androidx.core.app.NotificationManagerCompat
32import org.pacien.tincapp.R 30import org.pacien.tincapp.R
31import org.pacien.tincapp.utils.PendingIntentUtils
33 32
34/** 33/**
35 * @author pacien 34 * @author pacien
@@ -95,7 +94,7 @@ class AppNotificationManager(private val context: Context) {
95 94
96 private fun NotificationCompat.Builder.setManualLink(manualLink: String) = apply { 95 private fun NotificationCompat.Builder.setManualLink(manualLink: String) = apply {
97 val intent = Intent(Intent.ACTION_VIEW, Uri.parse(manualLink)) 96 val intent = Intent(Intent.ACTION_VIEW, Uri.parse(manualLink))
98 val pendingIntent = PendingIntent.getActivity(context, 0, intent, 0) 97 val pendingIntent = PendingIntentUtils.getActivity(context, 0, intent, 0)
99 addAction(R.drawable.ic_help_primary_24dp, context.getString(R.string.notification_error_action_open_manual), pendingIntent) 98 addAction(R.drawable.ic_help_primary_24dp, context.getString(R.string.notification_error_action_open_manual), pendingIntent)
100 } 99 }
101} 100}
diff --git a/app/src/main/java/org/pacien/tincapp/service/ConfigurationAccessService.kt b/app/src/main/java/org/pacien/tincapp/service/ConfigurationAccessService.kt
index 1708243..916f19d 100644
--- a/app/src/main/java/org/pacien/tincapp/service/ConfigurationAccessService.kt
+++ b/app/src/main/java/org/pacien/tincapp/service/ConfigurationAccessService.kt
@@ -1,6 +1,6 @@
1/* 1/*
2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon 2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon
3 * Copyright (C) 2017-2020 Pacien TRAN-GIRARD 3 * Copyright (C) 2017-2023 Pacien TRAN-GIRARD
4 * 4 *
5 * This program is free software: you can redistribute it and/or modify 5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
@@ -18,7 +18,6 @@
18 18
19package org.pacien.tincapp.service 19package org.pacien.tincapp.service
20 20
21import android.app.PendingIntent
22import android.app.Service 21import android.app.Service
23import android.content.Context 22import android.content.Context
24import android.content.Intent 23import android.content.Intent
@@ -39,6 +38,7 @@ import org.pacien.tincapp.activities.configure.ConfigureActivity
39import org.pacien.tincapp.context.App 38import org.pacien.tincapp.context.App
40import org.pacien.tincapp.context.AppNotificationManager 39import org.pacien.tincapp.context.AppNotificationManager
41import org.pacien.tincapp.extensions.Java.defaultMessage 40import org.pacien.tincapp.extensions.Java.defaultMessage
41import org.pacien.tincapp.utils.PendingIntentUtils
42import org.slf4j.LoggerFactory 42import org.slf4j.LoggerFactory
43import java.io.IOException 43import java.io.IOException
44 44
@@ -125,7 +125,7 @@ class ConfigurationAccessService : Service() {
125 .setContentTitle(resources.getString(R.string.notification_config_access_server_running_title)) 125 .setContentTitle(resources.getString(R.string.notification_config_access_server_running_title))
126 .setContentText(resources.getString(R.string.notification_config_access_server_running_message)) 126 .setContentText(resources.getString(R.string.notification_config_access_server_running_message))
127 .setContentIntent(Intent(this, ConfigureActivity::class.java).let { 127 .setContentIntent(Intent(this, ConfigureActivity::class.java).let {
128 PendingIntent.getActivity(this, 0, it, 0) 128 PendingIntentUtils.getActivity(this, 0, it, 0)
129 }) 129 })
130 .build() 130 .build()
131 ) 131 )
diff --git a/app/src/main/java/org/pacien/tincapp/utils/PendingIntentUtils.kt b/app/src/main/java/org/pacien/tincapp/utils/PendingIntentUtils.kt
new file mode 100644
index 0000000..f2a6abe
--- /dev/null
+++ b/app/src/main/java/org/pacien/tincapp/utils/PendingIntentUtils.kt
@@ -0,0 +1,35 @@
1/*
2 * Tinc App, an Android binding and user interface for the tinc mesh VPN daemon
3 * Copyright (C) 2017-2023 Pacien TRAN-GIRARD
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19package org.pacien.tincapp.utils
20
21import android.app.PendingIntent
22import android.content.Context
23import android.content.Intent
24import android.os.Build
25
26/**
27 * @author pacien
28 */
29object PendingIntentUtils {
30 fun getActivity(context: Context, requestCode: Int, intent: Intent, flags: Int): PendingIntent {
31 val extraFlags =
32 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) PendingIntent.FLAG_IMMUTABLE else 0
33 return PendingIntent.getActivity(context, requestCode, intent, flags or extraFlags)
34 }
35}