|
@@ -1,24 +1,17 @@
|
|
|
package com.vpn.fastestvpnservice.screens.bottomNavBarScreens
|
|
|
|
|
|
-import android.appwidget.AppWidgetProvider
|
|
|
import android.content.Context
|
|
|
import android.content.Intent
|
|
|
import android.content.res.Configuration
|
|
|
-import android.location.Location
|
|
|
import android.os.Handler
|
|
|
import android.util.Log
|
|
|
-import android.widget.Toast
|
|
|
import androidx.activity.ComponentActivity
|
|
|
-import androidx.compose.animation.AnimatedVisibility
|
|
|
import androidx.compose.foundation.BorderStroke
|
|
|
import androidx.compose.foundation.ExperimentalFoundationApi
|
|
|
import androidx.compose.foundation.Image
|
|
|
-import androidx.compose.foundation.LocalOverscrollConfiguration
|
|
|
import androidx.compose.foundation.background
|
|
|
import androidx.compose.foundation.border
|
|
|
-import androidx.compose.foundation.clickable
|
|
|
import androidx.compose.foundation.gestures.detectTapGestures
|
|
|
-import androidx.compose.foundation.isSystemInDarkTheme
|
|
|
import androidx.compose.foundation.layout.Arrangement
|
|
|
import androidx.compose.foundation.layout.Box
|
|
|
import androidx.compose.foundation.layout.BoxScope
|
|
@@ -31,25 +24,15 @@ 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
|
|
|
import androidx.compose.foundation.layout.wrapContentHeight
|
|
|
-import androidx.compose.foundation.rememberScrollState
|
|
|
import androidx.compose.foundation.shape.CircleShape
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
import androidx.compose.foundation.text.ClickableText
|
|
|
-import androidx.compose.foundation.verticalScroll
|
|
|
-import androidx.compose.material.icons.Icons
|
|
|
-import androidx.compose.material.icons.filled.Home
|
|
|
-import androidx.compose.material.ripple.LocalRippleTheme
|
|
|
import androidx.compose.material3.AlertDialog
|
|
|
import androidx.compose.material3.Button
|
|
|
import androidx.compose.material3.ButtonDefaults
|
|
|
-import androidx.compose.material3.Card
|
|
|
-import androidx.compose.material3.CardColors
|
|
|
-import androidx.compose.material3.CardDefaults
|
|
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
|
|
import androidx.compose.material3.Icon
|
|
|
import androidx.compose.material3.IconButton
|
|
@@ -57,52 +40,40 @@ import androidx.compose.material3.MaterialTheme
|
|
|
import androidx.compose.material3.Surface
|
|
|
import androidx.compose.material3.Text
|
|
|
import androidx.compose.runtime.Composable
|
|
|
-import androidx.compose.runtime.CompositionLocalProvider
|
|
|
import androidx.compose.runtime.DisposableEffect
|
|
|
-import androidx.compose.runtime.LaunchedEffect
|
|
|
import androidx.compose.runtime.MutableState
|
|
|
-import androidx.compose.runtime.remember
|
|
|
+import androidx.compose.runtime.livedata.observeAsState
|
|
|
+import androidx.compose.runtime.mutableStateOf
|
|
|
+import androidx.compose.runtime.rememberCoroutineScope
|
|
|
+import androidx.compose.runtime.rememberUpdatedState
|
|
|
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.platform.LocalLifecycleOwner
|
|
|
import androidx.compose.ui.res.colorResource
|
|
|
import androidx.compose.ui.res.painterResource
|
|
|
import androidx.compose.ui.text.AnnotatedString
|
|
|
import androidx.compose.ui.text.TextStyle
|
|
|
-import androidx.compose.ui.text.font.FontStyle
|
|
|
-import androidx.compose.ui.text.font.FontWeight
|
|
|
-import androidx.compose.ui.text.style.TextAlign
|
|
|
import androidx.compose.ui.tooling.preview.Preview
|
|
|
import androidx.compose.ui.unit.TextUnit
|
|
|
import androidx.compose.ui.unit.dp
|
|
|
import androidx.compose.ui.unit.sp
|
|
|
-import com.vpn.fastestvpnservice.R
|
|
|
-import com.vpn.fastestvpnservice.sealedClass.Screen
|
|
|
-import androidx.compose.runtime.setValue
|
|
|
-import androidx.compose.runtime.getValue
|
|
|
-import androidx.compose.runtime.livedata.observeAsState
|
|
|
-import androidx.compose.runtime.mutableStateOf
|
|
|
-import androidx.compose.runtime.rememberCoroutineScope
|
|
|
-import androidx.compose.runtime.rememberUpdatedState
|
|
|
-import androidx.compose.ui.draw.alpha
|
|
|
-import androidx.compose.ui.draw.clip
|
|
|
-import androidx.compose.ui.graphics.painter.Painter
|
|
|
-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
|
|
|
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.R
|
|
|
import com.vpn.fastestvpnservice.beans.Protocol
|
|
|
import com.vpn.fastestvpnservice.beans.Server
|
|
|
import com.vpn.fastestvpnservice.beans.isDarkTheme
|
|
@@ -110,21 +81,16 @@ 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.interfaces.IKEv2Callbacks
|
|
|
import com.vpn.fastestvpnservice.interfaces.ServerCallbacks
|
|
|
-import com.vpn.fastestvpnservice.navigation.navigationAnimation
|
|
|
-import com.vpn.fastestvpnservice.sealedClass.BottomBarScreen
|
|
|
-import com.vpn.fastestvpnservice.ui.theme.FastestVPNTheme
|
|
|
+import com.vpn.fastestvpnservice.sealedClass.Screen
|
|
|
import com.vpn.fastestvpnservice.ui.theme.customTypography
|
|
|
-import com.vpn.fastestvpnservice.ui.theme.customTypography2
|
|
|
import com.vpn.fastestvpnservice.utils.Utils
|
|
|
import com.vpn.fastestvpnservice.utils.VPNConnectionsUtil
|
|
|
import com.vpn.fastestvpnservice.viewmodels.HomeViewModel
|
|
|
import com.vpn.fastestvpnservice.viewmodels.ServerListViewModel
|
|
|
-import com.vpn.fastestvpnservice.viewmodels.SplashViewModel
|
|
|
import com.vpn.fastestvpnservice.widgets.SimpleAppWidget
|
|
|
import com.wireguard.android.backend.GoBackend
|
|
|
-import kotlinx.coroutines.CoroutineScope
|
|
|
+import de.blinkt.openvpn.core.App
|
|
|
|
|
|
lateinit var act: ComponentActivity
|
|
|
var isServerDialog: MutableState<Boolean> = mutableStateOf(false)
|
|
@@ -164,6 +130,15 @@ lateinit var vpnConnectionsUtil: VPNConnectionsUtil
|
|
|
basePreferenceHelper.setServerObject(server)
|
|
|
}
|
|
|
} else {
|
|
|
+ val recentList = basePreferenceHelper.getRecentlyList()
|
|
|
+ val tempList = ArrayList<Server>()
|
|
|
+ recentList?.forEachIndexed { index, server1 ->
|
|
|
+ tempList.add(server1)
|
|
|
+ }
|
|
|
+ tempList.add(server)
|
|
|
+
|
|
|
+ basePreferenceHelper.setRecentlyList(tempList)
|
|
|
+
|
|
|
basePreferenceHelper.setConnectedServer(server)
|
|
|
basePreferenceHelper.setServerObject(server)
|
|
|
wg.startVpn()
|
|
@@ -615,23 +590,24 @@ fun Home(
|
|
|
) {
|
|
|
AddRowSmart(navHostController, basePreferenceHelper, context)
|
|
|
var smartServer = basePreferenceHelper.getSmartServerObject()
|
|
|
+ val recommended = basePreferenceHelper.getRecommendedServerObject()
|
|
|
val selectedSmartList = basePreferenceHelper.getSmartList()
|
|
|
when(selectedSmartList) {
|
|
|
smartConnect[0] -> {
|
|
|
smartServer = basePreferenceHelper.getRecommendedServerObject()
|
|
|
}
|
|
|
smartConnect[1] -> {
|
|
|
- smartServer = basePreferenceHelper.getSmartServerObject()
|
|
|
+ smartServer = basePreferenceHelper.getSmartServerObject() ?: recommended
|
|
|
}
|
|
|
smartConnect[2] -> {
|
|
|
- smartServer = basePreferenceHelper.getSmartServerObject()
|
|
|
+ smartServer = basePreferenceHelper.getSmartServerObject() ?: recommended
|
|
|
}
|
|
|
else -> {}
|
|
|
}
|
|
|
Button(
|
|
|
onClick = {
|
|
|
Log.d("test_button", "onClick Smart Connect ${smartServer?.server_name}")
|
|
|
-// basePreferenceHelper.setSmartServerObject(smartServer)
|
|
|
+ basePreferenceHelper.setSmartServerObject(smartServer)
|
|
|
// basePreferenceHelper.setConnectedServer(smartServer)
|
|
|
|
|
|
if (isConnect == App.CONNECTED) {
|
|
@@ -644,6 +620,8 @@ fun Home(
|
|
|
if (smartServer != null) {
|
|
|
serverObj.value = smartServer
|
|
|
}
|
|
|
+// basePreferenceHelper.setConnectedServer(smartServer)
|
|
|
+
|
|
|
}
|
|
|
else {
|
|
|
vpnConnectionsUtil.stopVpn()
|
|
@@ -1081,13 +1059,13 @@ fun BoxScope.AddRowSmart(
|
|
|
selectedSmartServer = recommended
|
|
|
}
|
|
|
smartConnect[1] -> {
|
|
|
- icon = Utils.getDrawable(context, recently?.iso)
|
|
|
+ icon = Utils.getDrawable(context, recently?.iso ?: recommended?.iso)
|
|
|
selectedServer = recently ?: recommended
|
|
|
selectedSmartServer = recently
|
|
|
}
|
|
|
smartConnect[2] -> {
|
|
|
- icon = Utils.getDrawable(context, anySpecific?.iso)
|
|
|
- selectedServer = anySpecific
|
|
|
+ icon = Utils.getDrawable(context, anySpecific?.iso ?: recommended?.iso)
|
|
|
+ selectedServer = anySpecific ?: recommended
|
|
|
selectedSmartServer = anySpecific
|
|
|
}
|
|
|
else -> {}
|
|
@@ -1108,24 +1086,27 @@ fun BoxScope.AddRowSmart(
|
|
|
modifier = Modifier.padding(start = 0.dp),
|
|
|
color = Color.Transparent
|
|
|
) {
|
|
|
- Icon(
|
|
|
- painter = painterResource(id = icon),
|
|
|
- contentDescription = "Country Logo",
|
|
|
- tint = Color.Unspecified,
|
|
|
- modifier = Modifier
|
|
|
- .padding(start = 0.dp)
|
|
|
- .size(40.dp)
|
|
|
- .weight(1f)
|
|
|
- .clip(CircleShape)
|
|
|
- .paint(
|
|
|
- painter = painterResource(id = icon),
|
|
|
- contentScale = ContentScale.FillBounds
|
|
|
- )
|
|
|
- )
|
|
|
+ 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)
|
|
|
+ .paint(
|
|
|
+ painter = painterResource(id = icon),
|
|
|
+ contentScale = ContentScale.FillBounds
|
|
|
+ )
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
Column(
|
|
|
modifier = Modifier
|
|
|
.padding(start = 12.dp)
|
|
|
+
|
|
|
) {
|
|
|
ColumnText(
|
|
|
text = selectedSmartList,
|