Browse Source

Firebase crashlytics integrated..

Khubaib 1 year ago
parent
commit
97aa77171c

+ 4 - 4
.idea/appInsightsSettings.xml

@@ -27,10 +27,10 @@
             <InsightsFilterSettings>
               <option name="connection">
                 <ConnectionSetting>
-                  <option name="appId" value="PLACEHOLDER" />
-                  <option name="mobileSdkAppId" value="" />
-                  <option name="projectId" value="" />
-                  <option name="projectNumber" value="" />
+                  <option name="appId" value="com.vpn.fastestvpnservice" />
+                  <option name="mobileSdkAppId" value="1:25255984076:android:c1e8a85d02d206a28e3b69" />
+                  <option name="projectId" value="fastestvpn-7f2c5" />
+                  <option name="projectNumber" value="25255984076" />
                 </ConnectionSetting>
               </option>
               <option name="signal" value="SIGNAL_UNSPECIFIED" />

+ 3 - 0
app/build.gradle.kts

@@ -1,6 +1,8 @@
 plugins {
     id("com.android.application")
     id("org.jetbrains.kotlin.android")
+    id("com.google.gms.google-services")
+    id("com.google.firebase.crashlytics")
 }
 
 android {
@@ -96,6 +98,7 @@ dependencies {
 
     implementation("io.coil-kt:coil-compose:1.3.1")
     implementation("com.google.accompanist:accompanist-drawablepainter:0.34.0")
+    implementation("com.google.firebase:firebase-crashlytics:18.6.2")
 
     testImplementation("junit:junit:4.13.2")
     androidTestImplementation("androidx.test.ext:junit:1.1.5")

+ 46 - 0
app/google-services.json

@@ -0,0 +1,46 @@
+{
+  "project_info": {
+    "project_number": "25255984076",
+    "project_id": "fastestvpn-7f2c5",
+    "storage_bucket": "fastestvpn-7f2c5.appspot.com"
+  },
+  "client": [
+    {
+      "client_info": {
+        "mobilesdk_app_id": "1:25255984076:android:c1e8a85d02d206a28e3b69",
+        "android_client_info": {
+          "package_name": "com.vpn.fastestvpnservice"
+        }
+      },
+      "oauth_client": [
+        {
+          "client_id": "25255984076-j8u6vulo86m3gafclt4hh0l3qvfv5a26.apps.googleusercontent.com",
+          "client_type": 3
+        }
+      ],
+      "api_key": [
+        {
+          "current_key": "AIzaSyDigz5I8qQ7Edg2CxF2Rk6uyjCXEGZ_U2Y"
+        }
+      ],
+      "services": {
+        "appinvite_service": {
+          "other_platform_oauth_client": [
+            {
+              "client_id": "25255984076-j8u6vulo86m3gafclt4hh0l3qvfv5a26.apps.googleusercontent.com",
+              "client_type": 3
+            },
+            {
+              "client_id": "25255984076-43pnijtirtdbprthmq9mbugla3bjcjs3.apps.googleusercontent.com",
+              "client_type": 2,
+              "ios_info": {
+                "bundle_id": "com.fastestvpn.vpn.naum"
+              }
+            }
+          ]
+        }
+      }
+    }
+  ],
+  "configuration_version": "1"
+}

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

@@ -102,7 +102,7 @@ fun SubscriptionPackageItem(item: SubscriptionPackageList, position: Int, activi
 //                            )
 //                        }
 
-//                            subscriptionViewModel.setNumber(random)
+//                            subscriptionViewModel.setSelectedPosition(position)
 
                             subscriptionPackageList.forEachIndexed { index, subscriptionPackageList ->
 

+ 8 - 6
app/src/main/java/com/vpn/fastestvpnservice/screens/accountScreensAll/SubscriptionScreen.kt

@@ -197,19 +197,21 @@ fun SubscriptionScreen(navHostController: NavHostController, activity: Component
             }
         }
 
-//        val skuDetailsListsSubs = subscriptionViewModel.liveDataSkuDetails.observeAsState()
+        val skuDetailsListsSubs = subscriptionViewModel.liveDataSkuDetails.observeAsState().value
 
         Button(
 
             onClick = {
                 Log.d("test_button", "onClick")
                 selectedPosition = getSelectedPosition()
-//                Log.d("SubscriptionViewModel", "liveData ${skuDetailsListsSubs.value}")
-                val random = Random.nextInt(999)
-//                subscriptionViewModel.setNumber(1)
-                subscriptionViewModel.mutableLiveDataNumber.postValue(random)
+                Log.d("SubscriptionViewModel", "liveData ${skuDetailsListsSubs}")
 
-                subscriptionViewModel.startConnection(selectedPosition)
+//                subscriptionViewModel.startConnection(selectedPosition)
+                if (skuDetailsListsSubs != null) {
+                    subscriptionViewModel.subscriptionProduct(
+                        selectedPosition, skuDetailsListsSubs, activity
+                    )
+                }
 
             },
             modifier = Modifier

+ 52 - 58
app/src/main/java/com/vpn/fastestvpnservice/viewmodels/SubscriptionViewModel.kt

@@ -21,6 +21,7 @@ import com.google.gson.reflect.TypeToken
 import com.vpn.fastestvpnservice.application.App
 import com.vpn.fastestvpnservice.beans.DataResponse
 import com.vpn.fastestvpnservice.beans.ProductFeatures
+import com.vpn.fastestvpnservice.customItems.getSelectedPosition
 import com.vpn.fastestvpnservice.helpers.BasePreferenceHelper
 import com.vpn.fastestvpnservice.retrofit.RetrofitNetworkHandling
 import com.vpn.fastestvpnservice.retrofit.WebServiceFactory
@@ -46,13 +47,31 @@ class SubscriptionViewModel constructor(context: Context, activity: ComponentAct
     var mutableLiveDataNumber = MutableLiveData<Int>(0)
     var liveDataNumber: LiveData<Int> = mutableLiveDataNumber
 
+    val tag = "SubscriptionViewModel"
+    val prefHelper = BasePreferenceHelper(context)
+    private var skuDetailsList: List<SkuDetails>? = null
+
+    var featuresList = MutableLiveData<MutableList<ProductFeatures>>()
+    var featuresListSorted = MutableLiveData<MutableList<ProductFeatures>>()
+
+
+    private val billingClient: BillingClient by lazy {
+        BillingClient.newBuilder(context)
+            .setListener(this)
+            .enablePendingPurchases()
+            .build()
+    }
+
     init {
         this.context = context
         this.activity = activity
         preferenceHelper = BasePreferenceHelper(context)
+
+        startConnection(getSelectedPosition())
+
     }
 
-    fun setNumber(num: Int) {
+    fun setSelectedPosition(num: Int) {
         Log.d("test_plan", "[1] num = $num")
         mutableLiveDataNumber.postValue(num)
         Log.d("test_plan", "[2] num = $num")
@@ -77,6 +96,7 @@ class SubscriptionViewModel constructor(context: Context, activity: ComponentAct
 
                         data?.data?.let {
                             preferenceHelper.saveFeaturesData(it)
+                            featuresList.value = it
                         }
                         mutableLiveDataProducts.value = data
                         mutableLiveDataProductsErrorStatus.value = false
@@ -101,22 +121,6 @@ class SubscriptionViewModel constructor(context: Context, activity: ComponentAct
         )
     }
 
-    val tag = "SubscriptionViewModel"
-    val prefHelper = BasePreferenceHelper(context)
-    private var skuDetailsList: List<SkuDetails>? = null
-
-    private val billingClient: BillingClient by lazy {
-        BillingClient.newBuilder(context)
-            .setListener(this)
-            .enablePendingPurchases()
-            .build()
-    }
-
-    init {
-        Log.d(tag, "init Billing")
-//        startConnection()
-    }
-
     fun startConnection(selectedPosition: Int) {
         this.selectedPosition = selectedPosition
         Log.d(tag, "startConnection Billing")
@@ -178,9 +182,8 @@ class SubscriptionViewModel constructor(context: Context, activity: ComponentAct
                             Log.d(tag, "[2nd] ${skuDetails.title} Billing")
                             skuDetailsListsSubs.add(skuDetails)
                         }
-                        subscriptionProduct(selectedPosition, skuDetailsListsSubs, activity)
-                        mutableLiveDataSkuDetails.value = skuDetailsListsSubs
-
+                        mutableLiveDataSkuDetails.postValue(skuDetailsListsSubs)
+//                        subscriptionProduct(selectedPosition, skuDetailsListsSubs, activity)
 
 //                        initProductList(skuDetailsListsSubs)
                     }
@@ -207,31 +210,33 @@ class SubscriptionViewModel constructor(context: Context, activity: ComponentAct
         }
     }
 
-//    private fun initProductList(skuDetailsList: List<SkuDetails>) {
-//
-//        this.skuDetailsList = skuDetailsList
-//        if (this.skuDetailsList?.size!! > 0) {
-//
-//            var boolValue: Boolean
-//            var freePeriod: String
-//            var title: String
-//            var selectFeatureListSorted = ArrayList<ProductFeatures>()
-//
-//            for ((index, value) in skuDetailsList.withIndex()){
-//                for ((indexed, values) in featuresList.withIndex()){
-//
-//                    if (value.sku == values.identifier)
-//                    {
-//                        Log.d("value of sku", "Equal => $index + $indexed")
-//                        featuresListSorted.add(featuresList.get(indexed))
-//                    }
-//                }
-//            }
-//
-//            featuresListSorted.forEachIndexed { index, productFeatures ->
-//                Log.d("featuresListSorted", "${productFeatures.title} + ${productFeatures.identifier} + ${productFeatures.price}")
-//            }
-//
+    private fun initProductList(skuDetailsList: List<SkuDetails>) {
+
+        this.skuDetailsList = skuDetailsList
+        if (this.skuDetailsList?.size!! > 0) {
+
+            var boolValue: Boolean
+            var freePeriod: String
+            var title: String
+            var selectFeatureListSorted = ArrayList<ProductFeatures>()
+
+            featuresList.value?.let {
+                for ((index, value) in skuDetailsList.withIndex()){
+                    for ((indexed, values) in it.withIndex()){
+                        if (value.sku == values.identifier)
+                        {
+                            Log.d("value_of_sku", "Equal => $index + $indexed")
+                            featuresListSorted.value?.add(it.get(indexed))
+                        }
+                    }
+                }
+            }
+
+
+            featuresListSorted.value?.forEachIndexed { index, productFeatures ->
+                Log.d("featuresListSorted", "${productFeatures.title} + ${productFeatures.identifier} + ${productFeatures.price}")
+            }
+
 //            for ((index, value) in skuDetailsList.withIndex()){
 //
 //                Log.d("value of 1", value.title + " ," + value.freeTrialPeriod + "=>" + featuresList.get(index).identifier)
@@ -264,15 +269,11 @@ class SubscriptionViewModel constructor(context: Context, activity: ComponentAct
 //            }
 //
 //            selectPriceList.forEachIndexed { index, upgradePriceList ->
-//
 //                if (upgradePriceList.isEnabled) {
 //                    selectedPosition = index
 //                }
 //            }
 //
-//            requireActivity().runOnUiThread(Runnable {
-//                if (isVisible) mainActivity.hideLoading()
-//
 //                upgradeListAdapter.data.clear()
 //                if (featuresList.size > 1)
 //                {
@@ -282,16 +283,9 @@ class SubscriptionViewModel constructor(context: Context, activity: ComponentAct
 //                {
 //                    upgradeListAdapter.setNewData(featuresListSorted.get(0).features)
 //                }
-//
-//                selectPriceListAdapter.data.clear()
-//                selectPriceListAdapter.setNewData(selectPriceList)
-//                selectPriceListAdapter.notifyDataSetChanged()
-//                mDialogBoxes?.hideProgress()
-//
-//            })
-//        }
-//    }
 
+        }
+    }
 
     override fun onPurchasesUpdated(p0: BillingResult, p1: MutableList<Purchase>?) {
     }

+ 7 - 0
build.gradle.kts

@@ -1,3 +1,10 @@
+buildscript {
+    dependencies {
+        classpath("com.android.tools.build:gradle:8.1.0")
+        classpath("com.google.gms:google-services:4.4.1")
+        classpath("com.google.firebase:firebase-crashlytics-gradle:2.9.9")
+    }
+}
 // Top-level build file where you can add configuration options common to all sub-projects/modules.
 
 //buildString {