|
@@ -7,6 +7,7 @@ import android.os.Build
|
|
import android.os.Bundle
|
|
import android.os.Bundle
|
|
import android.os.Handler
|
|
import android.os.Handler
|
|
import android.util.Log
|
|
import android.util.Log
|
|
|
|
+import android.widget.Toast
|
|
import androidx.activity.compose.BackHandler
|
|
import androidx.activity.compose.BackHandler
|
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
|
import androidx.compose.foundation.Image
|
|
import androidx.compose.foundation.Image
|
|
@@ -88,8 +89,10 @@ import androidx.lifecycle.viewmodel.compose.viewModel
|
|
import androidx.navigation.NavHostController
|
|
import androidx.navigation.NavHostController
|
|
import androidx.navigation.compose.currentBackStackEntryAsState
|
|
import androidx.navigation.compose.currentBackStackEntryAsState
|
|
import com.vpn.fastestvpnservice.R
|
|
import com.vpn.fastestvpnservice.R
|
|
|
|
+import com.vpn.fastestvpnservice.beans.Protocol
|
|
import com.vpn.fastestvpnservice.beans.isDarkTheme
|
|
import com.vpn.fastestvpnservice.beans.isDarkTheme
|
|
import com.vpn.fastestvpnservice.beans.themesList
|
|
import com.vpn.fastestvpnservice.beans.themesList
|
|
|
|
+import com.vpn.fastestvpnservice.constants.AppEnum
|
|
import com.vpn.fastestvpnservice.constants.smartConnect
|
|
import com.vpn.fastestvpnservice.constants.smartConnect
|
|
import com.vpn.fastestvpnservice.customItems.ServerSpecificItem
|
|
import com.vpn.fastestvpnservice.customItems.ServerSpecificItem
|
|
import com.vpn.fastestvpnservice.helpers.BasePreferenceHelper
|
|
import com.vpn.fastestvpnservice.helpers.BasePreferenceHelper
|
|
@@ -100,12 +103,16 @@ import com.vpn.fastestvpnservice.navigation.isSecondItemPressed
|
|
import com.vpn.fastestvpnservice.navigation.isSettingsScreenPressed
|
|
import com.vpn.fastestvpnservice.navigation.isSettingsScreenPressed
|
|
import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.AddTextSettings
|
|
import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.AddTextSettings
|
|
import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.getAvailableProtocols
|
|
import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.getAvailableProtocols
|
|
|
|
+import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.navHostController1
|
|
|
|
+import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.onServer
|
|
import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.vpnConnectionsUtil
|
|
import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.vpnConnectionsUtil
|
|
import com.vpn.fastestvpnservice.screens.searchListViewModelSplash
|
|
import com.vpn.fastestvpnservice.screens.searchListViewModelSplash
|
|
|
|
+import com.vpn.fastestvpnservice.screens.serverListViewModelSplash
|
|
import com.vpn.fastestvpnservice.sealedClass.BottomBarScreen
|
|
import com.vpn.fastestvpnservice.sealedClass.BottomBarScreen
|
|
import com.vpn.fastestvpnservice.sealedClass.Screen
|
|
import com.vpn.fastestvpnservice.sealedClass.Screen
|
|
import com.vpn.fastestvpnservice.utils.isTablet
|
|
import com.vpn.fastestvpnservice.utils.isTablet
|
|
import com.vpn.fastestvpnservice.viewmodels.HomeViewModel
|
|
import com.vpn.fastestvpnservice.viewmodels.HomeViewModel
|
|
|
|
+import com.vpn.fastestvpnservice.viewmodels.ServerListViewModel
|
|
import de.blinkt.openvpn.core.App
|
|
import de.blinkt.openvpn.core.App
|
|
import kotlinx.coroutines.delay
|
|
import kotlinx.coroutines.delay
|
|
import kotlinx.coroutines.launch
|
|
import kotlinx.coroutines.launch
|
|
@@ -119,6 +126,8 @@ fun SettingsTV(navHostController: NavHostController) {
|
|
val focusRequester3 = remember { FocusRequester() }
|
|
val focusRequester3 = remember { FocusRequester() }
|
|
val focusRequester4 = remember { FocusRequester() }
|
|
val focusRequester4 = remember { FocusRequester() }
|
|
val focusRequester5 = remember { FocusRequester() }
|
|
val focusRequester5 = remember { FocusRequester() }
|
|
|
|
+ val focusRequesterProtocol = remember { FocusRequester() }
|
|
|
|
+
|
|
|
|
|
|
if (isSettingsScreenPressed.value) {
|
|
if (isSettingsScreenPressed.value) {
|
|
LaunchedEffect(Unit) {
|
|
LaunchedEffect(Unit) {
|
|
@@ -191,7 +200,8 @@ fun SettingsTV(navHostController: NavHostController) {
|
|
text = "VPN Protocols",
|
|
text = "VPN Protocols",
|
|
focusRequester1,
|
|
focusRequester1,
|
|
focusRequester2,
|
|
focusRequester2,
|
|
- navHostController
|
|
|
|
|
|
+ navHostController,
|
|
|
|
+ focusRequesterProtocol
|
|
)
|
|
)
|
|
AddRowSettingsSmartTV(
|
|
AddRowSettingsSmartTV(
|
|
icon = R.drawable.smart_connect3x,
|
|
icon = R.drawable.smart_connect3x,
|
|
@@ -475,7 +485,8 @@ fun ColumnScope.AddRowSettingsColumnTV(
|
|
text: String,
|
|
text: String,
|
|
focusRequester1: FocusRequester,
|
|
focusRequester1: FocusRequester,
|
|
focusRequester2: FocusRequester,
|
|
focusRequester2: FocusRequester,
|
|
- navHostController: NavHostController
|
|
|
|
|
|
+ navHostController: NavHostController,
|
|
|
|
+ focusRequesterProtocol: FocusRequester
|
|
) {
|
|
) {
|
|
val context = LocalContext.current
|
|
val context = LocalContext.current
|
|
val basePreferenceHelper = BasePreferenceHelper(context = context)
|
|
val basePreferenceHelper = BasePreferenceHelper(context = context)
|
|
@@ -488,7 +499,6 @@ fun ColumnScope.AddRowSettingsColumnTV(
|
|
var selectedProtocol by remember { mutableStateOf(basePreferenceHelper.getProtocol().full_name) }
|
|
var selectedProtocol by remember { mutableStateOf(basePreferenceHelper.getProtocol().full_name) }
|
|
var isFirstRowFocused by remember { mutableStateOf(false) }
|
|
var isFirstRowFocused by remember { mutableStateOf(false) }
|
|
|
|
|
|
-
|
|
|
|
// val serverListViewModel = serverListViewModelSplash
|
|
// val serverListViewModel = serverListViewModelSplash
|
|
// val serverListViewModel: ServerListViewModel = viewModel{
|
|
// val serverListViewModel: ServerListViewModel = viewModel{
|
|
// ServerListViewModel(context)
|
|
// ServerListViewModel(context)
|
|
@@ -543,7 +553,9 @@ fun ColumnScope.AddRowSettingsColumnTV(
|
|
// isSheetOpen = true
|
|
// isSheetOpen = true
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
- .clickable { isSheetOpen = true }
|
|
|
|
|
|
+ .clickable {
|
|
|
|
+ isSheetOpen = true
|
|
|
|
+ }
|
|
,
|
|
,
|
|
horizontalArrangement = Arrangement.Start,
|
|
horizontalArrangement = Arrangement.Start,
|
|
verticalAlignment = Alignment.CenterVertically
|
|
verticalAlignment = Alignment.CenterVertically
|
|
@@ -627,11 +639,13 @@ fun ColumnScope.AddRowSettingsColumnTV(
|
|
// containerColor = MaterialTheme.colorScheme.onBackground
|
|
// containerColor = MaterialTheme.colorScheme.onBackground
|
|
containerColor = Color.White,
|
|
containerColor = Color.White,
|
|
) {
|
|
) {
|
|
|
|
+ var isProtocolFocused by remember { mutableStateOf(false) }
|
|
Box(modifier = Modifier
|
|
Box(modifier = Modifier
|
|
.background(Color.Transparent)
|
|
.background(Color.Transparent)
|
|
.fillMaxWidth()
|
|
.fillMaxWidth()
|
|
.height(340.dp)
|
|
.height(340.dp)
|
|
- .padding(start = 0.dp, top = 5.dp),
|
|
|
|
|
|
+ .padding(start = 0.dp, top = 5.dp)
|
|
|
|
+ ,
|
|
) {
|
|
) {
|
|
Column(
|
|
Column(
|
|
verticalArrangement = Arrangement.Top,
|
|
verticalArrangement = Arrangement.Top,
|
|
@@ -649,18 +663,22 @@ fun ColumnScope.AddRowSettingsColumnTV(
|
|
Row(
|
|
Row(
|
|
modifier = Modifier
|
|
modifier = Modifier
|
|
.fillMaxWidth()
|
|
.fillMaxWidth()
|
|
- .background(Color.Transparent)
|
|
|
|
|
|
+ .background(Color.White)
|
|
.padding(start = 2.dp)
|
|
.padding(start = 2.dp)
|
|
.selectable(
|
|
.selectable(
|
|
selected = selectedProtocol == protocol,
|
|
selected = selectedProtocol == protocol,
|
|
onClick = {
|
|
onClick = {
|
|
selectedProtocol = protocol
|
|
selectedProtocol = protocol
|
|
isSheetOpen = false
|
|
isSheetOpen = false
|
|
-// selectProtocolCallback(
|
|
|
|
-// protocol = protocol,
|
|
|
|
-// context,
|
|
|
|
-// serverListViewModel
|
|
|
|
-// )
|
|
|
|
|
|
+ Toast.makeText(
|
|
|
|
+ context, selectedProtocol, Toast.LENGTH_SHORT
|
|
|
|
+ ).show()
|
|
|
|
+ selectProtocolCallbackTV(
|
|
|
|
+ protocol = protocol,
|
|
|
|
+ context,
|
|
|
|
+ serverListViewModelSplash,
|
|
|
|
+ navHostController
|
|
|
|
+ )
|
|
},
|
|
},
|
|
)
|
|
)
|
|
// .indication(
|
|
// .indication(
|
|
@@ -672,17 +690,25 @@ fun ColumnScope.AddRowSettingsColumnTV(
|
|
,
|
|
,
|
|
verticalAlignment = Alignment.CenterVertically
|
|
verticalAlignment = Alignment.CenterVertically
|
|
) {
|
|
) {
|
|
- RadioButton(selected = protocol == selectedProtocol,
|
|
|
|
|
|
+ RadioButton(
|
|
|
|
+ modifier = Modifier
|
|
|
|
+ .onFocusChanged {
|
|
|
|
+ isProtocolFocused = it.isFocused
|
|
|
|
+ }
|
|
|
|
+ .focusable()
|
|
|
|
+ ,
|
|
|
|
+ selected = protocol == selectedProtocol,
|
|
onClick = {
|
|
onClick = {
|
|
- selectedProtocol = protocol
|
|
|
|
- isSheetOpen = false
|
|
|
|
-// selectProtocolCallback(protocol = protocol, context, serverListViewModel)
|
|
|
|
|
|
+// selectedProtocol = protocol
|
|
|
|
+// isSheetOpen = false
|
|
},
|
|
},
|
|
colors = RadioButtonDefaults.colors(
|
|
colors = RadioButtonDefaults.colors(
|
|
selectedColor = colorResource(id = R.color.radio_button_blue),
|
|
selectedColor = colorResource(id = R.color.radio_button_blue),
|
|
- unselectedColor = colorResource(id = R.color.gray_icon),)
|
|
|
|
|
|
+ unselectedColor = colorResource(id = R.color.gray_icon),
|
|
|
|
+ )
|
|
)
|
|
)
|
|
- Text(text = protocol,
|
|
|
|
|
|
+ Text(
|
|
|
|
+ text = "$protocol $isProtocolFocused",
|
|
modifier = Modifier.padding(start = 12.dp),
|
|
modifier = Modifier.padding(start = 12.dp),
|
|
color = MaterialTheme.colorScheme.inversePrimary,
|
|
color = MaterialTheme.colorScheme.inversePrimary,
|
|
style = MaterialTheme.typography.bodySmall
|
|
style = MaterialTheme.typography.bodySmall
|
|
@@ -696,6 +722,39 @@ fun ColumnScope.AddRowSettingsColumnTV(
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+fun selectProtocolCallbackTV(
|
|
|
|
+ protocol: String,
|
|
|
|
+ context: Context,
|
|
|
|
+ serverListViewModel: ServerListViewModel,
|
|
|
|
+ navHostController: NavHostController
|
|
|
|
+) {
|
|
|
|
+ navHostController1 = navHostController
|
|
|
|
+ when (protocol) {
|
|
|
|
+ AppEnum.AUTO_PROTOCOL.title -> {
|
|
|
|
+ onServerTV.onChangeProtocol(
|
|
|
|
+ Protocol(AppEnum.AUTO_PROTOCOL.title, AppEnum.IKEV2_PROTOCOL.key, 0), context = context, serverListViewModel)
|
|
|
|
+ }
|
|
|
|
+ AppEnum.WG_PROTOCOL.title -> {
|
|
|
|
+ onServerTV.onChangeProtocol(
|
|
|
|
+ Protocol(AppEnum.WG_PROTOCOL.title, AppEnum.WG_PROTOCOL.key, 1), context = context, serverListViewModel)
|
|
|
|
+ }
|
|
|
|
+ AppEnum.IKEV2_PROTOCOL.title -> {
|
|
|
|
+ onServerTV.onChangeProtocol(
|
|
|
|
+ Protocol(AppEnum.IKEV2_PROTOCOL.title, AppEnum.IKEV2_PROTOCOL.key, 2), context = context, serverListViewModel)
|
|
|
|
+ }
|
|
|
|
+ AppEnum.TCP_PROTOCOL.title -> {
|
|
|
|
+ onServerTV.onChangeProtocol(
|
|
|
|
+ Protocol(AppEnum.TCP_PROTOCOL.title, AppEnum.TCP_PROTOCOL.key, 3), context = context, serverListViewModel)
|
|
|
|
+ }
|
|
|
|
+ AppEnum.UDP_PROTOCOL.title -> {
|
|
|
|
+ onServerTV.onChangeProtocol(
|
|
|
|
+ Protocol(AppEnum.UDP_PROTOCOL.title, AppEnum.UDP_PROTOCOL.key, 4), context = context, serverListViewModel)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
|
|
@OptIn(ExperimentalMaterial3Api::class, ExperimentalFoundationApi::class)
|
|
@Composable
|
|
@Composable
|
|
fun ColumnScope.AddRowSettingsSmartTV(
|
|
fun ColumnScope.AddRowSettingsSmartTV(
|