|
@@ -11,6 +11,7 @@ import androidx.compose.foundation.ExperimentalFoundationApi
|
|
|
import androidx.compose.foundation.Image
|
|
|
import androidx.compose.foundation.LocalOverscrollConfiguration
|
|
|
import androidx.compose.foundation.background
|
|
|
+import androidx.compose.foundation.clickable
|
|
|
import androidx.compose.foundation.gestures.detectTapGestures
|
|
|
import androidx.compose.foundation.isSystemInDarkTheme
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
@@ -30,8 +31,6 @@ import androidx.compose.foundation.rememberScrollState
|
|
|
import androidx.compose.foundation.selection.selectable
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
import androidx.compose.foundation.verticalScroll
|
|
|
-import androidx.compose.material.icons.Icons
|
|
|
-import androidx.compose.material.icons.filled.DarkMode
|
|
|
import androidx.compose.material3.DockedSearchBar
|
|
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
|
|
import androidx.compose.material3.Icon
|
|
@@ -60,12 +59,14 @@ import androidx.compose.ui.Modifier
|
|
|
import androidx.compose.ui.draw.alpha
|
|
|
import androidx.compose.ui.draw.clip
|
|
|
import androidx.compose.ui.draw.scale
|
|
|
+import androidx.compose.ui.focus.FocusRequester
|
|
|
+import androidx.compose.ui.focus.focusRequester
|
|
|
+import androidx.compose.ui.focus.onFocusChanged
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
import androidx.compose.ui.graphics.ColorFilter
|
|
|
import androidx.compose.ui.graphics.toArgb
|
|
|
import androidx.compose.ui.graphics.vector.ImageVector
|
|
|
import androidx.compose.ui.input.pointer.pointerInput
|
|
|
-import androidx.compose.ui.platform.LocalConfiguration
|
|
|
import androidx.compose.ui.platform.LocalContext
|
|
|
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
|
|
|
import androidx.compose.ui.platform.LocalView
|
|
@@ -87,12 +88,11 @@ import com.vpn.fastestvpnservice.customItems.ServerSpecificItem
|
|
|
import com.vpn.fastestvpnservice.helpers.BasePreferenceHelper
|
|
|
import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.AddTextSettings
|
|
|
import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.getAvailableProtocols
|
|
|
-import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.selectProtocolCallback
|
|
|
import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.vpnConnectionsUtil
|
|
|
import com.vpn.fastestvpnservice.screens.searchListViewModelSplash
|
|
|
-import com.vpn.fastestvpnservice.screens.serverListViewModelSplash
|
|
|
import com.vpn.fastestvpnservice.sealedClass.BottomBarScreen
|
|
|
import com.vpn.fastestvpnservice.sealedClass.Screen
|
|
|
+import com.vpn.fastestvpnservice.utils.isTablet
|
|
|
import com.vpn.fastestvpnservice.viewmodels.HomeViewModel
|
|
|
import de.blinkt.openvpn.core.App
|
|
|
import kotlinx.coroutines.delay
|
|
@@ -102,6 +102,12 @@ import kotlinx.coroutines.launch
|
|
|
@Composable
|
|
|
fun SettingsTV(navHostController: NavHostController) {
|
|
|
val context = LocalContext.current
|
|
|
+ val focusRequester1 = remember { FocusRequester() }
|
|
|
+ val focusRequester2 = remember { FocusRequester() }
|
|
|
+ val focusRequester3 = remember { FocusRequester() }
|
|
|
+ val focusRequester4 = remember { FocusRequester() }
|
|
|
+ val focusRequester5 = remember { FocusRequester() }
|
|
|
+
|
|
|
|
|
|
CompositionLocalProvider(
|
|
|
LocalOverscrollConfiguration provides null
|
|
@@ -118,6 +124,10 @@ fun SettingsTV(navHostController: NavHostController) {
|
|
|
window.statusBarColor = Color.Transparent.toArgb()
|
|
|
window.navigationBarColor = Color.Transparent.toArgb()
|
|
|
|
|
|
+ LaunchedEffect(Unit) {
|
|
|
+ focusRequester1.requestFocus()
|
|
|
+ }
|
|
|
+
|
|
|
Column(
|
|
|
verticalArrangement = Arrangement.Top,
|
|
|
horizontalAlignment = Alignment.Start,
|
|
@@ -148,32 +158,23 @@ fun SettingsTV(navHostController: NavHostController) {
|
|
|
|
|
|
AddRowSettingsColumnTV(
|
|
|
icon = R.drawable.vpn_protocols3x,
|
|
|
- text = "VPN Protocols"
|
|
|
+ text = "VPN Protocols",
|
|
|
+ focusRequester1,
|
|
|
+ focusRequester2
|
|
|
)
|
|
|
- /* Commenting so far ...*/
|
|
|
-
|
|
|
-
|
|
|
-// AddRowSwitch(
|
|
|
-// icon = R.drawable.autoconnect3x,
|
|
|
-// text = "Auto Connect"
|
|
|
-// )
|
|
|
-
|
|
|
-// AddRowSettingsTV(
|
|
|
-// icon = R.drawable.autoconnect3x,
|
|
|
-// text = "Auto Connect",
|
|
|
-// onClick = {}
|
|
|
-// )
|
|
|
-
|
|
|
AddRowSettingsSmartTV(
|
|
|
icon = R.drawable.smart_connect3x,
|
|
|
text = "Smart Connect",
|
|
|
isRowShown = true,
|
|
|
isSheetShown = false,
|
|
|
- navHostController
|
|
|
+ navHostController,
|
|
|
+ focusRequester2,
|
|
|
+ focusRequester3
|
|
|
)
|
|
|
AddRowSwitchTV(
|
|
|
icon = R.drawable.adblock3x,
|
|
|
- text = "AdBlock"
|
|
|
+ text = "AdBlock",
|
|
|
+ focusRequester3
|
|
|
)
|
|
|
AddRowSettingsTV(
|
|
|
icon = R.drawable.kill_switch3x,
|
|
@@ -221,17 +222,24 @@ fun ColumnScope.AddRowSettingsTV(
|
|
|
topPadding: Dp = 40.dp,
|
|
|
onClick: () -> Unit
|
|
|
) {
|
|
|
+ var isRowFocused by remember { mutableStateOf(false) }
|
|
|
Row(
|
|
|
modifier = Modifier
|
|
|
.fillMaxWidth()
|
|
|
.padding(top = 5.dp, end = 27.dp)
|
|
|
.clip(RoundedCornerShape(4.dp))
|
|
|
- .background(Color.White)
|
|
|
+ .background(if (isRowFocused) Color.LightGray else Color.White)
|
|
|
+ .onFocusChanged {
|
|
|
+ isRowFocused = it.isFocused
|
|
|
+ }
|
|
|
.height(61.dp)
|
|
|
.pointerInput(Unit) {
|
|
|
detectTapGestures {
|
|
|
onClick()
|
|
|
}
|
|
|
+ }
|
|
|
+ .clickable {
|
|
|
+ onClick()
|
|
|
},
|
|
|
horizontalArrangement = Arrangement.Start,
|
|
|
verticalAlignment = Alignment.CenterVertically
|
|
@@ -308,15 +316,38 @@ fun ColumnScope.AddTextSettingsTV(
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
|
-fun ColumnScope.AddRowSwitchTV(icon: Int, text: String) {
|
|
|
+fun ColumnScope.AddRowSwitchTV(icon: Int, text: String, focusRequester3: FocusRequester) {
|
|
|
val context = LocalContext.current
|
|
|
val basePreferenceHelper = BasePreferenceHelper(context)
|
|
|
+ var isRowFocused by remember { mutableStateOf(false) }
|
|
|
+ var isSwitch by remember { mutableStateOf(basePreferenceHelper.getAdBlockState()) }
|
|
|
+ val scope = rememberCoroutineScope()
|
|
|
+ val homeViewModel: HomeViewModel = viewModel{
|
|
|
+ HomeViewModel(context, scope)
|
|
|
+ }
|
|
|
+ val isConnect: Int? = homeViewModel.isConnect.observeAsState().value
|
|
|
+
|
|
|
Row(
|
|
|
modifier = Modifier
|
|
|
.fillMaxWidth()
|
|
|
.padding(top = 5.dp, end = 27.dp)
|
|
|
.clip(RoundedCornerShape(4.dp))
|
|
|
- .background(Color.White)
|
|
|
+ .background(if (isRowFocused) Color.LightGray else Color.White)
|
|
|
+// .focusRequester(focusRequester3)
|
|
|
+ .onFocusChanged {
|
|
|
+ isRowFocused = it.isFocused
|
|
|
+ }
|
|
|
+ .clickable {
|
|
|
+ isSwitch = !isSwitch
|
|
|
+ basePreferenceHelper.saveAdBlockState(isSwitch)
|
|
|
+ if (isConnect == App.CONNECTED || isConnect == App.CONNECTING) {
|
|
|
+ Log.d("isConnect_State_vpn", "stopVPN")
|
|
|
+ vpnConnectionsUtil.stopVpn()
|
|
|
+ Handler().postDelayed(Runnable {
|
|
|
+ vpnConnectionsUtil.startVpn()
|
|
|
+ }, 500)
|
|
|
+ }
|
|
|
+ }
|
|
|
.height(61.dp),
|
|
|
horizontalArrangement = Arrangement.Start,
|
|
|
verticalAlignment = Alignment.CenterVertically
|
|
@@ -351,11 +382,6 @@ fun ColumnScope.AddRowSwitchTV(icon: Int, text: String) {
|
|
|
)
|
|
|
}
|
|
|
Spacer(modifier = Modifier.weight(1f))
|
|
|
- val scope = rememberCoroutineScope()
|
|
|
- val homeViewModel: HomeViewModel = viewModel{
|
|
|
- HomeViewModel(context, scope)
|
|
|
- }
|
|
|
- val isConnect: Int? = homeViewModel.isConnect.observeAsState().value
|
|
|
|
|
|
// val vpnConnectionsUtil = VPNConnectionsUtil(context, act, homeViewModel)
|
|
|
|
|
@@ -365,7 +391,6 @@ fun ColumnScope.AddRowSwitchTV(icon: Int, text: String) {
|
|
|
.align(Alignment.CenterVertically),
|
|
|
color = Color.Transparent
|
|
|
) {
|
|
|
- var isSwitch by remember { mutableStateOf(basePreferenceHelper.getAdBlockState()) }
|
|
|
Switch(
|
|
|
checked = isSwitch,
|
|
|
onCheckedChange = {
|
|
@@ -400,37 +425,49 @@ fun ColumnScope.AddRowSwitchTV(icon: Int, text: String) {
|
|
|
@Composable
|
|
|
fun ColumnScope.AddRowSettingsColumnTV(
|
|
|
icon: Int,
|
|
|
- text: String
|
|
|
+ text: String,
|
|
|
+ focusRequester1: FocusRequester,
|
|
|
+ focusRequester2: FocusRequester
|
|
|
) {
|
|
|
val context = LocalContext.current
|
|
|
val basePreferenceHelper = BasePreferenceHelper(context = context)
|
|
|
val availableProtocols = getAvailableProtocols(basePreferenceHelper)
|
|
|
var isSheetOpen by remember { mutableStateOf(false) }
|
|
|
- val sheetState = rememberModalBottomSheetState()
|
|
|
+ val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
|
|
val protocols = listOf(
|
|
|
"Auto", "WireGuard", "IKEv2", "OpenVPN TCP", "OpenVPN UDP"
|
|
|
)
|
|
|
var selectedProtocol by remember { mutableStateOf(basePreferenceHelper.getProtocol().full_name) }
|
|
|
+ var isFirstRowFocused by remember { mutableStateOf(false) }
|
|
|
+
|
|
|
+
|
|
|
// val serverListViewModel = serverListViewModelSplash
|
|
|
// val serverListViewModel: ServerListViewModel = viewModel{
|
|
|
// ServerListViewModel(context)
|
|
|
// }
|
|
|
- val configuration = LocalConfiguration.current
|
|
|
- val isTablet = configuration.screenWidthDp > 840
|
|
|
+// val configuration = LocalConfiguration.current
|
|
|
+// val isTablet = configuration.screenWidthDp > 840
|
|
|
+
|
|
|
|
|
|
Row(
|
|
|
modifier = Modifier
|
|
|
.fillMaxWidth()
|
|
|
.padding(top = 5.dp, end = 27.dp)
|
|
|
.clip(RoundedCornerShape(4.dp))
|
|
|
- .background(Color.White)
|
|
|
+ .background(if (isFirstRowFocused) Color.LightGray else Color.White)
|
|
|
.height(61.dp)
|
|
|
-// .clickable { isSheetOpen = true }
|
|
|
+ .focusRequester(focusRequester1)
|
|
|
+ .onFocusChanged {
|
|
|
+ isFirstRowFocused = it.isFocused
|
|
|
+// if (!it.isFocused) focusRequester2.requestFocus()
|
|
|
+
|
|
|
+ }
|
|
|
.pointerInput(Unit) {
|
|
|
detectTapGestures {
|
|
|
isSheetOpen = true
|
|
|
}
|
|
|
}
|
|
|
+ .clickable { isSheetOpen = true }
|
|
|
,
|
|
|
horizontalArrangement = Arrangement.Start,
|
|
|
verticalAlignment = Alignment.CenterVertically
|
|
@@ -453,7 +490,8 @@ fun ColumnScope.AddRowSettingsColumnTV(
|
|
|
}
|
|
|
|
|
|
Surface(
|
|
|
- modifier = Modifier.padding(start = 0.dp)
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(start = 0.dp)
|
|
|
.align(Alignment.CenterVertically),
|
|
|
color = Color.Transparent
|
|
|
) {
|
|
@@ -472,7 +510,7 @@ fun ColumnScope.AddRowSettingsColumnTV(
|
|
|
Spacer(modifier = Modifier.height(2.dp))
|
|
|
Text(text = selectedProtocol,
|
|
|
style = MaterialTheme.typography.headlineSmall.copy(
|
|
|
- fontSize = if (isTablet) 14.sp else 12.sp
|
|
|
+ fontSize = if (isTablet()) 14.sp else 12.sp
|
|
|
),
|
|
|
color = MaterialTheme.colorScheme.inversePrimary,
|
|
|
maxLines = 1,
|
|
@@ -511,7 +549,7 @@ fun ColumnScope.AddRowSettingsColumnTV(
|
|
|
onDismissRequest = { isSheetOpen = false },
|
|
|
sheetState = sheetState,
|
|
|
// containerColor = MaterialTheme.colorScheme.onBackground
|
|
|
- containerColor = Color.White
|
|
|
+ containerColor = Color.White,
|
|
|
) {
|
|
|
Box(modifier = Modifier
|
|
|
.background(Color.Transparent)
|
|
@@ -589,13 +627,15 @@ fun ColumnScope.AddRowSettingsSmartTV(
|
|
|
text: String,
|
|
|
isRowShown: Boolean,
|
|
|
isSheetShown: Boolean,
|
|
|
- navHostController: NavHostController
|
|
|
+ navHostController: NavHostController,
|
|
|
+ focusRequester2: FocusRequester,
|
|
|
+ focusRequester3: FocusRequester
|
|
|
) {
|
|
|
var isSmartSheetOpen by remember { mutableStateOf(false) }
|
|
|
var isAnySpecificSheetOpen by remember { mutableStateOf(false) }
|
|
|
val context = LocalContext.current
|
|
|
val basePreferenceHelper = BasePreferenceHelper(context)
|
|
|
- val keyboardController = LocalSoftwareKeyboardController.current
|
|
|
+ var isRowFocused by remember { mutableStateOf(false) }
|
|
|
|
|
|
// if (isRowShown) { }
|
|
|
|
|
@@ -604,13 +644,19 @@ fun ColumnScope.AddRowSettingsSmartTV(
|
|
|
.fillMaxWidth()
|
|
|
.padding(top = 5.dp, end = 27.dp)
|
|
|
.clip(RoundedCornerShape(4.dp))
|
|
|
- .background(Color.White)
|
|
|
+ .background(if (isRowFocused) Color.LightGray else Color.White)
|
|
|
+// .focusRequester(focusRequester2)
|
|
|
+ .onFocusChanged {
|
|
|
+ isRowFocused = it.isFocused
|
|
|
+// if (!it.isFocused) focusRequester3.requestFocus()
|
|
|
+ }
|
|
|
.pointerInput(Unit) {
|
|
|
detectTapGestures {
|
|
|
isSmartSheetOpen = true
|
|
|
}
|
|
|
}
|
|
|
- .height(61.dp),
|
|
|
+ .height(61.dp)
|
|
|
+ .clickable { isSmartSheetOpen = true },
|
|
|
horizontalArrangement = Arrangement.Start,
|
|
|
verticalAlignment = Alignment.CenterVertically
|
|
|
) {
|
|
@@ -627,7 +673,8 @@ fun ColumnScope.AddRowSettingsSmartTV(
|
|
|
.size(24.dp)
|
|
|
.weight(1f),
|
|
|
colorFilter = ColorFilter.tint(
|
|
|
- MaterialTheme.colorScheme.inversePrimary) )
|
|
|
+ MaterialTheme.colorScheme.inversePrimary)
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
Surface(
|
|
@@ -665,7 +712,7 @@ fun ColumnScope.AddRowSettingsSmartTV(
|
|
|
}
|
|
|
|
|
|
if (isSmartSheetOpen) {
|
|
|
- val sheetState = rememberModalBottomSheetState()
|
|
|
+ val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
|
|
var selectedSmartConnect by remember {
|
|
|
mutableStateOf(basePreferenceHelper.getSmartList()) }
|
|
|
|