update branch from main

This commit is contained in:
white
2025-12-08 12:50:33 +03:00
4 changed files with 21 additions and 9 deletions

View File

@@ -1,4 +1,3 @@
@file:OptIn(ExperimentalMaterial3ExpressiveApi::class)
package com.cherret.zaprett.ui.screen package com.cherret.zaprett.ui.screen
import android.content.ClipData import android.content.ClipData
@@ -12,10 +11,12 @@ import android.widget.Toast
import androidx.activity.result.ActivityResultLauncher import androidx.activity.result.ActivityResultLauncher
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
@@ -32,6 +33,7 @@ import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons import androidx.compose.material.icons.Icons
@@ -151,8 +153,13 @@ fun StrategySelectionScreen(navController: NavController, vpnLauncher: ActivityR
snackbarHost = { SnackbarHost(snackbarHostState) }, snackbarHost = { SnackbarHost(snackbarHostState) },
content = { paddingValues -> content = { paddingValues ->
LazyColumn ( LazyColumn (
contentPadding = PaddingValues(
top = paddingValues.calculateTopPadding(),
bottom = paddingValues.calculateBottomPadding() + 40.dp
),
modifier = Modifier modifier = Modifier
.padding(paddingValues) .navigationBarsPadding()
.fillMaxSize()
) { ) {
item { item {
Row ( Row (

View File

@@ -122,16 +122,20 @@ class StrategySelectionViewModel(application: Application) : AndroidViewModel(ap
} }
suspend fun performTest() { suspend fun performTest() {
val targets = readActiveListsLines() val targets = readActiveListsLines()
var stopTest : Boolean = false;
for (index in strategyStates.indices) { for (index in strategyStates.indices) {
val current = strategyStates[index] val current = strategyStates[index]
if (stopTest) break
strategyStates[index] = current.copy(status = StrategyTestingStatus.Testing) strategyStates[index] = current.copy(status = StrategyTestingStatus.Testing)
enableStrategy(current.path, prefs) enableStrategy(current.path, prefs)
if (prefs.getBoolean("use_module", false)) { if (prefs.getBoolean("use_module", false)) {
getStatus { if (it) stopService { error -> getStatus { if (it) stopService { error ->
_errorFlow.value = error _errorFlow.value = error
if (error.isNotEmpty()) stopTest = true
} } } }
startService { error -> startService { error ->
_errorFlow.value = error _errorFlow.value = error
if (error.isNotEmpty()) stopTest = true
} }
try { try {
val progress = countReachable(index, targets) val progress = countReachable(index, targets)
@@ -143,6 +147,7 @@ class StrategySelectionViewModel(application: Application) : AndroidViewModel(ap
} finally { } finally {
stopService { error -> stopService { error ->
_errorFlow.value = error _errorFlow.value = error
if (error.isNotEmpty()) stopTest = true
} }
disableStrategy(current.path, prefs) disableStrategy(current.path, prefs)
} }
@@ -188,8 +193,8 @@ class StrategySelectionViewModel(application: Application) : AndroidViewModel(ap
} }
fun checkHosts() { fun checkHosts() {
if (getActiveLists(prefs).isEmpty()) noHostsCard.value = true if (getActiveLists(prefs).isEmpty() || getAllStrategies(prefs).isEmpty()) noHostsCard.value = true
Log.d("getActiveLists.isEmpty", getActiveLists(prefs).isEmpty().toString()) Log.d("getActiveLists.isEmpty || getAllStrategies.isEmpty", getActiveLists(prefs).isEmpty().toString())
} }
fun startVpn() { fun startVpn() {
ContextCompat.startForegroundService(context, Intent(context, ByeDpiVpnService::class.java).apply { action = "START_VPN" }) ContextCompat.startForegroundService(context, Intent(context, ByeDpiVpnService::class.java).apply { action = "START_VPN" })

View File

@@ -114,8 +114,8 @@
<string name="hint_enter_probe_timeout">Введите таймаут пробы</string> <string name="hint_enter_probe_timeout">Введите таймаут пробы</string>
<string name="strategy_selection_info_title">Информация</string> <string name="strategy_selection_info_title">Информация</string>
<string name="strategy_selection_info_msg">"В этом разделе настроек приложения представлен перебор стратегий\n Подбор проходит среди скачанных стратегий, поэтому заранее скачайте из репозитория или добавьте из файловой системы интересующие вас стратегии для сравнения. \n Перед началом так же выберете один или несколько листов доменов на вкладке \"Листы\", затем нажмите на \"Начать подбор\". Не используйте для перебора списки с большим количеством доменов."</string> <string name="strategy_selection_info_msg">"В этом разделе настроек приложения представлен перебор стратегий\n Подбор проходит среди скачанных стратегий, поэтому заранее скачайте из репозитория или добавьте из файловой системы интересующие вас стратегии для сравнения. \n Перед началом так же выберете один или несколько листов доменов на вкладке \"Листы\", затем нажмите на \"Начать подбор\". Не используйте для перебора списки с большим количеством доменов."</string>
<string name="selection_no_hosts_title">Нет активных листов</string> <string name="selection_no_hosts_title">Нет включенных листов/стратегий</string>
<string name="selection_no_hosts_message">Не обнаружено активных списков хостов, включите один или несколько, иначе подбор не сработает</string> <string name="selection_no_hosts_message">Не обнаружено активных списков хостов, либо доступных стратегий. Включите один или несколько, или скачайте стратегии для проверки, иначе подбор не сработает</string>
<string name="selection_available_domains">Доступные домены</string> <string name="selection_available_domains">Доступные домены</string>
<string name="no_storage_permission_message">Нет разрешения на доступ к файлам</string> <string name="no_storage_permission_message">Нет разрешения на доступ к файлам</string>
<string name="reset_settings_title">Сброс настроек</string> <string name="reset_settings_title">Сброс настроек</string>

View File

@@ -119,8 +119,8 @@
<string name="hint_enter_probe_timeout">Enter probe timeout</string> <string name="hint_enter_probe_timeout">Enter probe timeout</string>
<string name="strategy_selection_info_title">Tip</string> <string name="strategy_selection_info_title">Tip</string>
<string name="strategy_selection_info_msg">This section of the application settings allows you to iterate through strategies.\n The selection is based on downloaded strategies, so download the strategies you\'re interested in from the repository or add them from the file system for comparison.\n Before starting, select one or more domain lists in the \"Lists\" tab, then click \"Start selection\". Avoid using lists with a large number of domains.</string> <string name="strategy_selection_info_msg">This section of the application settings allows you to iterate through strategies.\n The selection is based on downloaded strategies, so download the strategies you\'re interested in from the repository or add them from the file system for comparison.\n Before starting, select one or more domain lists in the \"Lists\" tab, then click \"Start selection\". Avoid using lists with a large number of domains.</string>
<string name="selection_no_hosts_title">No active hosts</string> <string name="selection_no_hosts_title">No active hosts/strategies</string>
<string name="selection_no_hosts_message">No active host lists found, please enable one or more, otherwise the selection will not work</string> <string name="selection_no_hosts_message">No active host lists or available strategies were found. Please enable one or more, or download strategies for testing, otherwise the selection will not work.</string>
<string name="selection_available_domains">Available domains</string> <string name="selection_available_domains">Available domains</string>
<string name="no_storage_permission_message">Missing permission to access files</string> <string name="no_storage_permission_message">Missing permission to access files</string>
<string name="reset_settings_title">Reset settings</string> <string name="reset_settings_title">Reset settings</string>