feat: поддержка Android 6.0+ (minSdk 23)

This commit is contained in:
samosvalishe committed 2026-04-10 13:18:56 +03:00
1 parent a6a4361334
commit ba52490b06
8 files changed
+89 -51

No files matched your search

+1 -1
View File
@@ -29,7 +29,7 @@ Android-клиент для [vk-turn-proxy](https://github.com/cacggghp/vk-turn-
## Требования
- Android 8.0+ (API 26)
- Android 6.0+ (API 23)
- ARM64-устройство (arm64-v8a)
- VPS с установленным WireGuard или Hysteria
- Ссылка на VK Звонок
+1 -1
View File
@@ -9,7 +9,7 @@ android {
defaultConfig {
applicationId = "com.freeturn.app"
minSdk = 26
minSdk = 23
targetSdk = 36
versionCode = 13
versionName = "1.7.0"
+2 -1
View File
@@ -41,7 +41,8 @@
<service
android:name=".ProxyService"
android:exported="false"
android:foregroundServiceType="specialUse">
android:foregroundServiceType="specialUse"
tools:targetApi="29">
<!--
Обязательное свойство для foregroundServiceType="specialUse".
Без него Google Play отклоняет приложение.
@@ -3,6 +3,7 @@ package com.freeturn.app
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.os.Build
class ProxyReceiver : BroadcastReceiver() {
@@ -12,7 +13,11 @@ class ProxyReceiver : BroadcastReceiver() {
ProxyServiceState.clearLogs()
ProxyServiceState.setStartupResult(null)
val serviceIntent = Intent(context, ProxyService::class.java)
context.startForegroundService(serviceIntent)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.startForegroundService(serviceIntent)
} else {
context.startService(serviceIntent)
}
}
"com.freeturn.app.STOP_PROXY" -> {
val serviceIntent = Intent(context, ProxyService::class.java)
@@ -3,6 +3,7 @@ package com.freeturn.app.domain
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Build
import com.freeturn.app.ProxyService
import com.freeturn.app.ProxyServiceState
import com.freeturn.app.StartupResult
@@ -87,7 +88,12 @@ class LocalProxyManager(private val context: Context) {
ProxyServiceState.clearLogs()
ProxyServiceState.setStartupResult(null)
context.startForegroundService(Intent(context, ProxyService::class.java))
val intent = Intent(context, ProxyService::class.java)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
context.startForegroundService(intent)
} else {
context.startService(intent)
}
val result = withTimeoutOrNull(5_000L) {
ProxyServiceState.startupResult.filterNotNull().first()
@@ -1,6 +1,7 @@
package com.freeturn.app.ui
import android.content.Context
import android.os.Build
import android.os.VibrationEffect
import android.os.Vibrator
@@ -28,60 +29,73 @@ object HapticUtil {
LAUNCH,
}
@Suppress("DEPRECATION")
fun perform(context: Context, pattern: Pattern) {
val vibrator = context.getSystemService(Vibrator::class.java) ?: return
val effect = when (pattern) {
Pattern.SELECTION -> VibrationEffect.createOneShot(20, 120)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val effect = when (pattern) {
Pattern.SELECTION -> VibrationEffect.createOneShot(20, 120)
Pattern.CLICK -> VibrationEffect.createOneShot(25, 160)
Pattern.CLICK -> VibrationEffect.createOneShot(25, 160)
Pattern.TOGGLE_ON -> VibrationEffect.createWaveform(
longArrayOf(0L, 35L, 50L, 20L),
intArrayOf(0, 200, 0, 110),
-1
)
Pattern.TOGGLE_ON -> VibrationEffect.createWaveform(
longArrayOf(0L, 35L, 50L, 20L),
intArrayOf(0, 200, 0, 110),
-1
)
Pattern.TOGGLE_OFF -> VibrationEffect.createWaveform(
longArrayOf(0L, 28L, 45L, 16L),
intArrayOf(0, 140, 0, 70),
-1
)
Pattern.TOGGLE_OFF -> VibrationEffect.createWaveform(
longArrayOf(0L, 28L, 45L, 16L),
intArrayOf(0, 140, 0, 70),
-1
)
Pattern.SUCCESS -> VibrationEffect.createWaveform(
longArrayOf(0L, 22L, 40L, 16L, 40L, 12L),
intArrayOf(0, 140, 0, 100, 0, 65),
-1
)
Pattern.SUCCESS -> VibrationEffect.createWaveform(
longArrayOf(0L, 22L, 40L, 16L, 40L, 12L),
intArrayOf(0, 140, 0, 100, 0, 65),
-1
)
Pattern.ERROR -> VibrationEffect.createWaveform(
longArrayOf(0L, 45L, 25L, 45L, 25L, 30L),
intArrayOf(0, 210, 0, 175, 0, 130),
-1
)
Pattern.ERROR -> VibrationEffect.createWaveform(
longArrayOf(0L, 45L, 25L, 45L, 25L, 30L),
intArrayOf(0, 210, 0, 175, 0, 130),
-1
)
// Музыкальная вибрация
Pattern.LAUNCH -> VibrationEffect.createWaveform(
longArrayOf(
0L,
18L, 55L,
18L, 45L,
22L, 35L,
30L, 80L,
15L, 40L,
10L
),
intArrayOf(
0,
80, 0,
110, 0,
150, 0,
210, 0,
60, 0,
30
),
-1
)
// Музыкальная вибрация
Pattern.LAUNCH -> VibrationEffect.createWaveform(
longArrayOf(
0L,
18L, 55L,
18L, 45L,
22L, 35L,
30L, 80L,
15L, 40L,
10L
),
intArrayOf(
0,
80, 0,
110, 0,
150, 0,
210, 0,
60, 0,
30
),
-1
)
}
try { vibrator.vibrate(effect) } catch (_: Exception) {}
} else {
val duration = when (pattern) {
Pattern.SELECTION -> 20L
Pattern.CLICK -> 25L
Pattern.TOGGLE_ON, Pattern.TOGGLE_OFF -> 50L
Pattern.SUCCESS -> 60L
Pattern.ERROR -> 100L
Pattern.LAUNCH -> 70L
}
try { vibrator.vibrate(duration) } catch (_: Exception) {}
}
try { vibrator.vibrate(effect) } catch(_: Exception) {}
}
}
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
<monochrome android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@color/ic_launcher_background"/>
<foreground android:drawable="@drawable/ic_launcher_foreground"/>
<monochrome android:drawable="@drawable/ic_launcher_foreground"/>
</adaptive-icon>