|
@@ -106,6 +106,7 @@ import de.blinkt.openvpn.core.App
|
|
import com.vpn.fastestvpnservice.beans.Protocol
|
|
import com.vpn.fastestvpnservice.beans.Protocol
|
|
import com.vpn.fastestvpnservice.beans.Server
|
|
import com.vpn.fastestvpnservice.beans.Server
|
|
import com.vpn.fastestvpnservice.beans.isDarkTheme
|
|
import com.vpn.fastestvpnservice.beans.isDarkTheme
|
|
|
|
+import com.vpn.fastestvpnservice.beans.toChangeServer
|
|
import com.vpn.fastestvpnservice.constants.AppEnum
|
|
import com.vpn.fastestvpnservice.constants.AppEnum
|
|
import com.vpn.fastestvpnservice.constants.smartConnect
|
|
import com.vpn.fastestvpnservice.constants.smartConnect
|
|
import com.vpn.fastestvpnservice.helpers.BasePreferenceHelper
|
|
import com.vpn.fastestvpnservice.helpers.BasePreferenceHelper
|
|
@@ -149,9 +150,10 @@ lateinit var vpnConnectionsUtil: VPNConnectionsUtil
|
|
Log.d("ServerCallbacks", "onServerSelected called!")
|
|
Log.d("ServerCallbacks", "onServerSelected called!")
|
|
|
|
|
|
val lastServer = basePreferenceHelper.getConnectedServer()
|
|
val lastServer = basePreferenceHelper.getConnectedServer()
|
|
|
|
+ val connectState = basePreferenceHelper.getConnectState()
|
|
if (isServerDialogShown) {
|
|
if (isServerDialogShown) {
|
|
Log.d("ServerCallbacks", "onServerSelected true!")
|
|
Log.d("ServerCallbacks", "onServerSelected true!")
|
|
- if (wg.isVPNConnected()) {
|
|
|
|
|
|
+ if (connectState == 2) {
|
|
Log.d("ServerCallbacks", "onServerSelected isVPNConnected!")
|
|
Log.d("ServerCallbacks", "onServerSelected isVPNConnected!")
|
|
if (lastServer?.id != server.id) {
|
|
if (lastServer?.id != server.id) {
|
|
isServerDialog.value = true
|
|
isServerDialog.value = true
|
|
@@ -176,17 +178,22 @@ lateinit var vpnConnectionsUtil: VPNConnectionsUtil
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- override fun onChangeProtocol(protocol: Protocol, context: Context, serverListViewModel: ServerListViewModel) {
|
|
|
|
|
|
+ override fun onChangeProtocol(
|
|
|
|
+ protocol: Protocol,
|
|
|
|
+ context: Context,
|
|
|
|
+ serverListViewModel: ServerListViewModel
|
|
|
|
+ ) {
|
|
val prefHelper = BasePreferenceHelper(context)
|
|
val prefHelper = BasePreferenceHelper(context)
|
|
val wg = VPNConnectionsUtil(context, act , homeViewModel1)
|
|
val wg = VPNConnectionsUtil(context, act , homeViewModel1)
|
|
protocolObj.value = protocol
|
|
protocolObj.value = protocol
|
|
|
|
+ val connectState = prefHelper.getConnectState()
|
|
|
|
|
|
if (getEnableProtocols(protocol.title, prefHelper)) {
|
|
if (getEnableProtocols(protocol.title, prefHelper)) {
|
|
Log.d("OnChangeProtocol", "getEnableProtocols yes!")
|
|
Log.d("OnChangeProtocol", "getEnableProtocols yes!")
|
|
|
|
|
|
if (prefHelper.getProtocol().index != protocol.index) {
|
|
if (prefHelper.getProtocol().index != protocol.index) {
|
|
|
|
|
|
- if (wg.isVPNConnected()) {
|
|
|
|
|
|
+ if (connectState == 2) {
|
|
navHostController1.popBackStack()
|
|
navHostController1.popBackStack()
|
|
isProtocolDialog.value = true
|
|
isProtocolDialog.value = true
|
|
}
|
|
}
|
|
@@ -218,27 +225,6 @@ lateinit var vpnConnectionsUtil: VPNConnectionsUtil
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- val ikev2Callback = object : IKEv2Callbacks {
|
|
|
|
- override fun ServerNotResponding(context: Context, homeViewModel: HomeViewModel) {
|
|
|
|
- Log.d("ServerNotResponding", "Home -> ")
|
|
|
|
- val wg = VPNConnectionsUtil(context, act , homeViewModel)
|
|
|
|
- wg.onResumeCallBack()
|
|
|
|
-
|
|
|
|
- val basePreferenceHelper = BasePreferenceHelper(context)
|
|
|
|
- if (basePreferenceHelper.getProtocol().index == 0) {
|
|
|
|
- Log.d("ServerNotResponding", "Auto -> ${wg.isBound}")
|
|
|
|
- } else {
|
|
|
|
- Log.d("ServerNotResponding", "IKEv2 -> ${wg.isBound}")
|
|
|
|
- Toast.makeText(
|
|
|
|
- context,
|
|
|
|
- context.getString(R.string.server_not_responding),
|
|
|
|
- Toast.LENGTH_SHORT
|
|
|
|
- ).show()
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
@OptIn(ExperimentalFoundationApi::class, ExperimentalMaterial3Api::class)
|
|
@OptIn(ExperimentalFoundationApi::class, ExperimentalMaterial3Api::class)
|
|
@Composable
|
|
@Composable
|
|
fun Home(
|
|
fun Home(
|
|
@@ -292,7 +278,7 @@ fun Home(
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- prefHelper.setServerObject(filterServerByConnectionCount)
|
|
|
|
|
|
+// prefHelper.setServerObject(filterServerByConnectionCount)
|
|
|
|
|
|
val widgetIntent = Intent(context, SimpleAppWidget::class.java)
|
|
val widgetIntent = Intent(context, SimpleAppWidget::class.java)
|
|
widgetIntent.action = SimpleAppWidget.ACTION_CHANGE_SERVER
|
|
widgetIntent.action = SimpleAppWidget.ACTION_CHANGE_SERVER
|
|
@@ -352,6 +338,21 @@ fun Home(
|
|
.background(MaterialTheme.colorScheme.background)
|
|
.background(MaterialTheme.colorScheme.background)
|
|
.fillMaxSize(),
|
|
.fillMaxSize(),
|
|
) {
|
|
) {
|
|
|
|
+ if (isServerDialog.value) {
|
|
|
|
+ ShowServerDialog(
|
|
|
|
+ basePreferenceHelper,
|
|
|
|
+ vpnConnectionsUtil
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (isProtocolDialog.value) {
|
|
|
|
+ ShowProtocolDialog(
|
|
|
|
+ basePreferenceHelper,
|
|
|
|
+ vpnConnectionsUtil,
|
|
|
|
+ serverListViewModel
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
// 1st box
|
|
// 1st box
|
|
Box(
|
|
Box(
|
|
@@ -598,18 +599,20 @@ fun Home(
|
|
val selectedSmartList = basePreferenceHelper.getSmartList()
|
|
val selectedSmartList = basePreferenceHelper.getSmartList()
|
|
when(selectedSmartList) {
|
|
when(selectedSmartList) {
|
|
smartConnect[0] -> {
|
|
smartConnect[0] -> {
|
|
- smartServer = basePreferenceHelper.getSmartServerObject()
|
|
|
|
|
|
+ smartServer = basePreferenceHelper.getRecommendedServerObject()
|
|
}
|
|
}
|
|
smartConnect[1] -> {
|
|
smartConnect[1] -> {
|
|
- smartServer = basePreferenceHelper.getServerObject()
|
|
|
|
|
|
+ smartServer = basePreferenceHelper.getSmartServerObject()
|
|
|
|
+ }
|
|
|
|
+ smartConnect[2] -> {
|
|
|
|
+ smartServer = basePreferenceHelper.getSmartServerObject()
|
|
}
|
|
}
|
|
- smartConnect[2] -> {}
|
|
|
|
else -> {}
|
|
else -> {}
|
|
}
|
|
}
|
|
Button(
|
|
Button(
|
|
onClick = {
|
|
onClick = {
|
|
Log.d("test_button", "onClick Smart Connect ${smartServer?.server_name}")
|
|
Log.d("test_button", "onClick Smart Connect ${smartServer?.server_name}")
|
|
- basePreferenceHelper.setServerObject(smartServer)
|
|
|
|
|
|
+// basePreferenceHelper.setSmartServerObject(smartServer)
|
|
basePreferenceHelper.setConnectedServer(smartServer)
|
|
basePreferenceHelper.setConnectedServer(smartServer)
|
|
if (isConnect == App.CONNECTED || isConnect == App.CONNECTING) {
|
|
if (isConnect == App.CONNECTED || isConnect == App.CONNECTING) {
|
|
Log.d("isConnect_State_vpn", "stopVPN")
|
|
Log.d("isConnect_State_vpn", "stopVPN")
|
|
@@ -679,564 +682,9 @@ fun Home(
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
-@OptIn(ExperimentalFoundationApi::class, ExperimentalMaterial3Api::class)
|
|
|
|
-@Composable
|
|
|
|
-fun Home2(
|
|
|
|
- navHostController: NavHostController,
|
|
|
|
- activity: ComponentActivity,
|
|
|
|
- settingsNavHostController: NavHostController
|
|
|
|
-) {
|
|
|
|
-
|
|
|
|
- Log.d("OnChangeProtocol", "Home called!")
|
|
|
|
- navHostController1 = navHostController
|
|
|
|
-
|
|
|
|
- val context = LocalContext.current
|
|
|
|
- val basePreferenceHelper = BasePreferenceHelper(context)
|
|
|
|
- act = activity
|
|
|
|
-
|
|
|
|
-// var isConnect by remember { mutableStateOf(basePreferenceHelper.getConnectState()) }
|
|
|
|
-
|
|
|
|
- val prefHelper = BasePreferenceHelper(context)
|
|
|
|
- val scope = rememberCoroutineScope()
|
|
|
|
- val homeViewModel: HomeViewModel = viewModel{
|
|
|
|
- HomeViewModel(context, scope)
|
|
|
|
- }
|
|
|
|
- val serverListViewModel: ServerListViewModel = viewModel{
|
|
|
|
- ServerListViewModel(context)
|
|
|
|
- }
|
|
|
|
- val splashViewModel: SplashViewModel = viewModel{
|
|
|
|
- SplashViewModel(context)
|
|
|
|
- }
|
|
|
|
- var server: Server = Server()
|
|
|
|
- vpnConnectionsUtil = VPNConnectionsUtil(context, activity, homeViewModel)
|
|
|
|
-// val wg = VPNConnectionsUtil(context, activity, homeViewModel)
|
|
|
|
- homeViewModel1 = homeViewModel
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- var isConnect: Int? = homeViewModel.isConnect.observeAsState().value
|
|
|
|
- Log.d("isConnect_State", "live: $isConnect")
|
|
|
|
- isConnect = basePreferenceHelper.getConnectState()
|
|
|
|
- Log.d("isConnect_State", "$isConnect prefs => ${basePreferenceHelper.getConnectState()}")
|
|
|
|
-
|
|
|
|
- OnLifecycleEvent{owner, event ->
|
|
|
|
- when(event) {
|
|
|
|
- Lifecycle.Event.ON_RESUME -> {
|
|
|
|
- Log.d("test_home_resume", "ON_RESUME: Home Screen!")
|
|
|
|
-
|
|
|
|
- try {
|
|
|
|
- App.backend?.runningTunnelNames
|
|
|
|
- } catch (e: Exception) {
|
|
|
|
- val back = GoBackend(context)
|
|
|
|
- App.setBackend(back)
|
|
|
|
- App.backend = App.getBackend()
|
|
|
|
- }
|
|
|
|
- vpnConnectionsUtil.onResumeCallBack()
|
|
|
|
-
|
|
|
|
- homeViewModel.getIp()
|
|
|
|
-
|
|
|
|
- var filterServerByConnectionCount = Server()
|
|
|
|
- if (prefHelper.getServerObject() != null) {
|
|
|
|
- prefHelper.getServerObject()?.let {
|
|
|
|
- filterServerByConnectionCount = it
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- val smartServer = basePreferenceHelper.getSmartServerObject()
|
|
|
|
- smartServer?.let {
|
|
|
|
- filterServerByConnectionCount = it
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- prefHelper.setServerObject(filterServerByConnectionCount)
|
|
|
|
-
|
|
|
|
- val widgetIntent = Intent(context, SimpleAppWidget::class.java)
|
|
|
|
- widgetIntent.action = SimpleAppWidget.ACTION_CHANGE_SERVER
|
|
|
|
- context.sendBroadcast(widgetIntent)
|
|
|
|
-
|
|
|
|
- server = filterServerByConnectionCount
|
|
|
|
-
|
|
|
|
-// splashViewModel.serverDataApi()
|
|
|
|
- homeViewModel.validatePassword(
|
|
|
|
- prefHelper.getUser()?.userinfo?.email.toString(),
|
|
|
|
- prefHelper.getPassword().toString(),
|
|
|
|
- "android",
|
|
|
|
- android.os.Build.VERSION.RELEASE
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
- Lifecycle.Event.ON_PAUSE -> {
|
|
|
|
- Log.d("test_home_resume", "ON_PAUSE: Home Screen!")
|
|
|
|
- vpnConnectionsUtil.onPauseCallBack()
|
|
|
|
-
|
|
|
|
- val widgetIntent = Intent(context, SimpleAppWidget::class.java)
|
|
|
|
- widgetIntent.action = SimpleAppWidget.ACTION_CHANGE_SERVER
|
|
|
|
- context.sendBroadcast(widgetIntent)
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- Lifecycle.Event.ON_STOP -> {
|
|
|
|
- Log.d("test_home_resume", "ON_STOP: Home Screen!")
|
|
|
|
- vpnConnectionsUtil.onStopCallBack()
|
|
|
|
- }
|
|
|
|
- Lifecycle.Event.ON_DESTROY -> {
|
|
|
|
- Log.d("test_home_resume", "ON_DESTROY: Home Screen!")
|
|
|
|
- vpnConnectionsUtil.onPauseCallBack()
|
|
|
|
- }
|
|
|
|
- else -> {
|
|
|
|
- Log.d("test_home_resume", "else: Home Screen!")
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- val ip = homeViewModel.mutableLiveDataIpInfo.observeAsState().value
|
|
|
|
- val validateResponse = homeViewModel.liveDataValidate.observeAsState().value
|
|
|
|
- validateResponse?.let {
|
|
|
|
- Log.d("test_api_validate", "home => ${it.status} ${it.message}")
|
|
|
|
-
|
|
|
|
- if (!it.status) {
|
|
|
|
- basePreferenceHelper.setLoggedInState(false)
|
|
|
|
- basePreferenceHelper.clearAllData()
|
|
|
|
- settingsNavHostController.popBackStack()
|
|
|
|
- settingsNavHostController.navigate(Screen.Started.route)
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- homeViewModel._mutableLiveDataValidate.value = null
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-// LaunchedEffect(key1 = Unit){
|
|
|
|
-// homeViewModel.validatePassword(
|
|
|
|
-// prefHelper.getUser()?.userinfo?.email.toString(),
|
|
|
|
-// prefHelper.getPassword().toString(),
|
|
|
|
-// "android",
|
|
|
|
-// android.os.Build.VERSION.RELEASE
|
|
|
|
-// )
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
- Box(
|
|
|
|
- modifier = Modifier
|
|
|
|
- .background(MaterialTheme.colorScheme.background)
|
|
|
|
- .fillMaxSize(),
|
|
|
|
- ) {
|
|
|
|
-
|
|
|
|
- Image(
|
|
|
|
- modifier = Modifier
|
|
|
|
- .fillMaxWidth()
|
|
|
|
- .align(Alignment.TopStart)
|
|
|
|
- .height(300.dp)
|
|
|
|
- .padding(top = 0.dp),
|
|
|
|
- painter = if (isConnect == App.CONNECTED) blueBackground() else pinkBackground(),
|
|
|
|
- contentDescription = "Home Map",
|
|
|
|
- contentScale = ContentScale.FillBounds,
|
|
|
|
- )
|
|
|
|
-
|
|
|
|
- Image(
|
|
|
|
- modifier = Modifier
|
|
|
|
- .fillMaxWidth()
|
|
|
|
- .align(Alignment.TopStart)
|
|
|
|
- .padding(top = 30.dp)
|
|
|
|
- .alpha(if (isDarkTheme.value) 0.1F else 0.6F),
|
|
|
|
- painter = painterResource(id = R.drawable.map_home3x),
|
|
|
|
- contentDescription = "Home Map",
|
|
|
|
- contentScale = ContentScale.FillWidth,
|
|
|
|
- )
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- if (isServerDialog.value) {
|
|
|
|
- ShowServerDialog(
|
|
|
|
- basePreferenceHelper,
|
|
|
|
- vpnConnectionsUtil
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (isProtocolDialog.value) {
|
|
|
|
- ShowProtocolDialog(
|
|
|
|
- basePreferenceHelper,
|
|
|
|
- vpnConnectionsUtil,
|
|
|
|
- serverListViewModel
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- IconButton(
|
|
|
|
- onClick = {
|
|
|
|
- Log.d("isConnect_State", "onClick{} -> $isConnect")
|
|
|
|
- Log.d("isConnect_State_vpn", "onClick{} -> $isConnect")
|
|
|
|
-
|
|
|
|
- prefHelper.getProduct()?.identifier.let {
|
|
|
|
- val identifier = it
|
|
|
|
-
|
|
|
|
- if (identifier == AppEnum.FREE.key) {
|
|
|
|
- Log.d("isConnect_State", "identifier -> $identifier")
|
|
|
|
- Screen.Subscription.isTrue = true
|
|
|
|
- navHostController.navigate(
|
|
|
|
- Screen.Subscription.route
|
|
|
|
- )
|
|
|
|
-
|
|
|
|
- } else {
|
|
|
|
- prefHelper.getServerObject()?.let {
|
|
|
|
- prefHelper.setConnectedServer(it)
|
|
|
|
- }
|
|
|
|
- Log.d("isConnect_State", "identifier -> $identifier")
|
|
|
|
- if (isConnect == App.CONNECTED || isConnect == App.CONNECTING) {
|
|
|
|
- Log.d("isConnect_State_vpn", "stopVPN")
|
|
|
|
- vpnConnectionsUtil.stopVpn()
|
|
|
|
- homeViewModel.getIp()
|
|
|
|
- } else {
|
|
|
|
- Log.d("isConnect_State_vpn", "startVPN")
|
|
|
|
- vpnConnectionsUtil.startVpn()
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- val widgetIntent = Intent(context, SimpleAppWidget::class.java)
|
|
|
|
- widgetIntent.action = SimpleAppWidget.ACTION_CHANGE_SERVER
|
|
|
|
- context.sendBroadcast(widgetIntent)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- },
|
|
|
|
- modifier = Modifier
|
|
|
|
- .align(Alignment.TopCenter)
|
|
|
|
- .padding(top = 80.dp)
|
|
|
|
- .fillMaxSize()
|
|
|
|
- .size(235.dp)
|
|
|
|
- ,
|
|
|
|
- )
|
|
|
|
- {
|
|
|
|
- if (isConnect == App.CONNECTED) {
|
|
|
|
- Image(
|
|
|
|
- painter = if (isDarkTheme.value) painterResource(id = R.drawable.iv_connect_dark)
|
|
|
|
- else painterResource(id = R.drawable.iv_connect),
|
|
|
|
- contentDescription = "Home Map",
|
|
|
|
- contentScale = ContentScale.FillBounds,
|
|
|
|
- modifier = Modifier.size(235.dp)
|
|
|
|
- )
|
|
|
|
- } else {
|
|
|
|
- Image(
|
|
|
|
- painter = if (isDarkTheme.value) painterResource(id = R.drawable.iv_disconnect_dark)
|
|
|
|
- else painterResource(id = R.drawable.iv_disconnect),
|
|
|
|
- contentDescription = "Home Map",
|
|
|
|
- contentScale = ContentScale.FillBounds,
|
|
|
|
- modifier = Modifier.size(235.dp)
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- Column(
|
|
|
|
- verticalArrangement = Arrangement.SpaceEvenly,
|
|
|
|
- horizontalAlignment = Alignment.CenterHorizontally,
|
|
|
|
- modifier = Modifier
|
|
|
|
- .fillMaxWidth()
|
|
|
|
- .background(Color.Transparent)
|
|
|
|
- .align(Alignment.TopStart)
|
|
|
|
- .padding(top = 40.dp)
|
|
|
|
- .height(125.dp),
|
|
|
|
- ) {
|
|
|
|
- val serverObj = basePreferenceHelper.getConnectedServer()
|
|
|
|
- val serverDis = basePreferenceHelper.getIpinfo()
|
|
|
|
-
|
|
|
|
- var ipInfo = homeViewModel.mutableLiveDataIpInfo.observeAsState().value?.query
|
|
|
|
- ipInfo = if (isConnect == App.CONNECTED) serverObj?.ip.toString() else serverDis?.query
|
|
|
|
- AddText(
|
|
|
|
- text = "$ipInfo",
|
|
|
|
- size = 18.sp,
|
|
|
|
- color = MaterialTheme.colorScheme.primary,
|
|
|
|
- style = MaterialTheme.typography.customTypography.headlineLarge
|
|
|
|
- )
|
|
|
|
- Row(
|
|
|
|
- ) {
|
|
|
|
- if (isConnect == App.CONNECTED) {
|
|
|
|
- val image = Utils.getDrawable(context, serverObj?.iso)
|
|
|
|
- if (image != 0) {
|
|
|
|
- Image(
|
|
|
|
- painter = painterResource(id = image),
|
|
|
|
- contentDescription = "Country",
|
|
|
|
- modifier = Modifier
|
|
|
|
- .padding(end = 6.dp)
|
|
|
|
- .size(20.dp)
|
|
|
|
- .clip(CircleShape)
|
|
|
|
- .paint(
|
|
|
|
- painter = painterResource(id = image),
|
|
|
|
- contentScale = ContentScale.FillHeight
|
|
|
|
- )
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
- AddText(
|
|
|
|
- text = "${serverObj?.server_name ?: ""}, ${serverObj?.country ?: ""}",
|
|
|
|
- size = 16.sp,
|
|
|
|
- color = MaterialTheme.colorScheme.primary,
|
|
|
|
- )
|
|
|
|
- } else {
|
|
|
|
- val image = Utils.getDrawable(context, serverDis?.countryCode)
|
|
|
|
- Log.d("image_logo", "$image ${serverDis?.countryCode}")
|
|
|
|
- if (image != 0) {
|
|
|
|
- Image(
|
|
|
|
- painter = painterResource(id = image),
|
|
|
|
- contentDescription = "Server",
|
|
|
|
- modifier = Modifier
|
|
|
|
- .padding(end = 6.dp)
|
|
|
|
- .size(20.dp)
|
|
|
|
- .clip(CircleShape)
|
|
|
|
- .paint(
|
|
|
|
- painter = painterResource(id = image),
|
|
|
|
- contentScale = ContentScale.FillHeight
|
|
|
|
- )
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
- AddText(
|
|
|
|
- text = "${serverDis?.city ?: ""}, ${serverDis?.country ?: ""}",
|
|
|
|
- size = 16.sp,
|
|
|
|
- color = MaterialTheme.colorScheme.primary
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (isConnect == App.CONNECTED) {
|
|
|
|
- AddText(
|
|
|
|
- text = "Connected",
|
|
|
|
- size = 18.sp,
|
|
|
|
- color = MaterialTheme.colorScheme.surfaceContainerHigh,
|
|
|
|
- style = MaterialTheme.typography.customTypography.displaySmall
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
- else if (isConnect == App.DISCONNECTED) {
|
|
|
|
- AddText(
|
|
|
|
- text = "Disconnected",
|
|
|
|
- size = 18.sp,
|
|
|
|
- color = MaterialTheme.colorScheme.surfaceTint,
|
|
|
|
- style = MaterialTheme.typography.customTypography.displaySmall
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
- else if (isConnect == App.CONNECTING) {
|
|
|
|
- AddText(
|
|
|
|
- text = "Connecting...",
|
|
|
|
- size = 18.sp,
|
|
|
|
- color = MaterialTheme.colorScheme.surfaceTint,
|
|
|
|
- style = MaterialTheme.typography.customTypography.displaySmall
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- CompositionLocalProvider(
|
|
|
|
- LocalOverscrollConfiguration provides null
|
|
|
|
- ) {
|
|
|
|
- Column(
|
|
|
|
- modifier = Modifier
|
|
|
|
- .align(Alignment.TopCenter)
|
|
|
|
- .padding(top = 425.dp, bottom = 10.dp)
|
|
|
|
- .verticalScroll(rememberScrollState())
|
|
|
|
- .fillMaxSize()
|
|
|
|
- ) {
|
|
|
|
- /* Smart Connect Box*/
|
|
|
|
-// if (isConnect == App.CONNECTED) {
|
|
|
|
-//
|
|
|
|
-// /* Commenting so far because It's remaining... */
|
|
|
|
-// Box(
|
|
|
|
-// modifier = Modifier
|
|
|
|
-// .fillMaxWidth()
|
|
|
|
-// .padding(16.dp)
|
|
|
|
-// .padding(top = 0.dp)
|
|
|
|
-// .height(110.dp)
|
|
|
|
-//// .border(
|
|
|
|
-//// border = BorderStroke(0.dp, Color.Blue),
|
|
|
|
-//// shape = RoundedCornerShape(28.dp)
|
|
|
|
-//// )
|
|
|
|
-// .background(
|
|
|
|
-// color = Color.Transparent
|
|
|
|
-// ),
|
|
|
|
-// ) {
|
|
|
|
-// Row(
|
|
|
|
-// modifier = Modifier
|
|
|
|
-// .padding(0.dp)
|
|
|
|
-// .background(Color.Transparent),
|
|
|
|
-// horizontalArrangement = Arrangement.SpaceAround,
|
|
|
|
-// verticalAlignment = Alignment.CenterVertically
|
|
|
|
-// ) {
|
|
|
|
-// Surface(
|
|
|
|
-// modifier = Modifier
|
|
|
|
-// .weight(1f)
|
|
|
|
-// .background(Color.Transparent)
|
|
|
|
-// .fillMaxHeight()
|
|
|
|
-// .padding(end = 5.dp),
|
|
|
|
-// shape = RoundedCornerShape(24.dp)
|
|
|
|
-//
|
|
|
|
-// ) {
|
|
|
|
-// Column(
|
|
|
|
-// modifier = Modifier
|
|
|
|
-// .background(Color.White),
|
|
|
|
-// verticalArrangement = Arrangement.SpaceEvenly,
|
|
|
|
-// horizontalAlignment = Alignment.CenterHorizontally
|
|
|
|
-// ) {
|
|
|
|
-// Image(
|
|
|
|
-// painter = painterResource(id = R.drawable.greenarrow3x),
|
|
|
|
-// contentDescription = "Green Arrow",
|
|
|
|
-// modifier = Modifier
|
|
|
|
-// .size(30.dp)
|
|
|
|
-// )
|
|
|
|
-// Text(
|
|
|
|
-// text = "Download",
|
|
|
|
-// style = MaterialTheme.typography.customTypography.displayMedium,
|
|
|
|
-// modifier = Modifier.alpha(0.6F)
|
|
|
|
-// )
|
|
|
|
-// Row(
|
|
|
|
-// horizontalArrangement = Arrangement.SpaceAround,
|
|
|
|
-// verticalAlignment = Alignment.CenterVertically
|
|
|
|
-// ) {
|
|
|
|
-// Text(
|
|
|
|
-// text = "30.68",
|
|
|
|
-// style = MaterialTheme.typography.customTypography.displayLarge
|
|
|
|
-// )
|
|
|
|
-// Text(
|
|
|
|
-// text = " MB/S",
|
|
|
|
-// style = MaterialTheme.typography.customTypography2.labelSmall,
|
|
|
|
-// modifier = Modifier.alpha(0.5F)
|
|
|
|
-// )
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// Surface(
|
|
|
|
-// modifier = Modifier
|
|
|
|
-// .weight(1f)
|
|
|
|
-// .background(Color.Transparent)
|
|
|
|
-// .fillMaxHeight()
|
|
|
|
-// .padding(start = 5.dp),
|
|
|
|
-// shape = RoundedCornerShape(24.dp)
|
|
|
|
-// ) {
|
|
|
|
-// Column(
|
|
|
|
-// modifier = Modifier
|
|
|
|
-// .background(Color.White),
|
|
|
|
-// verticalArrangement = Arrangement.SpaceEvenly,
|
|
|
|
-// horizontalAlignment = Alignment.CenterHorizontally
|
|
|
|
-// ) {
|
|
|
|
-// Image(
|
|
|
|
-// painter = painterResource(id = R.drawable.yellowarrow3x),
|
|
|
|
-// contentDescription = "Green Arrow",
|
|
|
|
-// modifier = Modifier
|
|
|
|
-// .size(30.dp)
|
|
|
|
-// )
|
|
|
|
-// Text(
|
|
|
|
-// text = "Upload",
|
|
|
|
-// style = MaterialTheme.typography.customTypography.displayMedium,
|
|
|
|
-// modifier = Modifier.alpha(0.6F)
|
|
|
|
-// )
|
|
|
|
-// Row(
|
|
|
|
-// horizontalArrangement = Arrangement.SpaceAround,
|
|
|
|
-// verticalAlignment = Alignment.CenterVertically
|
|
|
|
-// ) {
|
|
|
|
-// Text(
|
|
|
|
-// text = "12.11",
|
|
|
|
-// style = MaterialTheme.typography.customTypography.displayLarge
|
|
|
|
-//
|
|
|
|
-// )
|
|
|
|
-// Text(
|
|
|
|
-// text = " MB/S",
|
|
|
|
-// style = MaterialTheme.typography.customTypography2.labelSmall,
|
|
|
|
-// modifier = Modifier.alpha(0.5F)
|
|
|
|
-// )
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// else { }
|
|
|
|
-
|
|
|
|
- Box(
|
|
|
|
- modifier = Modifier
|
|
|
|
- .fillMaxWidth()
|
|
|
|
- .padding(20.dp)
|
|
|
|
- .padding(top = 0.dp)
|
|
|
|
- .height(120.dp)
|
|
|
|
- .border(
|
|
|
|
- border = BorderStroke(2.dp, MaterialTheme.colorScheme.onBackground),
|
|
|
|
- shape = RoundedCornerShape(28.dp)
|
|
|
|
- )
|
|
|
|
- .background(
|
|
|
|
- shape = RoundedCornerShape(28.dp),
|
|
|
|
- color = MaterialTheme.colorScheme.onBackground
|
|
|
|
- ),
|
|
|
|
- ) {
|
|
|
|
- AddRowSmart(navHostController, basePreferenceHelper, context)
|
|
|
|
- var smartServer = basePreferenceHelper.getSmartServerObject()
|
|
|
|
- val selectedSmartList = basePreferenceHelper.getSmartList()
|
|
|
|
- when(selectedSmartList) {
|
|
|
|
- smartConnect[0] -> {
|
|
|
|
- smartServer = basePreferenceHelper.getSmartServerObject()
|
|
|
|
- }
|
|
|
|
- smartConnect[1] -> {
|
|
|
|
- smartServer = basePreferenceHelper.getServerObject()
|
|
|
|
- }
|
|
|
|
- smartConnect[2] -> {}
|
|
|
|
- else -> {}
|
|
|
|
- }
|
|
|
|
- Button(
|
|
|
|
- onClick = {
|
|
|
|
- Log.d("test_button", "onClick Smart Connect ${smartServer?.server_name}")
|
|
|
|
- basePreferenceHelper.setServerObject(smartServer)
|
|
|
|
- basePreferenceHelper.setConnectedServer(smartServer)
|
|
|
|
- if (isConnect == App.CONNECTED || isConnect == App.CONNECTING) {
|
|
|
|
- Log.d("isConnect_State_vpn", "stopVPN")
|
|
|
|
- vpnConnectionsUtil.stopVpn()
|
|
|
|
- Handler().postDelayed(Runnable {
|
|
|
|
- vpnConnectionsUtil.startVpn()
|
|
|
|
- }, 500)
|
|
|
|
- homeViewModel.getIp()
|
|
|
|
- } else {
|
|
|
|
- Log.d("isConnect_State_vpn", "startVPN")
|
|
|
|
- vpnConnectionsUtil.startVpn()
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-// navHostController.navigate(
|
|
|
|
-// BottomBarScreen.Settings.route
|
|
|
|
-// )
|
|
|
|
-// BottomBarScreen.Settings.isTrue = true
|
|
|
|
-
|
|
|
|
- },
|
|
|
|
- modifier = Modifier
|
|
|
|
- .padding(start = 14.dp, end = 14.dp, bottom = 12.dp, top = 16.dp)
|
|
|
|
- .align(Alignment.BottomCenter)
|
|
|
|
- .background(colorResource(id = R.color.transparent))
|
|
|
|
- .fillMaxWidth()
|
|
|
|
- .height(40.dp),
|
|
|
|
- shape = RoundedCornerShape(16.dp),
|
|
|
|
- colors = ButtonDefaults.buttonColors(
|
|
|
|
- contentColor = colorResource(id = R.color.white),
|
|
|
|
- containerColor = colorResource(id = R.color.blue_text),
|
|
|
|
- ),
|
|
|
|
- ) {
|
|
|
|
- Text(
|
|
|
|
- text = "Smart Connect",
|
|
|
|
- style = MaterialTheme.typography.customTypography.labelLarge,
|
|
|
|
- modifier = Modifier.background(Color.Transparent)
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /* Select Server Box*/
|
|
|
|
-// if (isConnect != App.CONNECTED) { }
|
|
|
|
-
|
|
|
|
- Box(
|
|
|
|
- modifier = Modifier
|
|
|
|
- .fillMaxWidth()
|
|
|
|
- .padding(horizontal = 20.dp, vertical = 5.dp)
|
|
|
|
- .padding(bottom = 0.dp)
|
|
|
|
- .height(70.dp)
|
|
|
|
- .border(
|
|
|
|
- border = BorderStroke(2.dp, MaterialTheme.colorScheme.onBackground),
|
|
|
|
- shape = RoundedCornerShape(28.dp)
|
|
|
|
- )
|
|
|
|
- .background(
|
|
|
|
- shape = RoundedCornerShape(28.dp),
|
|
|
|
- color = MaterialTheme.colorScheme.onBackground
|
|
|
|
- ),
|
|
|
|
- contentAlignment = Alignment.CenterStart,
|
|
|
|
- ) {
|
|
|
|
- AddRowSelectServer(navHostController)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
@Composable
|
|
@Composable
|
|
-fun BoxScope.ShowServerDialog(
|
|
|
|
|
|
+fun ColumnScope.ShowServerDialog(
|
|
prefHelper: BasePreferenceHelper,
|
|
prefHelper: BasePreferenceHelper,
|
|
wg: VPNConnectionsUtil
|
|
wg: VPNConnectionsUtil
|
|
) {
|
|
) {
|
|
@@ -1363,7 +811,7 @@ fun BoxScope.ShowServerDialog(
|
|
|
|
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
@Composable
|
|
@Composable
|
|
-fun BoxScope.ShowProtocolDialog(
|
|
|
|
|
|
+fun ColumnScope.ShowProtocolDialog(
|
|
prefHelper: BasePreferenceHelper,
|
|
prefHelper: BasePreferenceHelper,
|
|
wg: VPNConnectionsUtil,
|
|
wg: VPNConnectionsUtil,
|
|
serverListViewModel: ServerListViewModel
|
|
serverListViewModel: ServerListViewModel
|
|
@@ -1562,48 +1010,51 @@ fun BoxScope.AddRowSmart(
|
|
) {
|
|
) {
|
|
val smart = basePreferenceHelper.getSmartServerObject()
|
|
val smart = basePreferenceHelper.getSmartServerObject()
|
|
val recommended = basePreferenceHelper.getRecommendedServerObject()
|
|
val recommended = basePreferenceHelper.getRecommendedServerObject()
|
|
- val recently = basePreferenceHelper.getServerObject()
|
|
|
|
- val anySpecific = basePreferenceHelper.getServerObject()
|
|
|
|
|
|
+ val recently = basePreferenceHelper.getSmartServerObject()
|
|
|
|
+ val anySpecific = basePreferenceHelper.getSmartServerObject()
|
|
|
|
+
|
|
val ipInfo = basePreferenceHelper.getIpinfo()
|
|
val ipInfo = basePreferenceHelper.getIpinfo()
|
|
val selectedSmartList = basePreferenceHelper.getSmartList()
|
|
val selectedSmartList = basePreferenceHelper.getSmartList()
|
|
- var selectedServer = basePreferenceHelper.getServerObject()
|
|
|
|
|
|
+ var selectedServer = basePreferenceHelper.getSmartServerObject()
|
|
var selectedSmartServer = basePreferenceHelper.getSmartServerObject()
|
|
var selectedSmartServer = basePreferenceHelper.getSmartServerObject()
|
|
|
|
|
|
- Log.d("smartLocationList", "Home:: server = ${anySpecific?.server_name}")
|
|
|
|
|
|
+ Log.d("smartLocationList", "Home:: server = ${recently?.server_name}")
|
|
var icon = Utils.getDrawable(context, selectedServer?.iso)
|
|
var icon = Utils.getDrawable(context, selectedServer?.iso)
|
|
|
|
|
|
- if (MainActivity.isSelectedServersShown) {
|
|
|
|
- selectedServer = basePreferenceHelper.getServerObject()
|
|
|
|
- icon = Utils.getDrawable(context, selectedServer?.iso)
|
|
|
|
|
|
+// if (MainActivity.isSelectedServersShown) {
|
|
|
|
+// selectedServer = basePreferenceHelper.getServerObject()
|
|
|
|
+// icon = Utils.getDrawable(context, selectedServer?.iso)
|
|
|
|
+//
|
|
|
|
+// when(selectedSmartList) {
|
|
|
|
+// smartConnect[0] -> {
|
|
|
|
+// selectedSmartServer = recommended
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// } else {
|
|
|
|
+//
|
|
|
|
+// }
|
|
|
|
|
|
- when(selectedSmartList) {
|
|
|
|
- smartConnect[0] -> {
|
|
|
|
- selectedSmartServer = recommended
|
|
|
|
- }
|
|
|
|
|
|
+ when(selectedSmartList) {
|
|
|
|
+ smartConnect[0] -> {
|
|
|
|
+ icon = Utils.getDrawable(context, recommended?.iso)
|
|
|
|
+ selectedServer = recommended
|
|
|
|
+ selectedSmartServer = recommended
|
|
}
|
|
}
|
|
-
|
|
|
|
- } else {
|
|
|
|
- when(selectedSmartList) {
|
|
|
|
- smartConnect[0] -> {
|
|
|
|
- icon = Utils.getDrawable(context, smart?.iso)
|
|
|
|
- selectedServer = smart
|
|
|
|
- selectedSmartServer = recommended
|
|
|
|
- }
|
|
|
|
- smartConnect[1] -> {
|
|
|
|
- icon = Utils.getDrawable(context, recently?.iso)
|
|
|
|
- selectedServer = recently
|
|
|
|
- selectedSmartServer = recently
|
|
|
|
- }
|
|
|
|
- smartConnect[2] -> {
|
|
|
|
- icon = Utils.getDrawable(context, anySpecific?.iso)
|
|
|
|
- selectedServer = anySpecific
|
|
|
|
- selectedSmartServer = anySpecific
|
|
|
|
- }
|
|
|
|
- else -> {}
|
|
|
|
|
|
+ smartConnect[1] -> {
|
|
|
|
+ icon = Utils.getDrawable(context, recently?.iso)
|
|
|
|
+ selectedServer = recently
|
|
|
|
+ selectedSmartServer = recently
|
|
|
|
+ }
|
|
|
|
+ smartConnect[2] -> {
|
|
|
|
+ icon = Utils.getDrawable(context, anySpecific?.iso)
|
|
|
|
+ selectedServer = anySpecific
|
|
|
|
+ selectedSmartServer = anySpecific
|
|
}
|
|
}
|
|
|
|
+ else -> {}
|
|
}
|
|
}
|
|
|
|
|
|
- basePreferenceHelper.setSmartServerObject(selectedSmartServer)
|
|
|
|
|
|
+// basePreferenceHelper.setSmartServerObject(selectedSmartServer)
|
|
|
|
|
|
Row(
|
|
Row(
|
|
modifier = Modifier
|
|
modifier = Modifier
|
|
@@ -1661,6 +1112,7 @@ fun BoxScope.AddRowSmart(
|
|
MaterialTheme.colorScheme.surfaceContainerLow
|
|
MaterialTheme.colorScheme.surfaceContainerLow
|
|
),
|
|
),
|
|
onClick = {
|
|
onClick = {
|
|
|
|
+ toChangeServer.value = true
|
|
navHostController.navigate(
|
|
navHostController.navigate(
|
|
Screen.ServerList.route
|
|
Screen.ServerList.route
|
|
)
|
|
)
|
|
@@ -1681,6 +1133,7 @@ fun BoxScope.AddRowSelectServer(navHostController: NavHostController) {
|
|
.background(Color.Transparent)
|
|
.background(Color.Transparent)
|
|
.pointerInput(Unit) {
|
|
.pointerInput(Unit) {
|
|
detectTapGestures {
|
|
detectTapGestures {
|
|
|
|
+ toChangeServer.value = false
|
|
navHostController.navigate(
|
|
navHostController.navigate(
|
|
Screen.ServerList.route
|
|
Screen.ServerList.route
|
|
)
|
|
)
|