|
@@ -2,6 +2,7 @@ package com.vpn.fastestvpnservice.screens.bottomNavBarScreens
|
|
|
|
|
|
import android.content.Context
|
|
|
import android.content.res.Configuration
|
|
|
+import android.location.Location
|
|
|
import android.os.Handler
|
|
|
import android.util.Log
|
|
|
import android.widget.Toast
|
|
@@ -100,6 +101,7 @@ import com.vpn.fastestvpnservice.beans.Protocol
|
|
|
import com.vpn.fastestvpnservice.beans.Server
|
|
|
import com.vpn.fastestvpnservice.beans.isDarkTheme
|
|
|
import com.vpn.fastestvpnservice.constants.AppEnum
|
|
|
+import com.vpn.fastestvpnservice.constants.smartConnect
|
|
|
import com.vpn.fastestvpnservice.helpers.BasePreferenceHelper
|
|
|
import com.vpn.fastestvpnservice.interfaces.ServerCallbacks
|
|
|
import com.vpn.fastestvpnservice.sealedClass.BottomBarScreen
|
|
@@ -230,7 +232,7 @@ fun Home(navHostController: NavHostController, activity: ComponentActivity) {
|
|
|
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 -> {
|
|
@@ -323,6 +325,8 @@ fun Home(navHostController: NavHostController, activity: ComponentActivity) {
|
|
|
"android",
|
|
|
android.os.Build.VERSION.RELEASE
|
|
|
)
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
Box(
|
|
@@ -641,14 +645,36 @@ fun Home(navHostController: NavHostController, activity: ComponentActivity) {
|
|
|
),
|
|
|
// contentAlignment = Alignment.TopCenter,
|
|
|
) {
|
|
|
- AddRowSmart(navHostController)
|
|
|
+ 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")
|
|
|
- navHostController.navigate(
|
|
|
- BottomBarScreen.Settings.route
|
|
|
- )
|
|
|
- BottomBarScreen.Settings.isTrue = true
|
|
|
+ Log.d("test_button", "onClick Smart Connect ${smartServer?.server_name}")
|
|
|
+ basePreferenceHelper.setServerObject(smartServer)
|
|
|
+ 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()
|
|
|
+ }
|
|
|
+
|
|
|
+// navHostController.navigate(
|
|
|
+// BottomBarScreen.Settings.route
|
|
|
+// )
|
|
|
+// BottomBarScreen.Settings.isTrue = true
|
|
|
|
|
|
},
|
|
|
modifier = Modifier
|
|
@@ -1001,7 +1027,33 @@ fun ColumnScope.ColumnText(
|
|
|
}
|
|
|
|
|
|
@Composable
|
|
|
-fun BoxScope.AddRowSmart(navHostController: NavHostController) {
|
|
|
+fun BoxScope.AddRowSmart(
|
|
|
+ navHostController: NavHostController,
|
|
|
+ basePreferenceHelper: BasePreferenceHelper,
|
|
|
+ context: Context
|
|
|
+) {
|
|
|
+ val smart = basePreferenceHelper.getSmartServerObject()
|
|
|
+ val recently = basePreferenceHelper.getServerObject()
|
|
|
+ val ipInfo = basePreferenceHelper.getIpinfo()
|
|
|
+ val selectedSmartList = basePreferenceHelper.getSmartList()
|
|
|
+ var selectedServer = basePreferenceHelper.getServerObject()
|
|
|
+
|
|
|
+ Log.d("smartLocationList", "Home:: server = ${smart?.server_name}")
|
|
|
+ var icon = Utils.getDrawable(context, selectedServer?.iso)
|
|
|
+
|
|
|
+ when(selectedSmartList) {
|
|
|
+ smartConnect[0] -> {
|
|
|
+ icon = Utils.getDrawable(context, smart?.iso)
|
|
|
+ selectedServer = smart
|
|
|
+ }
|
|
|
+ smartConnect[1] -> {
|
|
|
+ icon = Utils.getDrawable(context, recently?.iso)
|
|
|
+ selectedServer = recently
|
|
|
+ }
|
|
|
+ smartConnect[2] -> {}
|
|
|
+ else -> {}
|
|
|
+ }
|
|
|
+
|
|
|
Row(
|
|
|
modifier = Modifier
|
|
|
.fillMaxWidth()
|
|
@@ -1015,13 +1067,19 @@ fun BoxScope.AddRowSmart(navHostController: NavHostController) {
|
|
|
modifier = Modifier.padding(start = 0.dp),
|
|
|
color = Color.Transparent
|
|
|
) {
|
|
|
- Image(
|
|
|
- painter = painterResource(id = R.drawable.dubai3x),
|
|
|
+ Icon(
|
|
|
+ painter = painterResource(id = icon),
|
|
|
contentDescription = "Country Logo",
|
|
|
+ tint = Color.Unspecified,
|
|
|
modifier = Modifier
|
|
|
.padding(start = 0.dp)
|
|
|
.size(40.dp)
|
|
|
.weight(1f)
|
|
|
+ .clip(CircleShape)
|
|
|
+ .paint(
|
|
|
+ painter = painterResource(id = icon),
|
|
|
+ contentScale = ContentScale.FillHeight
|
|
|
+ )
|
|
|
)
|
|
|
}
|
|
|
Column(
|
|
@@ -1029,13 +1087,13 @@ fun BoxScope.AddRowSmart(navHostController: NavHostController) {
|
|
|
.padding(start = 12.dp)
|
|
|
) {
|
|
|
ColumnText(
|
|
|
- text = "Fastest Location",
|
|
|
+ text = selectedSmartList,
|
|
|
color = colorResource(id = R.color.blue_text),
|
|
|
size = 12.sp,
|
|
|
style = MaterialTheme.typography.customTypography.headlineSmall
|
|
|
)
|
|
|
ColumnText(
|
|
|
- text = "United Arab Emirates",
|
|
|
+ text = "${selectedServer?.server_name}",
|
|
|
color = colorResource(id = R.color.dark_blue_gray_text),
|
|
|
size = 16.sp,
|
|
|
style = MaterialTheme.typography.labelMedium
|