Преглед на файлове

Added Ping of servers...

Khubaib преди 1 година
родител
ревизия
d83db97d66

+ 4 - 0
app/build.gradle.kts

@@ -84,6 +84,10 @@ dependencies {
     implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0")
     implementation("androidx.compose.runtime:runtime-livedata:1.6.1")
 
+    // Ping
+    implementation("com.github.stealthcopter:AndroidNetworkTools:0.4.5.3")
+
+
     testImplementation("junit:junit:4.13.2")
     androidTestImplementation("androidx.test.ext:junit:1.1.5")
     androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")

+ 3 - 1
app/src/main/java/com/vpn/fastestvpnservice/beans/ServerData.kt

@@ -1,5 +1,7 @@
 package com.vpn.fastestvpnservice.beans
 
+import androidx.compose.runtime.MutableState
+import androidx.compose.runtime.mutableStateOf
 import com.google.gson.annotations.SerializedName
 import java.util.*
 
@@ -8,5 +10,5 @@ class ServerData(
     var name: String? = null,
     @SerializedName("servers")
     val servers: ArrayList<Server>? = null,
-    val isSelected: Boolean = false
+    var isExpanded: MutableState<Boolean> = mutableStateOf(true)
 )

+ 50 - 11
app/src/main/java/com/vpn/fastestvpnservice/customItems/CountryItem.kt

@@ -1,5 +1,7 @@
 package com.vpn.fastestvpnservice.customItems
 
+import android.os.Looper
+import android.util.Log
 import android.widget.Toast
 import androidx.compose.foundation.background
 import androidx.compose.foundation.clickable
@@ -23,6 +25,7 @@ import androidx.compose.material3.Surface
 import androidx.compose.material3.Text
 import androidx.compose.runtime.Composable
 import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableIntStateOf
 import androidx.compose.runtime.mutableStateOf
 import androidx.compose.runtime.remember
 import androidx.compose.runtime.saveable.rememberSaveable
@@ -45,9 +48,14 @@ import com.vpn.fastestvpnservice.beans.allLocationsList
 import com.vpn.fastestvpnservice.beans.favList
 import com.vpn.fastestvpnservice.beans.favListServer
 import com.vpn.fastestvpnservice.utils.Utils
+import com.stealthcopter.networktools.Ping
+import com.stealthcopter.networktools.ping.PingResult
+import com.stealthcopter.networktools.ping.PingStats
+import java.lang.Exception
+import java.util.logging.Handler
 
 @Composable
-fun CountryItem(server: Server) {
+fun CountryItem(server: Server, category: String) {
     Box(
         modifier = Modifier
             .fillMaxWidth()
@@ -58,12 +66,10 @@ fun CountryItem(server: Server) {
 
     ) {
         val context = LocalContext.current
-
-        var countrySize by rememberSaveable { mutableStateOf(server.countryServers?.size) }
+        val countrySize by rememberSaveable { mutableStateOf(server.totalServers) }
         var isServerExpanded by rememberSaveable { mutableStateOf(false) }
 
-        if (countrySize != null) {
-            countrySize?.let { size ->
+            countrySize.let { size ->
                 if (size > 1) {
                     Column {
                         /* Country Location's Row */
@@ -144,13 +150,31 @@ fun CountryItem(server: Server) {
                     }
                 }
                 else {
+
+//                    Log.d("test_servers_count", "${server.server_name} ${server.countryServers?.size}")
                     /* Country Location's Row -> 1 Location() */
+
+                    var ping by remember { mutableIntStateOf(0) }
+                    Ping.onAddress(server.ip as String).setTimeOutMillis(1000).doPing(
+                        object : Ping.PingListener{
+                            override fun onResult(pingResult: PingResult?) {
+                                android.os.Handler(Looper.getMainLooper()).post {
+                                    ping = pingResult?.timeTaken?.toInt()!!
+                                    Log.d("test_ping", "ping = $ping")
+                                }
+                            }
+
+                            override fun onError(e: Exception?) {}
+                            override fun onFinished(pingStats: PingStats?) {}
+                        }
+                    )
+
                     Row(
                         verticalAlignment = Alignment.Top,
                         horizontalArrangement = Arrangement.Start,
                         modifier = Modifier
                             .fillMaxWidth()
-                            .padding(start = 12.dp, end = 7.dp, top = 12.dp)
+                            .padding(start = 16.dp, end = 7.dp, top = 12.dp)
                             .clickable(
                                 indication = null,
                                 interactionSource = remember { MutableInteractionSource() }
@@ -173,7 +197,8 @@ fun CountryItem(server: Server) {
                                 .padding(bottom = 16.dp)
                                 .size(24.dp)
                         )
-                        Text(text = server.country!!,
+                        val serverTitle = if (category.lowercase().toString() == "servers") server.country else server.server_name
+                        Text(text = serverTitle!!,
                             style = TextStyle(
                                 fontSize = 16.sp,
                                 color = MaterialTheme.colorScheme.primary
@@ -184,7 +209,7 @@ fun CountryItem(server: Server) {
                         )
                         Spacer(modifier = Modifier.weight(1F))
                         Text(
-                            text = "130 ms",
+                            text = "$ping ms",
                             style = TextStyle(
                                 fontSize = 16.sp,
                                 color = colorResource(id = R.color.blue_text)
@@ -226,7 +251,6 @@ fun CountryItem(server: Server) {
                 ,
                 color = colorResource(id = R.color.gray_icon)
             ) {}
-        }
 
     }
 }
@@ -243,6 +267,21 @@ fun ColumnScope.ExpandableRow(server: Server) {
             )
             .background(Color.Transparent)
     ) {
+
+        var ping by remember { mutableIntStateOf(0) } 
+        Ping.onAddress(server.ip as String).setTimeOutMillis(1000).doPing(
+            object : Ping.PingListener{
+                override fun onResult(pingResult: PingResult?) {
+                    android.os.Handler(Looper.getMainLooper()).post {
+                        ping = pingResult?.timeTaken?.toInt()!!
+                    }
+                }
+
+                override fun onError(e: Exception?) {}
+                override fun onFinished(pingStats: PingStats?) {}
+            }
+        )
+
             server.countryServers?.let { serverData ->
                 serverData.forEachIndexed { index, serverInfo ->
                     Row(
@@ -278,7 +317,7 @@ fun ColumnScope.ExpandableRow(server: Server) {
                         )
                         Spacer(modifier = Modifier.weight(1F))
 
-                        Text(text = "45 ms",
+                        Text(text = "$ping ms",
                             style = TextStyle(
                                 fontSize = 16.sp,
                                 color = colorResource(id = R.color.blue_text)
@@ -325,5 +364,5 @@ fun ColumnScope.ExpandableRow(server: Server) {
 @Preview
 @Composable
 fun CountryItemPreview() {
-    CountryItem(server = favListServer[0])
+    CountryItem(server = favListServer[0], "servers")
 }

+ 49 - 4
app/src/main/java/com/vpn/fastestvpnservice/customItems/ServerItem.kt

@@ -1,6 +1,7 @@
 package com.vpn.fastestvpnservice.customItems
 
 import android.content.res.Configuration
+import android.os.Looper
 import android.widget.Toast
 import androidx.compose.foundation.Image
 import androidx.compose.foundation.background
@@ -22,6 +23,7 @@ import androidx.compose.material3.Surface
 import androidx.compose.material3.Text
 import androidx.compose.runtime.Composable
 import androidx.compose.runtime.getValue
+import androidx.compose.runtime.mutableIntStateOf
 import androidx.compose.runtime.mutableStateOf
 import androidx.compose.runtime.remember
 import androidx.compose.runtime.saveable.rememberSaveable
@@ -40,12 +42,16 @@ import androidx.compose.ui.text.TextStyle
 import androidx.compose.ui.tooling.preview.Preview
 import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
+import com.stealthcopter.networktools.Ping
+import com.stealthcopter.networktools.ping.PingResult
+import com.stealthcopter.networktools.ping.PingStats
 import com.vpn.fastestvpnservice.R
 import com.vpn.fastestvpnservice.beans.Server
 import com.vpn.fastestvpnservice.beans.ServerList
 import com.vpn.fastestvpnservice.beans.favList
 import com.vpn.fastestvpnservice.beans.favListServer
 import com.vpn.fastestvpnservice.utils.Utils
+import java.lang.Exception
 
 @Composable
 fun ServerItem(server: Server) {
@@ -76,6 +82,19 @@ fun ServerItem(server: Server) {
                         .show()
                 }
         ) {
+            var ping by remember { mutableIntStateOf(0) }
+            Ping.onAddress(server.ip as String).setTimeOutMillis(1000).doPing(
+                object : Ping.PingListener{
+                    override fun onResult(pingResult: PingResult?) {
+                        android.os.Handler(Looper.getMainLooper()).post {
+                            ping = pingResult?.timeTaken?.toInt()!!
+                        }
+                    }
+
+                    override fun onError(e: Exception?) {}
+                    override fun onFinished(pingStats: PingStats?) {}
+                }
+            )
             val icon = Utils.getDrawable(context, server.iso)
             Icon(
                 painter = painterResource(id = icon),
@@ -95,7 +114,7 @@ fun ServerItem(server: Server) {
                     .align(Alignment.CenterVertically)
                 )
             Spacer(modifier = Modifier.weight(1F))
-            Text(text = "75 ms",
+            Text(text = "$ping ms",
                 style = TextStyle(
                     fontSize = 16.sp,
                     color = colorResource(id = R.color.blue_text)
@@ -182,6 +201,19 @@ fun FavoriteServerItem(server: Server) {
                         .show()
                 }
         ) {
+            var ping by remember { mutableIntStateOf(0) }
+            Ping.onAddress(server.ip as String).setTimeOutMillis(1000).doPing(
+                object : Ping.PingListener{
+                    override fun onResult(pingResult: PingResult?) {
+                        android.os.Handler(Looper.getMainLooper()).post {
+                            ping = pingResult?.timeTaken?.toInt()!!
+                        }
+                    }
+
+                    override fun onError(e: Exception?) {}
+                    override fun onFinished(pingStats: PingStats?) {}
+                }
+            )
             val icon = Utils.getDrawable(context, server.iso)
 
             Icon(
@@ -193,7 +225,7 @@ fun FavoriteServerItem(server: Server) {
                     .size(24.dp)
             )
 
-            Text(text = "65 ms",
+            Text(text = server.server_name!!,
                 style = TextStyle(
                     fontSize = 16.sp,
                     color = MaterialTheme.colorScheme.primary
@@ -203,7 +235,7 @@ fun FavoriteServerItem(server: Server) {
                     .align(Alignment.CenterVertically)
             )
             Spacer(modifier = Modifier.weight(1F))
-            Text(text = "125 ms",
+            Text(text = "$ping ms",
                 style = TextStyle(
                     fontSize = 16.sp,
                     color = colorResource(id = R.color.blue_text)
@@ -292,6 +324,19 @@ fun ServerSearchItem(server: Server) {
                         .show()
                 }
         ) {
+            var ping by remember { mutableIntStateOf(0) }
+            Ping.onAddress(server.ip as String).setTimeOutMillis(1000).doPing(
+                object : Ping.PingListener{
+                    override fun onResult(pingResult: PingResult?) {
+                        android.os.Handler(Looper.getMainLooper()).post {
+                            ping = pingResult?.timeTaken?.toInt()!!
+                        }
+                    }
+
+                    override fun onError(e: Exception?) {}
+                    override fun onFinished(pingStats: PingStats?) {}
+                }
+            )
             val icon = Utils.getDrawable(context, server.iso)
             Icon(
                 painter = painterResource(id = icon),
@@ -311,7 +356,7 @@ fun ServerSearchItem(server: Server) {
                     .align(Alignment.CenterVertically)
             )
             Spacer(modifier = Modifier.weight(1F))
-            Text(text = "145 ms",
+            Text(text = "$ping ms",
                 style = TextStyle(
                     fontSize = 16.sp,
                     color = colorResource(id = R.color.blue_text)

+ 1 - 1
app/src/main/java/com/vpn/fastestvpnservice/retrofit/WebServiceFactory.java

@@ -1,5 +1,6 @@
 package com.vpn.fastestvpnservice.retrofit;
 
+import com.stealthcopter.networktools.Ping;
 import com.vpn.fastestvpnservice.application.App;
 import com.vpn.fastestvpnservice.constants.AppConstant;
 import com.vpn.fastestvpnservice.helpers.BasePreferenceHelper;
@@ -30,7 +31,6 @@ public class WebServiceFactory {
     private static Api instance2;
 
     public static Api getInstance() {
-
         BasePreferenceHelper prefHelper = new BasePreferenceHelper(App.getApplication());
 
         OkHttpClient.Builder httpClient = new OkHttpClient.Builder();

+ 189 - 138
app/src/main/java/com/vpn/fastestvpnservice/screens/ServerListScreen.kt

@@ -296,7 +296,7 @@ fun ColumnScope.ShowRecommendedList(
                 }
             }
                 val fav = basePreferenceHelper.getServerData()
-                val filterData1 = fav.get(1).servers?.let {
+                val filterData1 = fav.get(2).servers?.let {
                     serverListViewModel.filterServersByStreamingServers(
                         it
                     )
@@ -443,19 +443,21 @@ fun ColumnScope.ShowAllLocationsList(
     val allLocationsTabItems = listOf(
         "Countries", "Streaming", "D-VPN", "P2P"
     )
-    val pagerState = rememberPagerState(pageCount = { allLocationsTabItems.size })
-    val selectedIndex by remember { derivedStateOf { pagerState.currentPage } }
-    val scope = rememberCoroutineScope()
-
-    val country = basePreferenceHelper.getServerData()
-    val filterData = country.get(0).servers?.let {
+    val serverData = basePreferenceHelper.getServerData()
+    val filterData = serverData.get(0).servers?.let {
         serverListViewModel.filterServersByISO(
             it
         )
     }
 
-    country.forEachIndexed { index, server ->
-        Log.d("test_data", server.name.toString())
+    val pagerState = rememberPagerState(pageCount = { serverData.size })
+    val selectedIndex by remember { derivedStateOf { pagerState.currentPage } }
+    val scope = rememberCoroutineScope()
+
+
+
+    serverData.forEachIndexed { index, server ->
+        Log.d("test_data", "${server.name} ${server.servers?.size} -> ${serverData.size}")
     }
 
     androidx.compose.material3.ScrollableTabRow(
@@ -476,7 +478,7 @@ fun ColumnScope.ShowAllLocationsList(
         },
 //                                divider = {}
     ) {
-        allLocationsTabItems.forEachIndexed { index1, locationTab ->
+        serverData.forEachIndexed { index1, locationTab ->
 //                                    val color = remember { Animatable(Color.Transparent) }
             var color by remember { mutableStateOf(Color.Transparent) }
             var alpha by remember { mutableFloatStateOf(1F) }
@@ -499,7 +501,7 @@ fun ColumnScope.ShowAllLocationsList(
                 unselectedContentColor = Color.White,
                 text = {
                     Text(
-                        text = locationTab,
+                        text = locationTab.name!!,
                         style = TextStyle(
                             color = color,
                             fontSize = 14.sp,
@@ -521,11 +523,16 @@ fun ColumnScope.ShowAllLocationsList(
         }
     }
 
-    var isCountriesExpanded by rememberSaveable { mutableStateOf(true) }
+    val data = basePreferenceHelper.getServerData()
+
+
+    var isServersListExpanded by rememberSaveable { mutableStateOf(List(data.size) {true}) }
     var isStreamingExpanded by rememberSaveable { mutableStateOf(true) }
     var isDvpnExpanded by rememberSaveable { mutableStateOf(true) }
     var isP2PExpanded by rememberSaveable { mutableStateOf(true) }
 
+    val isServersTabExpanded by rememberSaveable { mutableStateOf(listOf(true)) }
+
 //    val rotationState by animateFloatAsState(
 //        targetValue = if (isCountriesExpanded) 180f else 0f,
 //        label = if (isCountriesExpanded) "Show Less" else "Show More"
@@ -548,129 +555,172 @@ fun ColumnScope.ShowAllLocationsList(
                 var serverTitle by rememberSaveable { mutableStateOf("") }
                 var icon by rememberSaveable { mutableStateOf(0) }
 
-                when (serverTabPager) {
-                    0 -> {
-                        serverTitle = allLocationsTabItems[0]
-                        icon = if (isCountriesExpanded) R.drawable.dragarrow3x
-                        else R.drawable.downarrow3x
-                    }
-                    1 -> {
-                        serverTitle = allLocationsTabItems[1]
-                        icon = if (isStreamingExpanded) R.drawable.dragarrow3x
-                        else R.drawable.downarrow3x
-                    }
-                    2 -> {
-                        serverTitle = allLocationsTabItems[2]
-                        icon = if (isDvpnExpanded) R.drawable.dragarrow3x
-                        else R.drawable.downarrow3x
-                    }
-                    3 -> {
-                        serverTitle = allLocationsTabItems[3]
-                        icon = if (isP2PExpanded) R.drawable.dragarrow3x
-                        else R.drawable.downarrow3x
-                    }
-                }
+//                when (serverTabPager) {
+//                    0 -> {
+//                        serverTitle = serverData[0].name!!
+//                        icon = if (isCountriesExpanded) R.drawable.dragarrow3x
+//                        else R.drawable.downarrow3x
+//                    }
+//                    1 -> {
+//                        serverTitle = serverData[1].name!!
+//                        icon = if (isStreamingExpanded) R.drawable.dragarrow3x
+//                        else R.drawable.downarrow3x
+//                    }
+//                    2 -> {
+//                        serverTitle = serverData[2].name!!
+//                        icon = if (isDvpnExpanded) R.drawable.dragarrow3x
+//                        else R.drawable.downarrow3x
+//                    }
+//                    3 -> {
+//                        serverTitle = serverData[3].name!!
+//                        icon = if (isP2PExpanded) R.drawable.dragarrow3x
+//                        else R.drawable.downarrow3x
+//                    }
+//                    4 -> {
+//                        serverTitle = serverData[4].name!!
+//                        icon = if (isP2PExpanded) R.drawable.dragarrow3x
+//                        else R.drawable.downarrow3x
+//                    }
+//                }
+
+                serverTitle = serverData[serverTabPager].name!!
+                icon = if (isServersListExpanded[serverTabPager]) R.drawable.dragarrow3x
+                else R.drawable.downarrow3x
 
                 ShowHeaderItem(serverTitle, icon, serverTabPager) {
-                    when (serverTabPager) {
-                        0 -> {
-                            isCountriesExpanded = !isCountriesExpanded
-                        }
-                        1 -> {
-                            isStreamingExpanded = !isStreamingExpanded
-                        }
-                        2 -> {
-                            isDvpnExpanded = !isDvpnExpanded
-                        }
-                        3 -> {
-                            isP2PExpanded = !isP2PExpanded
-                        }
+                    isServersListExpanded = isServersListExpanded.toMutableList().also {
+                        it[serverTabPager] = !isServersListExpanded[serverTabPager]
                     }
+
+                    //                    when (serverTabPager) {
+//                        0 -> {
+//                            isCountriesExpanded = !isCountriesExpanded
+//                        }
+//                        1 -> {
+//                            isStreamingExpanded = !isStreamingExpanded
+//                        }
+//                        2 -> {
+//                            isDvpnExpanded = !isDvpnExpanded
+//                        }
+//                        3 -> {
+//                            isP2PExpanded = !isP2PExpanded
+//                        }
+//                    }
                 }
 
-                when (serverTabPager) {
-                    0 -> {
-                        if (isCountriesExpanded) {
-                            CompositionLocalProvider(
-                                LocalOverscrollConfiguration provides null
-                            ) {
-                                val country = basePreferenceHelper.getServerData()
-                                val filterData = country.get(0).servers?.let {
-                                    serverListViewModel.filterServersByISO(
-                                        it
-                                    )
-                                }
-
-                                LazyColumn() {
-                                    items(items = filterData!!) { country ->
-                                        CountryItem(server = country)
-                                    }
-                                }
+                if (isServersListExpanded[serverTabPager]) {
+                    CompositionLocalProvider(
+                        LocalOverscrollConfiguration provides null
+                    ) {
+                        val filterServersData = if (data[serverTabPager].name?.lowercase().toString() == "servers") {
+                            data.get(serverTabPager).servers?.let {
+                                serverListViewModel.filterServersByISO(
+                                    it
+                                )
                             }
-
                         }
-                    }
-                    1 -> {
-                        if (isStreamingExpanded) {
-                            CompositionLocalProvider(
-                                LocalOverscrollConfiguration provides null
-                            ) {
-                                val streaming = basePreferenceHelper.getServerData()
-                                val filterData = streaming.get(1).servers?.let {
-                                    serverListViewModel.filterServersByStreamingServers(
-                                        it
-                                    )
-                                }
-                                LazyColumn() {
-                                    items(items = filterData!!) { streaming ->
-                                        ServerItem(server = streaming)
-                                    }
-                                }
+                        else {
+                            data.get(serverTabPager).servers?.let {
+                                serverListViewModel.filterServersByStreamingServers(
+                                    it
+                                )
                             }
                         }
-                    }
-                    2 -> {
-                        if (isDvpnExpanded) {
-                            CompositionLocalProvider(
-                                LocalOverscrollConfiguration provides null
-                            ) {
-                                val dvpn = basePreferenceHelper.getServerData()
-                                val filterData = dvpn.get(2).servers?.let {
-                                    serverListViewModel.filterServersByISO(
-                                        it
-                                    )
-                                }
-
-                                LazyColumn() {
-                                    items(items = filterData!!) { dvpn ->
-                                        ServerItem(server = dvpn)
-                                    }
-                                }
-                            }
 
-                        }
-                    }
-                    3 -> {
-                        if (isP2PExpanded) {
-                            CompositionLocalProvider(
-                                LocalOverscrollConfiguration provides null
-                            ) {
-                                val p2p = basePreferenceHelper.getServerData()
-                                val filterData = p2p.get(3).servers?.let {
-                                    serverListViewModel.filterServersByISO(
-                                        it
-                                    )
-                                }
-
-                                LazyColumn() {
-                                    items(items = filterData!!) { p2p ->
-                                        ServerItem(server = p2p)
-                                    }
-                                }
+                        Log.d("streaming_servers",data[serverTabPager].name?.toString() + filterServersData?.size.toString())
+
+
+                        LazyColumn() {
+                            items(items = filterServersData!!) { country ->
+                                CountryItem(server = country, data[serverTabPager].name!!)
                             }
                         }
                     }
                 }
+
+//                when (serverTabPager) {
+//                    0 -> {
+//                        if (isCountriesExpanded) {
+//                            CompositionLocalProvider(
+//                                LocalOverscrollConfiguration provides null
+//                            ) {
+//                                val country = basePreferenceHelper.getServerData()
+//                                val filterData = country.get(0).servers?.let {
+//                                    serverListViewModel.filterServersByISO(
+//                                        it
+//                                    )
+//                                }
+//
+//                                LazyColumn() {
+//                                    items(items = filterData!!) { country ->
+//                                        CountryItem(server = country)
+//                                    }
+//                                }
+//                            }
+//
+//                        }
+//                    }
+//                    1 -> {
+//                        if (isStreamingExpanded) {
+//                            CompositionLocalProvider(
+//                                LocalOverscrollConfiguration provides null
+//                            ) {
+//                                val streaming = basePreferenceHelper.getServerData()
+//                                val filterData = streaming.get(1).servers?.let {
+//                                    serverListViewModel.filterServersByStreamingServers(
+//                                        it
+//                                    )
+//                                }
+//                                LazyColumn() {
+//                                    items(items = filterData!!) { streaming ->
+//                                        ServerItem(server = streaming)
+//                                    }
+//                                }
+//                            }
+//                        }
+//                    }
+//                    2 -> {
+//                        if (isDvpnExpanded) {
+//                            CompositionLocalProvider(
+//                                LocalOverscrollConfiguration provides null
+//                            ) {
+//                                val dvpn = basePreferenceHelper.getServerData()
+//                                val filterData = dvpn.get(2).servers?.let {
+//                                    serverListViewModel.filterServersByISO(
+//                                        it
+//                                    )
+//                                }
+//
+//                                LazyColumn() {
+//                                    items(items = filterData!!) { dvpn ->
+//                                        ServerItem(server = dvpn)
+//                                    }
+//                                }
+//                            }
+//
+//                        }
+//                    }
+//                    3 -> {
+//                        if (isP2PExpanded) {
+//                            CompositionLocalProvider(
+//                                LocalOverscrollConfiguration provides null
+//                            ) {
+//                                val p2p = basePreferenceHelper.getServerData()
+//                                val filterData = p2p.get(3).servers?.let {
+//                                    serverListViewModel.filterServersByISO(
+//                                        it
+//                                    )
+//                                }
+//
+//                                LazyColumn() {
+//                                    items(items = filterData!!) { p2p ->
+//                                        ServerItem(server = p2p)
+//                                    }
+//                                }
+//                            }
+//                        }
+//                    }
+//                }
             }
         }
 
@@ -716,23 +766,24 @@ fun ColumnScope.ShowHeaderItem(
 //                        .rotate(rotationState4)
                 .pointerInput(Unit) {
                     detectTapGestures {
-                        when (serverTabPager) {
-                            0 -> {
-                                onClick()
-                            }
-
-                            1 -> {
-                                onClick()
-                            }
-
-                            2 -> {
-                                onClick()
-                            }
-
-                            3 -> {
-                                onClick()
-                            }
-                        }
+                        onClick()
+//                        when (serverTabPager) {
+////                            0 -> {
+////                                onClick()
+////                            }
+////
+////                            1 -> {
+////                                onClick()
+////                            }
+////
+////                            2 -> {
+////                                onClick()
+////                            }
+////
+////                            3 -> {
+////                                onClick()
+////                            }
+//                        }
                     }
                 }
         )

+ 12 - 1
app/src/main/java/com/vpn/fastestvpnservice/viewmodels/ServerListViewModel.kt

@@ -90,6 +90,8 @@ class ServerListViewModel(context: Context): ViewModel() {
 
                 if (entry.key == value.country) {
                     distinctBy.get(index).totalServers = entry.value.sumBy { it.totalServers }
+//                    distinctBy.get(index).totalServers = 1
+
 
                     var total_enables = entry.value.sumBy { it.enable }
 
@@ -256,13 +258,22 @@ class ServerListViewModel(context: Context): ViewModel() {
             it.server_name
         }
 
+        Log.d("streaming_servers t", distinctBy.size.toString())
+
+
         serverprotocol.groupBy(Server::country).mapValues { entry ->
             for ((index, value) in distinctBy.withIndex()) {
                 if (entry.key == value.country) {
-                    distinctBy.get(index).totalServers = entry.value.sumBy { it.totalServers }
+//                    distinctBy.get(index).totalServers = entry.value.sumBy { it.totalServers }
+                    distinctBy.get(index).totalServers = 1
+
+                    distinctBy.get(index).countryServers = entry.value
+
                 }
             }
         }
+
+        Log.d("streaming_servers t", distinctBy.size.toString())
         return (distinctBy as ArrayList<Server>)
     }
 

+ 15 - 1
build.gradle.kts

@@ -1,5 +1,19 @@
 // Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+//buildString {
+//    repositories {
+//        maven { url = uri("https://jitpack.io") }
+//        maven { url = uri("https://maven.google.com") }
+//    }
+//}
+
 plugins {
     id("com.android.application") version "8.2.1" apply false
     id("org.jetbrains.kotlin.android") version "1.9.0" apply false
-}
+}
+
+//allprojects {
+//    repositories {
+//        maven { url = uri("https://www.jitpack.io" ) }
+//    }
+//}

+ 3 - 1
gradle.properties

@@ -20,4 +20,6 @@ kotlin.code.style=official
 # Enables namespacing of each library's R class so that its R class includes only the
 # resources declared in the library itself and none from the library's dependencies,
 # thereby reducing the size of the R class for that library
-android.nonTransitiveRClass=true
+android.nonTransitiveRClass=true
+
+android.enableJetifier=true

+ 1 - 0
settings.gradle.kts

@@ -10,6 +10,7 @@ dependencyResolutionManagement {
     repositories {
         google()
         mavenCentral()
+        maven { url = uri("https://www.jitpack.io") }
     }
 }