|
@@ -0,0 +1,702 @@
|
|
|
+package com.vpn.fastestvpnservice.screensTV
|
|
|
+
|
|
|
+import android.content.Context
|
|
|
+import android.content.Intent
|
|
|
+import android.util.Log
|
|
|
+import androidx.compose.foundation.BorderStroke
|
|
|
+import androidx.compose.foundation.Image
|
|
|
+import androidx.compose.foundation.background
|
|
|
+import androidx.compose.foundation.border
|
|
|
+import androidx.compose.foundation.gestures.detectTapGestures
|
|
|
+import androidx.compose.foundation.layout.Arrangement
|
|
|
+import androidx.compose.foundation.layout.Box
|
|
|
+import androidx.compose.foundation.layout.BoxScope
|
|
|
+import androidx.compose.foundation.layout.Column
|
|
|
+import androidx.compose.foundation.layout.Row
|
|
|
+import androidx.compose.foundation.layout.Spacer
|
|
|
+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.padding
|
|
|
+import androidx.compose.foundation.layout.size
|
|
|
+import androidx.compose.foundation.shape.CircleShape
|
|
|
+import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
+import androidx.compose.foundation.text.ClickableText
|
|
|
+import androidx.compose.material3.Button
|
|
|
+import androidx.compose.material3.ButtonDefaults
|
|
|
+import androidx.compose.material3.Icon
|
|
|
+import androidx.compose.material3.IconButton
|
|
|
+import androidx.compose.material3.MaterialTheme
|
|
|
+import androidx.compose.material3.Surface
|
|
|
+import androidx.compose.material3.Text
|
|
|
+import androidx.compose.runtime.Composable
|
|
|
+import androidx.compose.runtime.livedata.observeAsState
|
|
|
+import androidx.compose.runtime.rememberCoroutineScope
|
|
|
+import androidx.compose.ui.Alignment
|
|
|
+import androidx.compose.ui.Modifier
|
|
|
+import androidx.compose.ui.draw.alpha
|
|
|
+import androidx.compose.ui.draw.clip
|
|
|
+import androidx.compose.ui.draw.paint
|
|
|
+import androidx.compose.ui.graphics.Color
|
|
|
+import androidx.compose.ui.graphics.ColorFilter
|
|
|
+import androidx.compose.ui.graphics.painter.Painter
|
|
|
+import androidx.compose.ui.input.pointer.pointerInput
|
|
|
+import androidx.compose.ui.layout.ContentScale
|
|
|
+import androidx.compose.ui.platform.LocalContext
|
|
|
+import androidx.compose.ui.res.colorResource
|
|
|
+import androidx.compose.ui.res.painterResource
|
|
|
+import androidx.compose.ui.text.AnnotatedString
|
|
|
+import androidx.compose.ui.unit.dp
|
|
|
+import androidx.compose.ui.unit.sp
|
|
|
+import androidx.constraintlayout.compose.ConstraintLayout
|
|
|
+import androidx.constraintlayout.compose.Dimension
|
|
|
+import androidx.lifecycle.viewmodel.compose.viewModel
|
|
|
+import androidx.navigation.NavHostController
|
|
|
+import com.vpn.fastestvpnservice.R
|
|
|
+import com.vpn.fastestvpnservice.beans.isDarkTheme
|
|
|
+import com.vpn.fastestvpnservice.beans.toChangeServer
|
|
|
+import com.vpn.fastestvpnservice.constants.AppEnum
|
|
|
+import com.vpn.fastestvpnservice.constants.smartConnect
|
|
|
+import com.vpn.fastestvpnservice.helpers.BasePreferenceHelper
|
|
|
+import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.AddRowSelectServer
|
|
|
+import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.AddText
|
|
|
+import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.ColumnText
|
|
|
+import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.blueBackground
|
|
|
+import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.isServerDialog
|
|
|
+import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.serverObj
|
|
|
+import com.vpn.fastestvpnservice.screens.bottomNavBarScreens.vpnConnectionsUtil
|
|
|
+import com.vpn.fastestvpnservice.sealedClass.Screen
|
|
|
+import com.vpn.fastestvpnservice.ui.theme.customTypography
|
|
|
+import com.vpn.fastestvpnservice.utils.Utils
|
|
|
+import com.vpn.fastestvpnservice.utils.isTablet
|
|
|
+import com.vpn.fastestvpnservice.viewmodels.HomeViewModel
|
|
|
+import com.vpn.fastestvpnservice.widgets.SimpleAppWidget
|
|
|
+import de.blinkt.openvpn.core.App
|
|
|
+
|
|
|
+@Composable
|
|
|
+fun HomeTV(navHostController: NavHostController) {
|
|
|
+
|
|
|
+ val context = LocalContext.current
|
|
|
+ val basePreferenceHelper = BasePreferenceHelper(context)
|
|
|
+ val prefHelper = BasePreferenceHelper(context)
|
|
|
+ val scope = rememberCoroutineScope()
|
|
|
+ val homeViewModel: HomeViewModel = viewModel{
|
|
|
+ HomeViewModel(context, scope)
|
|
|
+ }
|
|
|
+ var isConnect: Int? = homeViewModel.isConnect.observeAsState().value
|
|
|
+ isConnect = basePreferenceHelper.getConnectState()
|
|
|
+
|
|
|
+ Column(
|
|
|
+ modifier = Modifier
|
|
|
+ .background(colorResource(id = R.color.background_color_gray))
|
|
|
+ .fillMaxSize(),
|
|
|
+ ) {
|
|
|
+ // 1st box
|
|
|
+ ConstraintLayout(modifier = Modifier
|
|
|
+ .fillMaxSize()
|
|
|
+ .weight(0.6f)
|
|
|
+// .background(Color.Green)
|
|
|
+ )
|
|
|
+ {
|
|
|
+ val (firstComposable, secondComposable) = createRefs()
|
|
|
+ val guideline = createGuidelineFromTop(0.6f)
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .constrainAs(firstComposable) {
|
|
|
+ top.linkTo(parent.top)
|
|
|
+ bottom.linkTo(guideline)
|
|
|
+ start.linkTo(parent.start)
|
|
|
+ end.linkTo(parent.end)
|
|
|
+ width = Dimension.fillToConstraints
|
|
|
+ height = Dimension.fillToConstraints
|
|
|
+ }
|
|
|
+ .background(Color.Transparent)
|
|
|
+ ) {
|
|
|
+ Image(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .fillMaxHeight()
|
|
|
+ .padding(top = 0.dp),
|
|
|
+// painter = if (isConnect == App.CONNECTED) blueBackgroundTV() else pinkBackgroundTV(),
|
|
|
+ painter = if (isConnect == App.CONNECTED) painterResource(id = R.drawable.bluebackground3x)
|
|
|
+ else painterResource(id = R.drawable.pinkbackground3x),
|
|
|
+ contentDescription = "Background Color",
|
|
|
+ contentScale = ContentScale.FillBounds,
|
|
|
+ )
|
|
|
+ Image(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .fillMaxHeight()
|
|
|
+ .padding(bottom = 0.dp)
|
|
|
+// .alpha(if (isDarkTheme.value) 0.1F else 0.6F),
|
|
|
+ .alpha(0.6F),
|
|
|
+ painter = painterResource(id = R.drawable.map_home3x),
|
|
|
+ contentDescription = "Home Map",
|
|
|
+ contentScale = ContentScale.FillWidth,
|
|
|
+ )
|
|
|
+ Column(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .fillMaxHeight()
|
|
|
+ .padding(bottom = 115.dp)
|
|
|
+// .offset(y = -(118).dp)
|
|
|
+ .background(Color.Transparent),
|
|
|
+ horizontalAlignment = Alignment.CenterHorizontally,
|
|
|
+ verticalArrangement = if (isTablet()) Arrangement.Bottom else 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,
|
|
|
+ color = colorResource(id = R.color.dark_blue_gray_text),
|
|
|
+ style = MaterialTheme.typography.customTypography.headlineLarge.copy(
|
|
|
+ fontSize = if (isTablet()) 24.sp else 18.sp
|
|
|
+ )
|
|
|
+ )
|
|
|
+ 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(if (isTablet()) 26.dp else 20.dp)
|
|
|
+ .clip(CircleShape)
|
|
|
+ .paint(
|
|
|
+ painter = painterResource(id = image),
|
|
|
+ contentScale = ContentScale.FillBounds
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ AddText(
|
|
|
+ text = "${serverObj?.server_name ?: ""}, ${serverObj?.country ?: ""}",
|
|
|
+ size = 16.sp,
|
|
|
+ color = colorResource(id = R.color.dark_blue_gray_text),
|
|
|
+ isTablet()
|
|
|
+ )
|
|
|
+ } 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(if (isTablet()) 26.dp else 20.dp)
|
|
|
+ .clip(CircleShape)
|
|
|
+ .paint(
|
|
|
+ painter = painterResource(id = image),
|
|
|
+ contentScale = ContentScale.FillBounds
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ AddText(
|
|
|
+ text = "${serverDis?.city ?: ""}, ${serverDis?.country ?: ""}",
|
|
|
+ size = 16.sp,
|
|
|
+ color = colorResource(id = R.color.dark_blue_gray_text),
|
|
|
+ isTablet()
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (isConnect == App.CONNECTED) {
|
|
|
+ AddText(
|
|
|
+ text = "Connected",
|
|
|
+ size = 18.sp,
|
|
|
+// color = MaterialTheme.colorScheme.surfaceContainerHigh,
|
|
|
+ color = colorResource(id = R.color.light_blue_2),
|
|
|
+ style = MaterialTheme.typography.customTypography.displaySmall.copy(
|
|
|
+ fontSize = if (isTablet()) 24.sp else 18.sp
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ else if (isConnect == App.DISCONNECTED) {
|
|
|
+ AddText(
|
|
|
+ text = "Disconnected",
|
|
|
+ size = 18.sp,
|
|
|
+// color = MaterialTheme.colorScheme.surfaceTint,
|
|
|
+ color = colorResource(id = R.color.maroon_text),
|
|
|
+ style = MaterialTheme.typography.customTypography.displaySmall.copy(
|
|
|
+ fontSize = if (isTablet()) 24.sp else 18.sp
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ else if (isConnect == App.CONNECTING) {
|
|
|
+ AddText(
|
|
|
+ text = "Connecting...",
|
|
|
+ size = 18.sp,
|
|
|
+// color = MaterialTheme.colorScheme.surfaceTint,
|
|
|
+ color = colorResource(id = R.color.maroon_text),
|
|
|
+ style = MaterialTheme.typography.customTypography.displaySmall.copy(
|
|
|
+ fontSize = if (isTablet()) 24.sp else 18.sp
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .constrainAs(secondComposable) {
|
|
|
+ top.linkTo(guideline)
|
|
|
+ bottom.linkTo(firstComposable.bottom)
|
|
|
+ start.linkTo(parent.start)
|
|
|
+ end.linkTo(parent.end)
|
|
|
+ width = Dimension.value(234.dp)
|
|
|
+ height = Dimension.value(234.dp)
|
|
|
+ }
|
|
|
+ .background(Color.Transparent)
|
|
|
+ ) {
|
|
|
+ IconButton(
|
|
|
+ onClick = {
|
|
|
+ val connectedServer = basePreferenceHelper.getConnectedServer()
|
|
|
+ val serverObject = basePreferenceHelper.getServerObject()
|
|
|
+ Log.d("test_conn_ser_obj", "cs = ${connectedServer?.server_name} so = ${serverObject?.server_name}")
|
|
|
+ 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")
|
|
|
+
|
|
|
+ if (basePreferenceHelper.getServerObject() != null) {
|
|
|
+ vpnConnectionsUtil.startVpn()
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ toChangeServer.value = false
|
|
|
+ navHostController.navigate(
|
|
|
+ Screen.ServerList.route
|
|
|
+ )
|
|
|
+ Screen.ServerList.isTrue = true
|
|
|
+ Log.d("button_click_change", "Pressed")
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ val widgetIntent = Intent(context, SimpleAppWidget::class.java)
|
|
|
+ widgetIntent.action = SimpleAppWidget.ACTION_CHANGE_SERVER
|
|
|
+ context.sendBroadcast(widgetIntent)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(bottom = 0.dp)
|
|
|
+ .size(234.dp),
|
|
|
+ )
|
|
|
+ {
|
|
|
+ if (isConnect == App.CONNECTED) {
|
|
|
+ Image(
|
|
|
+// painter = if (isDarkTheme.value) painterResource(id = R.drawable.iv_connect_dark)
|
|
|
+// else painterResource(id = R.drawable.iv_connect),
|
|
|
+ painter = 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),
|
|
|
+ painter = painterResource(id = R.drawable.iv_disconnect),
|
|
|
+ contentDescription = "Home Map",
|
|
|
+ contentScale = ContentScale.FillBounds,
|
|
|
+ modifier = Modifier.fillMaxSize()
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2nd box
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .background(colorResource(id = R.color.background_color_gray))
|
|
|
+// .background(Color.Blue)
|
|
|
+ .fillMaxSize()
|
|
|
+ .weight(0.4f)
|
|
|
+// .background(Color.Gray),
|
|
|
+ ) {
|
|
|
+ Column(
|
|
|
+ modifier = Modifier.fillMaxSize(),
|
|
|
+ verticalArrangement = Arrangement.Top
|
|
|
+ ) {
|
|
|
+
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth(fraction = if (isTablet()) 0.5f else 1f)
|
|
|
+ .padding(horizontal = 20.dp)
|
|
|
+ .padding(vertical = 5.dp)
|
|
|
+ .height(120.dp)
|
|
|
+ .border(
|
|
|
+ border = BorderStroke(2.dp, colorResource(id = R.color.white)),
|
|
|
+ shape = RoundedCornerShape(28.dp)
|
|
|
+ )
|
|
|
+ .background(
|
|
|
+ shape = RoundedCornerShape(28.dp),
|
|
|
+ color = colorResource(id = R.color.white)
|
|
|
+ )
|
|
|
+ .align(Alignment.CenterHorizontally),
|
|
|
+ ) {
|
|
|
+ AddRowSmartTV(navHostController, basePreferenceHelper, context, isTablet())
|
|
|
+ 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 -> {}
|
|
|
+ }
|
|
|
+ Button(
|
|
|
+ onClick = {
|
|
|
+ Log.d("test_button", "onClick Smart Connect ${smartServer?.server_name}")
|
|
|
+ basePreferenceHelper.setSmartServerObject(smartServer)
|
|
|
+// basePreferenceHelper.setConnectedServer(smartServer)
|
|
|
+
|
|
|
+ if (isConnect == App.CONNECTED) {
|
|
|
+ Log.d("isConnect_State_vpn", "stopVPN")
|
|
|
+ val lastServer = basePreferenceHelper.getConnectedServer()
|
|
|
+ Log.d("test_conn_ser_obj", "smart => ${lastServer?.server_name} ${smartServer?.server_name}")
|
|
|
+
|
|
|
+ if (lastServer?.id != smartServer?.id) {
|
|
|
+ isServerDialog.value = true
|
|
|
+ if (smartServer != null) {
|
|
|
+ serverObj.value = smartServer
|
|
|
+ }
|
|
|
+// basePreferenceHelper.setConnectedServer(smartServer)
|
|
|
+
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ vpnConnectionsUtil.stopVpn()
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+// vpnConnectionsUtil.stopVpn()
|
|
|
+// Handler().postDelayed(Runnable {
|
|
|
+// vpnConnectionsUtil.startVpn()
|
|
|
+// }, 500)
|
|
|
+// homeViewModel.getIp()
|
|
|
+ }
|
|
|
+ else if (isConnect == App.CONNECTING) {
|
|
|
+ vpnConnectionsUtil.stopVpn()
|
|
|
+ }
|
|
|
+ else if (isConnect == App.DISCONNECTED) {
|
|
|
+ Log.d("isConnect_State_vpn", "startVPN")
|
|
|
+ basePreferenceHelper.setConnectedServer(smartServer)
|
|
|
+ if (smartServer != null) {
|
|
|
+// serverListViewModel.setRecentlyConnectedServer(smartServer)
|
|
|
+ }
|
|
|
+ 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.copy(
|
|
|
+ fontSize = if (isTablet()) 21.sp else 18.sp
|
|
|
+ ),
|
|
|
+ modifier = Modifier.background(Color.Transparent)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /* Select Server Box*/
|
|
|
+// if (isConnect != App.CONNECTED) { }
|
|
|
+
|
|
|
+// Spacer(modifier = Modifier.weight(1f))
|
|
|
+
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth(fraction = if (isTablet()) 0.5f else 1f)
|
|
|
+ .padding(horizontal = 20.dp, vertical = 5.dp)
|
|
|
+ .padding(top = 0.dp)
|
|
|
+ .height(70.dp)
|
|
|
+ .border(
|
|
|
+ border = BorderStroke(2.dp, colorResource(id = R.color.white)),
|
|
|
+ shape = RoundedCornerShape(28.dp)
|
|
|
+ )
|
|
|
+ .background(
|
|
|
+ shape = RoundedCornerShape(28.dp),
|
|
|
+// color = MaterialTheme.colorScheme.onBackground
|
|
|
+ color = colorResource(id = R.color.white)
|
|
|
+ )
|
|
|
+ .align(Alignment.CenterHorizontally),
|
|
|
+ contentAlignment = Alignment.CenterStart,
|
|
|
+ ) {
|
|
|
+ AddRowSelectServerTV(navHostController, isTablet())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+@Composable
|
|
|
+fun BoxScope.AddRowSmartTV(
|
|
|
+ navHostController: NavHostController,
|
|
|
+ basePreferenceHelper: BasePreferenceHelper,
|
|
|
+ context: Context,
|
|
|
+ isTablet: Boolean
|
|
|
+) {
|
|
|
+ val smart = basePreferenceHelper.getSmartServerObject()
|
|
|
+ val recommended = basePreferenceHelper.getRecommendedServerObject()
|
|
|
+ val recently = basePreferenceHelper.getConnectedServer()
|
|
|
+ val anySpecific = basePreferenceHelper.getSmartServerObject()
|
|
|
+
|
|
|
+ val ipInfo = basePreferenceHelper.getIpinfo()
|
|
|
+ val selectedSmartList = basePreferenceHelper.getSmartList()
|
|
|
+ var selectedServer = basePreferenceHelper.getRecommendedServerObject()
|
|
|
+ var selectedSmartServer = basePreferenceHelper.getSmartServerObject()
|
|
|
+
|
|
|
+ Log.d("smartLocationList", "Home:: server = ${selectedServer?.server_name}")
|
|
|
+ var icon = Utils.getDrawable(context, selectedServer?.iso)
|
|
|
+
|
|
|
+// if (MainActivity.isSelectedServersShown) {
|
|
|
+// selectedServer = basePreferenceHelper.getServerObject()
|
|
|
+// icon = Utils.getDrawable(context, selectedServer?.iso)
|
|
|
+//
|
|
|
+// when(selectedSmartList) {
|
|
|
+// smartConnect[0] -> {
|
|
|
+// selectedSmartServer = recommended
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// } else {
|
|
|
+//
|
|
|
+// }
|
|
|
+
|
|
|
+ when(selectedSmartList) {
|
|
|
+ smartConnect[0] -> {
|
|
|
+ icon = Utils.getDrawable(context, recommended?.iso)
|
|
|
+ selectedServer = recommended
|
|
|
+ selectedSmartServer = recommended
|
|
|
+ }
|
|
|
+ smartConnect[1] -> {
|
|
|
+ icon = Utils.getDrawable(context, recently?.iso ?: recommended?.iso)
|
|
|
+ selectedServer = recently ?: recommended
|
|
|
+ selectedSmartServer = recently
|
|
|
+ }
|
|
|
+ smartConnect[2] -> {
|
|
|
+ icon = Utils.getDrawable(context, anySpecific?.iso ?: recommended?.iso)
|
|
|
+ selectedServer = anySpecific ?: recommended
|
|
|
+ selectedSmartServer = anySpecific
|
|
|
+ }
|
|
|
+ else -> {}
|
|
|
+ }
|
|
|
+
|
|
|
+// basePreferenceHelper.setSmartServerObject(selectedSmartServer)
|
|
|
+
|
|
|
+ Row(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .padding(15.dp)
|
|
|
+ .background(Color.Transparent),
|
|
|
+ horizontalArrangement = Arrangement.Start,
|
|
|
+ verticalAlignment = Alignment.CenterVertically
|
|
|
+ ) {
|
|
|
+
|
|
|
+ Surface(
|
|
|
+ modifier = Modifier.padding(start = 0.dp),
|
|
|
+ color = Color.Transparent
|
|
|
+ ) {
|
|
|
+ if (icon != 0) {
|
|
|
+ Icon(
|
|
|
+ painter = painterResource(id = icon),
|
|
|
+ contentDescription = "Country Logo",
|
|
|
+ tint = Color.Unspecified,
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(start = 0.dp)
|
|
|
+ .size(40.dp)
|
|
|
+ .weight(1f)
|
|
|
+ .clip(CircleShape)
|
|
|
+ .border(1.dp, colorResource(id = R.color.gray_opac_04), CircleShape)
|
|
|
+ .paint(
|
|
|
+ painter = painterResource(id = icon),
|
|
|
+ contentScale = ContentScale.FillBounds
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Column(
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(start = 12.dp)
|
|
|
+
|
|
|
+ ) {
|
|
|
+ ColumnText(
|
|
|
+ text = selectedSmartList,
|
|
|
+// color = MaterialTheme.colorScheme.surfaceContainerLow,
|
|
|
+ color = colorResource(id = R.color.blue_text),
|
|
|
+ size = 12.sp,
|
|
|
+ style = MaterialTheme.typography.customTypography.headlineSmall.copy(
|
|
|
+ fontSize = if (isTablet()) 16.sp else 12.sp
|
|
|
+ )
|
|
|
+ )
|
|
|
+ ColumnText(
|
|
|
+ text = "${selectedServer?.server_name}",
|
|
|
+// color = MaterialTheme.colorScheme.primary,
|
|
|
+ color = colorResource(id = R.color.dark_blue_gray_text),
|
|
|
+ size = 16.sp,
|
|
|
+ style = MaterialTheme.typography.labelMedium.copy(
|
|
|
+ fontSize = if (isTablet()) 20.sp else 16.sp
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
+ Spacer(modifier = Modifier.weight(1F))
|
|
|
+ Surface(
|
|
|
+ modifier = Modifier.padding(start = 15.dp),
|
|
|
+ color = Color.Transparent
|
|
|
+ ) {
|
|
|
+ ClickableText(
|
|
|
+ text = AnnotatedString("Change"),
|
|
|
+ style = MaterialTheme.typography.customTypography.headlineMedium.copy(
|
|
|
+// MaterialTheme.colorScheme.surfaceContainerLow,
|
|
|
+ color = colorResource(id = R.color.blue_text),
|
|
|
+ fontSize = if (isTablet()) 20.sp else 14.sp
|
|
|
+ ),
|
|
|
+ onClick = {
|
|
|
+ toChangeServer.value = true
|
|
|
+ navHostController.navigate(
|
|
|
+ Screen.ServerList.route
|
|
|
+ )
|
|
|
+ Screen.ServerList.isTrue = false
|
|
|
+ Log.d("button_click_change", "Pressed")
|
|
|
+ },
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+@Composable
|
|
|
+fun BoxScope.AddRowSelectServerTV(navHostController: NavHostController, isTablet: Boolean) {
|
|
|
+ Row(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .padding(15.dp)
|
|
|
+ .background(Color.Transparent)
|
|
|
+ .pointerInput(Unit) {
|
|
|
+ detectTapGestures {
|
|
|
+ toChangeServer.value = false
|
|
|
+ navHostController.navigate(
|
|
|
+ Screen.ServerList.route
|
|
|
+ )
|
|
|
+ Screen.ServerList.isTrue = true
|
|
|
+ Log.d("button_click_change", "Pressed")
|
|
|
+ }
|
|
|
+ }
|
|
|
+// .clickable {
|
|
|
+// Log.d("test_server_button", "ServerTab Clicked")
|
|
|
+// }
|
|
|
+ ,
|
|
|
+ horizontalArrangement = Arrangement.Start,
|
|
|
+ verticalAlignment = Alignment.CenterVertically
|
|
|
+ ) {
|
|
|
+
|
|
|
+ Surface(
|
|
|
+ modifier = Modifier.padding(start = 0.dp),
|
|
|
+ color = Color.Transparent
|
|
|
+ ) {
|
|
|
+ Image(
|
|
|
+ painter = painterResource(id = R.drawable.worldmap3x),
|
|
|
+ contentDescription = "World",
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(start = 0.dp)
|
|
|
+ .size(40.dp)
|
|
|
+ .weight(1f)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ Surface(
|
|
|
+ modifier = Modifier.padding(start = 0.dp),
|
|
|
+ color = Color.Transparent
|
|
|
+ ) {
|
|
|
+ Text(text = "See All Locations",
|
|
|
+ style = MaterialTheme.typography.labelMedium.copy(
|
|
|
+ fontSize = if (isTablet()) 20.sp else 16.sp
|
|
|
+ ),
|
|
|
+// color = MaterialTheme.colorScheme.primary,
|
|
|
+ color = colorResource(id = R.color.dark_blue_gray_text),
|
|
|
+ maxLines = 2,
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(start = 12.dp, end = 0.dp)
|
|
|
+ .weight(1f)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ Spacer(modifier = Modifier.weight(1F))
|
|
|
+ Surface(
|
|
|
+ modifier = Modifier.padding(start = 15.dp),
|
|
|
+ color = Color.Transparent
|
|
|
+
|
|
|
+ ) {
|
|
|
+ Image(
|
|
|
+ painter = painterResource(id = R.drawable.frontarrow3x),
|
|
|
+ contentDescription = "Front_Arrow",
|
|
|
+ colorFilter = ColorFilter.tint(colorResource(id = R.color.gray_icon)),
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(start = 0.dp, end = 5.dp)
|
|
|
+ .size(10.dp, 18.dp)
|
|
|
+ .weight(1f),
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+@Composable
|
|
|
+fun pinkBackgroundTV(): Painter {
|
|
|
+ return if (isDarkTheme.value) painterResource(id = R.drawable.darkpinkbackground)
|
|
|
+ else painterResource(id = R.drawable.pinkbackground3x)
|
|
|
+}
|
|
|
+
|
|
|
+@Composable
|
|
|
+fun blueBackgroundTV(): Painter {
|
|
|
+ return if (isDarkTheme.value) painterResource(id = R.drawable.darkbluebackground)
|
|
|
+ else painterResource(id = R.drawable.bluebackground3x)
|
|
|
+}
|