diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 46cf91c7..1773201a 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -19,6 +19,11 @@ android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_rounded" tools:targetApi="31"> + + + + + + = 25) { + getSystemService()?.reportShortcutUsed("toggle") + } + } + moveTaskToBack(true) + } + + override fun onServiceStatusChanged(status: Status) { + when (status) { + Status.Started -> BoxService.stop() + Status.Stopped -> BoxService.start() + else -> {} + } + finish() + } + + override fun onDestroy() { + connection.disconnect() + super.onDestroy() + } + +} \ No newline at end of file diff --git a/android/app/src/main/kotlin/com/hiddify/hiddify/bg/BoxService.kt b/android/app/src/main/kotlin/com/hiddify/hiddify/bg/BoxService.kt index 7fb07108..ab79cb4b 100644 --- a/android/app/src/main/kotlin/com/hiddify/hiddify/bg/BoxService.kt +++ b/android/app/src/main/kotlin/com/hiddify/hiddify/bg/BoxService.kt @@ -73,7 +73,7 @@ class BoxService( fun start() { val intent = runBlocking { withContext(Dispatchers.IO) { - Intent(Application.application, VPNService::class.java) + Intent(Application.application, Settings.serviceClass()) } } ContextCompat.startForegroundService(Application.application, intent) diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index fbb54ae9..31c16b69 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -1,4 +1,5 @@ Stop + Toggle \ No newline at end of file diff --git a/android/app/src/main/res/xml/shortcuts.xml b/android/app/src/main/res/xml/shortcuts.xml new file mode 100644 index 00000000..668ed275 --- /dev/null +++ b/android/app/src/main/res/xml/shortcuts.xml @@ -0,0 +1,13 @@ + + + + + + \ No newline at end of file