refactor: UI cleanup, noDtls removal, settings reorder
This commit is contained in:
1 parent
0f6d4fa1a6
commit
1482003fc8
6 files changed
+166
-174
No files matched your search
@@ -35,7 +35,6 @@ data class ClientConfig(
|
||||
val vkLink: String = "",
|
||||
val threads: Int = 4,
|
||||
val useUdp: Boolean = true,
|
||||
val noDtls: Boolean = false,
|
||||
val manualCaptcha: Boolean = false,
|
||||
val localPort: String = "127.0.0.1:9000",
|
||||
val isRawMode: Boolean = false,
|
||||
@@ -70,7 +69,6 @@ class AppPreferences(context: Context) {
|
||||
val CLIENT_VK_LINK = stringPreferencesKey("client_vk_link")
|
||||
val CLIENT_THREADS = intPreferencesKey("client_threads")
|
||||
val CLIENT_UDP = booleanPreferencesKey("client_udp")
|
||||
val CLIENT_NO_DTLS = booleanPreferencesKey("client_no_dtls")
|
||||
val CLIENT_MANUAL_CAPTCHA = booleanPreferencesKey("client_manual_captcha")
|
||||
val CLIENT_LOCAL_PORT = stringPreferencesKey("client_local_port")
|
||||
val CLIENT_IS_RAW = booleanPreferencesKey("client_is_raw")
|
||||
@@ -135,7 +133,6 @@ class AppPreferences(context: Context) {
|
||||
vkLink = prefs[CLIENT_VK_LINK] ?: "",
|
||||
threads = prefs[CLIENT_THREADS] ?: 4,
|
||||
useUdp = prefs[CLIENT_UDP] ?: true,
|
||||
noDtls = prefs[CLIENT_NO_DTLS] ?: false,
|
||||
manualCaptcha = prefs[CLIENT_MANUAL_CAPTCHA] ?: false,
|
||||
localPort = prefs[CLIENT_LOCAL_PORT] ?: "127.0.0.1:9000",
|
||||
isRawMode = prefs[CLIENT_IS_RAW] ?: false,
|
||||
@@ -198,8 +195,9 @@ class AppPreferences(context: Context) {
|
||||
prefs[CLIENT_VK_LINK] = config.vkLink
|
||||
prefs[CLIENT_THREADS] = config.threads
|
||||
prefs[CLIENT_UDP] = config.useUdp
|
||||
prefs[CLIENT_NO_DTLS] = config.noDtls
|
||||
prefs[CLIENT_MANUAL_CAPTCHA] = config.manualCaptcha
|
||||
// Мигрируем старый ключ: noDtls удалён из приложения.
|
||||
prefs.remove(booleanPreferencesKey("client_no_dtls"))
|
||||
prefs[CLIENT_LOCAL_PORT] = config.localPort
|
||||
prefs[CLIENT_IS_RAW] = config.isRawMode
|
||||
prefs[CLIENT_RAW_CMD] = config.rawCommand
|
||||
|
||||
@@ -14,7 +14,6 @@ import androidx.compose.material3.adaptive.navigationsuite.NavigationSuiteScaffo
|
||||
import androidx.compose.material3.adaptive.navigationsuite.NavigationSuiteScaffoldDefaults
|
||||
import androidx.compose.material3.adaptive.navigationsuite.NavigationSuiteType
|
||||
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
|
||||
@@ -61,30 +60,22 @@ private val BOTTOM_NAV_ROUTES = setOf(Routes.HOME, Routes.LOGS, Routes.SERVER_MA
|
||||
@Composable
|
||||
fun AppNavigation(viewModel: MainViewModel) {
|
||||
val isInitialized by viewModel.isInitialized.collectAsStateWithLifecycle()
|
||||
val onboardingDone by viewModel.onboardingDone.collectAsStateWithLifecycle()
|
||||
|
||||
// Не строим NavHost пока DataStore не загружен — иначе startDestination
|
||||
// захватит дефолтный onboardingDone=false и всегда покажет онбординг
|
||||
if (!isInitialized) return
|
||||
|
||||
val proxyState by viewModel.proxyState.collectAsStateWithLifecycle()
|
||||
val tgSubscribeShown by viewModel.tgSubscribeShown.collectAsStateWithLifecycle()
|
||||
val initialOnboardingDone by viewModel.initialOnboardingDone.collectAsStateWithLifecycle()
|
||||
// initialOnboardingDone гарантированно выставлен до isInitialized=true (один coroutine),
|
||||
// поэтому remember здесь безопасно захватывает правильное значение.
|
||||
val initialTgSubscribeShown by viewModel.initialTgSubscribeShown.collectAsStateWithLifecycle()
|
||||
val startDestination = remember { if (initialOnboardingDone) Routes.HOME else Routes.ONBOARDING }
|
||||
val navController = rememberNavController()
|
||||
val backStackEntry by navController.currentBackStackEntryAsState()
|
||||
val currentRoute = backStackEntry?.destination?.route
|
||||
val showNavSuite = currentRoute in BOTTOM_NAV_ROUTES
|
||||
|
||||
var showTgDialog by rememberSaveable { mutableStateOf(false) }
|
||||
LaunchedEffect(onboardingDone, tgSubscribeShown) {
|
||||
if (onboardingDone && !tgSubscribeShown) showTgDialog = true
|
||||
}
|
||||
var showTgDialog by rememberSaveable { mutableStateOf(!initialTgSubscribeShown && initialOnboardingDone) }
|
||||
|
||||
// Адаптивно: bar на телефоне, rail на ширинах ≥600dp, drawer — при расширенном классе.
|
||||
// На экранах онбординга и SSH-setup навигация скрыта через NavigationSuiteType.None.
|
||||
val adaptiveType = NavigationSuiteScaffoldDefaults
|
||||
.calculateFromAdaptiveInfo(currentWindowAdaptiveInfo())
|
||||
val layoutType = if (showNavSuite) adaptiveType else NavigationSuiteType.None
|
||||
|
||||
@@ -87,7 +87,6 @@ fun ClientSetupScreen(
|
||||
var vkLink by rememberSaveable(saved.vkLink) { mutableStateOf(saved.vkLink) }
|
||||
var threads by rememberSaveable(saved.threads) { mutableFloatStateOf(saved.threads.toFloat()) }
|
||||
var useUdp by rememberSaveable(saved.useUdp) { mutableStateOf(saved.useUdp) }
|
||||
var noDtls by rememberSaveable(saved.noDtls) { mutableStateOf(saved.noDtls) }
|
||||
var manualCaptcha by rememberSaveable(saved.manualCaptcha) { mutableStateOf(saved.manualCaptcha) }
|
||||
var localPort by rememberSaveable(saved.localPort) { mutableStateOf(saved.localPort) }
|
||||
var dnsMode by rememberSaveable(saved.dnsMode) { mutableStateOf(saved.dnsMode) }
|
||||
@@ -105,7 +104,7 @@ fun ClientSetupScreen(
|
||||
|
||||
// Авто-сохранение с дебаунсом 600 мс на каждое изменение поля.
|
||||
// vlessMode исключён — сохраняется через setVlessMode с автоперезапуском сервера.
|
||||
LaunchedEffect(serverAddress, vkLink, threads, useUdp, noDtls, manualCaptcha, localPort, dnsMode, forcePort443, debugMode) {
|
||||
LaunchedEffect(serverAddress, vkLink, threads, useUdp, manualCaptcha, localPort, dnsMode, forcePort443, debugMode) {
|
||||
delay(600)
|
||||
viewModel.saveClientConfig(
|
||||
ClientConfig(
|
||||
@@ -113,7 +112,6 @@ fun ClientSetupScreen(
|
||||
vkLink = vkLink.trim(),
|
||||
threads = threads.roundToInt(),
|
||||
useUdp = useUdp,
|
||||
noDtls = noDtls,
|
||||
manualCaptcha = manualCaptcha,
|
||||
localPort = localPort.trim(),
|
||||
vlessMode = saved.vlessMode,
|
||||
@@ -164,12 +162,12 @@ fun ClientSetupScreen(
|
||||
OutlinedTextField(
|
||||
value = vkLink.redact(privacyMode),
|
||||
onValueChange = { if (!privacyMode) vkLink = it },
|
||||
label = { Text(stringResource(R.string.vk_link_label)) },
|
||||
placeholder = { Text(stringResource(R.string.vk_link_placeholder)) },
|
||||
label = { Text(stringResource(R.string.call_link_label)) },
|
||||
placeholder = { Text(stringResource(R.string.call_link_placeholder)) },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true,
|
||||
readOnly = privacyMode,
|
||||
supportingText = { Text(stringResource(R.string.vk_link_support)) }
|
||||
supportingText = { Text(stringResource(R.string.call_link_support)) }
|
||||
)
|
||||
|
||||
OutlinedTextField(
|
||||
@@ -212,76 +210,12 @@ fun ClientSetupScreen(
|
||||
}
|
||||
threads = it
|
||||
},
|
||||
valueRange = 1f..8f,
|
||||
steps = 6,
|
||||
valueRange = 1f..16f,
|
||||
steps = 14,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
|
||||
SwitchRow(
|
||||
label = stringResource(R.string.vless_mode),
|
||||
description = stringResource(R.string.vless_mode_desc),
|
||||
checked = saved.vlessMode,
|
||||
onCheckedChange = {
|
||||
HapticUtil.perform(context, if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||
viewModel.setVlessMode(it)
|
||||
}
|
||||
)
|
||||
|
||||
if (!saved.vlessMode) {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Column {
|
||||
Text(stringResource(R.string.transport_protocol), style = MaterialTheme.typography.bodyMedium)
|
||||
Text(
|
||||
stringResource(R.string.transport_protocol_desc),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {
|
||||
SegmentedButton(
|
||||
selected = !useUdp,
|
||||
onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
||||
useUdp = false
|
||||
noDtls = false
|
||||
},
|
||||
shape = SegmentedButtonDefaults.itemShape(index = 0, count = 2)
|
||||
) { Text(stringResource(R.string.tcp)) }
|
||||
SegmentedButton(
|
||||
selected = useUdp,
|
||||
onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
||||
useUdp = true
|
||||
},
|
||||
shape = SegmentedButtonDefaults.itemShape(index = 1, count = 2)
|
||||
) { Text(stringResource(R.string.udp)) }
|
||||
}
|
||||
}
|
||||
|
||||
if (useUdp) {
|
||||
SwitchRow(
|
||||
label = stringResource(R.string.no_dtls),
|
||||
description = stringResource(R.string.no_dtls_desc),
|
||||
checked = noDtls,
|
||||
onCheckedChange = {
|
||||
HapticUtil.perform(context, if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||
noDtls = it
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
SwitchRow(
|
||||
label = stringResource(R.string.manual_captcha),
|
||||
description = stringResource(R.string.manual_captcha_desc),
|
||||
checked = manualCaptcha,
|
||||
onCheckedChange = {
|
||||
HapticUtil.perform(context, if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||
manualCaptcha = it
|
||||
}
|
||||
)
|
||||
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Column {
|
||||
Text(stringResource(R.string.dns_mode_title), style = MaterialTheme.typography.bodyMedium)
|
||||
@@ -310,6 +244,58 @@ fun ClientSetupScreen(
|
||||
}
|
||||
}
|
||||
|
||||
if (!saved.vlessMode) {
|
||||
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Column {
|
||||
Text(stringResource(R.string.transport_protocol), style = MaterialTheme.typography.bodyMedium)
|
||||
Text(
|
||||
stringResource(R.string.transport_protocol_desc),
|
||||
style = MaterialTheme.typography.labelSmall,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
}
|
||||
SingleChoiceSegmentedButtonRow(modifier = Modifier.fillMaxWidth()) {
|
||||
SegmentedButton(
|
||||
selected = !useUdp,
|
||||
onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
||||
useUdp = false
|
||||
},
|
||||
shape = SegmentedButtonDefaults.itemShape(index = 0, count = 2)
|
||||
) { Text(stringResource(R.string.tcp)) }
|
||||
SegmentedButton(
|
||||
selected = useUdp,
|
||||
onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
||||
useUdp = true
|
||||
},
|
||||
shape = SegmentedButtonDefaults.itemShape(index = 1, count = 2)
|
||||
) { Text(stringResource(R.string.udp)) }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SwitchRow(
|
||||
label = stringResource(R.string.vless_mode),
|
||||
description = stringResource(R.string.vless_mode_desc),
|
||||
checked = saved.vlessMode,
|
||||
onCheckedChange = {
|
||||
HapticUtil.perform(context, if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||
viewModel.setVlessMode(it)
|
||||
}
|
||||
)
|
||||
|
||||
SwitchRow(
|
||||
label = stringResource(R.string.manual_captcha),
|
||||
description = stringResource(R.string.manual_captcha_desc),
|
||||
checked = manualCaptcha,
|
||||
onCheckedChange = {
|
||||
HapticUtil.perform(context, if (it) HapticUtil.Pattern.TOGGLE_ON else HapticUtil.Pattern.TOGGLE_OFF)
|
||||
manualCaptcha = it
|
||||
}
|
||||
)
|
||||
|
||||
SwitchRow(
|
||||
label = stringResource(R.string.force_port_443),
|
||||
description = stringResource(R.string.force_port_443_desc),
|
||||
|
||||
@@ -82,8 +82,6 @@ import androidx.compose.ui.unit.dp
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import com.freeturn.app.ui.HapticUtil
|
||||
import com.freeturn.app.ui.theme.extendedColorScheme
|
||||
import com.freeturn.app.viewmodel.MainViewModel
|
||||
@@ -100,6 +98,8 @@ fun HomeScreen(
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val proxyState by viewModel.proxyState.collectAsStateWithLifecycle()
|
||||
val connectedSince by viewModel.connectedSince.collectAsStateWithLifecycle()
|
||||
val uptimeText = rememberProxyUptime(connectedSince)
|
||||
val sshState by viewModel.sshState.collectAsStateWithLifecycle()
|
||||
val sshConfig by viewModel.sshConfig.collectAsStateWithLifecycle()
|
||||
val clientConfig by viewModel.clientConfig.collectAsStateWithLifecycle()
|
||||
@@ -149,7 +149,6 @@ fun HomeScreen(
|
||||
val privacyMode by viewModel.privacyMode.collectAsStateWithLifecycle()
|
||||
val showBottomSheet = rememberSaveable { mutableStateOf(false) }
|
||||
val bottomSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
||||
val scope = rememberCoroutineScope()
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
|
||||
Scaffold(
|
||||
@@ -157,6 +156,12 @@ fun HomeScreen(
|
||||
TopAppBar(
|
||||
title = { Text(stringResource(R.string.turn_proxy_title)) },
|
||||
actions = {
|
||||
IconButton(onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
onNavigateToSshSetup()
|
||||
}) {
|
||||
Icon(painterResource(R.drawable.key_24px), contentDescription = stringResource(R.string.connection))
|
||||
}
|
||||
IconButton(onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
showBottomSheet.value = true
|
||||
@@ -185,7 +190,7 @@ fun HomeScreen(
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_ON)
|
||||
viewModel.startProxy()
|
||||
}
|
||||
is ProxyState.Running -> {
|
||||
is ProxyState.Running, is ProxyState.Connecting, is ProxyState.Starting -> {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.TOGGLE_OFF)
|
||||
viewModel.stopProxy()
|
||||
}
|
||||
@@ -197,14 +202,28 @@ fun HomeScreen(
|
||||
Spacer(Modifier.height(24.dp))
|
||||
|
||||
Text(
|
||||
text = when (proxyState) {
|
||||
is ProxyState.Running -> stringResource(R.string.proxy_active)
|
||||
text = when (val s = proxyState) {
|
||||
is ProxyState.Running -> {
|
||||
val base = stringResource(R.string.proxy_active)
|
||||
val counts = if (s.total > 0) "${s.active}/${s.total}" else "${s.active}"
|
||||
if (uptimeText != null) "$base — $counts · $uptimeText"
|
||||
else "$base — $counts"
|
||||
}
|
||||
is ProxyState.Connecting -> {
|
||||
val base = stringResource(R.string.proxy_connecting)
|
||||
val counts = if (s.total > 0) " — ${s.active}/${s.total}" else ""
|
||||
// Таймер всё ещё показываем: сессия не завершилась, просто
|
||||
// потоки временно отвалились и ядро переподключается.
|
||||
if (uptimeText != null) "$base$counts · $uptimeText" else "$base$counts"
|
||||
}
|
||||
is ProxyState.Starting -> stringResource(R.string.proxy_connecting)
|
||||
is ProxyState.Error -> (proxyState as ProxyState.Error).message
|
||||
is ProxyState.Error -> s.message
|
||||
is ProxyState.CaptchaRequired -> "Требуется прохождение капчи"
|
||||
else -> stringResource(R.string.proxy_press_to_start)
|
||||
},
|
||||
style = MaterialTheme.typography.titleMedium,
|
||||
// "tnum" — tabular numbers: все цифры одинаковой ширины. Без него
|
||||
// тикающий таймер и меняющийся счётчик N/M сдвигают остальной текст.
|
||||
style = MaterialTheme.typography.titleMedium.copy(fontFeatureSettings = "tnum"),
|
||||
color = when (proxyState) {
|
||||
is ProxyState.Running -> MaterialTheme.extendedColorScheme.success
|
||||
is ProxyState.Error -> MaterialTheme.colorScheme.error
|
||||
@@ -297,14 +316,7 @@ fun HomeScreen(
|
||||
viewModel = viewModel,
|
||||
containerColor = sheetColor,
|
||||
privacyMode = privacyMode,
|
||||
onPrivacyModeChange = { viewModel.setPrivacyMode(it) },
|
||||
onNavigateToSshSetup = {
|
||||
scope.launch {
|
||||
bottomSheetState.hide()
|
||||
showBottomSheet.value = false
|
||||
onNavigateToSshSetup()
|
||||
}
|
||||
}
|
||||
onPrivacyModeChange = { viewModel.setPrivacyMode(it) }
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -411,7 +423,8 @@ private fun ProxyToggleButton(state: ProxyState, onClick: () -> Unit) {
|
||||
targetValue = when (state) {
|
||||
is ProxyState.Running -> extended.successContainer
|
||||
is ProxyState.Error -> MaterialTheme.colorScheme.errorContainer
|
||||
is ProxyState.Starting -> MaterialTheme.colorScheme.secondaryContainer
|
||||
is ProxyState.Starting, is ProxyState.Connecting ->
|
||||
MaterialTheme.colorScheme.secondaryContainer
|
||||
else -> MaterialTheme.colorScheme.primaryContainer
|
||||
},
|
||||
animationSpec = tween(600),
|
||||
@@ -421,14 +434,15 @@ private fun ProxyToggleButton(state: ProxyState, onClick: () -> Unit) {
|
||||
targetValue = when (state) {
|
||||
is ProxyState.Running -> extended.onSuccessContainer
|
||||
is ProxyState.Error -> MaterialTheme.colorScheme.onErrorContainer
|
||||
is ProxyState.Starting -> MaterialTheme.colorScheme.onSecondaryContainer
|
||||
is ProxyState.Starting, is ProxyState.Connecting ->
|
||||
MaterialTheme.colorScheme.onSecondaryContainer
|
||||
else -> MaterialTheme.colorScheme.onPrimaryContainer
|
||||
},
|
||||
animationSpec = tween(600),
|
||||
label = "btn_fg"
|
||||
)
|
||||
val scale by animateFloatAsState(
|
||||
targetValue = if (state is ProxyState.Starting) 0.96f else 1f,
|
||||
targetValue = if (state is ProxyState.Starting || state is ProxyState.Connecting) 0.96f else 1f,
|
||||
animationSpec = spring(dampingRatio = Spring.DampingRatioMediumBouncy),
|
||||
label = "btn_scale"
|
||||
)
|
||||
@@ -449,7 +463,8 @@ private fun ProxyToggleButton(state: ProxyState, onClick: () -> Unit) {
|
||||
verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
when (state) {
|
||||
is ProxyState.Starting -> CircularWavyProgressIndicator(color = contentColor)
|
||||
is ProxyState.Starting, is ProxyState.Connecting ->
|
||||
CircularWavyProgressIndicator(color = contentColor)
|
||||
is ProxyState.Running -> Icon(
|
||||
painterResource(R.drawable.check_circle_24px), stringResource(R.string.proxy_active_stop),
|
||||
Modifier.size(52.dp), tint = contentColor
|
||||
@@ -475,12 +490,10 @@ private fun InfoBottomSheet(
|
||||
viewModel: MainViewModel,
|
||||
containerColor: Color,
|
||||
privacyMode: Boolean,
|
||||
onPrivacyModeChange: (Boolean) -> Unit,
|
||||
onNavigateToSshSetup: () -> Unit
|
||||
onPrivacyModeChange: (Boolean) -> Unit
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
val uriHandler = LocalUriHandler.current
|
||||
val sshState by viewModel.sshState.collectAsStateWithLifecycle()
|
||||
val dynamicTheme by viewModel.dynamicTheme.collectAsStateWithLifecycle()
|
||||
val updateState by viewModel.updateState.collectAsStateWithLifecycle()
|
||||
var showResetDialog by rememberSaveable { mutableStateOf(false) }
|
||||
@@ -490,7 +503,6 @@ private fun InfoBottomSheet(
|
||||
catch (_: Exception) { "—" }
|
||||
}
|
||||
|
||||
val isConnected = sshState is SshConnectionState.Connected
|
||||
val listColors = ListItemDefaults.colors(containerColor = containerColor)
|
||||
|
||||
LazyColumn(
|
||||
@@ -498,36 +510,22 @@ private fun InfoBottomSheet(
|
||||
.fillMaxWidth()
|
||||
.navigationBarsPadding()
|
||||
) {
|
||||
// Соединение
|
||||
// Обновление
|
||||
item {
|
||||
ListItem(
|
||||
headlineContent = { Text(stringResource(R.string.connection), style = MaterialTheme.typography.titleSmall) },
|
||||
UpdateListItem(
|
||||
state = updateState,
|
||||
colors = listColors,
|
||||
supportingContent = {
|
||||
Text(
|
||||
when (sshState) {
|
||||
is SshConnectionState.Connected ->
|
||||
stringResource(R.string.connected_format, (sshState as SshConnectionState.Connected).ip.redact(privacyMode))
|
||||
is SshConnectionState.Connecting ->
|
||||
stringResource(R.string.ssh_connecting)
|
||||
is SshConnectionState.Error ->
|
||||
stringResource(R.string.error_format_short, (sshState as SshConnectionState.Error).message)
|
||||
else -> stringResource(R.string.not_connected)
|
||||
}
|
||||
)
|
||||
onCheck = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
viewModel.checkForUpdate()
|
||||
},
|
||||
trailingContent = {
|
||||
if (isConnected) {
|
||||
TextButton(onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
onNavigateToSshSetup()
|
||||
}) { Text(stringResource(R.string.change)) }
|
||||
} else {
|
||||
TextButton(onClick = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
onNavigateToSshSetup()
|
||||
}) { Text(stringResource(R.string.configure)) }
|
||||
}
|
||||
onDownload = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
viewModel.downloadUpdate()
|
||||
},
|
||||
onInstall = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
viewModel.installUpdate()
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -560,7 +558,7 @@ private fun InfoBottomSheet(
|
||||
item {
|
||||
RepoLinkItem(
|
||||
title = stringResource(R.string.tg_channel),
|
||||
subtitle = stringResource(R.string.tg_channel_subtitle),
|
||||
subtitle = null,
|
||||
url = "https://t.me/+53nh4UNiSv5lNTgy",
|
||||
containerColor = containerColor,
|
||||
onHaptic = { HapticUtil.perform(context, HapticUtil.Pattern.SELECTION) },
|
||||
@@ -613,28 +611,6 @@ private fun InfoBottomSheet(
|
||||
|
||||
item { HorizontalDivider() }
|
||||
|
||||
// Обновление
|
||||
item {
|
||||
UpdateListItem(
|
||||
state = updateState,
|
||||
colors = listColors,
|
||||
onCheck = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
viewModel.checkForUpdate()
|
||||
},
|
||||
onDownload = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
viewModel.downloadUpdate()
|
||||
},
|
||||
onInstall = {
|
||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||
viewModel.installUpdate()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
item { HorizontalDivider() }
|
||||
|
||||
// Сброс
|
||||
item {
|
||||
ListItem(
|
||||
@@ -763,7 +739,7 @@ private fun UpdateListItem(
|
||||
@Composable
|
||||
private fun RepoLinkItem(
|
||||
title: String,
|
||||
subtitle: String,
|
||||
subtitle: String?,
|
||||
url: String,
|
||||
containerColor: Color = MaterialTheme.colorScheme.surface,
|
||||
onHaptic: () -> Unit,
|
||||
@@ -772,13 +748,13 @@ private fun RepoLinkItem(
|
||||
ListItem(
|
||||
headlineContent = { Text(title) },
|
||||
colors = ListItemDefaults.colors(containerColor = containerColor),
|
||||
supportingContent = {
|
||||
supportingContent = if (subtitle != null) ({
|
||||
Text(
|
||||
subtitle,
|
||||
style = MaterialTheme.typography.bodySmall,
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
},
|
||||
}) else null,
|
||||
trailingContent = {
|
||||
Icon(
|
||||
painterResource(R.drawable.open_in_new_24px),
|
||||
@@ -797,6 +773,39 @@ private fun RepoLinkItem(
|
||||
|
||||
internal fun String.redact(enabled: Boolean) = if (enabled) "••••••" else this
|
||||
|
||||
/**
|
||||
* Форматирует uptime прокси в «mm:ss» или «h:mm:ss», тикая раз в секунду.
|
||||
*
|
||||
* Источник времени — `SystemClock.elapsedRealtime()`, как и у `connectedSince`
|
||||
* в `ProxyServiceState`: это устойчиво к переводу системных часов (обычный
|
||||
* `System.currentTimeMillis()` при изменении времени показал бы отрицательные
|
||||
* или разорванные интервалы).
|
||||
*
|
||||
* Возвращает null, если прокси ни разу не подключался в текущей сессии.
|
||||
*/
|
||||
@Composable
|
||||
private fun rememberProxyUptime(connectedSince: Long?): String? {
|
||||
if (connectedSince == null) return null
|
||||
// Тик состояния, принудительно переформатирующий строку раз в секунду.
|
||||
// Пересоздаётся при смене connectedSince (новая сессия).
|
||||
val tick = androidx.compose.runtime.produceState(initialValue = 0L, connectedSince) {
|
||||
while (true) {
|
||||
value = android.os.SystemClock.elapsedRealtime()
|
||||
kotlinx.coroutines.delay(1_000)
|
||||
}
|
||||
}
|
||||
val now = tick.value.coerceAtLeast(connectedSince)
|
||||
val totalSec = ((now - connectedSince) / 1_000).coerceAtLeast(0)
|
||||
val h = totalSec / 3600
|
||||
val m = (totalSec % 3600) / 60
|
||||
val s = totalSec % 60
|
||||
// Ведущий ноль у минут, чтобы строка не прыгала при переходе 9:59 → 10:00.
|
||||
// Вместе с fontFeatureSettings="tnum" у Text это даёт полностью стабильную
|
||||
// ширину в первый час работы. Смена ширины остаётся только на переходе
|
||||
// 59:59 → 1:00:00 (раз за сессию) и 9:59:59 → 10:00:00.
|
||||
return if (h > 0) "%d:%02d:%02d".format(h, m, s) else "%02d:%02d".format(m, s)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ConfigRow(label: String, value: String) {
|
||||
Row(
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<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="M223.5,536.5Q200,513 200,480Q200,447 223.5,423.5Q247,400 280,400Q313,400 336.5,423.5Q360,447 360,480Q360,513 336.5,536.5Q313,560 280,560Q247,560 223.5,536.5ZM280,720Q180,720 110,650Q40,580 40,480Q40,380 110,310Q180,240 280,240Q347,240 401.5,273Q456,306 488,360L840,360L960,480L780,660L700,600L620,660L535,600L488,600Q456,654 401.5,687Q347,720 280,720ZM280,640Q336,640 378.5,606Q421,572 435,520L560,520L618,561L700,500L771,555L846,480L806,440L435,440Q421,388 378.5,354Q336,320 280,320Q214,320 167,367Q120,414 120,480Q120,546 167,593Q214,640 280,640Z"/>
|
||||
</vector>
|
||||
@@ -39,12 +39,12 @@
|
||||
<!-- ClientSetupScreen -->
|
||||
<string name="client_title">Клиент</string>
|
||||
<string name="connection_title">Подключение</string>
|
||||
<string name="server_address_label">Адрес vk-turn-proxy сервера</string>
|
||||
<string name="server_address_label">Адрес turn-proxy сервера</string>
|
||||
<string name="server_address_placeholder">1.2.3.4:56000</string>
|
||||
<string name="server_address_support">IP и порт vk-turn-proxy на вашем VPS</string>
|
||||
<string name="vk_link_label">Ссылка VK-звонок</string>
|
||||
<string name="vk_link_placeholder">https://vk.com/call/…</string>
|
||||
<string name="vk_link_support">VK: Звонки → Создать → Скопировать ссылку (не нажимайте «Завершить»)</string>
|
||||
<string name="server_address_support">IP и порт turn-proxy на вашем VPS</string>
|
||||
<string name="call_link_label">Ссылка на звонок</string>
|
||||
<string name="call_link_placeholder">https://site.ru/call/…</string>
|
||||
<string name="call_link_support">Звонки → Создать → Скопировать ссылку (не нажимайте «Завершить»)</string>
|
||||
<string name="local_listen_address">Локальный адрес прослушивания</string>
|
||||
<string name="local_listen_placeholder">127.0.0.1:9000</string>
|
||||
<string name="local_listen_support">Адрес, на котором клиент принимает трафик от WireGuard/Hysteria</string>
|
||||
@@ -53,12 +53,10 @@
|
||||
<string name="threads_recommendation">Рекомендуется 4–8</string>
|
||||
<string name="transport_protocol">Транспорт</string>
|
||||
<string name="transport_protocol_desc">UDP снижает задержки, TCP — стабильнее</string>
|
||||
<string name="no_dtls">Без DTLS-шифрования</string>
|
||||
<string name="no_dtls_desc">Может ускорить соединение, повышает риск блокировки</string>
|
||||
<string name="manual_captcha">Ручной ввод капчи</string>
|
||||
<string name="manual_captcha_desc">Решать капчу вручную вместо автоматического распознавания</string>
|
||||
<string name="force_port_443">TURN на порту 443</string>
|
||||
<string name="force_port_443_desc">Подменяет порт VK TURN на 443 (-port 443). Помогает, если оператор режет нестандартные порты</string>
|
||||
<string name="force_port_443_desc">Помогает, если оператор режет нестандартные порты</string>
|
||||
<string name="dns_mode_title">DNS-резолвер</string>
|
||||
<string name="dns_mode_desc">Авто — пробует системный DNS, переключается на DNS-over-HTTPS при блокировке</string>
|
||||
<string name="dns_mode_auto">Авто</string>
|
||||
@@ -145,8 +143,8 @@
|
||||
<string name="update_no_update">Установлена последняя версия</string>
|
||||
<string name="update_error">Ошибка: %1$s</string>
|
||||
|
||||
<string name="debug_mode">Дебаг-режим</string>
|
||||
<string name="debug_mode_desc">Расширенный вывод в логах (-debug)</string>
|
||||
<string name="debug_mode">Debug-режим</string>
|
||||
<string name="debug_mode_desc">Расширенный вывод в логах</string>
|
||||
|
||||
<string name="dynamic_theme_title">Динамическая тема</string>
|
||||
<string name="dynamic_theme_desc">Использовать системные цвета (Material You)</string>
|
||||
|
||||
Reference in new issue
Block a user