feat: logs screen, bottom sheet cleanup, wavy indicators, dynamic notification
This commit is contained in:
1 parent
d34edfe9c9
commit
d1237031b8
10 files changed
+309
-246
No files matched your search
@@ -2,6 +2,7 @@ package com.freeturn.app
|
|||||||
|
|
||||||
import android.app.NotificationChannel
|
import android.app.NotificationChannel
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
|
import android.app.PendingIntent
|
||||||
import android.app.Service
|
import android.app.Service
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
@@ -94,10 +95,15 @@ class ProxyService : Service() {
|
|||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
||||||
if (isRunning.value) return START_STICKY
|
if (isRunning.value) return START_STICKY
|
||||||
|
|
||||||
|
val openIntent = packageManager.getLaunchIntentForPackage(packageName)?.let {
|
||||||
|
PendingIntent.getActivity(this, 0, it, PendingIntent.FLAG_IMMUTABLE)
|
||||||
|
}
|
||||||
val notification = NotificationCompat.Builder(this, "ProxyChannel")
|
val notification = NotificationCompat.Builder(this, "ProxyChannel")
|
||||||
.setContentTitle("VK TURN Proxy")
|
.setContentTitle("VK TURN Proxy")
|
||||||
.setContentText("Работает в фоне")
|
.setContentText("Подключение...")
|
||||||
.setSmallIcon(android.R.drawable.ic_menu_preferences)
|
.setSmallIcon(android.R.drawable.ic_menu_preferences)
|
||||||
|
.setOngoing(true)
|
||||||
|
.setContentIntent(openIntent)
|
||||||
.build()
|
.build()
|
||||||
startForeground(1, notification)
|
startForeground(1, notification)
|
||||||
|
|
||||||
@@ -175,8 +181,10 @@ class ProxyService : Service() {
|
|||||||
if (lower.contains("panic") || lower.contains("fatal") ||
|
if (lower.contains("panic") || lower.contains("fatal") ||
|
||||||
lower.contains("rate limit")) {
|
lower.contains("rate limit")) {
|
||||||
startupResult.value = StartupResult.Failed(l)
|
startupResult.value = StartupResult.Failed(l)
|
||||||
|
updateNotification("VK TURN Proxy", "Ошибка подключения")
|
||||||
} else {
|
} else {
|
||||||
startupResult.value = StartupResult.Success
|
startupResult.value = StartupResult.Success
|
||||||
|
updateNotification("VK TURN Proxy", "Прокси активен")
|
||||||
}
|
}
|
||||||
startupEmitted = true
|
startupEmitted = true
|
||||||
}
|
}
|
||||||
@@ -243,6 +251,7 @@ class ProxyService : Service() {
|
|||||||
val jitter = Random.nextLong(0, 500)
|
val jitter = Random.nextLong(0, 500)
|
||||||
val delay = baseDelay + jitter
|
val delay = baseDelay + jitter
|
||||||
addLog("=== WATCHDOG: перезапуск через ${delay}мс (попытка $restartCount/$MAX_RESTARTS) ===")
|
addLog("=== WATCHDOG: перезапуск через ${delay}мс (попытка $restartCount/$MAX_RESTARTS) ===")
|
||||||
|
updateNotification("VK TURN Proxy", "Переподключение ($restartCount/$MAX_RESTARTS)...")
|
||||||
handler.postDelayed({
|
handler.postDelayed({
|
||||||
// Проверка userStopped + запуск через serviceScope вместо thread {}
|
// Проверка userStopped + запуск через serviceScope вместо thread {}
|
||||||
if (!userStopped.get()) serviceScope.launch { startBinaryProcess() }
|
if (!userStopped.get()) serviceScope.launch { startBinaryProcess() }
|
||||||
@@ -262,6 +271,7 @@ class ProxyService : Service() {
|
|||||||
}
|
}
|
||||||
if (!userStopped.get() && process.get() != null) {
|
if (!userStopped.get() && process.get() != null) {
|
||||||
addLog("=== СМЕНА СЕТИ — ПЕРЕЗАПУСК ===")
|
addLog("=== СМЕНА СЕТИ — ПЕРЕЗАПУСК ===")
|
||||||
|
updateNotification("VK TURN Proxy", "Смена сети, переподключение...")
|
||||||
restartCount = 0
|
restartCount = 0
|
||||||
// P2-5: destroyForcibly()
|
// P2-5: destroyForcibly()
|
||||||
process.get()?.destroyForcibly()
|
process.get()?.destroyForcibly()
|
||||||
@@ -282,6 +292,22 @@ class ProxyService : Service() {
|
|||||||
networkCallback = null
|
networkCallback = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Notification ─────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
private fun updateNotification(title: String, text: String) {
|
||||||
|
val openIntent = packageManager.getLaunchIntentForPackage(packageName)?.let {
|
||||||
|
PendingIntent.getActivity(this, 0, it, PendingIntent.FLAG_IMMUTABLE)
|
||||||
|
}
|
||||||
|
val notification = NotificationCompat.Builder(this, "ProxyChannel")
|
||||||
|
.setContentTitle(title)
|
||||||
|
.setContentText(text)
|
||||||
|
.setSmallIcon(android.R.drawable.ic_menu_preferences)
|
||||||
|
.setOngoing(true)
|
||||||
|
.setContentIntent(openIntent)
|
||||||
|
.build()
|
||||||
|
getSystemService(NotificationManager::class.java).notify(1, notification)
|
||||||
|
}
|
||||||
|
|
||||||
// ── Helpers ───────────────────────────────────────────────────────────────
|
// ── Helpers ───────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
private fun isQuotaError(line: String): Boolean {
|
private fun isQuotaError(line: String): Boolean {
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ import androidx.navigation.compose.rememberNavController
|
|||||||
import com.freeturn.app.ui.HapticUtil
|
import com.freeturn.app.ui.HapticUtil
|
||||||
import com.freeturn.app.ui.screens.ClientSetupScreen
|
import com.freeturn.app.ui.screens.ClientSetupScreen
|
||||||
import com.freeturn.app.ui.screens.HomeScreen
|
import com.freeturn.app.ui.screens.HomeScreen
|
||||||
|
import com.freeturn.app.ui.screens.LogsScreen
|
||||||
import com.freeturn.app.ui.screens.OnboardingScreen
|
import com.freeturn.app.ui.screens.OnboardingScreen
|
||||||
import com.freeturn.app.ui.screens.ServerManagementScreen
|
import com.freeturn.app.ui.screens.ServerManagementScreen
|
||||||
import com.freeturn.app.ui.screens.SshSetupScreen
|
import com.freeturn.app.ui.screens.SshSetupScreen
|
||||||
@@ -60,10 +61,11 @@ object Routes {
|
|||||||
const val CLIENT_SETUP = "client_setup"
|
const val CLIENT_SETUP = "client_setup"
|
||||||
const val CLIENT_SETUP_OB = "client_setup_onboarding"
|
const val CLIENT_SETUP_OB = "client_setup_onboarding"
|
||||||
const val HOME = "home"
|
const val HOME = "home"
|
||||||
|
const val LOGS = "logs"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Нижнее меню видно только в основном потоке, не во время онбординга
|
// Нижнее меню видно только в основном потоке, не во время онбординга
|
||||||
private val BOTTOM_NAV_ROUTES = setOf(Routes.HOME, Routes.SERVER_MANAGEMENT, Routes.CLIENT_SETUP)
|
private val BOTTOM_NAV_ROUTES = setOf(Routes.HOME, Routes.LOGS, Routes.SERVER_MANAGEMENT, Routes.CLIENT_SETUP)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun AppNavigation(viewModel: MainViewModel) {
|
fun AppNavigation(viewModel: MainViewModel) {
|
||||||
@@ -121,7 +123,10 @@ fun AppNavigation(viewModel: MainViewModel) {
|
|||||||
onSetupServer = { navController.navigate(Routes.SSH_SETUP_OB) },
|
onSetupServer = { navController.navigate(Routes.SSH_SETUP_OB) },
|
||||||
onSkip = {
|
onSkip = {
|
||||||
viewModel.setOnboardingDone()
|
viewModel.setOnboardingDone()
|
||||||
navController.navigate(Routes.HOME)
|
navController.navigate(Routes.HOME) {
|
||||||
|
popUpTo(navController.graph.startDestinationId) { inclusive = true }
|
||||||
|
launchSingleTop = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -157,7 +162,8 @@ fun AppNavigation(viewModel: MainViewModel) {
|
|||||||
onFinish = {
|
onFinish = {
|
||||||
viewModel.setOnboardingDone()
|
viewModel.setOnboardingDone()
|
||||||
navController.navigate(Routes.HOME) {
|
navController.navigate(Routes.HOME) {
|
||||||
popUpTo(Routes.ONBOARDING) { inclusive = true }
|
popUpTo(navController.graph.startDestinationId) { inclusive = true }
|
||||||
|
launchSingleTop = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -206,6 +212,10 @@ fun AppNavigation(viewModel: MainViewModel) {
|
|||||||
onNavigateToClientSetup = { navController.navigate(Routes.CLIENT_SETUP) }
|
onNavigateToClientSetup = { navController.navigate(Routes.CLIENT_SETUP) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
composable(Routes.LOGS) {
|
||||||
|
LogsScreen(viewModel = viewModel)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -284,7 +294,8 @@ private data class NavItem(
|
|||||||
private val navItems = listOf(
|
private val navItems = listOf(
|
||||||
NavItem(Routes.HOME, "Главная", R.drawable.home_24px, R.drawable.home_outlined_24px),
|
NavItem(Routes.HOME, "Главная", R.drawable.home_24px, R.drawable.home_outlined_24px),
|
||||||
NavItem(Routes.SERVER_MANAGEMENT, "Сервер", R.drawable.database_24px, R.drawable.database_outlined_24px),
|
NavItem(Routes.SERVER_MANAGEMENT, "Сервер", R.drawable.database_24px, R.drawable.database_outlined_24px),
|
||||||
NavItem(Routes.CLIENT_SETUP, "Клиент", R.drawable.mobile_24px, R.drawable.mobile_outlined_24px)
|
NavItem(Routes.CLIENT_SETUP, "Клиент", R.drawable.mobile_24px, R.drawable.mobile_outlined_24px),
|
||||||
|
NavItem(Routes.LOGS, "Логи", R.drawable.terminal_24px, R.drawable.terminal_24px)
|
||||||
)
|
)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|||||||
@@ -144,6 +144,18 @@ fun ClientSetupScreen(
|
|||||||
supportingText = { Text("VK: Звонки → Создать → Скопировать ссылку (не нажимайте «Завершить»)") }
|
supportingText = { Text("VK: Звонки → Создать → Скопировать ссылку (не нажимайте «Завершить»)") }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
OutlinedTextField(
|
||||||
|
value = localPort,
|
||||||
|
onValueChange = { localPort = it },
|
||||||
|
label = { Text("Локальный адрес прослушивания") },
|
||||||
|
placeholder = { Text("127.0.0.1:9000") },
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
singleLine = true,
|
||||||
|
supportingText = {
|
||||||
|
Text("Адрес, на котором клиент принимает трафик от WireGuard/Hysteria")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
||||||
|
|
||||||
// ── Параметры ─────────────────────────────────────────────────
|
// ── Параметры ─────────────────────────────────────────────────
|
||||||
@@ -199,18 +211,6 @@ fun ClientSetupScreen(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
OutlinedTextField(
|
|
||||||
value = localPort,
|
|
||||||
onValueChange = { localPort = it },
|
|
||||||
label = { Text("Локальный адрес прослушивания") },
|
|
||||||
placeholder = { Text("127.0.0.1:9000") },
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
singleLine = true,
|
|
||||||
supportingText = {
|
|
||||||
Text("Адрес, на котором клиент принимает трафик от WireGuard/Hysteria")
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
HorizontalDivider(Modifier, DividerDefaults.Thickness, DividerDefaults.color)
|
||||||
|
|
||||||
// ── Ядро ──────────────────────────────────────────────────────
|
// ── Ядро ──────────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
@file:OptIn(androidx.compose.material3.ExperimentalMaterial3Api::class)
|
@file:OptIn(
|
||||||
|
androidx.compose.material3.ExperimentalMaterial3Api::class,
|
||||||
|
androidx.compose.material3.ExperimentalMaterial3ExpressiveApi::class
|
||||||
|
)
|
||||||
|
|
||||||
package com.freeturn.app.ui.screens
|
package com.freeturn.app.ui.screens
|
||||||
|
|
||||||
@@ -17,13 +20,11 @@ import androidx.compose.foundation.layout.Spacer
|
|||||||
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.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.foundation.lazy.itemsIndexed
|
import androidx.compose.foundation.layout.navigationBarsPadding
|
||||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.shape.CircleShape
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
@@ -33,7 +34,7 @@ import androidx.compose.material3.AlertDialog
|
|||||||
import androidx.compose.material3.ButtonDefaults
|
import androidx.compose.material3.ButtonDefaults
|
||||||
import androidx.compose.material3.Card
|
import androidx.compose.material3.Card
|
||||||
import androidx.compose.material3.CardDefaults
|
import androidx.compose.material3.CardDefaults
|
||||||
import androidx.compose.material3.CircularProgressIndicator
|
import androidx.compose.material3.CircularWavyProgressIndicator
|
||||||
import androidx.compose.material3.HorizontalDivider
|
import androidx.compose.material3.HorizontalDivider
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
@@ -51,11 +52,8 @@ import androidx.compose.material3.TopAppBar
|
|||||||
import androidx.compose.material3.rememberModalBottomSheetState
|
import androidx.compose.material3.rememberModalBottomSheetState
|
||||||
import android.Manifest
|
import android.Manifest
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.ClipData
|
|
||||||
import android.content.ClipboardManager
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.PowerManager
|
import android.os.PowerManager
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
@@ -98,7 +96,9 @@ fun HomeScreen(
|
|||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val proxyState by viewModel.proxyState.collectAsStateWithLifecycle()
|
val proxyState by viewModel.proxyState.collectAsStateWithLifecycle()
|
||||||
val sshState by viewModel.sshState.collectAsStateWithLifecycle()
|
val sshState by viewModel.sshState.collectAsStateWithLifecycle()
|
||||||
|
val sshConfig by viewModel.sshConfig.collectAsStateWithLifecycle()
|
||||||
val clientConfig by viewModel.clientConfig.collectAsStateWithLifecycle()
|
val clientConfig by viewModel.clientConfig.collectAsStateWithLifecycle()
|
||||||
|
val isConfigured = sshConfig.ip.isNotBlank()
|
||||||
|
|
||||||
// ── Запрос разрешений при первом открытии главного экрана ─────────────
|
// ── Запрос разрешений при первом открытии главного экрана ─────────────
|
||||||
val batteryOptLauncher = rememberLauncherForActivityResult(
|
val batteryOptLauncher = rememberLauncherForActivityResult(
|
||||||
@@ -205,6 +205,7 @@ fun HomeScreen(
|
|||||||
textAlign = TextAlign.Center
|
textAlign = TextAlign.Center
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (isConfigured) {
|
||||||
Spacer(Modifier.height(40.dp))
|
Spacer(Modifier.height(40.dp))
|
||||||
|
|
||||||
Card(
|
Card(
|
||||||
@@ -216,18 +217,10 @@ fun HomeScreen(
|
|||||||
Column(modifier = Modifier.padding(20.dp)) {
|
Column(modifier = Modifier.padding(20.dp)) {
|
||||||
Text("Текущие настройки", style = MaterialTheme.typography.titleSmall)
|
Text("Текущие настройки", style = MaterialTheme.typography.titleSmall)
|
||||||
Spacer(Modifier.height(12.dp))
|
Spacer(Modifier.height(12.dp))
|
||||||
if (clientConfig.serverAddress.isNotBlank()) {
|
|
||||||
ConfigRow("Сервер", clientConfig.serverAddress)
|
ConfigRow("Сервер", clientConfig.serverAddress)
|
||||||
ConfigRow("Потоки", "${clientConfig.threads}")
|
ConfigRow("Потоки", "${clientConfig.threads}")
|
||||||
ConfigRow("UDP", if (clientConfig.useUdp) "Вкл" else "Выкл")
|
ConfigRow("UDP", if (clientConfig.useUdp) "Вкл" else "Выкл")
|
||||||
ConfigRow("Локальный порт", clientConfig.localPort)
|
ConfigRow("Локальный порт", clientConfig.localPort)
|
||||||
} else {
|
|
||||||
Text(
|
|
||||||
"Не настроено. Перейдите в раздел «Клиент».",
|
|
||||||
style = MaterialTheme.typography.bodySmall,
|
|
||||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.5f)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,6 +265,7 @@ fun HomeScreen(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Spacer(Modifier.height(32.dp))
|
Spacer(Modifier.height(32.dp))
|
||||||
}
|
}
|
||||||
@@ -340,7 +334,7 @@ private fun ProxyToggleButton(state: ProxyState, onClick: () -> Unit) {
|
|||||||
verticalArrangement = Arrangement.Center
|
verticalArrangement = Arrangement.Center
|
||||||
) {
|
) {
|
||||||
when (state) {
|
when (state) {
|
||||||
is ProxyState.Starting -> CircularProgressIndicator(color = contentColor)
|
is ProxyState.Starting -> CircularWavyProgressIndicator(color = contentColor)
|
||||||
is ProxyState.Running -> Icon(
|
is ProxyState.Running -> Icon(
|
||||||
painterResource(R.drawable.check_circle_24px), null,
|
painterResource(R.drawable.check_circle_24px), null,
|
||||||
Modifier.size(52.dp), tint = contentColor
|
Modifier.size(52.dp), tint = contentColor
|
||||||
@@ -367,8 +361,6 @@ private fun InfoBottomSheet(
|
|||||||
val context = LocalContext.current
|
val context = LocalContext.current
|
||||||
val uriHandler = LocalUriHandler.current
|
val uriHandler = LocalUriHandler.current
|
||||||
val sshState by viewModel.sshState.collectAsStateWithLifecycle()
|
val sshState by viewModel.sshState.collectAsStateWithLifecycle()
|
||||||
val logs by viewModel.logs.collectAsStateWithLifecycle()
|
|
||||||
var showLogs by rememberSaveable { mutableStateOf(false) }
|
|
||||||
var showResetDialog by rememberSaveable { mutableStateOf(false) }
|
var showResetDialog by rememberSaveable { mutableStateOf(false) }
|
||||||
|
|
||||||
val appVersion = remember {
|
val appVersion = remember {
|
||||||
@@ -376,30 +368,19 @@ private fun InfoBottomSheet(
|
|||||||
catch (_: Exception) { "—" }
|
catch (_: Exception) { "—" }
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.padding(bottom = 16.dp)
|
|
||||||
.verticalScroll(rememberScrollState())
|
|
||||||
) {
|
|
||||||
// ── SSH ────────────────────────────────────────────────────────────
|
|
||||||
val isConnected = sshState is SshConnectionState.Connected
|
val isConnected = sshState is SshConnectionState.Connected
|
||||||
val listColors = ListItemDefaults.colors(containerColor = containerColor)
|
val listColors = ListItemDefaults.colors(containerColor = containerColor)
|
||||||
|
|
||||||
|
LazyColumn(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.navigationBarsPadding()
|
||||||
|
) {
|
||||||
|
// ── Соединение ────────────────────────────────────────────────────
|
||||||
|
item {
|
||||||
ListItem(
|
ListItem(
|
||||||
headlineContent = { Text("Соединение", style = MaterialTheme.typography.titleSmall) },
|
headlineContent = { Text("Соединение", style = MaterialTheme.typography.titleSmall) },
|
||||||
colors = listColors,
|
colors = listColors,
|
||||||
trailingContent = {
|
|
||||||
TextButton(onClick = {
|
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
|
||||||
onNavigateToSshSetup()
|
|
||||||
}) { Text(if (isConnected) "Изменить" else "Настроить") }
|
|
||||||
}
|
|
||||||
)
|
|
||||||
HorizontalDivider()
|
|
||||||
|
|
||||||
ListItem(
|
|
||||||
headlineContent = { Text("SSH-статус") },
|
|
||||||
colors = listColors,
|
|
||||||
supportingContent = {
|
supportingContent = {
|
||||||
Text(
|
Text(
|
||||||
when (sshState) {
|
when (sshState) {
|
||||||
@@ -415,88 +396,35 @@ private fun InfoBottomSheet(
|
|||||||
},
|
},
|
||||||
trailingContent = {
|
trailingContent = {
|
||||||
if (isConnected) {
|
if (isConnected) {
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
|
||||||
Box(Modifier.size(10.dp).background(StatusGreen, CircleShape))
|
|
||||||
TextButton(onClick = {
|
TextButton(onClick = {
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||||
viewModel.disconnectSsh()
|
onNavigateToSshSetup()
|
||||||
}) { Text("Отключить") }
|
}) { Text("Изменить") }
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
IconButton(onClick = {
|
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
|
||||||
viewModel.reconnectSsh()
|
|
||||||
}) {
|
|
||||||
Icon(painterResource(R.drawable.refresh_24px), contentDescription = "Переподключить")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
HorizontalDivider()
|
|
||||||
|
|
||||||
// ── Логи ──────────────────────────────────────────────────────────
|
|
||||||
ListItem(
|
|
||||||
headlineContent = { Text("Логи", style = MaterialTheme.typography.titleSmall) },
|
|
||||||
colors = listColors,
|
|
||||||
trailingContent = {
|
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
|
||||||
IconButton(
|
|
||||||
onClick = {
|
|
||||||
val cm = context.getSystemService(ClipboardManager::class.java)
|
|
||||||
cm.setPrimaryClip(ClipData.newPlainText("proxy_logs", logs.joinToString("\n")))
|
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.SUCCESS)
|
|
||||||
},
|
|
||||||
enabled = logs.isNotEmpty()
|
|
||||||
) {
|
|
||||||
Icon(painterResource(R.drawable.content_copy_24px), contentDescription = "Копировать логи", modifier = Modifier.size(18.dp))
|
|
||||||
}
|
|
||||||
TextButton(onClick = {
|
TextButton(onClick = {
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||||
viewModel.clearLogs()
|
onNavigateToSshSetup()
|
||||||
}) { Text("Очистить") }
|
}) { Text("Настроить") }
|
||||||
TextButton(onClick = {
|
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.SELECTION)
|
|
||||||
showLogs = !showLogs
|
|
||||||
}) {
|
|
||||||
Text(if (showLogs) "Скрыть" else "Показать")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (showLogs) {
|
|
||||||
LogsPanel(
|
|
||||||
logs = logs,
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.padding(horizontal = 16.dp, vertical = 4.dp)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HorizontalDivider()
|
item { HorizontalDivider() }
|
||||||
|
|
||||||
// ── О приложении ───────────────────────────────────────────────────
|
|
||||||
ListItem(
|
|
||||||
headlineContent = { Text("О приложении", style = MaterialTheme.typography.titleSmall) },
|
|
||||||
colors = listColors
|
|
||||||
)
|
|
||||||
|
|
||||||
ListItem(
|
|
||||||
headlineContent = { Text("FreeTurn") },
|
|
||||||
colors = listColors,
|
|
||||||
supportingContent = { Text("Версия $appVersion") }
|
|
||||||
)
|
|
||||||
|
|
||||||
|
// ── Ссылки ────────────────────────────────────────────────────────
|
||||||
|
item {
|
||||||
RepoLinkItem(
|
RepoLinkItem(
|
||||||
title = "Android-клиент",
|
title = "Android-клиент",
|
||||||
subtitle = "Fork MYSOREZ/vk-turn-proxy-android",
|
subtitle = "antongospod/turn-proxy",
|
||||||
url = "https://github.com/MYSOREZ/vk-turn-proxy-android",
|
url = "https://github.com/antongospod/turn-proxy",
|
||||||
containerColor = containerColor,
|
containerColor = containerColor,
|
||||||
onHaptic = { HapticUtil.perform(context, HapticUtil.Pattern.SELECTION) },
|
onHaptic = { HapticUtil.perform(context, HapticUtil.Pattern.SELECTION) },
|
||||||
onOpen = { uriHandler.openUri(it) }
|
onOpen = { uriHandler.openUri(it) }
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
RepoLinkItem(
|
RepoLinkItem(
|
||||||
title = "Прокси-ядро",
|
title = "Прокси-ядро",
|
||||||
subtitle = "cacggghp/vk-turn-proxy",
|
subtitle = "cacggghp/vk-turn-proxy",
|
||||||
@@ -505,26 +433,49 @@ private fun InfoBottomSheet(
|
|||||||
onHaptic = { HapticUtil.perform(context, HapticUtil.Pattern.SELECTION) },
|
onHaptic = { HapticUtil.perform(context, HapticUtil.Pattern.SELECTION) },
|
||||||
onOpen = { uriHandler.openUri(it) }
|
onOpen = { uriHandler.openUri(it) }
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
HorizontalDivider()
|
item { HorizontalDivider() }
|
||||||
|
|
||||||
// ── Сброс ─────────────────────────────────────────────────────────
|
// ── Сброс ─────────────────────────────────────────────────────────
|
||||||
|
item {
|
||||||
ListItem(
|
ListItem(
|
||||||
headlineContent = { Text("Сбросить настройки") },
|
headlineContent = {
|
||||||
|
Text(
|
||||||
|
"Сбросить настройки",
|
||||||
|
style = MaterialTheme.typography.titleSmall,
|
||||||
|
color = MaterialTheme.colorScheme.error
|
||||||
|
)
|
||||||
|
},
|
||||||
colors = listColors,
|
colors = listColors,
|
||||||
supportingContent = { Text("SSH, клиент, прокси и кастомное ядро") },
|
|
||||||
trailingContent = {
|
trailingContent = {
|
||||||
TextButton(
|
Icon(
|
||||||
onClick = {
|
painterResource(R.drawable.delete_24px),
|
||||||
|
contentDescription = "Сбросить",
|
||||||
|
modifier = Modifier.size(20.dp),
|
||||||
|
tint = MaterialTheme.colorScheme.error
|
||||||
|
)
|
||||||
|
},
|
||||||
|
modifier = Modifier.clickable {
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||||
showResetDialog = true
|
showResetDialog = true
|
||||||
},
|
|
||||||
colors = ButtonDefaults.textButtonColors(
|
|
||||||
contentColor = MaterialTheme.colorScheme.error
|
|
||||||
)
|
|
||||||
) { Text("Сбросить") }
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Версия ────────────────────────────────────────────────────────
|
||||||
|
item {
|
||||||
|
Text(
|
||||||
|
text = "v$appVersion",
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(vertical = 16.dp),
|
||||||
|
textAlign = TextAlign.Center,
|
||||||
|
style = MaterialTheme.typography.labelSmall,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (showResetDialog) {
|
if (showResetDialog) {
|
||||||
AlertDialog(
|
AlertDialog(
|
||||||
@@ -547,7 +498,6 @@ private fun InfoBottomSheet(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@@ -584,92 +534,6 @@ private fun RepoLinkItem(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun LogsPanel(logs: List<String>, modifier: Modifier = Modifier) {
|
|
||||||
val listState = rememberLazyListState()
|
|
||||||
LaunchedEffect(logs.size) {
|
|
||||||
if (logs.isNotEmpty()) listState.animateScrollToItem(logs.lastIndex)
|
|
||||||
}
|
|
||||||
Card(
|
|
||||||
modifier = modifier,
|
|
||||||
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant)
|
|
||||||
) {
|
|
||||||
if (logs.isEmpty()) {
|
|
||||||
Text(
|
|
||||||
"Нет логов",
|
|
||||||
modifier = Modifier.padding(horizontal = 12.dp, vertical = 8.dp),
|
|
||||||
style = MaterialTheme.typography.bodySmall,
|
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.4f)
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
LazyColumn(
|
|
||||||
state = listState,
|
|
||||||
modifier = Modifier
|
|
||||||
.heightIn(max = 320.dp)
|
|
||||||
.padding(vertical = 8.dp)
|
|
||||||
) {
|
|
||||||
itemsIndexed(logs) { index, line ->
|
|
||||||
LogLine(line = line, isEven = index % 2 == 0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun LogLine(line: String, isEven: Boolean) {
|
|
||||||
val lower = line.lowercase()
|
|
||||||
val isHeader = line.startsWith("===")
|
|
||||||
val isError = lower.contains("ошибка") || lower.contains("error") ||
|
|
||||||
lower.contains("критическая") || lower.contains("failed") ||
|
|
||||||
lower.contains("fatal") || lower.contains("panic")
|
|
||||||
val isWarning = lower.contains("watchdog") || lower.contains("перезапуск") ||
|
|
||||||
lower.contains("quota") || lower.contains("warn") ||
|
|
||||||
lower.contains(">>>")
|
|
||||||
val isSuccess = lower.contains("запущен") || lower.contains("подключен") ||
|
|
||||||
lower.contains("success") || lower.contains("started") ||
|
|
||||||
lower.contains("ok")
|
|
||||||
|
|
||||||
val textColor = when {
|
|
||||||
isError -> MaterialTheme.colorScheme.error
|
|
||||||
isWarning -> androidx.compose.ui.graphics.Color(0xFFE67E22)
|
|
||||||
isSuccess -> StatusGreen
|
|
||||||
isHeader -> MaterialTheme.colorScheme.primary
|
|
||||||
else -> MaterialTheme.colorScheme.onSurfaceVariant
|
|
||||||
}
|
|
||||||
val bgColor = if (isEven)
|
|
||||||
MaterialTheme.colorScheme.surfaceVariant
|
|
||||||
else
|
|
||||||
MaterialTheme.colorScheme.surfaceVariant.copy(alpha = 0.6f)
|
|
||||||
|
|
||||||
Row(
|
|
||||||
modifier = Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.background(bgColor)
|
|
||||||
.padding(horizontal = 12.dp, vertical = 3.dp),
|
|
||||||
verticalAlignment = Alignment.Top
|
|
||||||
) {
|
|
||||||
if (isHeader || isError || isWarning || isSuccess) {
|
|
||||||
Box(
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(top = 5.dp, end = 6.dp)
|
|
||||||
.size(5.dp)
|
|
||||||
.background(textColor, CircleShape)
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
Spacer(Modifier.width(11.dp))
|
|
||||||
}
|
|
||||||
Text(
|
|
||||||
text = line,
|
|
||||||
style = MaterialTheme.typography.bodySmall.copy(
|
|
||||||
fontFamily = androidx.compose.ui.text.font.FontFamily.Monospace,
|
|
||||||
fontWeight = if (isHeader) androidx.compose.ui.text.font.FontWeight.SemiBold
|
|
||||||
else androidx.compose.ui.text.font.FontWeight.Normal
|
|
||||||
),
|
|
||||||
color = textColor
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun ConfigRow(label: String, value: String) {
|
private fun ConfigRow(label: String, value: String) {
|
||||||
|
|||||||
@@ -0,0 +1,161 @@
|
|||||||
|
@file:OptIn(androidx.compose.material3.ExperimentalMaterial3Api::class)
|
||||||
|
|
||||||
|
package com.freeturn.app.ui.screens
|
||||||
|
|
||||||
|
import android.content.ClipData
|
||||||
|
import android.content.ClipboardManager
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.layout.width
|
||||||
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
|
import androidx.compose.foundation.lazy.itemsIndexed
|
||||||
|
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||||
|
import androidx.compose.foundation.shape.CircleShape
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.IconButton
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Scaffold
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.TopAppBar
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
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.text.font.FontFamily
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.text.style.TextAlign
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
|
import com.freeturn.app.R
|
||||||
|
import com.freeturn.app.ui.HapticUtil
|
||||||
|
import com.freeturn.app.ui.theme.StatusGreen
|
||||||
|
import com.freeturn.app.viewmodel.MainViewModel
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun LogsScreen(viewModel: MainViewModel) {
|
||||||
|
val context = LocalContext.current
|
||||||
|
val logs by viewModel.logs.collectAsStateWithLifecycle()
|
||||||
|
val listState = rememberLazyListState()
|
||||||
|
|
||||||
|
LaunchedEffect(logs.size) {
|
||||||
|
if (logs.isNotEmpty()) listState.animateScrollToItem(logs.lastIndex)
|
||||||
|
}
|
||||||
|
|
||||||
|
Scaffold(
|
||||||
|
topBar = {
|
||||||
|
TopAppBar(
|
||||||
|
title = { Text("Логи") },
|
||||||
|
actions = {
|
||||||
|
IconButton(
|
||||||
|
onClick = {
|
||||||
|
val cm = context.getSystemService(ClipboardManager::class.java)
|
||||||
|
cm.setPrimaryClip(ClipData.newPlainText("proxy_logs", logs.joinToString("\n")))
|
||||||
|
HapticUtil.perform(context, HapticUtil.Pattern.SUCCESS)
|
||||||
|
},
|
||||||
|
enabled = logs.isNotEmpty()
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
painterResource(R.drawable.content_copy_24px),
|
||||||
|
contentDescription = "Копировать"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
IconButton(
|
||||||
|
onClick = {
|
||||||
|
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
||||||
|
viewModel.clearLogs()
|
||||||
|
},
|
||||||
|
enabled = logs.isNotEmpty()
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
painterResource(R.drawable.delete_24px),
|
||||||
|
contentDescription = "Очистить"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
) { padding ->
|
||||||
|
if (logs.isEmpty()) {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.padding(padding),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
"Нет логов",
|
||||||
|
style = MaterialTheme.typography.bodyMedium,
|
||||||
|
color = MaterialTheme.colorScheme.onSurfaceVariant.copy(alpha = 0.4f)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LazyColumn(
|
||||||
|
state = listState,
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxSize()
|
||||||
|
.padding(padding)
|
||||||
|
) {
|
||||||
|
itemsIndexed(logs) { _, line ->
|
||||||
|
LogLine(line = line)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun LogLine(line: String) {
|
||||||
|
val lower = line.lowercase()
|
||||||
|
val isHeader = line.startsWith("===")
|
||||||
|
val isError = lower.contains("ошибка") || lower.contains("error") ||
|
||||||
|
lower.contains("критическая") || lower.contains("failed") ||
|
||||||
|
lower.contains("fatal") || lower.contains("panic")
|
||||||
|
val isWarning = lower.contains("watchdog") || lower.contains("перезапуск") ||
|
||||||
|
lower.contains("quota") || lower.contains("warn") ||
|
||||||
|
lower.contains(">>>")
|
||||||
|
val isSuccess = lower.contains("запущен") || lower.contains("подключен") ||
|
||||||
|
lower.contains("success") || lower.contains("started") ||
|
||||||
|
lower.contains("ok")
|
||||||
|
|
||||||
|
val textColor = when {
|
||||||
|
isError -> MaterialTheme.colorScheme.error
|
||||||
|
isWarning -> androidx.compose.ui.graphics.Color(0xFFE67E22)
|
||||||
|
isSuccess -> StatusGreen
|
||||||
|
isHeader -> MaterialTheme.colorScheme.primary
|
||||||
|
else -> MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
}
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(horizontal = 16.dp, vertical = 3.dp),
|
||||||
|
verticalAlignment = Alignment.Top
|
||||||
|
) {
|
||||||
|
if (isHeader || isError || isWarning || isSuccess) {
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(top = 5.dp, end = 6.dp)
|
||||||
|
.size(5.dp)
|
||||||
|
.background(textColor, CircleShape)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
Spacer(Modifier.width(11.dp))
|
||||||
|
}
|
||||||
|
Text(
|
||||||
|
text = line,
|
||||||
|
style = MaterialTheme.typography.bodySmall.copy(
|
||||||
|
fontFamily = FontFamily.Monospace,
|
||||||
|
fontWeight = if (isHeader) FontWeight.SemiBold else FontWeight.Normal
|
||||||
|
),
|
||||||
|
color = textColor
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
@file:OptIn(androidx.compose.material3.ExperimentalMaterial3ExpressiveApi::class)
|
||||||
|
|
||||||
package com.freeturn.app.ui.screens
|
package com.freeturn.app.ui.screens
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
@@ -31,7 +33,7 @@ import androidx.compose.material3.ExperimentalMaterial3Api
|
|||||||
import androidx.compose.material3.FilledTonalButton
|
import androidx.compose.material3.FilledTonalButton
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.LinearProgressIndicator
|
import androidx.compose.material3.LinearWavyProgressIndicator
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.OutlinedButton
|
import androidx.compose.material3.OutlinedButton
|
||||||
import androidx.compose.material3.OutlinedTextField
|
import androidx.compose.material3.OutlinedTextField
|
||||||
@@ -116,7 +118,7 @@ fun ServerManagementScreen(
|
|||||||
when (serverState) {
|
when (serverState) {
|
||||||
is ServerState.Checking -> {
|
is ServerState.Checking -> {
|
||||||
Spacer(Modifier.height(12.dp))
|
Spacer(Modifier.height(12.dp))
|
||||||
LinearProgressIndicator(modifier = Modifier.fillMaxWidth())
|
LinearWavyProgressIndicator(modifier = Modifier.fillMaxWidth())
|
||||||
}
|
}
|
||||||
is ServerState.Working -> {
|
is ServerState.Working -> {
|
||||||
Spacer(Modifier.height(12.dp))
|
Spacer(Modifier.height(12.dp))
|
||||||
@@ -126,7 +128,7 @@ fun ServerManagementScreen(
|
|||||||
color = MaterialTheme.colorScheme.secondary
|
color = MaterialTheme.colorScheme.secondary
|
||||||
)
|
)
|
||||||
Spacer(Modifier.height(6.dp))
|
Spacer(Modifier.height(6.dp))
|
||||||
LinearProgressIndicator(modifier = Modifier.fillMaxWidth())
|
LinearWavyProgressIndicator(modifier = Modifier.fillMaxWidth())
|
||||||
}
|
}
|
||||||
is ServerState.Error -> {
|
is ServerState.Error -> {
|
||||||
Spacer(Modifier.height(12.dp))
|
Spacer(Modifier.height(12.dp))
|
||||||
@@ -238,33 +240,10 @@ fun ServerManagementScreen(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ── SSH-лог (вывод всех команд) ────────────────────────────────
|
// ── SSH-лог (вывод всех команд) ────────────────────────────────
|
||||||
|
if (sshLog.isNotEmpty()) {
|
||||||
Card(modifier = Modifier.fillMaxWidth()) {
|
Card(modifier = Modifier.fillMaxWidth()) {
|
||||||
Column(modifier = Modifier.padding(20.dp)) {
|
Column(modifier = Modifier.padding(20.dp)) {
|
||||||
Row(
|
|
||||||
modifier = Modifier.fillMaxWidth(),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.SpaceBetween
|
|
||||||
) {
|
|
||||||
Text("SSH-лог", style = MaterialTheme.typography.titleMedium)
|
Text("SSH-лог", style = MaterialTheme.typography.titleMedium)
|
||||||
IconButton(
|
|
||||||
onClick = {
|
|
||||||
HapticUtil.perform(context, HapticUtil.Pattern.CLICK)
|
|
||||||
viewModel.fetchServerLogs()
|
|
||||||
},
|
|
||||||
enabled = isConnected
|
|
||||||
) {
|
|
||||||
Icon(painterResource(R.drawable.refresh_24px), contentDescription = "Запросить server.log", modifier = Modifier.size(18.dp))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sshLog.isEmpty()) {
|
|
||||||
Spacer(Modifier.height(12.dp))
|
|
||||||
Text(
|
|
||||||
"Вывод SSH-команд появится здесь",
|
|
||||||
style = MaterialTheme.typography.bodySmall,
|
|
||||||
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.5f)
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
Spacer(Modifier.height(12.dp))
|
Spacer(Modifier.height(12.dp))
|
||||||
val listState = rememberLazyListState()
|
val listState = rememberLazyListState()
|
||||||
LaunchedEffect(sshLog.size) {
|
LaunchedEffect(sshLog.size) {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
@file:OptIn(androidx.compose.material3.ExperimentalMaterial3ExpressiveApi::class)
|
||||||
|
|
||||||
package com.freeturn.app.ui.screens
|
package com.freeturn.app.ui.screens
|
||||||
|
|
||||||
import androidx.compose.foundation.layout.Arrangement
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
@@ -24,7 +26,7 @@ import androidx.compose.material3.ExposedDropdownMenuBox
|
|||||||
import androidx.compose.material3.ExposedDropdownMenuDefaults
|
import androidx.compose.material3.ExposedDropdownMenuDefaults
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.LinearProgressIndicator
|
import androidx.compose.material3.LinearWavyProgressIndicator
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.ExposedDropdownMenuAnchorType
|
import androidx.compose.material3.ExposedDropdownMenuAnchorType
|
||||||
import androidx.compose.material3.OutlinedTextField
|
import androidx.compose.material3.OutlinedTextField
|
||||||
@@ -311,7 +313,7 @@ private fun ConnectionProgressCard(step: String) {
|
|||||||
horizontalAlignment = Alignment.CenterHorizontally,
|
horizontalAlignment = Alignment.CenterHorizontally,
|
||||||
verticalArrangement = Arrangement.spacedBy(20.dp)
|
verticalArrangement = Arrangement.spacedBy(20.dp)
|
||||||
) {
|
) {
|
||||||
LinearProgressIndicator(modifier = Modifier.fillMaxWidth())
|
LinearWavyProgressIndicator(modifier = Modifier.fillMaxWidth())
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = step,
|
text = step,
|
||||||
|
|||||||
@@ -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="M280,840q-33,0 -56.5,-23.5T200,760v-520h-40v-80h200v-40h240v40h200v80h-40v520q0,33 -23.5,56.5T680,840L280,840ZM680,240L280,240v520h400v-520ZM360,680h80v-360h-80v360ZM520,680h80v-360h-80v360ZM280,240v520,-520Z"/>
|
||||||
|
</vector>
|
||||||
@@ -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="M160,800Q127,800 103.5,776.5Q80,753 80,720L80,240Q80,207 103.5,183.5Q127,160 160,160L800,160Q833,160 856.5,183.5Q880,207 880,240L880,720Q880,753 856.5,776.5Q833,800 800,800L160,800ZM160,720L800,720Q800,720 800,720Q800,720 800,720L800,320L160,320L160,720Q160,720 160,720Q160,720 160,720ZM300,680L244,624L347,520L243,416L300,360L460,520L300,680ZM480,680L480,600L720,600L720,680L480,680Z"/>
|
||||||
|
</vector>
|
||||||
@@ -24,7 +24,7 @@ androidx-compose-ui = { group = "androidx.compose.ui", name = "ui" }
|
|||||||
androidx-compose-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
|
androidx-compose-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
|
||||||
androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
|
androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
|
||||||
androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
|
androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }
|
||||||
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3" }
|
androidx-compose-material3 = { group = "androidx.compose.material3", name = "material3", version = "1.5.0-alpha16" }
|
||||||
androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigationCompose" }
|
androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigationCompose" }
|
||||||
androidx-datastore-preferences = { group = "androidx.datastore", name = "datastore-preferences", version.ref = "datastorePreferences" }
|
androidx-datastore-preferences = { group = "androidx.datastore", name = "datastore-preferences", version.ref = "datastorePreferences" }
|
||||||
androidx-lifecycle-viewmodel-compose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "lifecycleViewmodelCompose" }
|
androidx-lifecycle-viewmodel-compose = { group = "androidx.lifecycle", name = "lifecycle-viewmodel-compose", version.ref = "lifecycleViewmodelCompose" }
|
||||||
|
|||||||
Reference in new issue
Block a user