|
@@ -0,0 +1,391 @@
|
|
|
+package com.vpn.fastestvpnservice.screens.settingsScreenAll
|
|
|
+
|
|
|
+import android.app.Activity
|
|
|
+import android.util.Log
|
|
|
+import androidx.compose.foundation.BorderStroke
|
|
|
+import androidx.compose.foundation.background
|
|
|
+import androidx.compose.foundation.border
|
|
|
+import androidx.compose.foundation.clickable
|
|
|
+import androidx.compose.foundation.gestures.detectTapGestures
|
|
|
+import androidx.compose.foundation.interaction.MutableInteractionSource
|
|
|
+import androidx.compose.foundation.layout.Arrangement
|
|
|
+import androidx.compose.foundation.layout.Box
|
|
|
+import androidx.compose.foundation.layout.BoxScope
|
|
|
+import androidx.compose.foundation.layout.Column
|
|
|
+import androidx.compose.foundation.layout.Row
|
|
|
+import androidx.compose.foundation.layout.Spacer
|
|
|
+import androidx.compose.foundation.layout.fillMaxHeight
|
|
|
+import androidx.compose.foundation.layout.fillMaxSize
|
|
|
+import androidx.compose.foundation.layout.fillMaxWidth
|
|
|
+import androidx.compose.foundation.layout.height
|
|
|
+import androidx.compose.foundation.layout.padding
|
|
|
+import androidx.compose.foundation.layout.size
|
|
|
+import androidx.compose.foundation.layout.wrapContentHeight
|
|
|
+import androidx.compose.foundation.shape.CircleShape
|
|
|
+import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
+import androidx.compose.material.Icon
|
|
|
+import androidx.compose.material.IconButton
|
|
|
+import androidx.compose.material.Surface
|
|
|
+import androidx.compose.material.Text
|
|
|
+import androidx.compose.material.icons.Icons
|
|
|
+import androidx.compose.material.icons.filled.Add
|
|
|
+import androidx.compose.material.icons.filled.Minimize
|
|
|
+import androidx.compose.material.icons.filled.NetworkCell
|
|
|
+import androidx.compose.material.icons.filled.Wifi
|
|
|
+import androidx.compose.material3.MaterialTheme
|
|
|
+import androidx.compose.runtime.Composable
|
|
|
+import androidx.compose.runtime.MutableState
|
|
|
+import androidx.compose.runtime.getValue
|
|
|
+import androidx.compose.runtime.mutableStateOf
|
|
|
+import androidx.compose.runtime.remember
|
|
|
+import androidx.compose.runtime.saveable.rememberSaveable
|
|
|
+import androidx.compose.runtime.setValue
|
|
|
+import androidx.compose.ui.Alignment
|
|
|
+import androidx.compose.ui.Modifier
|
|
|
+import androidx.compose.ui.draw.alpha
|
|
|
+import androidx.compose.ui.draw.clip
|
|
|
+import androidx.compose.ui.draw.paint
|
|
|
+import androidx.compose.ui.graphics.Color
|
|
|
+import androidx.compose.ui.graphics.toArgb
|
|
|
+import androidx.compose.ui.input.pointer.pointerInput
|
|
|
+import androidx.compose.ui.layout.ContentScale
|
|
|
+import androidx.compose.ui.platform.LocalContext
|
|
|
+import androidx.compose.ui.platform.LocalView
|
|
|
+import androidx.compose.ui.res.colorResource
|
|
|
+import androidx.compose.ui.res.painterResource
|
|
|
+import androidx.compose.ui.text.style.TextOverflow
|
|
|
+import androidx.compose.ui.unit.dp
|
|
|
+import androidx.navigation.NavHostController
|
|
|
+import com.vpn.fastestvpnservice.R
|
|
|
+import com.vpn.fastestvpnservice.beans.toChangeServer
|
|
|
+import com.vpn.fastestvpnservice.constants.smartConnect
|
|
|
+import com.vpn.fastestvpnservice.helpers.BasePreferenceHelper
|
|
|
+import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.AddRowSettingsSmart
|
|
|
+import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.onServer
|
|
|
+import com.vpn.fastestvpnservice.screens.serverListViewModelSplash
|
|
|
+import com.vpn.fastestvpnservice.sealedClass.Screen
|
|
|
+import com.vpn.fastestvpnservice.utils.Utils
|
|
|
+
|
|
|
+var selectedSmart: MutableState<String> = mutableStateOf("")
|
|
|
+
|
|
|
+@Composable
|
|
|
+fun AutoConnectScreen(navHostController: NavHostController) {
|
|
|
+ val context = LocalContext.current
|
|
|
+ val basePreferenceHelper = BasePreferenceHelper(context)
|
|
|
+ selectedSmart.value = basePreferenceHelper.getSmartList()
|
|
|
+ var isAdded by rememberSaveable { mutableStateOf(false) }
|
|
|
+ var isAddedWifi by rememberSaveable { mutableStateOf(false) }
|
|
|
+
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxSize()
|
|
|
+ .background(
|
|
|
+ color = MaterialTheme.colorScheme.background
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ val view = LocalView.current
|
|
|
+ val window = (view.context as Activity).window
|
|
|
+ window.statusBarColor = Color.Transparent.toArgb()
|
|
|
+ window.navigationBarColor = Color.Transparent.toArgb()
|
|
|
+
|
|
|
+ HeaderRowACS(navHostController = navHostController)
|
|
|
+
|
|
|
+ Column(
|
|
|
+ verticalArrangement = Arrangement.Top,
|
|
|
+ horizontalAlignment = Alignment.Start,
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(top = 120.dp, start = 16.dp, end = 0.dp)
|
|
|
+ .fillMaxSize()
|
|
|
+ .background(Color.Transparent)
|
|
|
+ ) {
|
|
|
+ Text(
|
|
|
+ text = context.getString(R.string.preferred_location),
|
|
|
+ color = MaterialTheme.colorScheme.primary,
|
|
|
+ style = MaterialTheme.typography.titleSmall,
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(end = 27.dp)
|
|
|
+ )
|
|
|
+
|
|
|
+ Text(
|
|
|
+ text = context.getString(R.string.auto_connect_location),
|
|
|
+ color = colorResource(id = R.color.gray_icon),
|
|
|
+ style = MaterialTheme.typography.displaySmall,
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(top = 5.dp, end = 27.dp)
|
|
|
+ .alpha(1f)
|
|
|
+ )
|
|
|
+
|
|
|
+ AddRowSettingsSmart(
|
|
|
+ icon = R.drawable.smart_connect3x,
|
|
|
+ text = selectedSmart.value,
|
|
|
+ isRowShown = true,
|
|
|
+ isSheetShown = false,
|
|
|
+ navHostController = navHostController,
|
|
|
+ topPadding = 20.dp
|
|
|
+ )
|
|
|
+
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .wrapContentHeight()
|
|
|
+ .fillMaxWidth()
|
|
|
+ .padding(top = 20.dp, end = 27.dp)
|
|
|
+ .border(
|
|
|
+ border = BorderStroke(1.dp, colorResource(id = R.color.graywidget)),
|
|
|
+ shape = RoundedCornerShape(14.dp)
|
|
|
+ )
|
|
|
+ .background(
|
|
|
+ shape = RoundedCornerShape(14.dp),
|
|
|
+ color = MaterialTheme.colorScheme.onBackground
|
|
|
+ )
|
|
|
+ ) {
|
|
|
+ Text(
|
|
|
+ text = context.getString(R.string.auto_connect_functionality),
|
|
|
+ color = colorResource(id = R.color.gray_icon),
|
|
|
+ style = MaterialTheme.typography.displaySmall,
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(all = 10.dp)
|
|
|
+ .alpha(1f)
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ Surface(
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(top = 20.dp, end = 27.dp)
|
|
|
+ .height(1.dp)
|
|
|
+ .fillMaxWidth()
|
|
|
+ .alpha(0.5F),
|
|
|
+ color = colorResource(id = R.color.gray_icon)
|
|
|
+ ) {}
|
|
|
+
|
|
|
+ Text(
|
|
|
+ text = context.getString(R.string.trusted_network),
|
|
|
+ color = MaterialTheme.colorScheme.primary,
|
|
|
+ style = MaterialTheme.typography.titleSmall,
|
|
|
+ modifier = Modifier.padding(top = 20.dp)
|
|
|
+ )
|
|
|
+
|
|
|
+ Text(
|
|
|
+ text = context.getString(R.string.trusted_network_disconnected),
|
|
|
+ color = colorResource(id = R.color.gray_icon),
|
|
|
+ style = MaterialTheme.typography.displaySmall,
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(top = 15.dp, end = 27.dp)
|
|
|
+ .alpha(1f)
|
|
|
+ )
|
|
|
+
|
|
|
+ Text(
|
|
|
+ text = context.getString(R.string.trusted_network_reconnected),
|
|
|
+ color = colorResource(id = R.color.gray_icon),
|
|
|
+ style = MaterialTheme.typography.displaySmall,
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(top = 5.dp, end = 27.dp)
|
|
|
+ .alpha(1f)
|
|
|
+ )
|
|
|
+
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .padding(start = 0.dp, end = 27.dp, top = 20.dp)
|
|
|
+ .background(Color.Transparent)
|
|
|
+ .clickable(
|
|
|
+ indication = null,
|
|
|
+ interactionSource = remember { MutableInteractionSource() }
|
|
|
+ ) {},
|
|
|
+ contentAlignment = Alignment.CenterStart
|
|
|
+ ) {
|
|
|
+ Icon(
|
|
|
+ painter = painterResource(id = R.drawable.cellular_alt_24),
|
|
|
+ contentDescription = "Mobile Network",
|
|
|
+ tint = colorResource(id = R.color.gray_icon),
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(top = 0.dp, bottom = 0.dp)
|
|
|
+ .size(20.dp)
|
|
|
+ .align(Alignment.CenterStart)
|
|
|
+ )
|
|
|
+
|
|
|
+ Surface(
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(start = 40.dp, bottom = 0.dp, end = 110.dp)
|
|
|
+ .align(Alignment.CenterStart)
|
|
|
+ .background(Color.Transparent),
|
|
|
+ color = Color.Transparent
|
|
|
+ ) {
|
|
|
+ Text(
|
|
|
+ text = "Mobile network",
|
|
|
+ style = MaterialTheme.typography.labelMedium,
|
|
|
+ color = colorResource(id = R.color.gray_icon),
|
|
|
+ maxLines = 1,
|
|
|
+ overflow = TextOverflow.Ellipsis,
|
|
|
+ modifier = Modifier
|
|
|
+ .align(Alignment.CenterStart)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ val isAddedText = if (isAdded) "Remove" else "Add"
|
|
|
+ val isAddedColor = if (isAdded) colorResource(id = R.color.Red) else colorResource(id = R.color.LightSeaGreen)
|
|
|
+
|
|
|
+ Row(
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(bottom = 0.dp, end = 0.dp)
|
|
|
+ .align(Alignment.CenterEnd)
|
|
|
+ .background(Color.Transparent)
|
|
|
+ .pointerInput(Unit) {
|
|
|
+ detectTapGestures {
|
|
|
+ isAdded = !isAdded
|
|
|
+ }
|
|
|
+ },
|
|
|
+ verticalAlignment = Alignment.CenterVertically
|
|
|
+ ) {
|
|
|
+ Text(
|
|
|
+ text = isAddedText,
|
|
|
+ style = MaterialTheme.typography.displayMedium,
|
|
|
+ color = isAddedColor,
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(end = 8.dp, bottom = 0.dp)
|
|
|
+
|
|
|
+ )
|
|
|
+ IconButton(
|
|
|
+ modifier = Modifier
|
|
|
+ .size(20.dp),
|
|
|
+ onClick = {
|
|
|
+ isAdded = !isAdded
|
|
|
+ }
|
|
|
+ ) {
|
|
|
+ Icon(
|
|
|
+ painter = if (isAdded) painterResource(id = R.drawable.remove_circle_outline_24)
|
|
|
+ else painterResource(id = R.drawable.add_circle_outline_24),
|
|
|
+ contentDescription = "Server Logo",
|
|
|
+ tint = isAddedColor,
|
|
|
+ modifier = Modifier.size(20.dp)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Surface(
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(top = 20.dp, end = 27.dp)
|
|
|
+ .height(1.dp)
|
|
|
+ .fillMaxWidth()
|
|
|
+ .alpha(0.6F),
|
|
|
+ color = colorResource(id = R.color.gray_icon)
|
|
|
+ ) {}
|
|
|
+
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .padding(start = 0.dp, end = 27.dp, top = 20.dp)
|
|
|
+ .background(Color.Transparent)
|
|
|
+ .clickable(
|
|
|
+ indication = null,
|
|
|
+ interactionSource = remember { MutableInteractionSource() }
|
|
|
+ ) {},
|
|
|
+ contentAlignment = Alignment.CenterStart
|
|
|
+ ) {
|
|
|
+ Icon(
|
|
|
+ imageVector = Icons.Default.Wifi,
|
|
|
+ contentDescription = "Mobile Network",
|
|
|
+ tint = colorResource(id = R.color.gray_icon),
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(top = 0.dp, bottom = 0.dp)
|
|
|
+ .size(20.dp)
|
|
|
+ .align(Alignment.CenterStart)
|
|
|
+ )
|
|
|
+
|
|
|
+ Surface(
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(start = 40.dp, bottom = 0.dp, end = 110.dp)
|
|
|
+ .align(Alignment.CenterStart)
|
|
|
+ .background(Color.Transparent),
|
|
|
+ color = Color.Transparent
|
|
|
+ ) {
|
|
|
+ Text(
|
|
|
+ text = "Wifi",
|
|
|
+ style = MaterialTheme.typography.labelMedium,
|
|
|
+ color = colorResource(id = R.color.gray_icon),
|
|
|
+ maxLines = 1,
|
|
|
+ overflow = TextOverflow.Ellipsis,
|
|
|
+ modifier = Modifier
|
|
|
+ .align(Alignment.CenterStart)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ val isAddedText = if (isAddedWifi) "Remove" else "Add"
|
|
|
+ val isAddedColor = if (isAddedWifi) colorResource(id = R.color.Red) else colorResource(id = R.color.LightSeaGreen)
|
|
|
+
|
|
|
+ Row(
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(bottom = 0.dp, end = 0.dp)
|
|
|
+ .align(Alignment.CenterEnd)
|
|
|
+ .background(Color.Transparent)
|
|
|
+ .pointerInput(Unit) {
|
|
|
+ detectTapGestures {
|
|
|
+ isAddedWifi = !isAddedWifi
|
|
|
+ }
|
|
|
+ },
|
|
|
+ verticalAlignment = Alignment.CenterVertically
|
|
|
+ ) {
|
|
|
+ Text(
|
|
|
+ text = isAddedText,
|
|
|
+ style = MaterialTheme.typography.displayMedium,
|
|
|
+ color = isAddedColor,
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(end = 8.dp, bottom = 0.dp)
|
|
|
+
|
|
|
+ )
|
|
|
+ IconButton(
|
|
|
+ modifier = Modifier
|
|
|
+ .size(20.dp),
|
|
|
+ onClick = {
|
|
|
+ isAddedWifi = !isAddedWifi
|
|
|
+ }
|
|
|
+ ) {
|
|
|
+ Icon(
|
|
|
+ painter = if (isAddedWifi) painterResource(id = R.drawable.remove_circle_outline_24)
|
|
|
+ else painterResource(id = R.drawable.add_circle_outline_24),
|
|
|
+ contentDescription = "Server Logo",
|
|
|
+ tint = isAddedColor,
|
|
|
+ modifier = Modifier.size(20.dp)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+@Composable
|
|
|
+fun BoxScope.HeaderRowACS(navHostController: NavHostController) {
|
|
|
+ val context = LocalContext.current
|
|
|
+ IconButton(
|
|
|
+ onClick = {
|
|
|
+ navHostController.popBackStack()
|
|
|
+// navHostController.navigate(BottomBarScreen.Help.route)
|
|
|
+ },
|
|
|
+ modifier = Modifier
|
|
|
+ .align(Alignment.TopStart)
|
|
|
+ .padding(top = 50.dp)
|
|
|
+ .padding(start = 16.dp)
|
|
|
+ .size(30.dp, 32.dp)
|
|
|
+ ) {
|
|
|
+ Icon(
|
|
|
+ painter = painterResource(id = R.drawable.backarrow3x),
|
|
|
+ contentDescription = "Arrow-Back",
|
|
|
+ tint = MaterialTheme.colorScheme.primary,
|
|
|
+ modifier = Modifier.size(18.dp, 12.dp)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ Surface(
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(top = 50.dp)
|
|
|
+ .height(32.dp)
|
|
|
+ .align(Alignment.TopCenter)
|
|
|
+ .padding(5.dp),
|
|
|
+ color = colorResource(id = R.color.transparent)
|
|
|
+ ) {
|
|
|
+ Text(text = context.getString(R.string.auto_connect),
|
|
|
+ color = MaterialTheme.colorScheme.primary,
|
|
|
+ style = MaterialTheme.typography.bodyMedium,
|
|
|
+ modifier = Modifier.fillMaxHeight()
|
|
|
+
|
|
|
+ )
|
|
|
+ }
|
|
|
+}
|