feat: приватный режим — скрытие IP и портов для скриншотов
This commit is contained in:
1 parent
5b2d9a5778
commit
d0bab79b31
5 files changed
+45
-14
No files matched your search
@@ -74,6 +74,7 @@ fun ClientSetupScreen(
|
||||
val proxyListen by viewModel.proxyListen.collectAsStateWithLifecycle()
|
||||
val customKernelExists by viewModel.customKernelExists.collectAsStateWithLifecycle()
|
||||
val kernelError by viewModel.kernelError.collectAsStateWithLifecycle()
|
||||
val privacyMode by viewModel.privacyMode.collectAsStateWithLifecycle()
|
||||
|
||||
val context = LocalContext.current
|
||||
|
||||
@@ -134,35 +135,36 @@ fun ClientSetupScreen(
|
||||
Text(stringResource(R.string.connection_title), style = MaterialTheme.typography.titleMedium)
|
||||
|
||||
OutlinedTextField(
|
||||
value = serverAddress,
|
||||
onValueChange = { serverAddress = it },
|
||||
value = serverAddress.redact(privacyMode),
|
||||
onValueChange = { if (!privacyMode) serverAddress = it },
|
||||
label = { Text(stringResource(R.string.server_address_label)) },
|
||||
placeholder = { Text(stringResource(R.string.server_address_placeholder)) },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true,
|
||||
readOnly = privacyMode,
|
||||
supportingText = { Text(stringResource(R.string.server_address_support)) }
|
||||
)
|
||||
|
||||
OutlinedTextField(
|
||||
value = vkLink,
|
||||
onValueChange = { vkLink = it },
|
||||
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)) },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true,
|
||||
readOnly = privacyMode,
|
||||
supportingText = { Text(stringResource(R.string.vk_link_support)) }
|
||||
)
|
||||
|
||||
OutlinedTextField(
|
||||
value = localPort,
|
||||
onValueChange = { localPort = it },
|
||||
value = localPort.redact(privacyMode),
|
||||
onValueChange = { if (!privacyMode) localPort = it },
|
||||
label = { Text(stringResource(R.string.local_listen_address)) },
|
||||
placeholder = { Text(stringResource(R.string.local_listen_placeholder)) },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true,
|
||||
supportingText = {
|
||||
Text(stringResource(R.string.local_listen_support))
|
||||
}
|
||||
readOnly = privacyMode,
|
||||
supportingText = { Text(stringResource(R.string.local_listen_support)) }
|
||||
)
|
||||
|
||||
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
||||
|
||||
@@ -143,6 +143,7 @@ fun HomeScreen(
|
||||
}
|
||||
}
|
||||
|
||||
val privacyMode by viewModel.privacyMode.collectAsStateWithLifecycle()
|
||||
val showBottomSheet = rememberSaveable { mutableStateOf(false) }
|
||||
val bottomSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
||||
val snackbarHostState = remember { SnackbarHostState() }
|
||||
@@ -219,10 +220,10 @@ fun HomeScreen(
|
||||
Column(modifier = Modifier.padding(20.dp)) {
|
||||
Text(stringResource(R.string.current_settings), style = MaterialTheme.typography.titleSmall)
|
||||
Spacer(Modifier.height(12.dp))
|
||||
ConfigRow(stringResource(R.string.server), clientConfig.serverAddress)
|
||||
ConfigRow(stringResource(R.string.server), clientConfig.serverAddress.redact(privacyMode))
|
||||
ConfigRow(stringResource(R.string.threads), "${clientConfig.threads}")
|
||||
ConfigRow(stringResource(R.string.transport_protocol), if (clientConfig.useUdp) stringResource(R.string.udp) else stringResource(R.string.tcp))
|
||||
ConfigRow(stringResource(R.string.local_port), clientConfig.localPort)
|
||||
ConfigRow(stringResource(R.string.local_port), clientConfig.localPort.redact(privacyMode))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,7 +247,7 @@ fun HomeScreen(
|
||||
Spacer(Modifier.width(8.dp))
|
||||
Text(
|
||||
when (sshState) {
|
||||
is SshConnectionState.Connected -> "SSH: ${(sshState as SshConnectionState.Connected).ip}"
|
||||
is SshConnectionState.Connected -> "SSH: ${(sshState as SshConnectionState.Connected).ip.redact(privacyMode)}"
|
||||
is SshConnectionState.Connecting -> stringResource(R.string.ssh_connecting)
|
||||
is SshConnectionState.Error -> stringResource(R.string.ssh_error)
|
||||
else -> stringResource(R.string.ssh_disconnected)
|
||||
@@ -284,6 +285,8 @@ fun HomeScreen(
|
||||
InfoBottomSheet(
|
||||
viewModel = viewModel,
|
||||
containerColor = sheetColor,
|
||||
privacyMode = privacyMode,
|
||||
onPrivacyModeChange = { viewModel.setPrivacyMode(it) },
|
||||
onNavigateToSshSetup = {
|
||||
showBottomSheet.value = false
|
||||
onNavigateToSshSetup()
|
||||
@@ -360,6 +363,8 @@ private fun ProxyToggleButton(state: ProxyState, onClick: () -> Unit) {
|
||||
private fun InfoBottomSheet(
|
||||
viewModel: MainViewModel,
|
||||
containerColor: Color,
|
||||
privacyMode: Boolean,
|
||||
onPrivacyModeChange: (Boolean) -> Unit,
|
||||
onNavigateToSshSetup: () -> Unit
|
||||
) {
|
||||
val context = LocalContext.current
|
||||
@@ -390,7 +395,7 @@ private fun InfoBottomSheet(
|
||||
Text(
|
||||
when (sshState) {
|
||||
is SshConnectionState.Connected ->
|
||||
stringResource(R.string.connected_format, (sshState as SshConnectionState.Connected).ip)
|
||||
stringResource(R.string.connected_format, (sshState as SshConnectionState.Connected).ip.redact(privacyMode))
|
||||
is SshConnectionState.Connecting ->
|
||||
stringResource(R.string.ssh_connecting)
|
||||
is SshConnectionState.Error ->
|
||||
@@ -443,6 +448,20 @@ private fun InfoBottomSheet(
|
||||
item { HorizontalDivider() }
|
||||
|
||||
// ── Настройки интерфейса ──────────────────────────────────────────
|
||||
item {
|
||||
ListItem(
|
||||
headlineContent = { Text(stringResource(R.string.privacy_mode_title)) },
|
||||
supportingContent = { Text(stringResource(R.string.privacy_mode_desc)) },
|
||||
colors = listColors,
|
||||
trailingContent = {
|
||||
androidx.compose.material3.Switch(
|
||||
checked = privacyMode,
|
||||
onCheckedChange = onPrivacyModeChange
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
item {
|
||||
ListItem(
|
||||
headlineContent = { Text(stringResource(R.string.dynamic_theme_title)) },
|
||||
@@ -557,6 +576,8 @@ private fun RepoLinkItem(
|
||||
}
|
||||
|
||||
|
||||
internal fun String.redact(enabled: Boolean) = if (enabled) "••••••" else this
|
||||
|
||||
@Composable
|
||||
private fun ConfigRow(label: String, value: String) {
|
||||
Row(
|
||||
|
||||
@@ -78,6 +78,7 @@ fun ServerManagementScreen(
|
||||
val savedListen by viewModel.proxyListen.collectAsStateWithLifecycle()
|
||||
val savedConnect by viewModel.proxyConnect.collectAsStateWithLifecycle()
|
||||
val sshLog by viewModel.sshLog.collectAsStateWithLifecycle()
|
||||
val privacyMode by viewModel.privacyMode.collectAsStateWithLifecycle()
|
||||
|
||||
var proxyListenPort by rememberSaveable(savedListen) { mutableStateOf(savedListen.substringAfterLast(":", "56000")) }
|
||||
var proxyConnect by rememberSaveable(savedConnect) { mutableStateOf(savedConnect) }
|
||||
@@ -93,7 +94,7 @@ fun ServerManagementScreen(
|
||||
TopAppBar(
|
||||
title = { Text(stringResource(R.string.server)) },
|
||||
actions = {
|
||||
SshStatusBadge(sshState = sshState, ip = sshConfig.ip)
|
||||
SshStatusBadge(sshState = sshState, ip = sshConfig.ip.redact(privacyMode))
|
||||
}
|
||||
)
|
||||
},
|
||||
|
||||
@@ -82,6 +82,11 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
|
||||
viewModelScope.launch { prefs.setDynamicTheme(enabled) }
|
||||
}
|
||||
|
||||
private val _privacyMode = MutableStateFlow(false)
|
||||
val privacyMode: StateFlow<Boolean> = _privacyMode.asStateFlow()
|
||||
|
||||
fun setPrivacyMode(enabled: Boolean) { _privacyMode.value = enabled }
|
||||
|
||||
// ── SSH ────────────────────────────────────────────────────────────────
|
||||
fun connectSsh(config: SshConfig) {
|
||||
viewModelScope.launch {
|
||||
|
||||
@@ -123,4 +123,6 @@
|
||||
|
||||
<string name="dynamic_theme_title">Динамическая тема</string>
|
||||
<string name="dynamic_theme_desc">Использовать системные цвета (Material You)</string>
|
||||
<string name="privacy_mode_title">Приватный режим</string>
|
||||
<string name="privacy_mode_desc">Скрывает IP и порты</string>
|
||||
</resources>
|
||||
Reference in new issue
Block a user