|
@@ -4,6 +4,7 @@ import android.app.Activity
|
|
import android.app.LocaleManager
|
|
import android.app.LocaleManager
|
|
import android.content.Context
|
|
import android.content.Context
|
|
import android.content.Intent
|
|
import android.content.Intent
|
|
|
|
+import android.location.Location
|
|
import android.os.Build
|
|
import android.os.Build
|
|
import android.os.Bundle
|
|
import android.os.Bundle
|
|
import android.os.Handler
|
|
import android.os.Handler
|
|
@@ -96,6 +97,7 @@ import androidx.navigation.NavHostController
|
|
import androidx.navigation.compose.currentBackStackEntryAsState
|
|
import androidx.navigation.compose.currentBackStackEntryAsState
|
|
import com.vpn.fastestvpnservice.R
|
|
import com.vpn.fastestvpnservice.R
|
|
import com.vpn.fastestvpnservice.beans.Protocol
|
|
import com.vpn.fastestvpnservice.beans.Protocol
|
|
|
|
+import com.vpn.fastestvpnservice.beans.Server
|
|
import com.vpn.fastestvpnservice.beans.isDarkTheme
|
|
import com.vpn.fastestvpnservice.beans.isDarkTheme
|
|
import com.vpn.fastestvpnservice.beans.languages
|
|
import com.vpn.fastestvpnservice.beans.languages
|
|
import com.vpn.fastestvpnservice.beans.themesList
|
|
import com.vpn.fastestvpnservice.beans.themesList
|
|
@@ -141,6 +143,7 @@ fun SettingsTV(navHostController: NavHostController) {
|
|
}
|
|
}
|
|
val vpnConnectionsUtil = VPNConnectionsUtil(context, activityGlobal, homeViewModel)
|
|
val vpnConnectionsUtil = VPNConnectionsUtil(context, activityGlobal, homeViewModel)
|
|
var settingsString by remember { mutableStateOf(context.getString(R.string.settings)) }
|
|
var settingsString by remember { mutableStateOf(context.getString(R.string.settings)) }
|
|
|
|
+ val basePreferenceHelper = BasePreferenceHelper(context)
|
|
|
|
|
|
if (isSettingsScreenPressed.value) {
|
|
if (isSettingsScreenPressed.value) {
|
|
LaunchedEffect(Unit) {
|
|
LaunchedEffect(Unit) {
|
|
@@ -263,6 +266,64 @@ fun SettingsTV(navHostController: NavHostController) {
|
|
) {
|
|
) {
|
|
settingsString = it
|
|
settingsString = it
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ val serversResponse = splashViewModelSplash.liveDataServerData.observeAsState().value
|
|
|
|
+ serversResponse?.let { data ->
|
|
|
|
+ Log.d("test_lingual_splash", "serversResponse - in")
|
|
|
|
+ if (data.status) {
|
|
|
|
+ Log.d("test_lingual_splash", "serversResponse - true")
|
|
|
|
+ serverListViewModelSplash.setCountryDataTV()
|
|
|
|
+ val smartLocationList: MutableList<Server> = ArrayList<Server>()
|
|
|
|
+ basePreferenceHelper.getServerData().get(0).servers?.let {
|
|
|
|
+ val serverDataLocation = it
|
|
|
|
+
|
|
|
|
+ val distinctdatanotnull =
|
|
|
|
+ serverDataLocation.filter { // servers's lt and lt not be null
|
|
|
|
+ it.lt != null && it.lg != null
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ val distinctdata =
|
|
|
|
+ distinctdatanotnull.distinctBy { // servers's lt filter, no same lt of a server
|
|
|
|
+ it.lt
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ val result = FloatArray(1)
|
|
|
|
+ val ipinfo = basePreferenceHelper.getIpinfo()
|
|
|
|
+
|
|
|
|
+ distinctdata.forEachIndexed { index, server ->
|
|
|
|
+ val lat1 = ipinfo?.latitute
|
|
|
|
+ val lon1 = ipinfo?.longitude
|
|
|
|
+ val lat2 = server.lt
|
|
|
|
+ val lon2 = server.lg
|
|
|
|
+
|
|
|
|
+ if (lat1 != null && lat2 != null && lon1 != null && lon2 != null) {
|
|
|
|
+ Location.distanceBetween(lat1, lon1, lat2, lon2, result)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ val distance: Float = result[0]
|
|
|
|
+ distinctdata.get(index).distance = distance
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ val sortedDistance = distinctdata.sortedBy {
|
|
|
|
+ it.distance
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (sortedDistance.isNotEmpty()) {
|
|
|
|
+ for (i in 0..0) {
|
|
|
|
+ smartLocationList.add(sortedDistance.get(i))
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ smartLocationList.forEach {
|
|
|
|
+// prefHelper.setSmartServerObject(it)
|
|
|
|
+ basePreferenceHelper.setRecommendedServerObject(it)
|
|
|
|
+ Log.d("test_lingual_splash", "L:: server = ${it.server_name}")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ splashViewModelSplash.mutableLiveDataServerData.value = null
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1568,7 +1629,7 @@ fun AddLanguageTV(
|
|
}
|
|
}
|
|
|
|
|
|
splashViewModelSplash.serverDataApi()
|
|
splashViewModelSplash.serverDataApi()
|
|
- isLanguageSheetOpen = false
|
|
|
|
|
|
+// isLanguageSheetOpen = false
|
|
},
|
|
},
|
|
)
|
|
)
|
|
// .indication(
|
|
// .indication(
|
|
@@ -1608,7 +1669,7 @@ fun AddLanguageTV(
|
|
}
|
|
}
|
|
|
|
|
|
splashViewModelSplash.serverDataApi()
|
|
splashViewModelSplash.serverDataApi()
|
|
- isLanguageSheetOpen = false
|
|
|
|
|
|
+// isLanguageSheetOpen = false
|
|
},
|
|
},
|
|
colors = RadioButtonDefaults.colors(
|
|
colors = RadioButtonDefaults.colors(
|
|
selectedColor = colorResource(id = R.color.radio_button_blue),
|
|
selectedColor = colorResource(id = R.color.radio_button_blue),
|