feat(settings): server-centric settings flow and connection-mode screen
Вводит иерархию Настройки → Серверы → [сервер] → подключение/режим/сервер поверх единого серверного хаба (SettingsScreens, SettingsGroup). Выносит выбор Proxy/VPN и загрузку WireGuard-конфига файлом в отдельный экран ConnectionModeScreen. ClientSetupScreen и ServerManagementScreen работают с конкретным профилем by-id, серверные настройки применяются по кнопке «Применить» (apply-модель). Чистит устаревшие после переноса строки/иконки (client_title, obf_key_apply, tcp_forward_mode_desc, memory/switch_account drawables и др.) и мёртвый rememberHaptic.
This commit is contained in:
1 parent
c339d91b78
commit
f45454a77c
12 files changed
+1736
-513
No files matched your search
@@ -0,0 +1,149 @@
|
||||
@file:OptIn(androidx.compose.material3.ExperimentalMaterial3ExpressiveApi::class)
|
||||
|
||||
package com.freeturn.app.ui.components
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ColumnScope
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialShapes
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.toShape
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.semantics.heading
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.freeturn.app.R
|
||||
import com.freeturn.app.ui.HapticUtil
|
||||
import com.freeturn.app.ui.util.hapticClickable
|
||||
|
||||
// Общие строительные блоки экранов настроек (Settings-флоу и «Режим подключения»):
|
||||
// заголовок секции, карточка-группа, строка-вход, inset-разделитель. Один источник —
|
||||
// чтобы экраны выглядели одинаково и не дублировали верстку.
|
||||
|
||||
/** Макс. ширина контента — читаемая колонка на планшетах/foldable (MD3 large+). */
|
||||
val SettingsContentMaxWidth = 840.dp
|
||||
|
||||
// Левый отступ inset-разделителя = иконка(40) + отступ слева(16) + зазор(16).
|
||||
private val RowDividerIndent = 72.dp
|
||||
|
||||
/** Заголовок секции — мелкий акцентный лейбл над карточкой-группой. */
|
||||
@Composable
|
||||
fun SectionLabel(text: String) {
|
||||
Text(
|
||||
text,
|
||||
style = MaterialTheme.typography.titleSmall,
|
||||
color = MaterialTheme.colorScheme.primary,
|
||||
// heading() — TalkBack прыгает между секциями.
|
||||
modifier = Modifier
|
||||
.padding(start = 4.dp)
|
||||
.semantics { heading() }
|
||||
)
|
||||
}
|
||||
|
||||
/** Карточка-группа: тональный контейнер со скруглением, строки внутри. */
|
||||
@Composable
|
||||
fun SettingsCard(content: @Composable ColumnScope.() -> Unit) {
|
||||
Surface(
|
||||
shape = MaterialTheme.shapes.large,
|
||||
color = MaterialTheme.colorScheme.surfaceContainerLow,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Column(content = content)
|
||||
}
|
||||
}
|
||||
|
||||
/** Тональная иконка-кружок (Sunny) строки настроек. Один источник формы/размера. */
|
||||
@Composable
|
||||
fun SettingsRowIcon(iconRes: Int, enabled: Boolean = true) {
|
||||
// Disabled: гасим контейнер и тинт вместе с заголовком — строка не выглядит наполовину живой.
|
||||
val alpha = if (enabled) 1f else 0.38f
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(40.dp)
|
||||
.background(
|
||||
MaterialTheme.colorScheme.secondaryContainer.copy(alpha = alpha),
|
||||
MaterialShapes.Sunny.toShape()
|
||||
),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Icon(
|
||||
painterResource(iconRes),
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.onSecondaryContainer.copy(alpha = alpha),
|
||||
modifier = Modifier.size(22.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Строка-вход: тональная иконка, заголовок/подзаголовок, опциональный трейлинг.
|
||||
* По умолчанию трейлинг — шеврон (навигация). Передай null, чтобы убрать, или другой
|
||||
* ресурс (напр. галочку статуса). Haptic-клик встроен; [onClick] — чистое действие.
|
||||
*/
|
||||
@Composable
|
||||
fun SettingsEntryRow(
|
||||
iconRes: Int,
|
||||
title: String,
|
||||
subtitle: String? = null,
|
||||
trailingRes: Int? = R.drawable.chevron_right_24px,
|
||||
trailingTint: Color = Color.Unspecified,
|
||||
enabled: Boolean = true,
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
val titleColor = if (enabled) MaterialTheme.colorScheme.onSurface
|
||||
else MaterialTheme.colorScheme.onSurface.copy(alpha = 0.38f)
|
||||
val subtitleColor = if (enabled) MaterialTheme.colorScheme.onSurfaceVariant
|
||||
else MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.38f)
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.hapticClickable(HapticUtil.Pattern.CLICK, enabled = enabled, onClick = onClick)
|
||||
.padding(horizontal = 16.dp, vertical = 14.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
SettingsRowIcon(iconRes, enabled = enabled)
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Text(title, style = MaterialTheme.typography.bodyLarge, color = titleColor)
|
||||
if (subtitle != null) {
|
||||
Text(
|
||||
subtitle,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = subtitleColor
|
||||
)
|
||||
}
|
||||
}
|
||||
if (trailingRes != null) {
|
||||
val baseTrailing = if (trailingTint == Color.Unspecified) MaterialTheme.colorScheme.onSurfaceVariant
|
||||
else trailingTint
|
||||
Icon(
|
||||
painterResource(trailingRes),
|
||||
contentDescription = null,
|
||||
tint = if (enabled) baseTrailing else baseTrailing.copy(alpha = 0.38f)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Inset-разделитель между строками карточки (отступ под иконку). */
|
||||
@Composable
|
||||
fun SettingsRowDivider() {
|
||||
HorizontalDivider(
|
||||
modifier = Modifier.padding(start = RowDividerIndent),
|
||||
color = MaterialTheme.colorScheme.outlineVariant
|
||||
)
|
||||
}
|
||||
@@ -6,16 +6,15 @@
|
||||
package com.freeturn.app.ui.screens
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.imePadding
|
||||
import androidx.compose.foundation.layout.navigationBars
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
@@ -55,13 +54,10 @@ import com.freeturn.app.R
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.freeturn.app.data.ClientConfig
|
||||
import com.freeturn.app.data.DnsMode
|
||||
import com.freeturn.app.data.ObfProfile
|
||||
import com.freeturn.app.data.Provider
|
||||
import com.freeturn.app.data.TunnelTransport
|
||||
import com.freeturn.app.ui.HapticUtil
|
||||
import com.freeturn.app.viewmodel.ServerViewModel
|
||||
import com.freeturn.app.viewmodel.SettingsViewModel
|
||||
import com.freeturn.app.viewmodel.SshConnectionState
|
||||
import kotlin.math.roundToInt
|
||||
import kotlinx.coroutines.delay
|
||||
|
||||
@@ -74,26 +70,44 @@ import kotlinx.coroutines.delay
|
||||
fun ClientSetupScreen(
|
||||
settingsViewModel: SettingsViewModel,
|
||||
serverViewModel: ServerViewModel,
|
||||
// null = онбординг/legacy-режим (профиль ещё не создан, пишем в legacy-ключи).
|
||||
// не-null = редактируем конкретный профиль по id (Settings-флоу).
|
||||
profileId: String? = null,
|
||||
onBack: (() -> Unit)? = null,
|
||||
showFinishButton: Boolean = false,
|
||||
onFinish: (() -> Unit)? = null
|
||||
) {
|
||||
val saved by settingsViewModel.clientConfig.collectAsStateWithLifecycle()
|
||||
val snapshot by settingsViewModel.profilesSnapshot.collectAsStateWithLifecycle()
|
||||
val legacyClient by settingsViewModel.clientConfig.collectAsStateWithLifecycle()
|
||||
val sshConfig by serverViewModel.sshConfig.collectAsStateWithLifecycle()
|
||||
val sshState by serverViewModel.sshState.collectAsStateWithLifecycle()
|
||||
val serverState by serverViewModel.serverState.collectAsStateWithLifecycle()
|
||||
val serverOpts by serverViewModel.serverOpts.collectAsStateWithLifecycle()
|
||||
val proxyListen by settingsViewModel.proxyListen.collectAsStateWithLifecycle()
|
||||
val legacyProxyListen by settingsViewModel.proxyListen.collectAsStateWithLifecycle()
|
||||
val privacyMode by settingsViewModel.privacyMode.collectAsStateWithLifecycle()
|
||||
val isRegeneratingObfKey by serverViewModel.isRegeneratingObfKey.collectAsStateWithLifecycle()
|
||||
|
||||
val isSshConnected = sshState is SshConnectionState.Connected
|
||||
// Источник данных: конкретный профиль по id либо legacy (онбординг).
|
||||
val profile = profileId?.let { id -> snapshot.list.firstOrNull { it.id == id } }
|
||||
val saved = profile?.client ?: legacyClient
|
||||
// Активный профиль (или онбординг) рулит живым рантаймом: SSH-сессия, рестарты,
|
||||
// sync с сервером. Для неактивного редактируем только хранимые данные.
|
||||
val isActive = profileId == null || profileId == snapshot.activeId
|
||||
val effSshIp = profile?.ssh?.ip ?: sshConfig.ip
|
||||
val effProxyListen = profile?.proxyListen ?: legacyProxyListen
|
||||
|
||||
// Единая точка записи client-конфига: профиль by-id либо legacy.
|
||||
fun clientEdit(transform: (ClientConfig) -> ClientConfig) {
|
||||
if (profileId != null) {
|
||||
settingsViewModel.updateProfileClient(profileId, transform)
|
||||
} else {
|
||||
settingsViewModel.saveClientConfig(transform(settingsViewModel.clientConfig.value), snapshot.activeId)
|
||||
}
|
||||
}
|
||||
|
||||
val serverKnown = serverState as? com.freeturn.app.viewmodel.ServerState.Known
|
||||
// В sync-режиме эффективное значение — реальное состояние сервера из probe
|
||||
// (если запущен), иначе сохранённое. В !sync режиме — всегда сохранённое:
|
||||
// серверная и клиентская стороны могут различаться, и UI отражает клиента.
|
||||
// TCP-форвард: в sync-режиме у активного сервера берём реальное состояние из probe
|
||||
// (если запущен), иначе — сохранённое значение клиента. Нужно лишь для показа Bond.
|
||||
val syncOn = saved.syncServerSwitches
|
||||
val effectiveTcpForward = if (syncOn && serverKnown?.running == true) serverKnown.tcpMode ?: saved.tcpForward else saved.tcpForward
|
||||
val effectiveObfProfile = if (syncOn && serverKnown?.running == true) serverKnown.obfProfile ?: serverOpts.obfProfile else serverOpts.obfProfile
|
||||
val effectiveTcpForward = if (isActive && syncOn && serverKnown?.running == true)
|
||||
serverKnown.tcpMode ?: saved.tcpForward else saved.tcpForward
|
||||
|
||||
val context = LocalContext.current
|
||||
|
||||
@@ -105,43 +119,34 @@ fun ClientSetupScreen(
|
||||
var streamsPerCred by remember(saved.streamsPerCred) { mutableFloatStateOf(saved.streamsPerCred.toFloat()) }
|
||||
var localPort by remember(saved.localPort) { mutableStateOf(saved.localPort) }
|
||||
var magicTurn by remember(saved.magicTurn) { mutableStateOf(saved.magicTurn) }
|
||||
var wireGuardTunnelName by remember(saved.wireGuardTunnelName) { mutableStateOf(saved.wireGuardTunnelName) }
|
||||
var wireGuardConfig by remember(saved.wireGuardConfig) { mutableStateOf(saved.wireGuardConfig) }
|
||||
var lastSliderInt by remember(saved.threads) { mutableIntStateOf(saved.threads) }
|
||||
var lastStreamsInt by remember(saved.streamsPerCred) { mutableIntStateOf(saved.streamsPerCred) }
|
||||
|
||||
// Автозаполнение адреса сервера из SSH-конфига если поле пустое
|
||||
LaunchedEffect(sshConfig.ip, proxyListen) {
|
||||
if (serverAddress.isBlank() && sshConfig.ip.isNotBlank()) {
|
||||
val port = proxyListen.substringAfterLast(":", "56000")
|
||||
serverAddress = "${sshConfig.ip}:$port"
|
||||
LaunchedEffect(effSshIp, effProxyListen) {
|
||||
if (serverAddress.isBlank() && effSshIp.isNotBlank()) {
|
||||
val port = effProxyListen.substringAfterLast(":", "56000")
|
||||
serverAddress = "$effSshIp:$port"
|
||||
}
|
||||
}
|
||||
|
||||
// Профиль полей (синхронно с saved). Сейв сверит с активным — защита от гонки
|
||||
// переключения за время дебаунса.
|
||||
val fieldsProfileId = remember(saved) { settingsViewModel.profilesSnapshot.value.activeId }
|
||||
|
||||
// Авто-сохранение с дебаунсом 600 мс для текстовых полей и ползунков
|
||||
// Авто-сохранение с дебаунсом 600 мс для текстовых полей и ползунков.
|
||||
// clientEdit сам маршрутизирует запись в профиль by-id либо в legacy и под
|
||||
// mutex сверяет цель — защита от гонки переключения за время дебаунса.
|
||||
LaunchedEffect(
|
||||
serverAddress, vkLink, threads, streamsPerCred, localPort, magicTurn,
|
||||
wireGuardTunnelName, wireGuardConfig
|
||||
serverAddress, vkLink, threads, streamsPerCred, localPort, magicTurn
|
||||
) {
|
||||
delay(600)
|
||||
val current = settingsViewModel.clientConfig.value
|
||||
settingsViewModel.saveClientConfig(
|
||||
clientEdit { current ->
|
||||
current.copy(
|
||||
serverAddress = serverAddress.trim(),
|
||||
vkLink = vkLink.trim(),
|
||||
threads = threads.roundToInt(),
|
||||
streamsPerCred = streamsPerCred.roundToInt(),
|
||||
localPort = localPort.trim(),
|
||||
magicTurn = magicTurn.trim(),
|
||||
wireGuardTunnelName = wireGuardTunnelName.trim().ifBlank { TunnelTransport.DEFAULT_TUNNEL_NAME },
|
||||
wireGuardConfig = wireGuardConfig.trim()
|
||||
),
|
||||
fieldsProfileId
|
||||
)
|
||||
magicTurn = magicTurn.trim()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior()
|
||||
@@ -150,11 +155,21 @@ fun ClientSetupScreen(
|
||||
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text(stringResource(R.string.client_title)) },
|
||||
title = { Text(stringResource(R.string.provider_connection_settings)) },
|
||||
navigationIcon = {
|
||||
if (onBack != null) {
|
||||
IconButton(onClick = onBack) {
|
||||
Icon(
|
||||
painterResource(R.drawable.arrow_back_24px),
|
||||
contentDescription = stringResource(R.string.back)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
scrollBehavior = scrollBehavior
|
||||
)
|
||||
},
|
||||
contentWindowInsets = WindowInsets(0, 0, 0, 0)
|
||||
contentWindowInsets = if (onBack != null) WindowInsets(0, 0, 0, 0) else WindowInsets.navigationBars
|
||||
) { padding ->
|
||||
Column(
|
||||
modifier = Modifier
|
||||
@@ -292,7 +307,7 @@ fun ClientSetupScreen(
|
||||
selected = saved.dnsMode == value,
|
||||
onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
||||
settingsViewModel.setDnsMode(value)
|
||||
clientEdit { it.copy(dnsMode = value) }
|
||||
},
|
||||
shape = SegmentedButtonDefaults.itemShape(index = idx, count = dnsOptions.size)
|
||||
) { Text(label) }
|
||||
@@ -315,7 +330,7 @@ fun ClientSetupScreen(
|
||||
selected = !saved.useUdp,
|
||||
onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
||||
settingsViewModel.setUseUdp(false)
|
||||
clientEdit { it.copy(useUdp = false) }
|
||||
},
|
||||
shape = SegmentedButtonDefaults.itemShape(index = 0, count = 2)
|
||||
) { Text(stringResource(R.string.tcp)) }
|
||||
@@ -323,7 +338,7 @@ fun ClientSetupScreen(
|
||||
selected = saved.useUdp,
|
||||
onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
||||
settingsViewModel.setUseUdp(true)
|
||||
clientEdit { it.copy(useUdp = true) }
|
||||
},
|
||||
shape = SegmentedButtonDefaults.itemShape(index = 1, count = 2)
|
||||
) { Text(stringResource(R.string.udp)) }
|
||||
@@ -336,9 +351,9 @@ fun ClientSetupScreen(
|
||||
label = stringResource(R.string.manual_captcha),
|
||||
description = stringResource(R.string.manual_captcha_desc),
|
||||
checked = saved.manualCaptcha,
|
||||
onCheckedChange = {
|
||||
HapticUtil.perform(context, if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||
settingsViewModel.setManualCaptcha(it)
|
||||
onCheckedChange = { v ->
|
||||
HapticUtil.perform(context, if (v) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||
clientEdit { it.copy(manualCaptcha = v) }
|
||||
}
|
||||
)
|
||||
|
||||
@@ -346,9 +361,9 @@ fun ClientSetupScreen(
|
||||
label = stringResource(R.string.use_carrier_dns),
|
||||
description = stringResource(R.string.use_carrier_dns_desc),
|
||||
checked = saved.useCarrierDns,
|
||||
onCheckedChange = {
|
||||
HapticUtil.perform(context, if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||
settingsViewModel.setUseCarrierDns(it)
|
||||
onCheckedChange = { v ->
|
||||
HapticUtil.perform(context, if (v) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||
clientEdit { it.copy(useCarrierDns = v) }
|
||||
}
|
||||
)
|
||||
|
||||
@@ -356,9 +371,9 @@ fun ClientSetupScreen(
|
||||
label = stringResource(R.string.debug_mode),
|
||||
description = stringResource(R.string.debug_mode_desc),
|
||||
checked = saved.debugMode,
|
||||
onCheckedChange = {
|
||||
HapticUtil.perform(context, if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||
settingsViewModel.setDebugMode(it)
|
||||
onCheckedChange = { v ->
|
||||
HapticUtil.perform(context, if (v) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||
clientEdit { it.copy(debugMode = v) }
|
||||
}
|
||||
)
|
||||
|
||||
@@ -366,9 +381,9 @@ fun ClientSetupScreen(
|
||||
label = stringResource(R.string.magic_switch),
|
||||
description = stringResource(R.string.magic_switch_desc),
|
||||
checked = saved.magicSwitch,
|
||||
onCheckedChange = {
|
||||
HapticUtil.perform(context, if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||
settingsViewModel.setMagicSwitch(it)
|
||||
onCheckedChange = { v ->
|
||||
HapticUtil.perform(context, if (v) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||
clientEdit { it.copy(magicSwitch = v) }
|
||||
}
|
||||
)
|
||||
|
||||
@@ -392,221 +407,30 @@ fun ClientSetupScreen(
|
||||
label = stringResource(R.string.client_bond),
|
||||
description = stringResource(R.string.client_bond_desc),
|
||||
checked = saved.bond,
|
||||
onCheckedChange = {
|
||||
HapticUtil.perform(context, if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||
settingsViewModel.setBond(it)
|
||||
onCheckedChange = { v ->
|
||||
HapticUtil.perform(context, if (v) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||
// bond триггерит рестарт прокси только у активного; иначе пишем данные.
|
||||
if (isActive) settingsViewModel.setBond(v) else clientEdit { it.copy(bond = v) }
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
||||
|
||||
// --- Туннельное приложение (WireGuard) ---
|
||||
Text(stringResource(R.string.tunnel_transport_title), style = MaterialTheme.typography.titleMedium)
|
||||
Text(
|
||||
stringResource(R.string.tunnel_transport_desc),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
|
||||
Text(stringResource(R.string.wireguard_section), style = MaterialTheme.typography.bodyMedium)
|
||||
OutlinedTextField(
|
||||
value = wireGuardTunnelName.redact(privacyMode),
|
||||
onValueChange = { if (!privacyMode) wireGuardTunnelName = it },
|
||||
label = { Text(stringResource(R.string.wireguard_tunnel_name)) },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true,
|
||||
readOnly = privacyMode
|
||||
)
|
||||
OutlinedTextField(
|
||||
value = wireGuardConfig.redact(privacyMode),
|
||||
onValueChange = { if (!privacyMode) wireGuardConfig = it },
|
||||
label = { Text(stringResource(R.string.wireguard_config_label)) },
|
||||
placeholder = { Text(stringResource(R.string.wireguard_config_placeholder)) },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
minLines = 8,
|
||||
readOnly = privacyMode,
|
||||
supportingText = { Text(stringResource(R.string.wireguard_config_support)) }
|
||||
)
|
||||
|
||||
// Split-tunneling настраивается на главном экране (SplitTunnelSheet),
|
||||
// здесь — только WG-конфиг и тоггл логов.
|
||||
// Режим подключения (Proxy/VPN) и WireGuard-конфиг вынесены в отдельный
|
||||
// экран «Режим подключения» (ConnectionModeScreen). Здесь — клиентские
|
||||
// параметры ядра и тоггл логов.
|
||||
|
||||
SwitchRow(
|
||||
label = stringResource(R.string.logs_enabled),
|
||||
description = stringResource(R.string.logs_enabled_desc),
|
||||
checked = saved.logsEnabled,
|
||||
onCheckedChange = {
|
||||
HapticUtil.perform(context, if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||
settingsViewModel.setLogsEnabled(it)
|
||||
onCheckedChange = { v ->
|
||||
HapticUtil.perform(context, if (v) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||
clientEdit { it.copy(logsEnabled = v) }
|
||||
}
|
||||
)
|
||||
|
||||
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
||||
|
||||
Text(
|
||||
stringResource(R.string.server_sync_section),
|
||||
style = MaterialTheme.typography.titleMedium
|
||||
)
|
||||
|
||||
SwitchRow(
|
||||
label = stringResource(R.string.sync_server_switches),
|
||||
description = stringResource(R.string.sync_server_switches_desc),
|
||||
checked = syncOn,
|
||||
onCheckedChange = {
|
||||
HapticUtil.perform(context, if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||
settingsViewModel.setSyncServerSwitches(it)
|
||||
}
|
||||
)
|
||||
|
||||
// В sync-режиме менять эти флаги без SSH опасно (рассинхрон).
|
||||
// В !sync — клиентские, SSH не нужен.
|
||||
val controlsEnabled = if (syncOn) isSshConnected else true
|
||||
val lockedHint = if (syncOn)
|
||||
stringResource(R.string.locked_disconnect_hint) else null
|
||||
|
||||
// TCP-форвард — табы (UDP по умолчанию / TCP для проброса). Синхр. с сервером.
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Column {
|
||||
Text(stringResource(R.string.tcp_forward_mode), style = MaterialTheme.typography.bodyMedium)
|
||||
Text(
|
||||
lockedHint?.takeIf { !isSshConnected }
|
||||
?: stringResource(R.string.tcp_forward_mode_desc),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {
|
||||
SegmentedButton(
|
||||
selected = !effectiveTcpForward,
|
||||
enabled = controlsEnabled,
|
||||
onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
||||
settingsViewModel.setTcpForward(false)
|
||||
},
|
||||
shape = SegmentedButtonDefaults.itemShape(index = 0, count = 2)
|
||||
) { Text(stringResource(R.string.udp)) }
|
||||
SegmentedButton(
|
||||
selected = effectiveTcpForward,
|
||||
enabled = controlsEnabled,
|
||||
onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
||||
settingsViewModel.setTcpForward(true)
|
||||
},
|
||||
shape = SegmentedButtonDefaults.itemShape(index = 1, count = 2)
|
||||
) { Text(stringResource(R.string.tcp)) }
|
||||
}
|
||||
}
|
||||
|
||||
// Профиль обфускации — табы (как транспорт). Должен совпадать с сервером.
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Column {
|
||||
Text(stringResource(R.string.obf_profile_title), style = MaterialTheme.typography.bodyMedium)
|
||||
Text(
|
||||
lockedHint?.takeIf { !isSshConnected }
|
||||
?: stringResource(R.string.obf_profile_desc),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {
|
||||
ObfProfile.ALL.forEachIndexed { idx, value ->
|
||||
SegmentedButton(
|
||||
selected = effectiveObfProfile == value,
|
||||
enabled = controlsEnabled,
|
||||
onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
||||
settingsViewModel.setObfProfile(value)
|
||||
},
|
||||
shape = SegmentedButtonDefaults.itemShape(index = idx, count = ObfProfile.ALL.size)
|
||||
) { Text(obfProfileLabel(value)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (effectiveObfProfile != ObfProfile.NONE) {
|
||||
val obfKeyRegex = remember { Regex("^[0-9a-fA-F]{64}$") }
|
||||
// Локальный черновик: правки в TextField не дёргают saveServerOpts/restart
|
||||
// на каждом keystroke. Применение — отдельной кнопкой ниже, только когда
|
||||
// ключ валидный (64 hex). Серверный ключ из serverOpts — источник истины:
|
||||
// при внешнем обновлении (regen/probe) черновик пересинхронизируется.
|
||||
var obfKeyDraft by remember(serverOpts.obfKey) {
|
||||
mutableStateOf(serverOpts.obfKey)
|
||||
}
|
||||
val draftValid = obfKeyDraft.matches(obfKeyRegex)
|
||||
val draftDirty = obfKeyDraft != serverOpts.obfKey
|
||||
OutlinedTextField(
|
||||
value = if (privacyMode) serverOpts.obfKey.redact(true) else obfKeyDraft,
|
||||
onValueChange = { if (!privacyMode) obfKeyDraft = it },
|
||||
label = { Text(stringResource(R.string.server_obf_key_label)) },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
readOnly = privacyMode,
|
||||
singleLine = true,
|
||||
isError = obfKeyDraft.isNotBlank() && !draftValid,
|
||||
trailingIcon = {
|
||||
if (serverOpts.obfKey.isNotBlank() && !privacyMode) {
|
||||
IconButton(onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
val cm = context.getSystemService(android.content.ClipboardManager::class.java)
|
||||
cm?.setPrimaryClip(
|
||||
android.content.ClipData.newPlainText("obf-key", serverOpts.obfKey)
|
||||
)
|
||||
}) {
|
||||
Icon(
|
||||
painter = painterResource(R.drawable.content_copy_24px),
|
||||
contentDescription = stringResource(R.string.copy)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
supportingText = {
|
||||
when {
|
||||
obfKeyDraft.isBlank() -> Text(
|
||||
stringResource(R.string.obf_key_empty_hint),
|
||||
color = MaterialTheme.colorScheme.error
|
||||
)
|
||||
!draftValid -> Text(
|
||||
stringResource(R.string.obf_key_invalid_hint),
|
||||
color = MaterialTheme.colorScheme.error
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
if (!privacyMode && draftDirty) {
|
||||
androidx.compose.material3.TextButton(
|
||||
onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
settingsViewModel.setObfKey(obfKeyDraft)
|
||||
},
|
||||
enabled = draftValid,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Text(stringResource(R.string.obf_key_apply))
|
||||
}
|
||||
}
|
||||
if (isSshConnected) {
|
||||
Box(modifier = Modifier.fillMaxWidth()) {
|
||||
androidx.compose.material3.TextButton(
|
||||
onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
serverViewModel.regenerateObfKey()
|
||||
},
|
||||
enabled = !isRegeneratingObfKey,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
if (isRegeneratingObfKey) {
|
||||
androidx.compose.material3.CircularWavyProgressIndicator(
|
||||
modifier = Modifier.size(20.dp)
|
||||
)
|
||||
Spacer(Modifier.size(8.dp))
|
||||
Text(stringResource(R.string.obf_key_regen_in_progress))
|
||||
} else {
|
||||
Text(stringResource(R.string.obf_key_regen))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Кнопка «Завершить» — только в онбординг-флоу
|
||||
if (showFinishButton && onFinish != null) {
|
||||
@@ -628,7 +452,7 @@ fun ClientSetupScreen(
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SwitchRow(
|
||||
internal fun SwitchRow(
|
||||
label: String,
|
||||
description: String,
|
||||
checked: Boolean,
|
||||
@@ -657,9 +481,3 @@ private fun SwitchRow(
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun obfProfileLabel(value: String): String = when (value) {
|
||||
ObfProfile.NONE -> stringResource(R.string.obf_none)
|
||||
ObfProfile.RTPOPUS -> stringResource(R.string.obf_rtpopus)
|
||||
else -> value
|
||||
}
|
||||
@@ -0,0 +1,278 @@
|
||||
@file:OptIn(androidx.compose.material3.ExperimentalMaterial3Api::class)
|
||||
|
||||
package com.freeturn.app.ui.screens
|
||||
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.imePadding
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.SegmentedButton
|
||||
import androidx.compose.material3.SegmentedButtonDefaults
|
||||
import androidx.compose.material3.SingleChoiceSegmentedButtonRow
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.DisposableEffect
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.rememberUpdatedState
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.freeturn.app.R
|
||||
import com.freeturn.app.data.ClientConfig
|
||||
import com.freeturn.app.data.TunnelTransport
|
||||
import com.freeturn.app.ui.HapticUtil
|
||||
import com.freeturn.app.ui.components.SectionLabel
|
||||
import com.freeturn.app.ui.components.SettingsCard
|
||||
import com.freeturn.app.ui.components.SettingsContentMaxWidth
|
||||
import com.freeturn.app.ui.components.SettingsEntryRow
|
||||
import com.freeturn.app.ui.components.SettingsRowDivider
|
||||
import com.freeturn.app.ui.theme.extendedColorScheme
|
||||
import com.freeturn.app.viewmodel.ProxyState
|
||||
import com.freeturn.app.viewmodel.ProxyViewModel
|
||||
import com.freeturn.app.viewmodel.SettingsViewModel
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
/**
|
||||
* Экран «Режим подключения»: явный переключатель Proxy / VPN (WireGuard). В VPN-режиме
|
||||
* — импорт .conf из файла, имя туннеля и split-tunnel модалкой (для активного сервера).
|
||||
* Режим хранится в [ClientConfig.tunnelTransport] (NONE = proxy, WIREGUARD = vpn).
|
||||
*/
|
||||
@Composable
|
||||
fun ConnectionModeScreen(
|
||||
settingsViewModel: SettingsViewModel,
|
||||
proxyViewModel: ProxyViewModel,
|
||||
profileId: String? = null,
|
||||
onBack: (() -> Unit)? = null
|
||||
) {
|
||||
val snapshot by settingsViewModel.profilesSnapshot.collectAsStateWithLifecycle()
|
||||
val legacyClient by settingsViewModel.clientConfig.collectAsStateWithLifecycle()
|
||||
val privacyMode by settingsViewModel.privacyMode.collectAsStateWithLifecycle()
|
||||
val proxyState by proxyViewModel.proxyState.collectAsStateWithLifecycle()
|
||||
|
||||
val profile = profileId?.let { id -> snapshot.list.firstOrNull { it.id == id } }
|
||||
val saved = profile?.client ?: legacyClient
|
||||
val isActive = profileId == null || profileId == snapshot.activeId
|
||||
|
||||
fun clientEdit(transform: (ClientConfig) -> ClientConfig) {
|
||||
if (profileId != null) {
|
||||
settingsViewModel.updateProfileClient(profileId, transform)
|
||||
} else {
|
||||
settingsViewModel.saveClientConfig(transform(settingsViewModel.clientConfig.value), snapshot.activeId)
|
||||
}
|
||||
}
|
||||
|
||||
val context = LocalContext.current
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
// userPickedVpn держит VPN-выбор на сессию экрана: пока конфиг пуст, транспорт при
|
||||
// чтении нормализуется в NONE (WIREGUARD без конфига = выключен, см. AppPreferences),
|
||||
// и без локального флага сегмент мигал бы обратно на Proxy. Сброс по saved.tunnelTransport.
|
||||
var userPickedVpn by remember(profileId, saved.tunnelTransport) { mutableStateOf<Boolean?>(null) }
|
||||
val isVpn = userPickedVpn ?: (saved.tunnelTransport == TunnelTransport.WIREGUARD)
|
||||
|
||||
var wgConfig by remember(saved.wireGuardConfig) { mutableStateOf(saved.wireGuardConfig) }
|
||||
var wgName by remember(saved.wireGuardTunnelName) { mutableStateOf(saved.wireGuardTunnelName) }
|
||||
|
||||
// Единая запись WG-настроек: транспорт всегда выставляется по [isVpn] вместе с конфигом.
|
||||
// Иначе segment-выбор VPN при пустом конфиге нормализуется в NONE, а последующая
|
||||
// загрузка .conf транспорт не переписывает — VPN тихо остаётся выключенным.
|
||||
fun persistWg(vpn: Boolean = isVpn) {
|
||||
clientEdit {
|
||||
it.copy(
|
||||
tunnelTransport = if (vpn) TunnelTransport.WIREGUARD else TunnelTransport.NONE,
|
||||
wireGuardConfig = wgConfig.trim(),
|
||||
wireGuardTunnelName = wgName.trim().ifBlank { TunnelTransport.DEFAULT_TUNNEL_NAME }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
var showSplitSheet by rememberSaveable { mutableStateOf(false) }
|
||||
// Лист только для активного сервера — при потере активности скрываем.
|
||||
LaunchedEffect(isActive) { if (!isActive) showSplitSheet = false }
|
||||
|
||||
// Дебаунс WG-полей 600 мс. Первый прогон (значения = saved) пропускаем, чтобы не писать
|
||||
// на входе. pendingSave → flush при выходе: dispose отменяет корутину и теряет правку.
|
||||
var wgDirty by remember(profileId) { mutableStateOf(false) }
|
||||
var pendingSave by remember(profileId) { mutableStateOf(false) }
|
||||
LaunchedEffect(wgConfig, wgName) {
|
||||
if (!wgDirty) { wgDirty = true; return@LaunchedEffect }
|
||||
pendingSave = true
|
||||
delay(600)
|
||||
persistWg()
|
||||
pendingSave = false
|
||||
}
|
||||
val flush by rememberUpdatedState { persistWg() }
|
||||
DisposableEffect(Unit) {
|
||||
onDispose { if (pendingSave) flush() }
|
||||
}
|
||||
|
||||
val filePicker = rememberLauncherForActivityResult(ActivityResultContracts.GetContent()) { uri ->
|
||||
if (uri != null) {
|
||||
scope.launch {
|
||||
val text = withContext(Dispatchers.IO) {
|
||||
runCatching {
|
||||
context.contentResolver.openInputStream(uri)?.bufferedReader()?.use { it.readText() }
|
||||
}.getOrNull()
|
||||
}
|
||||
if (!text.isNullOrBlank()) {
|
||||
wgConfig = text
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text(stringResource(R.string.connection_mode_title)) },
|
||||
navigationIcon = {
|
||||
if (onBack != null) {
|
||||
IconButton(onClick = onBack) {
|
||||
Icon(
|
||||
painterResource(R.drawable.arrow_back_24px),
|
||||
contentDescription = stringResource(R.string.back)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
},
|
||||
// Всегда внутри NavigationSuite — нижний бар держит навбар-инсет сам.
|
||||
contentWindowInsets = WindowInsets(0, 0, 0, 0)
|
||||
) { padding ->
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(padding)
|
||||
.imePadding()
|
||||
.verticalScroll(rememberScrollState()),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.widthIn(max = SettingsContentMaxWidth)
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 24.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
Spacer(Modifier.height(4.dp))
|
||||
|
||||
SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {
|
||||
SegmentedButton(
|
||||
selected = !isVpn,
|
||||
onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
||||
userPickedVpn = false
|
||||
persistWg(vpn = false)
|
||||
},
|
||||
shape = SegmentedButtonDefaults.itemShape(index = 0, count = 2)
|
||||
) { Text(stringResource(R.string.mode_proxy)) }
|
||||
SegmentedButton(
|
||||
selected = isVpn,
|
||||
onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
||||
userPickedVpn = true
|
||||
persistWg(vpn = true)
|
||||
},
|
||||
shape = SegmentedButtonDefaults.itemShape(index = 1, count = 2)
|
||||
) { Text(stringResource(R.string.mode_vpn)) }
|
||||
}
|
||||
|
||||
Text(
|
||||
stringResource(if (isVpn) R.string.mode_vpn_desc else R.string.mode_proxy_desc),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
|
||||
if (isVpn) {
|
||||
val configLoaded = wgConfig.isNotBlank()
|
||||
|
||||
// --- Конфигурация туннеля ---
|
||||
SectionLabel(stringResource(R.string.connection_config_section))
|
||||
SettingsCard {
|
||||
// Конфиг задаётся только файлом — вставка текстом давала тот же
|
||||
// результат, а endpoint всё равно подменяется в рантайме.
|
||||
SettingsEntryRow(
|
||||
iconRes = R.drawable.cloud_download_24px,
|
||||
title = stringResource(R.string.load_wg_conf),
|
||||
trailingRes = if (configLoaded) R.drawable.check_circle_24px else null,
|
||||
trailingTint = MaterialTheme.extendedColorScheme.success,
|
||||
enabled = !privacyMode,
|
||||
onClick = { filePicker.launch("*/*") }
|
||||
)
|
||||
SettingsRowDivider()
|
||||
Box(modifier = Modifier.padding(16.dp)) {
|
||||
OutlinedTextField(
|
||||
value = wgName.redact(privacyMode),
|
||||
onValueChange = { if (!privacyMode) wgName = it },
|
||||
label = { Text(stringResource(R.string.wireguard_tunnel_name)) },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true,
|
||||
readOnly = privacyMode
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// --- Раздельное туннелирование (модалка как на главном) ---
|
||||
SectionLabel(stringResource(R.string.split_tunnel_title))
|
||||
SettingsCard {
|
||||
SettingsEntryRow(
|
||||
iconRes = R.drawable.mobile_24px,
|
||||
title = stringResource(R.string.split_tunnel_title),
|
||||
trailingRes = R.drawable.unfold_more_24px,
|
||||
enabled = isActive,
|
||||
onClick = { showSplitSheet = true }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(24.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Тот же лист split-tunnel, что на главном экране. Только для активного сервера —
|
||||
// живой прокси/состояние принадлежат ему.
|
||||
if (showSplitSheet && isActive) {
|
||||
SplitTunnelModal(
|
||||
settingsViewModel = settingsViewModel,
|
||||
mode = saved.splitTunnelMode,
|
||||
apps = saved.splitTunnelApps,
|
||||
locked = proxyState !is ProxyState.Idle && proxyState !is ProxyState.Error,
|
||||
onDismiss = { showSplitSheet = false },
|
||||
// Тот же фон листа, что на главном экране (HomeScreen.sheetColor).
|
||||
containerColor = MaterialTheme.colorScheme.surfaceContainerLow
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,6 @@ import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
@@ -53,7 +52,7 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.rememberBottomSheetScaffoldState
|
||||
import androidx.compose.material3.rememberModalBottomSheetState
|
||||
import androidx.compose.material3.rememberBottomSheetState
|
||||
import androidx.compose.material3.rememberStandardBottomSheetState
|
||||
import android.Manifest
|
||||
import android.annotation.SuppressLint
|
||||
@@ -155,8 +154,10 @@ fun HomeScreen(
|
||||
val profilesSnapshot by settingsViewModel.profilesSnapshot.collectAsStateWithLifecycle()
|
||||
val showBottomSheet = rememberSaveable { mutableStateOf(false) }
|
||||
val showSplitSheet = rememberSaveable { mutableStateOf(false) }
|
||||
val bottomSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
||||
val splitSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
||||
val bottomSheetState = rememberBottomSheetState(
|
||||
initialValue = SheetValue.Hidden,
|
||||
enabledValues = setOf(SheetValue.Hidden, SheetValue.Expanded)
|
||||
)
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
val scope = rememberCoroutineScope()
|
||||
// Standard bottom sheet: свёрнутый peek = карточка активного профиля,
|
||||
@@ -332,21 +333,14 @@ fun HomeScreen(
|
||||
}
|
||||
|
||||
if (showSplitSheet.value) {
|
||||
ModalBottomSheet(
|
||||
onDismissRequest = { showSplitSheet.value = false },
|
||||
sheetState = splitSheetState,
|
||||
containerColor = sheetColor,
|
||||
// Не поднимаем контент над клавиатурой — иначе высокий лист «вырастает»
|
||||
// на весь экран при фокусе поиска. Свои инсеты лист держит сам.
|
||||
contentWindowInsets = { WindowInsets(0, 0, 0, 0) }
|
||||
) {
|
||||
SplitTunnelSheetContent(
|
||||
settingsViewModel = settingsViewModel,
|
||||
mode = clientConfig.splitTunnelMode,
|
||||
apps = clientConfig.splitTunnelApps,
|
||||
locked = proxyState !is ProxyState.Idle && proxyState !is ProxyState.Error
|
||||
)
|
||||
}
|
||||
SplitTunnelModal(
|
||||
settingsViewModel = settingsViewModel,
|
||||
mode = clientConfig.splitTunnelMode,
|
||||
apps = clientConfig.splitTunnelApps,
|
||||
locked = proxyState !is ProxyState.Idle && proxyState !is ProxyState.Error,
|
||||
onDismiss = { showSplitSheet.value = false },
|
||||
containerColor = sheetColor
|
||||
)
|
||||
}
|
||||
|
||||
UpdateDialogs(settingsViewModel)
|
||||
@@ -832,7 +826,7 @@ private fun rememberProxyUptime(connectedSince: Long?): String? {
|
||||
val tick = androidx.compose.runtime.produceState(initialValue = 0L, connectedSince) {
|
||||
while (true) {
|
||||
value = android.os.SystemClock.elapsedRealtime()
|
||||
kotlinx.coroutines.delay(1_000)
|
||||
delay(1_000)
|
||||
}
|
||||
}
|
||||
val now = tick.value.coerceAtLeast(connectedSince)
|
||||
|
||||
@@ -8,7 +8,6 @@ import androidx.compose.animation.expandVertically
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.shrinkVertically
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
@@ -19,6 +18,7 @@ import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.navigationBars
|
||||
import androidx.compose.foundation.layout.imePadding
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
@@ -28,7 +28,6 @@ import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
@@ -37,8 +36,13 @@ import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.CircularWavyProgressIndicator
|
||||
import androidx.compose.material3.DividerDefaults
|
||||
import androidx.compose.material3.DropdownMenu
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.FilledTonalButton
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.LinearWavyProgressIndicator
|
||||
@@ -46,9 +50,13 @@ import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedButton
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.SegmentedButton
|
||||
import androidx.compose.material3.SegmentedButtonDefaults
|
||||
import androidx.compose.material3.SingleChoiceSegmentedButtonRow
|
||||
import androidx.compose.material3.SnackbarHost
|
||||
import androidx.compose.material3.SnackbarHostState
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -60,9 +68,9 @@ import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.semantics.heading
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import kotlinx.coroutines.delay
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
@@ -71,8 +79,8 @@ import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.freeturn.app.data.ObfProfile
|
||||
import com.freeturn.app.ui.HapticUtil
|
||||
import com.freeturn.app.ui.theme.extendedColorScheme
|
||||
import com.freeturn.app.viewmodel.ServerState
|
||||
import com.freeturn.app.viewmodel.SshConnectionState
|
||||
import com.freeturn.app.viewmodel.ServerViewModel
|
||||
@@ -83,52 +91,53 @@ import com.freeturn.app.viewmodel.SettingsViewModel
|
||||
fun ServerManagementScreen(
|
||||
serverViewModel: ServerViewModel,
|
||||
settingsViewModel: SettingsViewModel,
|
||||
onContinue: () -> Unit,
|
||||
// null — поток онбординга (SERVER_MANAGEMENT_OB): сюда приходят уже сопряжёнными,
|
||||
// SSH-логика не активна, экран рендерится как раньше. Не-null — основная вкладка:
|
||||
// включает авто-сопряжение при открытии, кнопку смены сервера и состояния
|
||||
// «не сопряжено / подключаюсь / ошибка».
|
||||
onEditConnection: (() -> Unit)? = null
|
||||
// Шаг мастера онбординга «продолжить к настройке клиента». В settings-флоу не нужен.
|
||||
onContinue: (() -> Unit)? = null,
|
||||
// Кнопка смены сервера (overflow ⋮). null в онбординге.
|
||||
onEditConnection: (() -> Unit)? = null,
|
||||
// null = онбординг/legacy. Не-null = настройки сервера конкретного профиля (Settings).
|
||||
profileId: String? = null,
|
||||
onBack: (() -> Unit)? = null
|
||||
) {
|
||||
val mainFlow = onEditConnection != null
|
||||
// Settings-флоу vs мастер онбординга. В settings: apply-модель (черновики → «Применить»,
|
||||
// один рестарт), карточки сопряжения, смена сервера. В онбординге — proxy + действия.
|
||||
val settingsFlow = onBack != null
|
||||
val snapshot by settingsViewModel.profilesSnapshot.collectAsStateWithLifecycle()
|
||||
val profile = profileId?.let { id -> snapshot.list.firstOrNull { it.id == id } }
|
||||
// Живая SSH-сессия и состояние сервера принадлежат активному серверу. Управлять
|
||||
// ядром можно только когда редактируемый профиль активен (или онбординг).
|
||||
val isActive = profileId == null || profileId == snapshot.activeId
|
||||
val sshState by serverViewModel.sshState.collectAsStateWithLifecycle()
|
||||
val serverState by serverViewModel.serverState.collectAsStateWithLifecycle()
|
||||
val sshConfig by serverViewModel.sshConfig.collectAsStateWithLifecycle()
|
||||
val savedListen by settingsViewModel.proxyListen.collectAsStateWithLifecycle()
|
||||
val savedConnect by settingsViewModel.proxyConnect.collectAsStateWithLifecycle()
|
||||
val legacyListen by settingsViewModel.proxyListen.collectAsStateWithLifecycle()
|
||||
val legacyConnect by settingsViewModel.proxyConnect.collectAsStateWithLifecycle()
|
||||
val savedListen = profile?.proxyListen ?: legacyListen
|
||||
val savedConnect = profile?.proxyConnect ?: legacyConnect
|
||||
val sshLog by serverViewModel.sshLog.collectAsStateWithLifecycle()
|
||||
val privacyMode by settingsViewModel.privacyMode.collectAsStateWithLifecycle()
|
||||
val installStage by serverViewModel.serverInstallStage.collectAsStateWithLifecycle()
|
||||
val clientCfg by settingsViewModel.clientConfig.collectAsStateWithLifecycle()
|
||||
val serverLogs by serverViewModel.serverLogs.collectAsStateWithLifecycle()
|
||||
val serverOpts by serverViewModel.serverOpts.collectAsStateWithLifecycle()
|
||||
val isRegen by serverViewModel.isRegeneratingObfKey.collectAsStateWithLifecycle()
|
||||
|
||||
// --- Черновики конфигурации (без авто-сохранения) ---
|
||||
var proxyListenIp by rememberSaveable(savedListen) {
|
||||
mutableStateOf(savedListen.substringBeforeLast(":", "0.0.0.0").ifBlank { "0.0.0.0" })
|
||||
}
|
||||
var proxyListenPort by rememberSaveable(savedListen) { mutableStateOf(savedListen.substringAfterLast(":", "56000")) }
|
||||
var proxyConnect by rememberSaveable(savedConnect) { mutableStateOf(savedConnect) }
|
||||
var tcpDraft by rememberSaveable(clientCfg.tcpForward) { mutableStateOf(clientCfg.tcpForward) }
|
||||
var obfDraft by rememberSaveable(serverOpts.obfProfile) { mutableStateOf(serverOpts.obfProfile) }
|
||||
var keyDraft by rememberSaveable(serverOpts.obfKey) { mutableStateOf(serverOpts.obfKey) }
|
||||
|
||||
LaunchedEffect(proxyListenIp, proxyListenPort, proxyConnect) {
|
||||
kotlinx.coroutines.delay(400)
|
||||
val ip = proxyListenIp.ifBlank { "0.0.0.0" }
|
||||
val listen = "$ip:$proxyListenPort"
|
||||
if (listen != savedListen || proxyConnect != savedConnect) {
|
||||
settingsViewModel.saveProxyServerConfig(listen, proxyConnect)
|
||||
}
|
||||
}
|
||||
|
||||
// Авто-сопряжение при открытии основной вкладки: есть сохранённый конфиг, но
|
||||
// соединение не установлено → пробуем переподключиться. Триггер только из
|
||||
// Disconnected (после неудачи состояние Error — без бесконечного цикла). Ключ по
|
||||
// ip корректно отрабатывает асинхронную загрузку конфига из DataStore.
|
||||
LaunchedEffect(sshConfig.ip, mainFlow) {
|
||||
if (mainFlow && sshConfig.ip.isNotBlank() && sshState is SshConnectionState.Disconnected) {
|
||||
serverViewModel.reconnectSsh()
|
||||
}
|
||||
}
|
||||
// SSH-сессию держит хаб (ServerDetailScreen): этот экран в settings-флоу открыт только
|
||||
// при активном подключении, в онбординг сюда приходят уже Connected. Свой реконнект
|
||||
// не нужен — не дублируем коннект на двух экранах.
|
||||
|
||||
val context = LocalContext.current
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
var showServerMenu by rememberSaveable { mutableStateOf(false) }
|
||||
val isConnected = sshState is SshConnectionState.Connected
|
||||
// Дебаунс карточки сопряжения: при открытии config грузится из DataStore async,
|
||||
// а sshState стартует Disconnected — без задержки карточка мигает на доли секунды
|
||||
@@ -147,31 +156,74 @@ fun ServerManagementScreen(
|
||||
val serverKnown = serverState as? ServerState.Known
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior()
|
||||
|
||||
// --- Dirty-детект для apply-модели ---
|
||||
val obfKeyRegex = remember { Regex("^[0-9a-fA-F]{64}$") }
|
||||
val listenFull = "${proxyListenIp.ifBlank { "0.0.0.0" }}:$proxyListenPort"
|
||||
val proxyDirty = listenFull != savedListen || proxyConnect != savedConnect
|
||||
val configDirty = settingsFlow && (proxyDirty ||
|
||||
tcpDraft != clientCfg.tcpForward ||
|
||||
obfDraft != serverOpts.obfProfile ||
|
||||
keyDraft != serverOpts.obfKey)
|
||||
// Ключ валиден для применения: обфускация выкл, ИЛИ пусто (сервер сгенерит), ИЛИ 64 hex.
|
||||
val keyOkForApply = obfDraft == ObfProfile.NONE || keyDraft.isBlank() || keyDraft.matches(obfKeyRegex)
|
||||
|
||||
|
||||
Scaffold(
|
||||
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = { Text(stringResource(R.string.server)) },
|
||||
title = {
|
||||
Text(stringResource(
|
||||
if (onBack != null) R.string.provider_server_settings else R.string.server
|
||||
))
|
||||
},
|
||||
navigationIcon = {
|
||||
if (onBack != null) {
|
||||
IconButton(onClick = onBack) {
|
||||
Icon(
|
||||
painterResource(R.drawable.arrow_back_24px),
|
||||
contentDescription = stringResource(R.string.back)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
scrollBehavior = scrollBehavior,
|
||||
actions = {
|
||||
SshStatusBadge(sshState = sshState, ip = sshConfig.ip.redact(privacyMode))
|
||||
// Вход в форму сопряжения / смены сервера (перенесён с главного экрана).
|
||||
if (onEditConnection != null) {
|
||||
IconButton(onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
onEditConnection()
|
||||
}) {
|
||||
Icon(
|
||||
painterResource(R.drawable.host_24px),
|
||||
contentDescription = stringResource(R.string.connection)
|
||||
)
|
||||
// App bar разгружен: SSH-статус живёт в карточке статуса ниже, смена
|
||||
// сервера спрятана в overflow ⋮ — заголовок остаётся в одну строку.
|
||||
if (isActive && onEditConnection != null) {
|
||||
Box {
|
||||
IconButton(onClick = { showServerMenu = true }) {
|
||||
Icon(
|
||||
painterResource(R.drawable.more_vert_24px),
|
||||
contentDescription = stringResource(R.string.change_server)
|
||||
)
|
||||
}
|
||||
DropdownMenu(
|
||||
expanded = showServerMenu,
|
||||
onDismissRequest = { showServerMenu = false }
|
||||
) {
|
||||
DropdownMenuItem(
|
||||
text = { Text(stringResource(R.string.change_server)) },
|
||||
onClick = {
|
||||
showServerMenu = false
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
onEditConnection()
|
||||
},
|
||||
leadingIcon = {
|
||||
Icon(painterResource(R.drawable.host_24px), contentDescription = null)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
},
|
||||
snackbarHost = { SnackbarHost(snackbarHostState) },
|
||||
contentWindowInsets = WindowInsets(0, 0, 0, 0)
|
||||
// Settings-флоу (onBack != null) — внутри NavigationSuite, бар держит навбар-инсет.
|
||||
// Онбординг (onBack == null) — полноэкранный, инсет держим сами.
|
||||
contentWindowInsets = if (onBack != null) WindowInsets(0, 0, 0, 0) else WindowInsets.navigationBars
|
||||
) { padding ->
|
||||
Column(
|
||||
modifier = Modifier
|
||||
@@ -190,10 +242,23 @@ fun ServerManagementScreen(
|
||||
) {
|
||||
Spacer(Modifier.height(4.dp))
|
||||
|
||||
// Основная вкладка без активного сопряжения → приглашение/прогресс/ошибка
|
||||
// вместо бесполезных задизейбленных контролов. В онбординге (mainFlow=false)
|
||||
// сюда приходят уже Connected, поэтому ветка management как раньше.
|
||||
if (mainFlow && !isConnected) {
|
||||
// Неактивный профиль: живая SSH-сессия и управление ядром недоступны.
|
||||
// Предлагаем сделать активным — после этого SSH/управление оживают.
|
||||
if (!isActive) {
|
||||
InactiveServerCard(
|
||||
onMakeActive = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
profileId?.let { settingsViewModel.applyProfile(it) }
|
||||
}
|
||||
)
|
||||
Spacer(Modifier.height(24.dp))
|
||||
return@Column
|
||||
}
|
||||
|
||||
// Settings-флоу без активного сопряжения → приглашение/прогресс/ошибка
|
||||
// вместо бесполезных задизейбленных контролов. В онбординге сюда приходят
|
||||
// уже Connected, поэтому ветка management как раньше.
|
||||
if (settingsFlow && !isConnected) {
|
||||
// showPairing дебаунсит первичный показ — пустой экран до 400мс
|
||||
// вместо мигающей карточки при загрузке config / авто-сопряжении.
|
||||
if (showPairing) {
|
||||
@@ -228,72 +293,15 @@ fun ServerManagementScreen(
|
||||
}
|
||||
}
|
||||
|
||||
// Status card
|
||||
Card(modifier = Modifier.fillMaxWidth()) {
|
||||
Column(modifier = Modifier.padding(20.dp)) {
|
||||
Text(stringResource(R.string.server_status), style = MaterialTheme.typography.titleMedium)
|
||||
Spacer(Modifier.height(16.dp))
|
||||
StatusRow(
|
||||
label = stringResource(R.string.ssh_connection),
|
||||
isActive = isConnected,
|
||||
activeLabel = stringResource(R.string.paired),
|
||||
activeColor = MaterialTheme.extendedColorScheme.info
|
||||
)
|
||||
Spacer(Modifier.height(10.dp))
|
||||
StatusRow(stringResource(R.string.free_turn_proxy), serverKnown?.running == true)
|
||||
|
||||
if (serverKnown?.installed == true && !serverKnown.version.isNullOrBlank()) {
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Text(
|
||||
stringResource(R.string.server_version_label, serverKnown.version),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
|
||||
installStage?.let { stage ->
|
||||
Spacer(Modifier.height(8.dp))
|
||||
Text(
|
||||
when (stage) {
|
||||
"cached" -> stringResource(R.string.server_install_cached)
|
||||
"downloaded" -> stringResource(R.string.server_install_downloaded)
|
||||
else -> stage
|
||||
},
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.extendedColorScheme.info
|
||||
)
|
||||
}
|
||||
|
||||
when (serverState) {
|
||||
is ServerState.Checking -> {
|
||||
Spacer(Modifier.height(12.dp))
|
||||
LinearWavyProgressIndicator(modifier = Modifier.fillMaxWidth())
|
||||
}
|
||||
is ServerState.Working -> {
|
||||
Spacer(Modifier.height(12.dp))
|
||||
Text(
|
||||
(serverState as ServerState.Working).action,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.secondary
|
||||
)
|
||||
Spacer(Modifier.height(6.dp))
|
||||
LinearWavyProgressIndicator(modifier = Modifier.fillMaxWidth())
|
||||
}
|
||||
is ServerState.Error -> {
|
||||
Spacer(Modifier.height(12.dp))
|
||||
Text(
|
||||
stringResource(R.string.error_format, (serverState as ServerState.Error).message),
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.error
|
||||
)
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Статус сервера теперь в хабе (ServerDetailScreen.ServerStatusCard) —
|
||||
// тут не дублируем. На этом экране — конфиг (apply-модель) + действия.
|
||||
|
||||
// Server config
|
||||
Text(stringResource(R.string.server_config), style = MaterialTheme.typography.titleMedium)
|
||||
Text(
|
||||
stringResource(R.string.server_config),
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
modifier = Modifier.semantics { heading() }
|
||||
)
|
||||
|
||||
OutlinedTextField(
|
||||
value = proxyListenIp,
|
||||
@@ -326,17 +334,125 @@ fun ServerManagementScreen(
|
||||
supportingText = { Text(stringResource(R.string.turn_client_desc)) }
|
||||
)
|
||||
|
||||
// Индикатор TCP-форвард режима сервера
|
||||
if (serverKnown?.running == true && serverKnown.tcpMode == true) {
|
||||
// --- Синхронные настройки сервера (apply-модель, только settings-флоу) ---
|
||||
if (settingsFlow) {
|
||||
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
||||
|
||||
Text(
|
||||
text = stringResource(R.string.server_running_tcp),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.extendedColorScheme.info
|
||||
stringResource(R.string.server_sync_section),
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
modifier = Modifier.semantics { heading() }
|
||||
)
|
||||
|
||||
// Проброс: UDP / TCP.
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Text(stringResource(R.string.tcp_forward_mode), style = MaterialTheme.typography.bodyMedium)
|
||||
SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {
|
||||
SegmentedButton(
|
||||
selected = !tcpDraft,
|
||||
onClick = { HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON); tcpDraft = false },
|
||||
shape = SegmentedButtonDefaults.itemShape(index = 0, count = 2)
|
||||
) { Text(stringResource(R.string.udp)) }
|
||||
SegmentedButton(
|
||||
selected = tcpDraft,
|
||||
onClick = { HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON); tcpDraft = true },
|
||||
shape = SegmentedButtonDefaults.itemShape(index = 1, count = 2)
|
||||
) { Text(stringResource(R.string.tcp)) }
|
||||
}
|
||||
}
|
||||
|
||||
// Профиль обфускации.
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Text(stringResource(R.string.obf_profile_title), style = MaterialTheme.typography.bodyMedium)
|
||||
SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {
|
||||
ObfProfile.ALL.forEachIndexed { idx, value ->
|
||||
SegmentedButton(
|
||||
selected = obfDraft == value,
|
||||
onClick = { HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON); obfDraft = value },
|
||||
shape = SegmentedButtonDefaults.itemShape(index = idx, count = ObfProfile.ALL.size)
|
||||
) { Text(obfProfileLabel(value)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// obf-ключ (черновик) + регенерация на сервере (живая SSH-операция).
|
||||
if (obfDraft != ObfProfile.NONE) {
|
||||
OutlinedTextField(
|
||||
value = if (privacyMode) serverOpts.obfKey.redact(true) else keyDraft,
|
||||
onValueChange = { if (!privacyMode) keyDraft = it },
|
||||
label = { Text(stringResource(R.string.server_obf_key_label)) },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
readOnly = privacyMode,
|
||||
singleLine = true,
|
||||
isError = keyDraft.isNotBlank() && !keyDraft.matches(obfKeyRegex),
|
||||
trailingIcon = {
|
||||
if (serverOpts.obfKey.isNotBlank() && !privacyMode) {
|
||||
IconButton(onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
val cm = context.getSystemService(android.content.ClipboardManager::class.java)
|
||||
cm?.setPrimaryClip(android.content.ClipData.newPlainText("obf-key", serverOpts.obfKey))
|
||||
}) {
|
||||
Icon(
|
||||
painterResource(R.drawable.content_copy_24px),
|
||||
contentDescription = stringResource(R.string.copy)
|
||||
)
|
||||
}
|
||||
}
|
||||
},
|
||||
supportingText = {
|
||||
when {
|
||||
keyDraft.isBlank() -> Text(stringResource(R.string.obf_key_empty_hint))
|
||||
!keyDraft.matches(obfKeyRegex) -> Text(
|
||||
stringResource(R.string.obf_key_invalid_hint),
|
||||
color = MaterialTheme.colorScheme.error
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
if (isConnected && !privacyMode) {
|
||||
TextButton(
|
||||
onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
serverViewModel.regenerateObfKey()
|
||||
},
|
||||
enabled = !isRegen,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
if (isRegen) {
|
||||
CircularWavyProgressIndicator(modifier = Modifier.size(20.dp))
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text(stringResource(R.string.obf_key_regen_in_progress))
|
||||
} else {
|
||||
Text(stringResource(R.string.obf_key_regen))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Применить — фиксирует весь черновик одним рестартом, затем назад в хаб.
|
||||
Button(
|
||||
onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
settingsViewModel.applyServerConfig(listenFull, proxyConnect, tcpDraft, obfDraft, keyDraft)
|
||||
onBack?.invoke()
|
||||
},
|
||||
enabled = configDirty && keyOkForApply && !isWorking,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
shape = MaterialTheme.shapes.large
|
||||
) {
|
||||
Icon(painterResource(R.drawable.check_circle_24px), null)
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text(stringResource(R.string.server_apply))
|
||||
}
|
||||
Text(
|
||||
stringResource(R.string.server_apply_restart_note),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
|
||||
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
||||
}
|
||||
|
||||
// Режим туннеля / обфускация управляются на клиентском экране — общий source.
|
||||
// Здесь не дублируем, чтобы не путать пользователя двумя точками контроля.
|
||||
|
||||
// Action buttons
|
||||
FilledTonalButton(
|
||||
@@ -387,12 +503,15 @@ fun ServerManagementScreen(
|
||||
Text(stringResource(R.string.stop_server))
|
||||
}
|
||||
|
||||
if (serverKnown?.running == true) {
|
||||
// «Продолжить к настройке клиента» — шаг мастера онбординга (onBack == null).
|
||||
// В settings-флоу (onBack != null) этой кнопки нет — там провайдер уже
|
||||
// даёт отдельный вход в «Настройки подключения».
|
||||
if (serverKnown?.running == true && onBack == null) {
|
||||
Spacer(Modifier.height(4.dp))
|
||||
Button(
|
||||
onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
onContinue()
|
||||
onContinue?.invoke()
|
||||
},
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
shape = MaterialTheme.shapes.large
|
||||
@@ -417,7 +536,7 @@ fun ServerManagementScreen(
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
modifier = Modifier.weight(1f)
|
||||
)
|
||||
androidx.compose.material3.IconButton(
|
||||
IconButton(
|
||||
onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
serverViewModel.fetchServerLogs()
|
||||
@@ -430,7 +549,7 @@ fun ServerManagementScreen(
|
||||
)
|
||||
}
|
||||
if (serverLogs != null) {
|
||||
androidx.compose.material3.IconButton(
|
||||
IconButton(
|
||||
onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
serverViewModel.clearServerLogs()
|
||||
@@ -525,6 +644,40 @@ fun ServerManagementScreen(
|
||||
}
|
||||
}
|
||||
|
||||
/** Карточка для неактивного профиля: управление ядром требует активного сервера. */
|
||||
@Composable
|
||||
private fun InactiveServerCard(onMakeActive: () -> Unit) {
|
||||
Card(modifier = Modifier.fillMaxWidth()) {
|
||||
Column(
|
||||
modifier = Modifier.padding(24.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
Icon(
|
||||
painterResource(R.drawable.host_24px),
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
Text(
|
||||
stringResource(R.string.server_inactive_title),
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
Text(
|
||||
stringResource(R.string.server_inactive_desc),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
Button(
|
||||
onClick = onMakeActive,
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
shape = MaterialTheme.shapes.large
|
||||
) { Text(stringResource(R.string.make_active)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Состояние сопряжения для основной вкладки сервера, когда соединение ещё не
|
||||
* установлено: приглашение подключиться (нет конфига), прогресс (идёт авто-/ручное
|
||||
@@ -629,56 +782,9 @@ private fun SshPairingPrompt(
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun SshStatusBadge(sshState: SshConnectionState, ip: String) {
|
||||
val connected = sshState is SshConnectionState.Connected
|
||||
val dotColor = if (connected) MaterialTheme.extendedColorScheme.info
|
||||
else MaterialTheme.colorScheme.error
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.padding(end = 16.dp)
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(8.dp)
|
||||
.background(dotColor, CircleShape)
|
||||
)
|
||||
Spacer(Modifier.width(6.dp))
|
||||
Text(
|
||||
if (connected) ip else stringResource(R.string.not_connected),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
private fun obfProfileLabel(value: String): String = when (value) {
|
||||
ObfProfile.NONE -> stringResource(R.string.obf_none)
|
||||
ObfProfile.RTPOPUS -> stringResource(R.string.obf_rtpopus)
|
||||
else -> value
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun StatusRow(
|
||||
label: String,
|
||||
isActive: Boolean,
|
||||
activeLabel: String = stringResource(R.string.active),
|
||||
activeColor: Color = MaterialTheme.extendedColorScheme.success
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
Text(label, style = MaterialTheme.typography.bodyMedium)
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(8.dp)
|
||||
.background(
|
||||
if (isActive) activeColor else MaterialTheme.colorScheme.outline,
|
||||
CircleShape
|
||||
)
|
||||
)
|
||||
Spacer(Modifier.width(6.dp))
|
||||
Text(
|
||||
if (isActive) activeLabel else stringResource(R.string.inactive),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = if (isActive) activeColor else MaterialTheme.colorScheme.outline
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,847 @@
|
||||
@file:OptIn(
|
||||
androidx.compose.material3.ExperimentalMaterial3Api::class,
|
||||
androidx.compose.material3.ExperimentalMaterial3ExpressiveApi::class
|
||||
)
|
||||
|
||||
package com.freeturn.app.ui.screens
|
||||
|
||||
import androidx.compose.animation.AnimatedContent
|
||||
import androidx.compose.animation.SizeTransform
|
||||
import androidx.compose.animation.animateColorAsState
|
||||
import androidx.compose.animation.core.RepeatMode
|
||||
import androidx.compose.animation.core.Spring
|
||||
import androidx.compose.animation.core.animateFloat
|
||||
import androidx.compose.animation.core.infiniteRepeatable
|
||||
import androidx.compose.animation.core.rememberInfiniteTransition
|
||||
import androidx.compose.animation.core.snap
|
||||
import androidx.compose.animation.core.spring
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.togetherWith
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.FlowRow
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.widthIn
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.shape.CircleShape
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.AlertDialog
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.DropdownMenu
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.LargeFlexibleTopAppBar
|
||||
import androidx.compose.material3.LinearWavyProgressIndicator
|
||||
import androidx.compose.material3.MaterialShapes
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.Scaffold
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.material3.toShape
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.graphicsLayer
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.LiveRegionMode
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.semantics.liveRegion
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.util.lerp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.freeturn.app.R
|
||||
import com.freeturn.app.data.Profile
|
||||
import com.freeturn.app.ui.HapticUtil
|
||||
import com.freeturn.app.ui.components.SectionLabel
|
||||
import com.freeturn.app.ui.components.SettingsCard
|
||||
import com.freeturn.app.ui.components.SettingsContentMaxWidth
|
||||
import com.freeturn.app.ui.components.SettingsEntryRow
|
||||
import com.freeturn.app.ui.components.SettingsRowDivider
|
||||
import com.freeturn.app.ui.components.SettingsRowIcon
|
||||
import com.freeturn.app.ui.theme.LocalReducedMotion
|
||||
import com.freeturn.app.ui.theme.extendedColorScheme
|
||||
import com.freeturn.app.ui.util.hapticClickable
|
||||
import com.freeturn.app.viewmodel.ServerHubStatus
|
||||
import com.freeturn.app.viewmodel.ServerViewModel
|
||||
import com.freeturn.app.viewmodel.SettingsViewModel
|
||||
import com.freeturn.app.viewmodel.SshConnectionState
|
||||
|
||||
|
||||
/** Корневой экран настроек (нижнее меню). Пока единственный пункт — «Серверы». */
|
||||
@Composable
|
||||
fun SettingsScreen(
|
||||
onOpenServers: () -> Unit
|
||||
) {
|
||||
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior()
|
||||
Scaffold(
|
||||
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
|
||||
topBar = {
|
||||
LargeFlexibleTopAppBar(
|
||||
title = { Text(stringResource(R.string.settings_title)) },
|
||||
scrollBehavior = scrollBehavior
|
||||
)
|
||||
},
|
||||
// Корневой экран — внутри NavigationSuite, нижний бар сам держит инсет.
|
||||
contentWindowInsets = WindowInsets(0, 0, 0, 0)
|
||||
) { padding ->
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(padding)
|
||||
.verticalScroll(rememberScrollState()),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.widthIn(max = SettingsContentMaxWidth)
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp)
|
||||
) {
|
||||
SettingsCard {
|
||||
SettingsEntryRow(
|
||||
iconRes = R.drawable.database_24px,
|
||||
title = stringResource(R.string.settings_servers),
|
||||
subtitle = stringResource(R.string.settings_servers_desc),
|
||||
onClick = onOpenServers
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Список добавленных серверов (профилей). Клик по серверу → его детальный экран. */
|
||||
@Composable
|
||||
fun ServersListScreen(
|
||||
settingsViewModel: SettingsViewModel,
|
||||
onBack: () -> Unit,
|
||||
onOpenServer: (String) -> Unit
|
||||
) {
|
||||
val snapshot by settingsViewModel.profilesSnapshot.collectAsStateWithLifecycle()
|
||||
val privacyMode by settingsViewModel.privacyMode.collectAsStateWithLifecycle()
|
||||
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior()
|
||||
|
||||
Scaffold(
|
||||
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
|
||||
topBar = {
|
||||
LargeFlexibleTopAppBar(
|
||||
title = { Text(stringResource(R.string.settings_servers)) },
|
||||
navigationIcon = { BackButton(onBack) },
|
||||
scrollBehavior = scrollBehavior
|
||||
)
|
||||
},
|
||||
// Экран всегда внутри NavigationSuite — нижний бар сам держит навбар-инсет.
|
||||
contentWindowInsets = WindowInsets(0, 0, 0, 0)
|
||||
) { padding ->
|
||||
if (snapshot.loaded && snapshot.list.isEmpty()) {
|
||||
EmptyServers(modifier = Modifier.fillMaxSize().padding(padding))
|
||||
return@Scaffold
|
||||
}
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(padding)
|
||||
.verticalScroll(rememberScrollState()),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.widthIn(max = SettingsContentMaxWidth)
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp)
|
||||
) {
|
||||
// Активный профиль закрепляем сверху — быстрый доступ к текущему серверу.
|
||||
val ordered = remember(snapshot.list, snapshot.activeId) {
|
||||
snapshot.list.sortedByDescending { it.id == snapshot.activeId }
|
||||
}
|
||||
SettingsCard {
|
||||
ordered.forEachIndexed { index, p ->
|
||||
if (index > 0) SettingsRowDivider()
|
||||
ServerListRow(
|
||||
profile = p,
|
||||
isActive = snapshot.activeId == p.id,
|
||||
privacyMode = privacyMode,
|
||||
onClick = { onOpenServer(p.id) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ServerListRow(
|
||||
profile: Profile,
|
||||
isActive: Boolean,
|
||||
privacyMode: Boolean,
|
||||
onClick: () -> Unit
|
||||
) {
|
||||
// Подзаголовок: адрес сервера + метка «SSH», если сопряжение настроено. Сам SSH-ip
|
||||
// не дублируем (он уже не несёт пользе в списке) — достаточно факта наличия.
|
||||
val sub = listOfNotNull(
|
||||
profile.client.serverAddress.takeIf { it.isNotBlank() }?.redact(privacyMode),
|
||||
stringResource(R.string.profile_has_ssh).takeIf { profile.ssh.ip.isNotBlank() }
|
||||
).joinToString(" · ").ifBlank { "—" }
|
||||
|
||||
// «Активный» = выбранный профиль (а не статус SSH-подключения). Озвучиваем для TalkBack.
|
||||
val activeBadge = stringResource(R.string.profile_active_badge)
|
||||
val rowDesc = if (isActive) "${profile.name}, $activeBadge" else profile.name
|
||||
|
||||
// Круглый аватар вместо Sunny-формы — нейтральнее, не выбивается в плотном списке.
|
||||
// Активный — primaryContainer, остальные — приглушённый surface-контейнер.
|
||||
val iconContainer = if (isActive) MaterialTheme.colorScheme.primaryContainer
|
||||
else MaterialTheme.colorScheme.surfaceContainerHighest
|
||||
val iconTint = if (isActive) MaterialTheme.colorScheme.onPrimaryContainer
|
||||
else MaterialTheme.colorScheme.onSurfaceVariant
|
||||
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.hapticClickable(HapticUtil.Pattern.CLICK, onClick = onClick)
|
||||
.semantics { contentDescription = rowDesc }
|
||||
.padding(horizontal = 16.dp, vertical = 14.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(44.dp)
|
||||
.background(iconContainer, CircleShape),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Icon(
|
||||
painterResource(R.drawable.database_24px),
|
||||
contentDescription = null,
|
||||
tint = iconTint,
|
||||
modifier = Modifier.size(22.dp)
|
||||
)
|
||||
}
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
Text(
|
||||
profile.name,
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
modifier = Modifier.weight(1f, fill = false)
|
||||
)
|
||||
// Тональный бейдж «Активный» вместо зелёного pill — читается как
|
||||
// «выбранный профиль», а не как живой статус подключения.
|
||||
if (isActive) ActiveBadge(activeBadge)
|
||||
}
|
||||
Text(
|
||||
sub,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis
|
||||
)
|
||||
}
|
||||
Icon(
|
||||
painterResource(R.drawable.chevron_right_24px),
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ActiveBadge(label: String) {
|
||||
Surface(
|
||||
shape = CircleShape,
|
||||
color = MaterialTheme.colorScheme.primaryContainer
|
||||
) {
|
||||
Text(
|
||||
label,
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
color = MaterialTheme.colorScheme.onPrimaryContainer,
|
||||
maxLines = 1,
|
||||
modifier = Modifier.padding(horizontal = 10.dp, vertical = 4.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Детальный экран сервера — плоский хаб: шапка-сводка, вход в настройки провайдера
|
||||
* (подключение / сервер), удаление через меню в TopAppBar.
|
||||
*/
|
||||
@Composable
|
||||
fun ServerDetailScreen(
|
||||
profileId: String,
|
||||
settingsViewModel: SettingsViewModel,
|
||||
serverViewModel: ServerViewModel,
|
||||
onBack: () -> Unit,
|
||||
onOpenConnection: (String) -> Unit,
|
||||
onOpenConnectionMode: (String) -> Unit,
|
||||
onOpenServerSettings: (String) -> Unit
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val snapshot by settingsViewModel.profilesSnapshot.collectAsStateWithLifecycle()
|
||||
val privacyMode by settingsViewModel.privacyMode.collectAsStateWithLifecycle()
|
||||
val sshState by serverViewModel.sshState.collectAsStateWithLifecycle()
|
||||
val sshConfig by serverViewModel.sshConfig.collectAsStateWithLifecycle()
|
||||
val coreStatus by serverViewModel.hubStatus.collectAsStateWithLifecycle()
|
||||
val profile = snapshot.list.firstOrNull { it.id == profileId }
|
||||
val isActive = snapshot.activeId == profileId
|
||||
|
||||
// Профиль удалён (например, из этого же экрана) — выходим назад.
|
||||
if (snapshot.loaded && profile == null) {
|
||||
LaunchedEffect(Unit) { onBack() }
|
||||
return
|
||||
}
|
||||
|
||||
// Единая статус-модель хаба: core-статус от VM (активный сервер) + profile-контекст.
|
||||
// Порядок гарантирует отсутствие мигания: пока снапшот не загружен — skeleton, а не Offline.
|
||||
val status: ServerHubStatus = when {
|
||||
!snapshot.loaded -> ServerHubStatus.Connecting
|
||||
!isActive -> ServerHubStatus.Offline(
|
||||
serverAddress = profile?.client?.serverAddress?.takeIf { it.isNotBlank() }?.redact(privacyMode),
|
||||
sshIp = profile?.ssh?.ip?.takeIf { it.isNotBlank() }?.redact(privacyMode)
|
||||
)
|
||||
profile?.ssh?.ip.isNullOrBlank() -> ServerHubStatus.NotPaired
|
||||
else -> coreStatus
|
||||
}
|
||||
// Вход в «Настройки сервера» доступен только при живом ядре (Online).
|
||||
val connected = status is ServerHubStatus.Online
|
||||
|
||||
// Best-effort авто-сопряжение активного сервера при входе (не дублируем на других экранах).
|
||||
LaunchedEffect(isActive, sshConfig.ip, sshState) {
|
||||
if (isActive && sshConfig.ip.isNotBlank() && sshState is SshConnectionState.Disconnected) {
|
||||
serverViewModel.reconnectSsh()
|
||||
}
|
||||
}
|
||||
|
||||
var showMenu by rememberSaveable { mutableStateOf(false) }
|
||||
var showDelete by rememberSaveable { mutableStateOf(false) }
|
||||
var showRename by rememberSaveable { mutableStateOf(false) }
|
||||
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior()
|
||||
|
||||
// Подзаголовок hero-шапки: адрес сервера либо SSH-ip (что есть).
|
||||
val headerSubtitle = profile?.let { p ->
|
||||
p.client.serverAddress.takeIf { it.isNotBlank() }?.redact(privacyMode)
|
||||
?: p.ssh.ip.takeIf { it.isNotBlank() }?.let { "SSH ${it.redact(privacyMode)}" }
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
modifier = Modifier.nestedScroll(scrollBehavior.nestedScrollConnection),
|
||||
topBar = {
|
||||
LargeFlexibleTopAppBar(
|
||||
title = {
|
||||
Text(profile?.name ?: "", maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
},
|
||||
subtitle = headerSubtitle?.let { sub ->
|
||||
{ Text(sub, maxLines = 1, overflow = TextOverflow.Ellipsis) }
|
||||
},
|
||||
navigationIcon = { BackButton(onBack) },
|
||||
scrollBehavior = scrollBehavior,
|
||||
actions = {
|
||||
Box {
|
||||
IconButton(onClick = { showMenu = true }) {
|
||||
Icon(
|
||||
painterResource(R.drawable.more_vert_24px),
|
||||
contentDescription = stringResource(R.string.menu_delete_server)
|
||||
)
|
||||
}
|
||||
DropdownMenu(expanded = showMenu, onDismissRequest = { showMenu = false }) {
|
||||
DropdownMenuItem(
|
||||
text = { Text(stringResource(R.string.menu_rename_server)) },
|
||||
onClick = { showMenu = false; showRename = true },
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
painterResource(R.drawable.edit_24px),
|
||||
contentDescription = null
|
||||
)
|
||||
}
|
||||
)
|
||||
DropdownMenuItem(
|
||||
text = {
|
||||
Text(
|
||||
stringResource(R.string.menu_delete_server),
|
||||
color = MaterialTheme.colorScheme.error
|
||||
)
|
||||
},
|
||||
onClick = { showMenu = false; showDelete = true },
|
||||
leadingIcon = {
|
||||
Icon(
|
||||
painterResource(R.drawable.delete_24px),
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.error
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
},
|
||||
// Экран всегда внутри NavigationSuite — нижний бар сам держит навбар-инсет.
|
||||
contentWindowInsets = WindowInsets(0, 0, 0, 0)
|
||||
) { padding ->
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(padding)
|
||||
.verticalScroll(rememberScrollState()),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.widthIn(max = SettingsContentMaxWidth)
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
if (profile != null) {
|
||||
ServerStatusCard(
|
||||
status = status,
|
||||
privacyMode = privacyMode,
|
||||
onActivate = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
settingsViewModel.applyProfile(profileId)
|
||||
},
|
||||
onRetry = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
serverViewModel.reconnectSsh()
|
||||
}
|
||||
)
|
||||
|
||||
// Мастер-свитч синхронизации — перенесён из «Настроек сервера» в хаб.
|
||||
SettingsCard {
|
||||
SyncToggleRow(
|
||||
checked = profile.client.syncServerSwitches,
|
||||
onCheckedChange = { v ->
|
||||
HapticUtil.perform(context, if (v) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||
if (isActive) settingsViewModel.setSyncServerSwitches(v)
|
||||
else settingsViewModel.updateProfileClient(profileId) { it.copy(syncServerSwitches = v) }
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
SectionLabel(stringResource(R.string.provider_vk_calls))
|
||||
SettingsCard {
|
||||
SettingsEntryRow(
|
||||
iconRes = R.drawable.mobile_24px,
|
||||
title = stringResource(R.string.provider_connection_settings),
|
||||
subtitle = stringResource(R.string.provider_connection_settings_desc),
|
||||
onClick = { onOpenConnection(profileId) }
|
||||
)
|
||||
SettingsRowDivider()
|
||||
SettingsEntryRow(
|
||||
iconRes = R.drawable.wifi_24px,
|
||||
title = stringResource(R.string.connection_mode_title),
|
||||
subtitle = stringResource(R.string.provider_connection_mode_desc),
|
||||
onClick = { onOpenConnectionMode(profileId) }
|
||||
)
|
||||
// «Настройки сервера» требуют живого SSH — показываем только при
|
||||
// успешном подключении (best-effort коннект идёт при входе в хаб).
|
||||
if (isActive && connected) {
|
||||
SettingsRowDivider()
|
||||
SettingsEntryRow(
|
||||
iconRes = R.drawable.database_24px,
|
||||
title = stringResource(R.string.provider_server_settings),
|
||||
subtitle = stringResource(R.string.provider_server_settings_desc),
|
||||
onClick = { onOpenServerSettings(profileId) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (showDelete && profile != null) {
|
||||
AlertDialog(
|
||||
onDismissRequest = { showDelete = false },
|
||||
title = { Text(stringResource(R.string.server_delete_confirm_title)) },
|
||||
text = { Text(stringResource(R.string.server_delete_confirm_desc, profile.name)) },
|
||||
confirmButton = {
|
||||
TextButton(
|
||||
onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.ERROR)
|
||||
settingsViewModel.deleteProfile(profileId)
|
||||
showDelete = false
|
||||
// Навигацию назад делает null-guard выше (profile станет null
|
||||
// после async-удаления) — не зовём pop тут, иначе двойной pop.
|
||||
},
|
||||
colors = ButtonDefaults.textButtonColors(
|
||||
contentColor = MaterialTheme.colorScheme.error
|
||||
)
|
||||
) { Text(stringResource(R.string.profile_delete)) }
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = { showDelete = false }) { Text(stringResource(R.string.cancel)) }
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
if (showRename && profile != null) {
|
||||
var newName by remember(profile.id) { mutableStateOf(profile.name) }
|
||||
AlertDialog(
|
||||
onDismissRequest = { showRename = false },
|
||||
title = { Text(stringResource(R.string.rename_server_title)) },
|
||||
text = {
|
||||
OutlinedTextField(
|
||||
value = newName,
|
||||
onValueChange = { newName = it },
|
||||
label = { Text(stringResource(R.string.server_name_label)) },
|
||||
singleLine = true,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
},
|
||||
confirmButton = {
|
||||
TextButton(
|
||||
onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
settingsViewModel.renameProfile(profileId, newName)
|
||||
showRename = false
|
||||
},
|
||||
enabled = newName.isNotBlank()
|
||||
) { Text(stringResource(R.string.save)) }
|
||||
},
|
||||
dismissButton = {
|
||||
TextButton(onClick = { showRename = false }) { Text(stringResource(R.string.cancel)) }
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Карточка статуса сервера в хабе. Один источник истины — [ServerHubStatus] (собран в VM).
|
||||
* Дизайн: hero-строка (живой индикатор + заголовок фазы) несёт статус ОДИН раз — без
|
||||
* дублирующего чипа; детали (SSH, режим, версия) — meta-чипы во [FlowRow], переносятся на
|
||||
* узком экране. Тело меняется одним [AnimatedContent] (size-spring, M3 expressive); фазы
|
||||
* холодного захода (disconnected/connecting/checking) свёрнуты в Connecting — один переход в Online.
|
||||
*/
|
||||
@Composable
|
||||
private fun ServerStatusCard(
|
||||
status: ServerHubStatus,
|
||||
privacyMode: Boolean,
|
||||
onActivate: () -> Unit,
|
||||
onRetry: () -> Unit
|
||||
) {
|
||||
val reducedMotion = LocalReducedMotion.current
|
||||
Surface(
|
||||
shape = MaterialTheme.shapes.large,
|
||||
color = MaterialTheme.colorScheme.surfaceContainerLow,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
AnimatedContent(
|
||||
targetState = status,
|
||||
// Переход только при смене ФАЗЫ; правки данных внутри Online обновляют тело на месте.
|
||||
contentKey = { it.phaseKey() },
|
||||
transitionSpec = {
|
||||
if (reducedMotion) {
|
||||
(fadeIn(snap()) togetherWith fadeOut(snap()))
|
||||
.using(SizeTransform(clip = false) { _, _ -> snap() })
|
||||
} else {
|
||||
(fadeIn(tween(200)) togetherWith fadeOut(tween(120)))
|
||||
.using(
|
||||
SizeTransform(clip = false) { _, _ ->
|
||||
spring(
|
||||
dampingRatio = Spring.DampingRatioNoBouncy,
|
||||
stiffness = Spring.StiffnessMediumLow
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
},
|
||||
label = "hub_status",
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) { s ->
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(20.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
when (s) {
|
||||
is ServerHubStatus.Online -> OnlineContent(s, privacyMode)
|
||||
ServerHubStatus.Connecting -> BusyContent(stringResource(R.string.pill_connecting))
|
||||
is ServerHubStatus.Working -> BusyContent(s.action)
|
||||
is ServerHubStatus.Failed -> FailedContent(s.message, onRetry)
|
||||
is ServerHubStatus.Offline -> OfflineContent(s, onActivate)
|
||||
ServerHubStatus.NotPaired -> StatusHero(
|
||||
color = MaterialTheme.extendedColorScheme.warning,
|
||||
title = stringResource(R.string.pill_not_paired),
|
||||
subtitle = stringResource(R.string.not_paired_hint)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Стабильный ключ фазы — AnimatedContent анимирует только при его смене. */
|
||||
private fun ServerHubStatus.phaseKey(): Int = when (this) {
|
||||
is ServerHubStatus.Offline -> 0
|
||||
ServerHubStatus.NotPaired -> 1
|
||||
ServerHubStatus.Connecting -> 2
|
||||
is ServerHubStatus.Working -> 3
|
||||
is ServerHubStatus.Online -> 4
|
||||
is ServerHubStatus.Failed -> 5
|
||||
}
|
||||
|
||||
/**
|
||||
* Hero-строка статуса: живой индикатор-«ореол» слева + заголовок фазы и опц. подзаголовок.
|
||||
* Статус озвучивается один раз тут (никакого дублирующего чипа). [liveRegion] — TalkBack
|
||||
* объявляет смену фазы. Заголовок onSurface (читаемость), цвет несёт индикатор.
|
||||
*/
|
||||
@Composable
|
||||
private fun StatusHero(
|
||||
color: Color,
|
||||
title: String,
|
||||
subtitle: String? = null,
|
||||
pulsing: Boolean = false
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(14.dp),
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.semantics { liveRegion = LiveRegionMode.Polite }
|
||||
) {
|
||||
StatusIndicator(color, pulsing)
|
||||
Column(modifier = Modifier.weight(1f), verticalArrangement = Arrangement.spacedBy(2.dp)) {
|
||||
Text(
|
||||
title,
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
color = MaterialTheme.colorScheme.onSurface
|
||||
)
|
||||
if (subtitle != null) {
|
||||
Text(
|
||||
subtitle,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Цветная точка-«ореол» статуса. В busy-фазах ореол мягко пульсирует (reduced-motion → статично). */
|
||||
@Composable
|
||||
private fun StatusIndicator(color: Color, pulsing: Boolean) {
|
||||
val reducedMotion = LocalReducedMotion.current
|
||||
val active = pulsing && !reducedMotion
|
||||
val t = rememberInfiniteTransition(label = "halo")
|
||||
val phase by t.animateFloat(
|
||||
initialValue = 0f, targetValue = 1f,
|
||||
animationSpec = infiniteRepeatable(tween(1100), RepeatMode.Reverse),
|
||||
label = "halo_phase"
|
||||
)
|
||||
val haloAlpha = if (active) lerp(0.06f, 0.30f, phase) else 0.16f
|
||||
val haloScale = if (active) lerp(0.80f, 1.18f, phase) else 1f
|
||||
val animatedColor by animateColorAsState(color, label = "indicator_color")
|
||||
Box(contentAlignment = Alignment.Center, modifier = Modifier.size(28.dp)) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(28.dp)
|
||||
.graphicsLayer { scaleX = haloScale; scaleY = haloScale }
|
||||
.background(animatedColor.copy(alpha = haloAlpha), CircleShape)
|
||||
)
|
||||
Box(modifier = Modifier.size(12.dp).background(animatedColor, CircleShape))
|
||||
}
|
||||
}
|
||||
|
||||
/** Компактный meta-чип детали (SSH/режим/версия). Переносится во FlowRow на узком экране. */
|
||||
@Composable
|
||||
private fun MetaChip(text: String, color: Color = MaterialTheme.colorScheme.onSurfaceVariant) {
|
||||
Surface(shape = MaterialTheme.shapes.small, color = MaterialTheme.colorScheme.surfaceContainerHighest) {
|
||||
Text(
|
||||
text,
|
||||
style = MaterialTheme.typography.labelMedium,
|
||||
color = color,
|
||||
maxLines = 1,
|
||||
modifier = Modifier.padding(horizontal = 10.dp, vertical = 6.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** Busy-фаза (подключение/серверное действие): hero с пульсом + тонкий wavy-индикатор. */
|
||||
@Composable
|
||||
private fun BusyContent(title: String) {
|
||||
StatusHero(
|
||||
color = MaterialTheme.colorScheme.secondary,
|
||||
title = title,
|
||||
pulsing = true
|
||||
)
|
||||
LinearWavyProgressIndicator(modifier = Modifier.fillMaxWidth())
|
||||
}
|
||||
|
||||
/**
|
||||
* Живое ядро: hero несёт главный статус ОДИН раз (работает/остановлен/не установлено),
|
||||
* детали — meta-чипы во [FlowRow] (SSH, режим, обфускация, версия, стадия установки). Чипы
|
||||
* переносятся на узком экране, ничего не сплющивается.
|
||||
*/
|
||||
@Composable
|
||||
private fun OnlineContent(status: ServerHubStatus.Online, privacyMode: Boolean) {
|
||||
val ext = MaterialTheme.extendedColorScheme
|
||||
val (color, title) = when {
|
||||
!status.installed -> ext.warning to stringResource(R.string.hub_not_installed)
|
||||
status.running -> ext.success to stringResource(R.string.hub_server_running)
|
||||
else -> MaterialTheme.colorScheme.onSurfaceVariant to stringResource(R.string.hub_server_stopped)
|
||||
}
|
||||
StatusHero(color = color, title = title)
|
||||
|
||||
FlowRow(
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
status.sshIp.redact(privacyMode).takeIf { it.isNotBlank() }?.let {
|
||||
MetaChip("SSH · $it", color = ext.info)
|
||||
}
|
||||
if (status.running) {
|
||||
MetaChip(if (status.tcpMode == true) stringResource(R.string.tcp) else stringResource(R.string.udp))
|
||||
if (status.obfProfile == "rtpopus") MetaChip(stringResource(R.string.obf_rtpopus))
|
||||
}
|
||||
if (status.installed && !status.version.isNullOrBlank()) {
|
||||
MetaChip("v${status.version}")
|
||||
}
|
||||
status.installStage?.let { stage ->
|
||||
val label = when (stage) {
|
||||
"cached" -> stringResource(R.string.server_install_cached)
|
||||
"downloaded" -> stringResource(R.string.server_install_downloaded)
|
||||
else -> stage
|
||||
}
|
||||
MetaChip(label, color = ext.info)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Ошибка подключения/команды — hero + причина + «Переподключиться». */
|
||||
@Composable
|
||||
private fun FailedContent(message: String?, onRetry: () -> Unit) {
|
||||
StatusHero(
|
||||
color = MaterialTheme.colorScheme.error,
|
||||
title = stringResource(R.string.hub_connect_failed),
|
||||
subtitle = message
|
||||
)
|
||||
Button(onClick = onRetry, modifier = Modifier.fillMaxWidth(), shape = MaterialTheme.shapes.large) {
|
||||
Text(stringResource(R.string.reconnect))
|
||||
}
|
||||
}
|
||||
|
||||
/** Неактивный профиль — hero + адреса (meta-чипы) + «Сделать активным». */
|
||||
@Composable
|
||||
private fun OfflineContent(status: ServerHubStatus.Offline, onActivate: () -> Unit) {
|
||||
StatusHero(
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
title = stringResource(R.string.pill_offline),
|
||||
subtitle = stringResource(R.string.server_inactive_desc)
|
||||
)
|
||||
if (status.serverAddress != null || status.sshIp != null) {
|
||||
FlowRow(
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(8.dp),
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
status.serverAddress?.let { MetaChip(it) }
|
||||
status.sshIp?.let { MetaChip("SSH · $it") }
|
||||
}
|
||||
}
|
||||
Button(onClick = onActivate, modifier = Modifier.fillMaxWidth(), shape = MaterialTheme.shapes.large) {
|
||||
Text(stringResource(R.string.make_active))
|
||||
}
|
||||
}
|
||||
|
||||
/** Мастер-свитч синхронизации с сервером (в хабе). */
|
||||
@Composable
|
||||
private fun SyncToggleRow(
|
||||
checked: Boolean,
|
||||
onCheckedChange: (Boolean) -> Unit
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 12.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(16.dp)
|
||||
) {
|
||||
SettingsRowIcon(R.drawable.cached_24px)
|
||||
Column(modifier = Modifier.weight(1f)) {
|
||||
Text(stringResource(R.string.sync_server_switches), style = MaterialTheme.typography.bodyLarge)
|
||||
Text(
|
||||
stringResource(R.string.sync_server_switches_desc),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
Switch(checked = checked, onCheckedChange = onCheckedChange)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun BackButton(onBack: () -> Unit) {
|
||||
IconButton(onClick = onBack) {
|
||||
Icon(
|
||||
painterResource(R.drawable.arrow_back_24px),
|
||||
contentDescription = stringResource(R.string.back)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun EmptyServers(modifier: Modifier = Modifier) {
|
||||
Column(
|
||||
modifier = modifier.padding(horizontal = 32.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
Surface(
|
||||
shape = MaterialShapes.Cookie9Sided.toShape(),
|
||||
color = MaterialTheme.colorScheme.primaryContainer,
|
||||
modifier = Modifier.size(112.dp)
|
||||
) {
|
||||
Box(contentAlignment = Alignment.Center, modifier = Modifier.fillMaxSize()) {
|
||||
Icon(
|
||||
painterResource(R.drawable.database_outlined_24px),
|
||||
contentDescription = null,
|
||||
tint = MaterialTheme.colorScheme.onPrimaryContainer,
|
||||
modifier = Modifier.size(48.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
Spacer(Modifier.height(16.dp))
|
||||
Text(
|
||||
stringResource(R.string.settings_empty_servers),
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.navigationBarsPadding
|
||||
@@ -16,6 +17,7 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.selection.toggleable
|
||||
import androidx.compose.material3.BottomSheetDefaults
|
||||
import androidx.compose.material3.Checkbox
|
||||
import androidx.compose.material3.CircularWavyProgressIndicator
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
@@ -26,8 +28,11 @@ import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.ListItem
|
||||
import androidx.compose.material3.ListItemDefaults
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.ModalBottomSheet
|
||||
import androidx.compose.material3.OutlinedTextField
|
||||
import androidx.compose.material3.SheetValue
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.rememberBottomSheetState
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -53,6 +58,40 @@ import com.freeturn.app.ui.components.installedInternetApps
|
||||
import com.freeturn.app.ui.components.toPackageSet
|
||||
import com.freeturn.app.viewmodel.SettingsViewModel
|
||||
|
||||
/**
|
||||
* Общий модальный лист split-tunneling. Один источник для главного экрана и экрана
|
||||
* «Режим подключения» — обёртка [ModalBottomSheet] вокруг [SplitTunnelSheetContent].
|
||||
* Лист открывается сразу на полную высоту (skipPartiallyExpanded) и держит инсеты сам
|
||||
* (contentWindowInsets = 0), чтобы не «вырастать» над клавиатурой при фокусе поиска.
|
||||
*/
|
||||
@Composable
|
||||
fun SplitTunnelModal(
|
||||
settingsViewModel: SettingsViewModel,
|
||||
mode: String,
|
||||
apps: String,
|
||||
locked: Boolean,
|
||||
onDismiss: () -> Unit,
|
||||
containerColor: Color = BottomSheetDefaults.ContainerColor
|
||||
) {
|
||||
val sheetState = rememberBottomSheetState(
|
||||
initialValue = SheetValue.Hidden,
|
||||
enabledValues = setOf(SheetValue.Hidden, SheetValue.Expanded)
|
||||
)
|
||||
ModalBottomSheet(
|
||||
onDismissRequest = onDismiss,
|
||||
sheetState = sheetState,
|
||||
containerColor = containerColor,
|
||||
contentWindowInsets = { WindowInsets(0, 0, 0, 0) }
|
||||
) {
|
||||
SplitTunnelSheetContent(
|
||||
settingsViewModel = settingsViewModel,
|
||||
mode = mode,
|
||||
apps = apps,
|
||||
locked = locked
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Лист split-tunneling с главного экрана. Один общий sheet: свитч вкл/выкл,
|
||||
* выбор режима (include/exclude), поиск и список приложений с иконками/чекбоксами.
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.freeturn.app.ui.util
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.composed
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
@@ -22,9 +21,3 @@ fun Modifier.hapticClickable(
|
||||
onClick()
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun rememberHaptic(): (HapticUtil.Pattern) -> Unit {
|
||||
val context = LocalContext.current
|
||||
return { pattern -> HapticUtil.perform(context, pattern) }
|
||||
}
|
||||
+3
-2
@@ -3,8 +3,9 @@
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
android:tint="?attr/colorControlNormal"
|
||||
android:autoMirrored="true">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M480,600L280,400L680,400L480,600Z"/>
|
||||
android:pathData="M504,480L320,296L376,240L616,480L376,720L320,664L504,480Z"/>
|
||||
</vector>
|
||||
@@ -1,10 +0,0 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M360,600L360,360L600,360L600,600L360,600ZM440,520L520,520L520,440L440,440L440,520ZM360,840L360,760L280,760Q247,760 223.5,736.5Q200,713 200,680L200,600L120,600L120,520L200,520L200,440L120,440L120,360L200,360L200,280Q200,247 223.5,223.5Q247,200 280,200L360,200L360,120L440,120L440,200L520,200L520,120L600,120L600,200L680,200Q713,200 736.5,223.5Q760,247 760,280L760,360L840,360L840,440L760,440L760,520L840,520L840,600L760,600L760,680Q760,713 736.5,736.5Q713,760 680,760L600,760L600,840L520,840L520,760L440,760L440,840L360,840ZM680,680Q680,680 680,680Q680,680 680,680L680,280Q680,280 680,280Q680,280 680,280L280,280Q280,280 280,280Q280,280 280,280L280,680Q280,680 280,680Q280,680 280,680L680,680ZM480,480L480,480L480,480L480,480Z"/>
|
||||
</vector>
|
||||
@@ -1,10 +0,0 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="960"
|
||||
android:viewportHeight="960"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M645,405Q680,370 680,320Q680,270 645,235Q610,200 560,200Q510,200 475,235Q440,270 440,320Q440,370 475,405Q510,440 560,440Q610,440 645,405ZM320,630Q365,577 428,548.5Q491,520 560,520Q629,520 692,548.5Q755,577 800,630Q800,630 800,630Q800,630 800,630L800,160Q800,160 800,160Q800,160 800,160L320,160Q320,160 320,160Q320,160 320,160L320,630Q320,630 320,630Q320,630 320,630ZM320,720Q287,720 263.5,696.5Q240,673 240,640L240,160Q240,127 263.5,103.5Q287,80 320,80L800,80Q833,80 856.5,103.5Q880,127 880,160L880,640Q880,673 856.5,696.5Q833,720 800,720L320,720ZM160,880Q127,880 103.5,856.5Q80,833 80,800L80,240L160,240L160,800Q160,800 160,800Q160,800 160,800L720,800L720,880L160,880ZM531.5,348.5Q520,337 520,320Q520,303 531.5,291.5Q543,280 560,280Q577,280 588.5,291.5Q600,303 600,320Q600,337 588.5,348.5Q577,360 560,360Q543,360 531.5,348.5ZM428,640L692,640L692,640Q663,620 629,610Q595,600 560,600Q525,600 491,610Q457,620 428,640ZM560,395Q560,395 560,395Q560,395 560,395L560,395Q560,395 560,395Q560,395 560,395L560,395Q560,395 560,395Q560,395 560,395L560,395Q560,395 560,395Q560,395 560,395Q560,395 560,395Q560,395 560,395Q560,395 560,395Q560,395 560,395Z"/>
|
||||
</vector>
|
||||
@@ -18,8 +18,6 @@
|
||||
<string name="proxy_active_stop">Прокси активен - нажмите для остановки</string>
|
||||
<string name="proxy_error_restart">Ошибка - нажмите для повторного запуска</string>
|
||||
<string name="start_proxy">Запустить прокси</string>
|
||||
<string name="connection">Соединение</string>
|
||||
<string name="not_connected">Не сопряжено</string>
|
||||
<string name="android_client">Android-клиент</string>
|
||||
<string name="proxy_core">Прокси-ядро</string>
|
||||
<string name="btn_open">Открыть</string>
|
||||
@@ -30,7 +28,6 @@
|
||||
<string name="cancel">Отмена</string>
|
||||
|
||||
<!-- ClientSetupScreen -->
|
||||
<string name="client_title">Клиент</string>
|
||||
<string name="connection_title">Подключение</string>
|
||||
<string name="server_address_label">Адрес turn-proxy сервера</string>
|
||||
<string name="server_address_placeholder">1.2.3.4:56000</string>
|
||||
@@ -48,25 +45,20 @@
|
||||
<string name="streams_per_cred_format">Потоков на аккаунт: %1$d</string>
|
||||
|
||||
<string name="tcp_forward_mode">Режим</string>
|
||||
<string name="tcp_forward_mode_desc">Режим tcp для проброса Xray/VLESS/Trojan</string>
|
||||
<string name="client_bond">Bond (стрипинг TCP)</string>
|
||||
<string name="client_bond_desc">Распределяет TCP по smux-сессиям. Только в TCP-режиме.</string>
|
||||
<string name="obf_profile_title">Обфускация</string>
|
||||
<string name="obf_profile_desc">Профиль маскировки</string>
|
||||
<string name="obf_none">Выкл</string>
|
||||
<string name="obf_rtpopus">rtpopus</string>
|
||||
<string name="provider_vk">VK Calls</string>
|
||||
<string name="locked_disconnect_hint">Подключитесь к серверу, чтобы изменить</string>
|
||||
<string name="obf_key_empty_hint">Ключ не сгенерирован - нажмите кнопку ниже</string>
|
||||
<string name="obf_key_invalid_hint">Неверный формат - нужны 64 hex-символа</string>
|
||||
<string name="obf_key_apply">Применить</string>
|
||||
<string name="obf_key_regen_in_progress">Генерация ключа…</string>
|
||||
<string name="server_sync_section">Синхронные настройки сервера</string>
|
||||
<string name="sync_server_switches">Синхронизировать с сервером</string>
|
||||
<string name="sync_server_switches_desc">При выкл. флаги меняются только у клиента, серверный процесс не перезапускается</string>
|
||||
<string name="sync_off_banner">Sync с сервером выключен. Cледите за совпадением вручную.</string>
|
||||
<string name="server_journal_title">Журнал</string>
|
||||
<string name="server_journal_fetch">Показать журнал</string>
|
||||
<string name="server_journal_refresh">Обновить</string>
|
||||
<string name="server_journal_loading">Загрузка журнала…</string>
|
||||
<string name="server_journal_empty">Журнал пуст</string>
|
||||
@@ -91,10 +83,6 @@
|
||||
<string name="no_logs">Нет логов</string>
|
||||
|
||||
<!-- ServerManagementScreen -->
|
||||
<string name="server_status">Статус сервера</string>
|
||||
<string name="ssh_connection">SSH‑соединение</string>
|
||||
<string name="free_turn_proxy">free-turn-proxy</string>
|
||||
<string name="error_format">Ошибка: %1$s</string>
|
||||
<string name="server_config">Конфигурация сервера</string>
|
||||
<string name="listen_port">Порт прослушивания</string>
|
||||
<string name="listen_port_placeholder">56000</string>
|
||||
@@ -108,17 +96,12 @@
|
||||
<string name="install">Установить / обновить</string>
|
||||
<string name="server_install_cached">Актуально</string>
|
||||
<string name="server_install_downloaded">Обновлено</string>
|
||||
<string name="server_version_label">Версия: %1$s</string>
|
||||
<string name="server_obf_key_label">Obf-ключ (64 hex)</string>
|
||||
<string name="obf_key_regen">Сгенерировать новый ключ на сервере</string>
|
||||
<string name="start_server">Запустить сервер</string>
|
||||
<string name="stop_server">Остановить сервер</string>
|
||||
<string name="continue_client_setup">Продолжить настройку клиента</string>
|
||||
<string name="server_running_tcp">Сервер запущен в TCP-форвард режиме</string>
|
||||
<string name="ssh_log_title">SSH-лог</string>
|
||||
<string name="active">Активно</string>
|
||||
<string name="inactive">Неактивно</string>
|
||||
<string name="paired">Сопряжено</string>
|
||||
|
||||
<!-- SshSetupScreen -->
|
||||
<string name="show_password">Показать пароль</string>
|
||||
@@ -198,7 +181,6 @@
|
||||
<string name="tg_not_now">Не сейчас</string>
|
||||
|
||||
<!-- Profiles -->
|
||||
<string name="profiles_title">Профили</string>
|
||||
<string name="profiles_empty_title">Пока нет сохранённых профилей</string>
|
||||
<string name="profiles_empty_desc">Сохраните текущие настройки как профиль или импортируйте ссылку, чтобы переключаться между разными профилями.</string>
|
||||
<string name="profile_save_current">Сохранить текущие настройки</string>
|
||||
@@ -214,8 +196,6 @@
|
||||
<string name="profile_default_name">Новый профиль</string>
|
||||
<string name="profile_name_taken">Профиль с таким именем уже существует</string>
|
||||
<string name="profile_unsaved_label">Несохранённая конфигурация</string>
|
||||
<string name="profile_update_current">Обновить активный профиль</string>
|
||||
<string name="profile_updated_toast">Профиль обновлён</string>
|
||||
|
||||
<!-- Notification & Tile -->
|
||||
<string name="notif_proxy_stop_action">Отключить</string>
|
||||
@@ -224,13 +204,7 @@
|
||||
<string name="proxy_active_wireguard">Прокси и WireGuard активны</string>
|
||||
|
||||
<!-- Туннельное приложение (WireGuard) -->
|
||||
<string name="tunnel_transport_title">Туннельное приложение</string>
|
||||
<string name="tunnel_transport_desc">Поднимает VPN-туннель поверх локального прокси: трафик устройства заворачивается через TURN-релей. Оставьте конфиг пустым, чтобы не использовать туннель.</string>
|
||||
<string name="wireguard_section">WireGuard</string>
|
||||
<string name="wireguard_tunnel_name">Имя туннеля</string>
|
||||
<string name="wireguard_config_label">Конфигурация WireGuard (.conf)</string>
|
||||
<string name="wireguard_config_placeholder">[Interface]\nPrivateKey = …\nAddress = …\n\n[Peer]\nPublicKey = …\nAllowedIPs = 0.0.0.0/0</string>
|
||||
<string name="wireguard_config_support">Endpoint подменяется на локальный порт прокси автоматически. Пусто = туннель не поднимается.</string>
|
||||
|
||||
<!-- Split tunneling -->
|
||||
<string name="split_tunnel_title">Раздельное туннелирование</string>
|
||||
@@ -245,9 +219,53 @@
|
||||
|
||||
<!-- Profiles sheet (servers) -->
|
||||
<string name="profiles_servers_title">Серверы</string>
|
||||
<string name="profiles_provider_label">Провайдер</string>
|
||||
|
||||
<!-- Логи -->
|
||||
<string name="logs_enabled">Сбор логов</string>
|
||||
<string name="logs_enabled_desc">Показывать вывод ядра на экране логов. Выключите для экономии памяти.</string>
|
||||
|
||||
<!-- Настройки (новый раздел) -->
|
||||
<string name="nav_settings">Настройки</string>
|
||||
<string name="settings_title">Настройки</string>
|
||||
<string name="settings_servers">Серверы</string>
|
||||
<string name="settings_servers_desc">Управление добавленными серверами и их настройками</string>
|
||||
<string name="settings_empty_servers">Нет добавленных серверов. Сохраните конфигурацию на главном экране.</string>
|
||||
<string name="provider_vk_calls">VK Звонки</string>
|
||||
<string name="server_delete_confirm_title">Удалить сервер?</string>
|
||||
<string name="server_delete_confirm_desc">Сервер «%1$s» и все его настройки будут удалены из приложения.</string>
|
||||
<string name="provider_connection_settings">Настройки подключения</string>
|
||||
<string name="provider_connection_settings_desc">Параметры клиента: адрес, потоки, DNS</string>
|
||||
<string name="provider_server_settings">Настройки сервера</string>
|
||||
<string name="provider_server_settings_desc">Состояние, обфускация, проброс и управление ядром</string>
|
||||
<!-- Живой статус сервера в хабе -->
|
||||
<string name="hub_server_running">Сервер работает</string>
|
||||
<string name="hub_server_stopped">Сервер остановлен</string>
|
||||
<string name="hub_connect_failed">Не удалось подключиться</string>
|
||||
<string name="hub_not_installed">Ядро не установлено</string>
|
||||
<!-- Заголовки фаз статуса (hero) -->
|
||||
<string name="pill_connecting">Подключение…</string>
|
||||
<string name="pill_not_paired">SSH не настроен</string>
|
||||
<string name="pill_offline">Сервер неактивен</string>
|
||||
<string name="not_paired_hint">Настройте подключение к серверу ниже</string>
|
||||
<string name="server_apply">Применить</string>
|
||||
<string name="server_apply_restart_note">Изменения перезапустят сервер</string>
|
||||
<string name="server_inactive_title">Сервер не активен</string>
|
||||
<string name="server_inactive_desc">Чтобы управлять ядром и SSH-подключением, сделайте этот сервер активным.</string>
|
||||
<string name="make_active">Сделать активным</string>
|
||||
<string name="profile_active_badge">Активный</string>
|
||||
<string name="profile_has_ssh">SSH</string>
|
||||
<string name="menu_delete_server">Удалить сервер</string>
|
||||
<string name="menu_rename_server">Переименовать</string>
|
||||
<string name="rename_server_title">Переименовать сервер</string>
|
||||
<string name="server_name_label">Имя сервера</string>
|
||||
<string name="save">Сохранить</string>
|
||||
<string name="connection_mode_title">Режим подключения</string>
|
||||
<string name="provider_connection_mode_desc">Proxy или VPN (WireGuard), импорт конфига</string>
|
||||
<string name="mode_proxy">Proxy</string>
|
||||
<string name="mode_vpn">VPN</string>
|
||||
<string name="mode_proxy_desc">Трафик идёт через локальный прокси, без туннеля.</string>
|
||||
<string name="mode_vpn_desc">Весь трафик устройства туннелируется через WireGuard.</string>
|
||||
<string name="load_wg_conf">Загрузить из файла</string>
|
||||
<string name="connection_config_section">Конфигурация туннеля</string>
|
||||
<string name="change_server">Сменить сервер</string>
|
||||
</resources>
|
||||
Reference in new issue
Block a user