From 7ad21ea5a9f3fcb340ff656617c4b67ac5b85b6e Mon Sep 17 00:00:00 2001 From: sathwikcs <85106054+sathwikcs@users.noreply.github.com> Date: Thu, 13 Mar 2025 15:23:15 +0530 Subject: [PATCH] 131-STABLE-super-server --- .../hpostesting/data/constant/Constants.kt | 4 +- .../hpostesting/firebase/FirebaseManage.kt | 39 +++++++++++++++---- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/example/hpostesting/data/constant/Constants.kt b/app/src/main/java/com/example/hpostesting/data/constant/Constants.kt index f666779..39c356d 100644 --- a/app/src/main/java/com/example/hpostesting/data/constant/Constants.kt +++ b/app/src/main/java/com/example/hpostesting/data/constant/Constants.kt @@ -28,8 +28,8 @@ object Constants { const val DOCUMENT_ID_FOR_UPDATE ="2o71vBKLqdgEKYtFG8Lb" const val ABHA_APP_PACKAGE = "in.ndhm.phr" - const val MOLBIO_INTEGRATION = true - const val FIREBASE_INTEGRATION = false + var MOLBIO_INTEGRATION = true + var FIREBASE_INTEGRATION = false const val deviceProvisionEmail = "HPOS_provisioner@bigtec.co.in" const val deviceProvisionPassword = "f2ab0e7f9d69" const val DEVICE_ID_API = "deviceIDAPI" diff --git a/app/src/main/java/com/example/hpostesting/firebase/FirebaseManage.kt b/app/src/main/java/com/example/hpostesting/firebase/FirebaseManage.kt index 54875d4..2826691 100644 --- a/app/src/main/java/com/example/hpostesting/firebase/FirebaseManage.kt +++ b/app/src/main/java/com/example/hpostesting/firebase/FirebaseManage.kt @@ -15,6 +15,7 @@ import android.content.Context import android.content.Intent import android.os.Process import androidx.core.content.edit +import com.example.hpostesting.data.constant.Constants import com.google.firebase.FirebaseApp import com.google.firebase.FirebaseOptions import com.google.firebase.firestore.FirebaseFirestore @@ -37,7 +38,8 @@ class FirebaseManager @Inject constructor(private val context: Context) { private val defaultServers = listOf( // i have it in different place look down - firebaseConfigProd, firebaseConfigDev , firebaseConfigQaQc, firebaseConfigPreProd + firebaseConfigProd, firebaseConfigDev , firebaseConfigQaQc, firebaseConfigPreProd, + configMolbio //not a firebase config ) init { @@ -61,11 +63,17 @@ class FirebaseManager @Inject constructor(private val context: Context) { fun getCurrentStorage(): FirebaseStorage = currentStorage fun switchServer(firebaseConfig: FirebaseConfig) { - saveSelectedServer(firebaseConfig) - val firebaseApp = getOrInitializeFirebaseApp(firebaseConfig) - currentFirestore = FirebaseFirestore.getInstance(firebaseApp) - currentStorage = FirebaseStorage.getInstance(firebaseApp) - updateStatus = true + if (firebaseConfig.serverName =="molbio" ||firebaseConfig.apiKey == "molbio"){ + saveSelectedServer(firebaseConfig) + makeMolbioAsBackEnd() + }else { + makeSMIBackEnd() + saveSelectedServer(firebaseConfig) + val firebaseApp = getOrInitializeFirebaseApp(firebaseConfig) + currentFirestore = FirebaseFirestore.getInstance(firebaseApp) + currentStorage = FirebaseStorage.getInstance(firebaseApp) + updateStatus = true + } } @@ -73,7 +81,6 @@ class FirebaseManager @Inject constructor(private val context: Context) { val existingApp = FirebaseApp.getApps(context).find { it.name == firebaseConfig.serverName } return if (existingApp != null) { - existingApp } else { @@ -125,6 +132,16 @@ class FirebaseManager @Inject constructor(private val context: Context) { fun getAvailableServers(): List { return defaultServers } + + private fun makeMolbioAsBackEnd(){ + Constants.FIREBASE_INTEGRATION = false + Constants.MOLBIO_INTEGRATION = true + restartApp() + } + private fun makeSMIBackEnd(){ + Constants.FIREBASE_INTEGRATION = true + Constants.MOLBIO_INTEGRATION = false + } } fun restartApp(context: Context) { @@ -172,3 +189,11 @@ private val firebaseConfigPreProd = FirebaseConfig( projectId = "hpos-preprod", storageBucket = "hpos-preprod.appspot.com" ) + +private val configMolbio = FirebaseConfig( + serverName = "molbio", + apiKey = "molbio", + appId = "molbio", + projectId = "molbio", + storageBucket = "molbio" +) \ No newline at end of file