|
@@ -40,6 +40,7 @@ import androidx.compose.ui.unit.dp
|
|
|
import androidx.lifecycle.viewmodel.compose.viewModel
|
|
|
import com.vpn.fastestvpnservice.R
|
|
|
import com.vpn.fastestvpnservice.beans.AutoConnectModel
|
|
|
+import com.vpn.fastestvpnservice.constants.smartConnect
|
|
|
import com.vpn.fastestvpnservice.helpers.BasePreferenceHelper
|
|
|
import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.homeViewModel1
|
|
|
import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.settingsViewModel
|
|
@@ -332,6 +333,25 @@ fun onClickAutoConnect(
|
|
|
|
|
|
Log.d("autoconnect_state", "isConnect = $isConnect $isTrustedWifiConnected")
|
|
|
|
|
|
+ var smartServer = basePreferenceHelper.getSmartServerObject()
|
|
|
+ val recommended = basePreferenceHelper.getRecommendedServerObject()
|
|
|
+ val selectedSmartList = basePreferenceHelper.getSmartList()
|
|
|
+ when(selectedSmartList) {
|
|
|
+ smartConnect[0] -> {
|
|
|
+ smartServer = basePreferenceHelper.getRecommendedServerObject()
|
|
|
+ }
|
|
|
+ smartConnect[1] -> {
|
|
|
+ smartServer = basePreferenceHelper.getSmartServerObject() ?: recommended
|
|
|
+ }
|
|
|
+ smartConnect[2] -> {
|
|
|
+ smartServer = basePreferenceHelper.getSmartServerObject() ?: recommended
|
|
|
+ }
|
|
|
+ else -> {}
|
|
|
+ }
|
|
|
+
|
|
|
+ Log.d("autoconnect_state", "smartServer = ${smartServer?.server_name} & $selectedSmartList")
|
|
|
+ basePreferenceHelper.setConnectedServer(smartServer)
|
|
|
+
|
|
|
if (isTrustedWifiConnected && isConnect == App.CONNECTED) {
|
|
|
Log.d("autoconnect_state", "Disconnect VPN")
|
|
|
vpnConnectionsUtil.stopVpn()
|