diff --git a/app/build.gradle b/app/build.gradle
index d1b9298..fab676a 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -10,8 +10,8 @@ android {
applicationId "eu.neilalexander.yggdrasil"
minSdkVersion 21
targetSdkVersion 33
- versionCode 15
- versionName "0.1-015"
+ versionCode 16
+ versionName "0.1-016"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@@ -55,6 +55,7 @@ dependencies {
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.preference:preference-ktx:1.2.1'
+ implementation 'com.guolindev.permissionx:permissionx:1.7.1'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
diff --git a/app/src/main/java/eu/neilalexander/yggdrasil/MainActivity.kt b/app/src/main/java/eu/neilalexander/yggdrasil/MainActivity.kt
index 947dd07..1e6c65d 100644
--- a/app/src/main/java/eu/neilalexander/yggdrasil/MainActivity.kt
+++ b/app/src/main/java/eu/neilalexander/yggdrasil/MainActivity.kt
@@ -1,9 +1,11 @@
package eu.neilalexander.yggdrasil
+import android.Manifest
import android.app.Activity
import android.content.*
import android.graphics.Color
import android.net.VpnService
+import android.os.Build
import android.os.Bundle
import android.widget.Switch
import android.widget.TextView
@@ -14,6 +16,7 @@ import androidx.appcompat.widget.LinearLayoutCompat
import androidx.core.content.edit
import androidx.localbroadcastmanager.content.LocalBroadcastManager
import androidx.preference.PreferenceManager
+import com.permissionx.guolindev.PermissionX
import eu.neilalexander.yggdrasil.PacketTunnelProvider.Companion.STATE_INTENT
import mobile.Mobile
import org.json.JSONArray
@@ -37,6 +40,38 @@ class MainActivity : AppCompatActivity() {
startService(intent)
}
+ private fun checkNotificationPermission() {
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) {
+ return
+ }
+
+ PermissionX.init(this)
+ .permissions(
+ Manifest.permission.POST_NOTIFICATIONS,
+ )
+ .onExplainRequestReason { scope, deniedList ->
+ scope.showRequestReasonDialog(
+ deniedList,
+ getString(R.string.explain_ntfn_perms),
+ getString(R.string.ok),
+ getString(R.string.cancel),
+ )
+ }
+ .onForwardToSettings { scope, deniedList ->
+ scope.showForwardToSettingsDialog(
+ deniedList,
+ getString(R.string.manual_ntfn_perms),
+ getString(R.string.ok),
+ getString(R.string.cancel),
+ )
+ }
+ .request { allGranted, _, _ ->
+ if (!allGranted) {
+ Toast.makeText(this, R.string.ntfn_denied, Toast.LENGTH_LONG).show()
+ }
+ }
+ }
+
private var startVpnActivity = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
if (result.resultCode == Activity.RESULT_OK) {
start()
@@ -65,6 +100,7 @@ class MainActivity : AppCompatActivity() {
enabledSwitch.setOnCheckedChangeListener { _, isChecked ->
when (isChecked) {
true -> {
+ checkNotificationPermission()
val vpnIntent = VpnService.prepare(this)
if (vpnIntent != null) {
startVpnActivity.launch(vpnIntent)
diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml
index 35be1ee..e4bf757 100644
--- a/app/src/main/res/values-ru/strings.xml
+++ b/app/src/main/res/values-ru/strings.xml
@@ -42,6 +42,9 @@
Сброс
Состояние
Включить Yggdrasil
+ Пожалуйста включите нотификации чтобы видеть статус подключения Yggdrasil
+ Чтобы видеть статус подключения Yggdrasil, включите нотификации в настройках
+ Нотификация статуса подключения Yggdrasil не будет показана
Статистика
Н/Д
Адрес
@@ -83,4 +86,4 @@
Приватный ключ:
Установить свой ключ
Сохранить
-
\ No newline at end of file
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 7bf2dac..8208a91 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -42,6 +42,9 @@
Reset
Status
Enable Yggdrasil
+ Please enable notifications to easily see Yggdrasil connection status
+ To see Yggdrasil connection status, enable notifications in app settings
+ Yggdrasil connection status notification will not be shown
Statistics
N/A
IP
@@ -83,4 +86,4 @@
Private key:
Set your own key
Save
-
\ No newline at end of file
+