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 proxyListen by viewModel.proxyListen.collectAsStateWithLifecycle()
|
||||||
val customKernelExists by viewModel.customKernelExists.collectAsStateWithLifecycle()
|
val customKernelExists by viewModel.customKernelExists.collectAsStateWithLifecycle()
|
||||||
val kernelError by viewModel.kernelError.collectAsStateWithLifecycle()
|
val kernelError by viewModel.kernelError.collectAsStateWithLifecycle()
|
||||||
|
val privacyMode by viewModel.privacyMode.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
|
|
||||||
@@ -134,35 +135,36 @@ fun ClientSetupScreen(
|
|||||||
Text(stringResource(R.string.connection_title), style = MaterialTheme.typography.titleMedium)
|
Text(stringResource(R.string.connection_title), style = MaterialTheme.typography.titleMedium)
|
||||||
|
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
value = serverAddress,
|
value = serverAddress.redact(privacyMode),
|
||||||
onValueChange = { serverAddress = it },
|
onValueChange = { if (!privacyMode) serverAddress = it },
|
||||||
label = { Text(stringResource(R.string.server_address_label)) },
|
label = { Text(stringResource(R.string.server_address_label)) },
|
||||||
placeholder = { Text(stringResource(R.string.server_address_placeholder)) },
|
placeholder = { Text(stringResource(R.string.server_address_placeholder)) },
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
singleLine = true,
|
singleLine = true,
|
||||||
|
readOnly = privacyMode,
|
||||||
supportingText = { Text(stringResource(R.string.server_address_support)) }
|
supportingText = { Text(stringResource(R.string.server_address_support)) }
|
||||||
)
|
)
|
||||||
|
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
value = vkLink,
|
value = vkLink.redact(privacyMode),
|
||||||
onValueChange = { vkLink = it },
|
onValueChange = { if (!privacyMode) vkLink = it },
|
||||||
label = { Text(stringResource(R.string.vk_link_label)) },
|
label = { Text(stringResource(R.string.vk_link_label)) },
|
||||||
placeholder = { Text(stringResource(R.string.vk_link_placeholder)) },
|
placeholder = { Text(stringResource(R.string.vk_link_placeholder)) },
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
singleLine = true,
|
singleLine = true,
|
||||||
|
readOnly = privacyMode,
|
||||||
supportingText = { Text(stringResource(R.string.vk_link_support)) }
|
supportingText = { Text(stringResource(R.string.vk_link_support)) }
|
||||||
)
|
)
|
||||||
|
|
||||||
OutlinedTextField(
|
OutlinedTextField(
|
||||||
value = localPort,
|
value = localPort.redact(privacyMode),
|
||||||
onValueChange = { localPort = it },
|
onValueChange = { if (!privacyMode) localPort = it },
|
||||||
label = { Text(stringResource(R.string.local_listen_address)) },
|
label = { Text(stringResource(R.string.local_listen_address)) },
|
||||||
placeholder = { Text(stringResource(R.string.local_listen_placeholder)) },
|
placeholder = { Text(stringResource(R.string.local_listen_placeholder)) },
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
singleLine = true,
|
singleLine = true,
|
||||||
supportingText = {
|
readOnly = privacyMode,
|
||||||
Text(stringResource(R.string.local_listen_support))
|
supportingText = { Text(stringResource(R.string.local_listen_support)) }
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ fun HomeScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val privacyMode by viewModel.privacyMode.collectAsStateWithLifecycle()
|
||||||
val showBottomSheet = rememberSaveable { mutableStateOf(false) }
|
val showBottomSheet = rememberSaveable { mutableStateOf(false) }
|
||||||
val bottomSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
val bottomSheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
||||||
val snackbarHostState = remember { SnackbarHostState() }
|
val snackbarHostState = remember { SnackbarHostState() }
|
||||||
@@ -219,10 +220,10 @@ fun HomeScreen(
|
|||||||
Column(modifier = Modifier.padding(20.dp)) {
|
Column(modifier = Modifier.padding(20.dp)) {
|
||||||
Text(stringResource(R.string.current_settings), style = MaterialTheme.typography.titleSmall)
|
Text(stringResource(R.string.current_settings), style = MaterialTheme.typography.titleSmall)
|
||||||
Spacer(Modifier.height(12.dp))
|
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.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.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))
|
Spacer(Modifier.width(8.dp))
|
||||||
Text(
|
Text(
|
||||||
when (sshState) {
|
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.Connecting -> stringResource(R.string.ssh_connecting)
|
||||||
is SshConnectionState.Error -> stringResource(R.string.ssh_error)
|
is SshConnectionState.Error -> stringResource(R.string.ssh_error)
|
||||||
else -> stringResource(R.string.ssh_disconnected)
|
else -> stringResource(R.string.ssh_disconnected)
|
||||||
@@ -284,6 +285,8 @@ fun HomeScreen(
|
|||||||
InfoBottomSheet(
|
InfoBottomSheet(
|
||||||
viewModel = viewModel,
|
viewModel = viewModel,
|
||||||
containerColor = sheetColor,
|
containerColor = sheetColor,
|
||||||
|
privacyMode = privacyMode,
|
||||||
|
onPrivacyModeChange = { viewModel.setPrivacyMode(it) },
|
||||||
onNavigateToSshSetup = {
|
onNavigateToSshSetup = {
|
||||||
showBottomSheet.value = false
|
showBottomSheet.value = false
|
||||||
onNavigateToSshSetup()
|
onNavigateToSshSetup()
|
||||||
@@ -360,6 +363,8 @@ private fun ProxyToggleButton(state: ProxyState, onClick: () -> Unit) {
|
|||||||
private fun InfoBottomSheet(
|
private fun InfoBottomSheet(
|
||||||
viewModel: MainViewModel,
|
viewModel: MainViewModel,
|
||||||
containerColor: Color,
|
containerColor: Color,
|
||||||
|
privacyMode: Boolean,
|
||||||
|
onPrivacyModeChange: (Boolean) -> Unit,
|
||||||
onNavigateToSshSetup: () -> Unit
|
onNavigateToSshSetup: () -> Unit
|
||||||
) {
|
) {
|
||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
@@ -390,7 +395,7 @@ private fun InfoBottomSheet(
|
|||||||
Text(
|
Text(
|
||||||
when (sshState) {
|
when (sshState) {
|
||||||
is SshConnectionState.Connected ->
|
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 ->
|
is SshConnectionState.Connecting ->
|
||||||
stringResource(R.string.ssh_connecting)
|
stringResource(R.string.ssh_connecting)
|
||||||
is SshConnectionState.Error ->
|
is SshConnectionState.Error ->
|
||||||
@@ -443,6 +448,20 @@ private fun InfoBottomSheet(
|
|||||||
item { HorizontalDivider() }
|
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 {
|
item {
|
||||||
ListItem(
|
ListItem(
|
||||||
headlineContent = { Text(stringResource(R.string.dynamic_theme_title)) },
|
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
|
@Composable
|
||||||
private fun ConfigRow(label: String, value: String) {
|
private fun ConfigRow(label: String, value: String) {
|
||||||
Row(
|
Row(
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ fun ServerManagementScreen(
|
|||||||
val savedListen by viewModel.proxyListen.collectAsStateWithLifecycle()
|
val savedListen by viewModel.proxyListen.collectAsStateWithLifecycle()
|
||||||
val savedConnect by viewModel.proxyConnect.collectAsStateWithLifecycle()
|
val savedConnect by viewModel.proxyConnect.collectAsStateWithLifecycle()
|
||||||
val sshLog by viewModel.sshLog.collectAsStateWithLifecycle()
|
val sshLog by viewModel.sshLog.collectAsStateWithLifecycle()
|
||||||
|
val privacyMode by viewModel.privacyMode.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
var proxyListenPort by rememberSaveable(savedListen) { mutableStateOf(savedListen.substringAfterLast(":", "56000")) }
|
var proxyListenPort by rememberSaveable(savedListen) { mutableStateOf(savedListen.substringAfterLast(":", "56000")) }
|
||||||
var proxyConnect by rememberSaveable(savedConnect) { mutableStateOf(savedConnect) }
|
var proxyConnect by rememberSaveable(savedConnect) { mutableStateOf(savedConnect) }
|
||||||
@@ -93,7 +94,7 @@ fun ServerManagementScreen(
|
|||||||
TopAppBar(
|
TopAppBar(
|
||||||
title = { Text(stringResource(R.string.server)) },
|
title = { Text(stringResource(R.string.server)) },
|
||||||
actions = {
|
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) }
|
viewModelScope.launch { prefs.setDynamicTheme(enabled) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val _privacyMode = MutableStateFlow(false)
|
||||||
|
val privacyMode: StateFlow<Boolean> = _privacyMode.asStateFlow()
|
||||||
|
|
||||||
|
fun setPrivacyMode(enabled: Boolean) { _privacyMode.value = enabled }
|
||||||
|
|
||||||
// ── SSH ────────────────────────────────────────────────────────────────
|
// ── SSH ────────────────────────────────────────────────────────────────
|
||||||
fun connectSsh(config: SshConfig) {
|
fun connectSsh(config: SshConfig) {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
|
|||||||
@@ -123,4 +123,6 @@
|
|||||||
|
|
||||||
<string name="dynamic_theme_title">Динамическая тема</string>
|
<string name="dynamic_theme_title">Динамическая тема</string>
|
||||||
<string name="dynamic_theme_desc">Использовать системные цвета (Material You)</string>
|
<string name="dynamic_theme_desc">Использовать системные цвета (Material You)</string>
|
||||||
|
<string name="privacy_mode_title">Приватный режим</string>
|
||||||
|
<string name="privacy_mode_desc">Скрывает IP и порты</string>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in new issue
Block a user