Ver código fonte

Showing subscription screen to a free user on click on server if disabled

Khubaib 8 meses atrás
pai
commit
a6d1420d90

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

@@ -56,6 +56,7 @@ import com.vpn.fastestvpnservice.R
 import com.vpn.fastestvpnservice.beans.Server
 import com.vpn.fastestvpnservice.beans.favListServer
 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.onServer
@@ -271,6 +272,15 @@ fun ColumnScope.ExpandableRow(
     val homeViewModel: HomeViewModel = viewModel { HomeViewModel(context, scope) }
     var isExpServerClicked by remember { mutableStateOf(false) }
 
+    var isFreeAccount: Boolean = false
+    basePreferenceHelper.getProduct()?.identifier?.let {
+        if (it == AppEnum.FREE.key) {
+            isFreeAccount = true
+        } else {
+            isFreeAccount = false
+        }
+    }
+
     Column(
         modifier = Modifier
             .padding(
@@ -337,7 +347,7 @@ fun ColumnScope.ExpandableRow(
                             indication = null,
                             interactionSource = remember { MutableInteractionSource() }
                         ) {
-                            if (serverInfo.enable == 1) {
+                            if (!isFreeAccount) {
 
                                 if (toChangeServer.value) {
                                     Log.d("test_change_Server", "true-Change")

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

@@ -48,6 +48,7 @@ import com.vpn.fastestvpnservice.R
 import com.vpn.fastestvpnservice.beans.Server
 import com.vpn.fastestvpnservice.beans.favListServer
 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.onServer
@@ -99,6 +100,14 @@ fun ServerItem(server: Server, navHostController: NavHostController, serverPing:
 //        else Utils.getDrawableGray(context, server.iso)
 
         val icon = Utils.getDrawable(context, server.iso)
+        var isFreeAccount: Boolean = false
+        basePreferenceHelper.getProduct()?.identifier?.let {
+            if (it == AppEnum.FREE.key) {
+                isFreeAccount = true
+            } else {
+                isFreeAccount = false
+            }
+        }
 
         Box(
 //            verticalAlignment = Alignment.Top,
@@ -111,7 +120,7 @@ fun ServerItem(server: Server, navHostController: NavHostController, serverPing:
                     indication = null,
                     interactionSource = remember { MutableInteractionSource() }
                 ) {
-                    if (server.enable == 1) {
+                    if (!isFreeAccount) {
                         if (toChangeServer.value) {
                             basePreferenceHelper.saveSmartList(smartConnect[2])
                             basePreferenceHelper.setSmartServerObject(server)
@@ -289,6 +298,14 @@ fun FavoriteServerItem(
 //        else Utils.getDrawableGray(context, server.iso)
 
         val icon = Utils.getDrawable(context, server.iso)
+        var isFreeAccount: Boolean = false
+        basePreferenceHelper.getProduct()?.identifier?.let {
+            if (it == AppEnum.FREE.key) {
+                isFreeAccount = true
+            } else {
+                isFreeAccount = false
+            }
+        }
 
         Box(
 //            verticalAlignment = Alignment.Top,
@@ -300,7 +317,7 @@ fun FavoriteServerItem(
                     indication = null,
                     interactionSource = remember { MutableInteractionSource() }
                 ) {
-                    if (server.enable == 1) {
+                    if (!isFreeAccount) {
                         isFavServerClicked = true
                     } else {
                         basePreferenceHelper.setSubscriptionServerObject(server)
@@ -478,6 +495,14 @@ fun ServerSearchItem(
 //        else Utils.getDrawableGray(context, server.iso)
 
         val icon = Utils.getDrawable(context, server.iso)
+        var isFreeAccount: Boolean = false
+        basePreferenceHelper.getProduct()?.identifier?.let {
+            if (it == AppEnum.FREE.key) {
+                isFreeAccount = true
+            } else {
+                isFreeAccount = false
+            }
+        }
 
         Box(
 //            verticalAlignment = Alignment.Top,
@@ -489,7 +514,7 @@ fun ServerSearchItem(
                     indication = null,
                     interactionSource = remember { MutableInteractionSource() }
                 ) {
-                    if (server.enable == 1) {
+                    if (!isFreeAccount) {
                         if (toChangeServer.value) {
                             basePreferenceHelper.saveSmartList(smartConnect[2])
                             basePreferenceHelper.setSmartServerObject(server)
@@ -652,6 +677,14 @@ fun ServerSpecificItem(
 //        else Utils.getDrawableGray(context, server.iso)
 
         val icon = Utils.getDrawable(context, server.iso)
+        var isFreeAccount: Boolean = false
+        basePreferenceHelper.getProduct()?.identifier?.let {
+            if (it == AppEnum.FREE.key) {
+                isFreeAccount = true
+            } else {
+                isFreeAccount = false
+            }
+        }
 
         Row(
             verticalAlignment = Alignment.Top,
@@ -663,7 +696,7 @@ fun ServerSpecificItem(
                     indication = null,
                     interactionSource = remember { MutableInteractionSource() }
                 ) {
-                    if (server.enable == 1) {
+                    if (!isFreeAccount) {
 //                        MainActivity.isSelectedServersShown = true
 //                        basePreferenceHelper.setServerObject(server)
                         basePreferenceHelper.saveSmartList(smartConnect[2])

+ 12 - 1
app/src/main/java/com/vpn/fastestvpnservice/screens/bottomNavBarScreens/HomeScreen.kt

@@ -91,6 +91,7 @@ import androidx.lifecycle.LifecycleEventObserver
 import androidx.lifecycle.LifecycleOwner
 import androidx.lifecycle.viewmodel.compose.viewModel
 import androidx.navigation.NavHostController
+import com.google.android.material.snackbar.Snackbar
 import com.google.firebase.BuildConfig
 import com.vpn.fastestvpnservice.MainActivity
 import com.vpn.fastestvpnservice.R
@@ -108,6 +109,7 @@ import com.vpn.fastestvpnservice.screens.serverListViewModelSplash
 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.SnackBarUtils
 import com.vpn.fastestvpnservice.utils.Utils
 import com.vpn.fastestvpnservice.utils.VPNConnectionsUtil
 import com.vpn.fastestvpnservice.utils.isTablet
@@ -210,7 +212,16 @@ lateinit var vpnConnectionsUtil: VPNConnectionsUtil
          protocolObj.value = protocol
          val connectState = prefHelper.getConnectState()
 
-         if (getEnableProtocols(protocol.title, prefHelper)) {
+         var isFreeAccount: Boolean = false
+         prefHelper.getProduct()?.identifier?.let {
+             if (it == AppEnum.FREE.key) {
+                 isFreeAccount = true
+             } else {
+                 isFreeAccount = false
+             }
+         }
+
+         if (!isFreeAccount) {
              Log.d("OnChangeProtocol", "getEnableProtocols yes!")
 
              if (prefHelper.getProtocol().index != protocol.index) {

+ 10 - 1
app/src/main/java/com/vpn/fastestvpnservice/screensTV/HomeScreenTV.kt

@@ -199,7 +199,16 @@ val onServerTV = object : ServerCallbacksTV {
         protocolObj.value = protocol
         val connectState = prefHelper.getConnectState()
 
-        if (getEnableProtocols(protocol.title, prefHelper)) {
+        var isFreeAccount: Boolean = false
+        prefHelper.getProduct()?.identifier?.let {
+            if (it == AppEnum.FREE.key) {
+                isFreeAccount = true
+            } else {
+                isFreeAccount = false
+            }
+        }
+
+        if (!isFreeAccount) {
             Log.d("OnChangeProtocol", "getEnableProtocols yes!")
 
             if (prefHelper.getProtocol().index != protocol.index) {