|  | @@ -31,6 +31,7 @@ import androidx.compose.foundation.layout.fillMaxHeight
 | 
	
		
			
				|  |  |  import androidx.compose.foundation.layout.fillMaxSize
 | 
	
		
			
				|  |  |  import androidx.compose.foundation.layout.fillMaxWidth
 | 
	
		
			
				|  |  |  import androidx.compose.foundation.layout.height
 | 
	
		
			
				|  |  | +import androidx.compose.foundation.layout.offset
 | 
	
		
			
				|  |  |  import androidx.compose.foundation.layout.padding
 | 
	
		
			
				|  |  |  import androidx.compose.foundation.layout.size
 | 
	
		
			
				|  |  |  import androidx.compose.foundation.layout.width
 | 
	
	
		
			
				|  | @@ -93,6 +94,7 @@ import androidx.compose.ui.input.pointer.pointerInput
 | 
	
		
			
				|  |  |  import androidx.compose.ui.platform.LocalContext
 | 
	
		
			
				|  |  |  import androidx.compose.ui.platform.LocalLifecycleOwner
 | 
	
		
			
				|  |  |  import androidx.compose.ui.window.DialogProperties
 | 
	
		
			
				|  |  | +import androidx.compose.ui.zIndex
 | 
	
		
			
				|  |  |  import androidx.lifecycle.Lifecycle
 | 
	
		
			
				|  |  |  import androidx.lifecycle.LifecycleEventObserver
 | 
	
		
			
				|  |  |  import androidx.lifecycle.LifecycleOwner
 | 
	
	
		
			
				|  | @@ -239,7 +241,452 @@ lateinit var vpnConnectionsUtil: VPNConnectionsUtil
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  @OptIn(ExperimentalFoundationApi::class, ExperimentalMaterial3Api::class)
 | 
	
		
			
				|  |  |  @Composable
 | 
	
		
			
				|  |  | -fun Home(navHostController: NavHostController, activity: ComponentActivity, settingsNavHostController: NavHostController) {
 | 
	
		
			
				|  |  | +fun Home(
 | 
	
		
			
				|  |  | +    navHostController: NavHostController,
 | 
	
		
			
				|  |  | +    activity: ComponentActivity,
 | 
	
		
			
				|  |  | +    settingsNavHostController: NavHostController
 | 
	
		
			
				|  |  | +) {
 | 
	
		
			
				|  |  | +    navHostController1 = navHostController
 | 
	
		
			
				|  |  | +    val context = LocalContext.current
 | 
	
		
			
				|  |  | +    val basePreferenceHelper = BasePreferenceHelper(context)
 | 
	
		
			
				|  |  | +    act = activity
 | 
	
		
			
				|  |  | +    val prefHelper = BasePreferenceHelper(context)
 | 
	
		
			
				|  |  | +    val scope = rememberCoroutineScope()
 | 
	
		
			
				|  |  | +    val homeViewModel: HomeViewModel = viewModel{
 | 
	
		
			
				|  |  | +        HomeViewModel(context, scope)
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    val serverListViewModel: ServerListViewModel = viewModel{
 | 
	
		
			
				|  |  | +        ServerListViewModel(context)
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    vpnConnectionsUtil = VPNConnectionsUtil(context, activity, homeViewModel)
 | 
	
		
			
				|  |  | +    homeViewModel1 = homeViewModel
 | 
	
		
			
				|  |  | +    var isConnect: Int? = homeViewModel.isConnect.observeAsState().value
 | 
	
		
			
				|  |  | +    isConnect = basePreferenceHelper.getConnectState()
 | 
	
		
			
				|  |  | +    var server: Server = Server()
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    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
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    Column(
 | 
	
		
			
				|  |  | +        modifier = Modifier
 | 
	
		
			
				|  |  | +            .background(MaterialTheme.colorScheme.background)
 | 
	
		
			
				|  |  | +            .fillMaxSize(),
 | 
	
		
			
				|  |  | +    ) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 1st box
 | 
	
		
			
				|  |  | +        Box(
 | 
	
		
			
				|  |  | +            modifier = Modifier
 | 
	
		
			
				|  |  | +//                .background(MaterialTheme.colorScheme.background)
 | 
	
		
			
				|  |  | +                .fillMaxSize()
 | 
	
		
			
				|  |  | +                .weight(0.6f),
 | 
	
		
			
				|  |  | +        ) {
 | 
	
		
			
				|  |  | +            Column(
 | 
	
		
			
				|  |  | +                modifier = Modifier
 | 
	
		
			
				|  |  | +                    .fillMaxSize()
 | 
	
		
			
				|  |  | +                    .background(Color.Transparent),
 | 
	
		
			
				|  |  | +                horizontalAlignment = Alignment.CenterHorizontally,
 | 
	
		
			
				|  |  | +                verticalArrangement = Arrangement.spacedBy(-(117).dp)
 | 
	
		
			
				|  |  | +            ) {
 | 
	
		
			
				|  |  | +                // background image
 | 
	
		
			
				|  |  | +                Box(
 | 
	
		
			
				|  |  | +                    modifier = Modifier
 | 
	
		
			
				|  |  | +                        .fillMaxWidth()
 | 
	
		
			
				|  |  | +                        .fillMaxHeight(fraction = 0.6f)
 | 
	
		
			
				|  |  | +                ) {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    Image(
 | 
	
		
			
				|  |  | +                        modifier = Modifier
 | 
	
		
			
				|  |  | +                            .fillMaxWidth()
 | 
	
		
			
				|  |  | +                            .fillMaxHeight()
 | 
	
		
			
				|  |  | +                            .padding(top = 0.dp),
 | 
	
		
			
				|  |  | +                        painter = if (isConnect == App.CONNECTED) blueBackground() else pinkBackground(),
 | 
	
		
			
				|  |  | +                        contentDescription = "Home Map",
 | 
	
		
			
				|  |  | +                        contentScale = ContentScale.FillBounds,
 | 
	
		
			
				|  |  | +                    )
 | 
	
		
			
				|  |  | +                    Image(
 | 
	
		
			
				|  |  | +                        modifier = Modifier
 | 
	
		
			
				|  |  | +                            .fillMaxWidth()
 | 
	
		
			
				|  |  | +                            .fillMaxHeight()
 | 
	
		
			
				|  |  | +                            .padding(bottom = 0.dp)
 | 
	
		
			
				|  |  | +                            .alpha(if (isDarkTheme.value) 0.1F else 0.6F),
 | 
	
		
			
				|  |  | +                        painter = painterResource(id = R.drawable.map_home3x),
 | 
	
		
			
				|  |  | +                        contentDescription = "Home Map",
 | 
	
		
			
				|  |  | +                        contentScale = ContentScale.FillWidth,
 | 
	
		
			
				|  |  | +                    )
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    Column(
 | 
	
		
			
				|  |  | +                        modifier = Modifier.fillMaxWidth()
 | 
	
		
			
				|  |  | +                            .fillMaxHeight()
 | 
	
		
			
				|  |  | +                            .padding(bottom = 118.dp)
 | 
	
		
			
				|  |  | +//                            .offset(y = -(118).dp)
 | 
	
		
			
				|  |  | +                            .background(Color.Transparent),
 | 
	
		
			
				|  |  | +                        horizontalAlignment = Alignment.CenterHorizontally,
 | 
	
		
			
				|  |  | +                        verticalArrangement = Arrangement.SpaceEvenly
 | 
	
		
			
				|  |  | +                    ) {
 | 
	
		
			
				|  |  | +                        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 = "IP $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
 | 
	
		
			
				|  |  | +                            )
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                // connect button
 | 
	
		
			
				|  |  | +                Box(modifier = Modifier
 | 
	
		
			
				|  |  | +//                    .fillMaxWidth()
 | 
	
		
			
				|  |  | +//                    .fillMaxHeight()
 | 
	
		
			
				|  |  | +                    .background(Color.Transparent)
 | 
	
		
			
				|  |  | +                    .align(Alignment.CenterHorizontally),
 | 
	
		
			
				|  |  | +                ) {
 | 
	
		
			
				|  |  | +                    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
 | 
	
		
			
				|  |  | +                            .padding(bottom = 0.dp)
 | 
	
		
			
				|  |  | +//                    .fillMaxSize()
 | 
	
		
			
				|  |  | +                            .size(234.dp)
 | 
	
		
			
				|  |  | +//                            .align(Alignment.Center)
 | 
	
		
			
				|  |  | +//                            .offset(y = 117.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.fillMaxSize()
 | 
	
		
			
				|  |  | +                            )
 | 
	
		
			
				|  |  | +                        } 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.fillMaxSize()
 | 
	
		
			
				|  |  | +                            )
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        // 2nd box
 | 
	
		
			
				|  |  | +        Box(
 | 
	
		
			
				|  |  | +            modifier = Modifier
 | 
	
		
			
				|  |  | +                .background(MaterialTheme.colorScheme.background)
 | 
	
		
			
				|  |  | +                .fillMaxSize()
 | 
	
		
			
				|  |  | +                .weight(0.4f)
 | 
	
		
			
				|  |  | +//                .background(Color.Gray),
 | 
	
		
			
				|  |  | +        ) {
 | 
	
		
			
				|  |  | +            Column(
 | 
	
		
			
				|  |  | +                modifier = Modifier.fillMaxSize(),
 | 
	
		
			
				|  |  | +                verticalArrangement = Arrangement.SpaceEvenly
 | 
	
		
			
				|  |  | +            ) {
 | 
	
		
			
				|  |  | +                Box(
 | 
	
		
			
				|  |  | +                    modifier = Modifier
 | 
	
		
			
				|  |  | +                        .fillMaxWidth()
 | 
	
		
			
				|  |  | +                        .padding(horizontal = 20.dp)
 | 
	
		
			
				|  |  | +                        .padding(vertical = 5.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(ExperimentalFoundationApi::class, ExperimentalMaterial3Api::class)
 | 
	
		
			
				|  |  | +@Composable
 | 
	
		
			
				|  |  | +fun Home2(
 | 
	
		
			
				|  |  | +    navHostController: NavHostController,
 | 
	
		
			
				|  |  | +    activity: ComponentActivity,
 | 
	
		
			
				|  |  | +    settingsNavHostController: NavHostController
 | 
	
		
			
				|  |  | +) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      Log.d("OnChangeProtocol", "Home called!")
 | 
	
		
			
				|  |  |      navHostController1 = navHostController
 | 
	
	
		
			
				|  | @@ -271,7 +718,7 @@ fun Home(navHostController: NavHostController, activity: ComponentActivity, sett
 | 
	
		
			
				|  |  |      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 -> {
 | 
	
	
		
			
				|  | @@ -380,16 +827,16 @@ fun Home(navHostController: NavHostController, activity: ComponentActivity, sett
 | 
	
		
			
				|  |  |              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,
 | 
	
		
			
				|  |  | -            )
 | 
	
		
			
				|  |  | +        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) {
 | 
	
	
		
			
				|  | @@ -445,8 +892,10 @@ fun Home(navHostController: NavHostController, activity: ComponentActivity, sett
 | 
	
		
			
				|  |  |              },
 | 
	
		
			
				|  |  |              modifier = Modifier
 | 
	
		
			
				|  |  |                  .align(Alignment.TopCenter)
 | 
	
		
			
				|  |  | -                .padding(top = 180.dp)
 | 
	
		
			
				|  |  | -                .size(234.dp),
 | 
	
		
			
				|  |  | +                .padding(top = 80.dp)
 | 
	
		
			
				|  |  | +                .fillMaxSize()
 | 
	
		
			
				|  |  | +                .size(235.dp)
 | 
	
		
			
				|  |  | +            ,
 | 
	
		
			
				|  |  |          )
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              if (isConnect == App.CONNECTED) {
 | 
	
	
		
			
				|  | @@ -454,14 +903,16 @@ fun Home(navHostController: NavHostController, activity: ComponentActivity, sett
 | 
	
		
			
				|  |  |                      painter = if (isDarkTheme.value) painterResource(id = R.drawable.iv_connect_dark)
 | 
	
		
			
				|  |  |                      else painterResource(id = R.drawable.iv_connect),
 | 
	
		
			
				|  |  |                      contentDescription = "Home Map",
 | 
	
		
			
				|  |  | -                    contentScale = ContentScale.FillWidth,
 | 
	
		
			
				|  |  | +                    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.FillWidth,
 | 
	
		
			
				|  |  | +                    contentScale = ContentScale.FillBounds,
 | 
	
		
			
				|  |  | +                    modifier = Modifier.size(235.dp)
 | 
	
		
			
				|  |  |                  )
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |  
 |