feat(connection): вернуть ручную вставку WG-конфига в режиме VPN

This commit is contained in:
samosvalishe committed 2026-06-11 19:33:23 +03:00
1 parent 8a56fb381f
commit 8e9d0923eb
1 file changed
+19 -6
@@ -8,13 +8,13 @@ package com.freeturn.app.ui.screens
import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.imePadding import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.widthIn import androidx.compose.foundation.layout.widthIn
@@ -57,6 +57,7 @@ import com.freeturn.app.ui.components.SectionLabel
import com.freeturn.app.ui.components.SettingsCard import com.freeturn.app.ui.components.SettingsCard
import com.freeturn.app.ui.components.SettingsContentMaxWidth import com.freeturn.app.ui.components.SettingsContentMaxWidth
import com.freeturn.app.ui.components.SettingsEntryRow import com.freeturn.app.ui.components.SettingsEntryRow
import com.freeturn.app.ui.components.SettingsFieldSlot
import com.freeturn.app.ui.components.SettingsRowDivider import com.freeturn.app.ui.components.SettingsRowDivider
import com.freeturn.app.ui.theme.extendedColorScheme import com.freeturn.app.ui.theme.extendedColorScheme
import com.freeturn.app.ui.util.redact import com.freeturn.app.ui.util.redact
@@ -70,8 +71,9 @@ import kotlinx.coroutines.withContext
/** /**
* Экран «Режим подключения»: явный переключатель Proxy / VPN (WireGuard). В VPN-режиме * Экран «Режим подключения»: явный переключатель Proxy / VPN (WireGuard). В VPN-режиме
* — импорт .conf из файла, имя туннеля и split-tunnel модалкой (для активного сервера). * — .conf из файла или ручной вставкой, имя туннеля и split-tunnel модалкой (для
* Режим хранится в [ClientConfig.tunnelTransport] (NONE = proxy, WIREGUARD = vpn). * активного сервера). Режим хранится в [ClientConfig.tunnelTransport] (NONE = proxy,
* WIREGUARD = vpn).
*/ */
@Composable @Composable
fun ConnectionModeScreen( fun ConnectionModeScreen(
@@ -228,8 +230,6 @@ fun ConnectionModeScreen(
// --- Конфигурация туннеля --- // --- Конфигурация туннеля ---
SectionLabel(stringResource(R.string.connection_config_section)) SectionLabel(stringResource(R.string.connection_config_section))
SettingsCard { SettingsCard {
// Конфиг задаётся только файлом — вставка текстом давала тот же
// результат, а endpoint всё равно подменяется в рантайме.
SettingsEntryRow( SettingsEntryRow(
iconRes = R.drawable.cloud_download_24px, iconRes = R.drawable.cloud_download_24px,
title = stringResource(R.string.load_wg_conf), title = stringResource(R.string.load_wg_conf),
@@ -239,7 +239,20 @@ fun ConnectionModeScreen(
onClick = { filePicker.launch("*/*") } onClick = { filePicker.launch("*/*") }
) )
SettingsRowDivider() SettingsRowDivider()
Box(modifier = Modifier.padding(16.dp)) { SettingsFieldSlot {
// Та же ручная вставка .conf, что на шаге конфига мастера.
// Конфиг содержит приватный ключ — под privacyMode маскируем.
OutlinedTextField(
value = wgConfig.redact(privacyMode),
onValueChange = { if (!privacyMode) wgConfig = it },
label = { Text(stringResource(R.string.setup_wg_conf_label)) },
placeholder = { Text(stringResource(R.string.setup_wg_conf_placeholder)) },
modifier = Modifier
.fillMaxWidth()
.heightIn(min = 160.dp),
maxLines = 10,
readOnly = privacyMode
)
OutlinedTextField( OutlinedTextField(
value = wgName.redact(privacyMode), value = wgName.redact(privacyMode),
onValueChange = { if (!privacyMode) wgName = it }, onValueChange = { if (!privacyMode) wgName = it },