feat(shortcuts): запуск/стоп прокси по long-press иконки

This commit is contained in:
samosvalishe committed 2026-06-17 19:41:24 +03:00
1 parent a49a61ddec
commit 9bb468b1d3
4 files changed
+67

No files matched your search

+15
View File
@@ -65,8 +65,23 @@
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="freeturn" />
</intent-filter>
<!-- Долгое нажатие плитки Quick Settings открывает приложение. -->
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES" />
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>
<!-- Трамплин App Shortcuts (long-press иконки): шлёт START/STOP в ProxyReceiver. -->
<activity
android:name=".service.ProxyShortcutActivity"
android:exported="true"
android:excludeFromRecents="true"
android:taskAffinity=""
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<service
android:name=".service.ProxyService"
android:exported="false"
@@ -0,0 +1,21 @@
package com.freeturn.app.service
import android.app.Activity
import android.content.Intent
import android.os.Bundle
/**
* Прозрачный трамплин для App Shortcuts (long-press иконки). Launcher запускает
* только activity - шлём START/STOP в [ProxyReceiver] и сразу закрываемся.
*/
class ProxyShortcutActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
when (intent?.action) {
ProxyActions.START, ProxyActions.STOP -> sendBroadcast(
Intent(this, ProxyReceiver::class.java).setAction(intent.action)
)
}
finish()
}
}
+6
View File
@@ -339,6 +339,12 @@
<string name="tile_service_label">Free Turn</string>
<string name="proxy_active_wireguard">Прокси и WireGuard активны</string>
<!-- App Shortcuts (long-press иконки) -->
<string name="shortcut_start_short">Запуск</string>
<string name="shortcut_start_long">Запустить прокси</string>
<string name="shortcut_stop_short">Стоп</string>
<string name="shortcut_stop_long">Остановить прокси</string>
<!-- Туннельное приложение (WireGuard) -->
<string name="wireguard_tunnel_name">Имя туннеля</string>
<string name="wireguard_mtu">MTU</string>
+25
View File
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
<shortcut
android:shortcutId="start_proxy"
android:enabled="true"
android:icon="@drawable/play_arrow_24px"
android:shortcutShortLabel="@string/shortcut_start_short"
android:shortcutLongLabel="@string/shortcut_start_long">
<intent
android:action="com.freeturn.app.START_PROXY"
android:targetPackage="com.freeturn.app"
android:targetClass="com.freeturn.app.service.ProxyShortcutActivity" />
</shortcut>
<shortcut
android:shortcutId="stop_proxy"
android:enabled="true"
android:icon="@drawable/stop_24px"
android:shortcutShortLabel="@string/shortcut_stop_short"
android:shortcutLongLabel="@string/shortcut_stop_long">
<intent
android:action="com.freeturn.app.STOP_PROXY"
android:targetPackage="com.freeturn.app"
android:targetClass="com.freeturn.app.service.ProxyShortcutActivity" />
</shortcut>
</shortcuts>