|
@@ -97,6 +97,7 @@ import androidx.lifecycle.LifecycleOwner
|
|
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
|
|
import androidx.navigation.NavHostController
|
|
|
import androidx.navigation.compose.rememberNavController
|
|
|
+import com.vpn.fastestvpnservice.MainActivity
|
|
|
import de.blinkt.openvpn.core.App
|
|
|
import com.vpn.fastestvpnservice.beans.Protocol
|
|
|
import com.vpn.fastestvpnservice.beans.Server
|
|
@@ -162,6 +163,7 @@ lateinit var homeViewModel1: HomeViewModel
|
|
|
wg.startVpn()
|
|
|
Log.d("isConnect_State", "onServerSelected ${homeViewModel.isConnect.value}")
|
|
|
}
|
|
|
+ MainActivity.isSelectedServersShown = true
|
|
|
|
|
|
onClick()
|
|
|
|
|
@@ -278,20 +280,26 @@ fun Home(navHostController: NavHostController, activity: ComponentActivity) {
|
|
|
var filterServerByConnectionCount = Server()
|
|
|
if (prefHelper.getServerObject() != null) {
|
|
|
prefHelper.getServerObject()?.let {
|
|
|
+ Log.d("test_smart_server_n", "server nn = ${it.server_name}")
|
|
|
filterServerByConnectionCount = it
|
|
|
}
|
|
|
} else {
|
|
|
- prefHelper.getServerData().get(0).servers?.let {
|
|
|
-
|
|
|
- val temp = it.filter { server ->
|
|
|
- server.protocol.equals(prefHelper.getProtocol().title, ignoreCase = true)
|
|
|
- }
|
|
|
-
|
|
|
- if (temp.isNotEmpty()) {
|
|
|
- filterServerByConnectionCount = serverListViewModel.filterServerByConnectionCount(
|
|
|
- it
|
|
|
- )
|
|
|
- }
|
|
|
+// prefHelper.getServerData().get(0).servers?.let {
|
|
|
+//
|
|
|
+// val temp = it.filter { server ->
|
|
|
+// server.protocol.equals(prefHelper.getProtocol().title, ignoreCase = true)
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (temp.isNotEmpty()) {
|
|
|
+// filterServerByConnectionCount = serverListViewModel.filterServerByConnectionCount(
|
|
|
+// it
|
|
|
+// )
|
|
|
+// }
|
|
|
+// }
|
|
|
+ val smartServer = basePreferenceHelper.getSmartServerObject()
|
|
|
+ smartServer?.let {
|
|
|
+ Log.d("test_smart_server_n", "server = ${it.server_name}")
|
|
|
+ filterServerByConnectionCount = it
|
|
|
}
|
|
|
}
|
|
|
prefHelper.setServerObject(filterServerByConnectionCount)
|
|
@@ -1074,26 +1082,33 @@ fun BoxScope.AddRowSmart(
|
|
|
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] -> {
|
|
|
- icon = Utils.getDrawable(context, anySpecific?.iso)
|
|
|
- selectedServer = anySpecific
|
|
|
+ if (MainActivity.isSelectedServersShown) {
|
|
|
+ selectedServer = basePreferenceHelper.getServerObject()
|
|
|
+ icon = Utils.getDrawable(context, selectedServer?.iso)
|
|
|
+ } else {
|
|
|
+ when(selectedSmartList) {
|
|
|
+ smartConnect[0] -> {
|
|
|
+ icon = Utils.getDrawable(context, smart?.iso)
|
|
|
+ selectedServer = smart
|
|
|
+ }
|
|
|
+ smartConnect[1] -> {
|
|
|
+ icon = Utils.getDrawable(context, recently?.iso)
|
|
|
+ selectedServer = recently
|
|
|
+ }
|
|
|
+ smartConnect[2] -> {
|
|
|
+ icon = Utils.getDrawable(context, anySpecific?.iso)
|
|
|
+ selectedServer = anySpecific
|
|
|
+ }
|
|
|
+ else -> {}
|
|
|
}
|
|
|
- else -> {}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ basePreferenceHelper.setSmartServerObject(selectedServer)
|
|
|
+
|
|
|
Row(
|
|
|
modifier = Modifier
|
|
|
.fillMaxWidth()
|