|
@@ -43,6 +43,8 @@ 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.isHomeViewModel1
|
|
|
+import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.isVpnConnectionsUtil
|
|
|
import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.settingsViewModel
|
|
|
import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.vpnConnectionsUtil
|
|
|
import com.vpn.fastestvpnservice.viewmodels.HomeViewModel
|
|
@@ -329,7 +331,10 @@ fun onClickAutoConnect(
|
|
|
|
|
|
val isTrustedWifiConnected = wifiListAdded.any { it.wifiName == connectedWifiSsid && it.isAdded }
|
|
|
|
|
|
- val isConnect = homeViewModel1.isConnect.value
|
|
|
+ var isConnect = 0
|
|
|
+ if (isHomeViewModel1) {
|
|
|
+ isConnect = homeViewModel1.isConnect.value ?: 0
|
|
|
+ }
|
|
|
|
|
|
Log.d("autoconnect_state", "isConnect = $isConnect $isTrustedWifiConnected")
|
|
|
|
|
@@ -352,17 +357,19 @@ fun onClickAutoConnect(
|
|
|
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()
|
|
|
- }
|
|
|
- else if (!isTrustedWifiConnected && isConnect == App.DISCONNECTED) {
|
|
|
- Log.d("autoconnect_state", "Connect VPN")
|
|
|
- vpnConnectionsUtil.startVpn()
|
|
|
- }
|
|
|
- else if (isTrustedWifiConnected && isConnect == App.CONNECTING) {
|
|
|
- Log.d("autoconnect_state", "Connecting VPN")
|
|
|
- vpnConnectionsUtil.stopVpn()
|
|
|
+ if (isVpnConnectionsUtil) {
|
|
|
+ if (isTrustedWifiConnected && isConnect == App.CONNECTED) {
|
|
|
+ Log.d("autoconnect_state", "Disconnect VPN")
|
|
|
+ vpnConnectionsUtil.stopVpn()
|
|
|
+ }
|
|
|
+ else if (!isTrustedWifiConnected && isConnect == App.DISCONNECTED) {
|
|
|
+ Log.d("autoconnect_state", "Connect VPN")
|
|
|
+ vpnConnectionsUtil.startVpn()
|
|
|
+ }
|
|
|
+ else if (isTrustedWifiConnected && isConnect == App.CONNECTING) {
|
|
|
+ Log.d("autoconnect_state", "Connecting VPN")
|
|
|
+ vpnConnectionsUtil.stopVpn()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
settingsViewModel.mutableLiveDataConnectedWifi.value = wifiListAdded
|