131-STABLE-super-server

This commit is contained in:
sathwikcs
2025-03-13 15:23:15 +05:30
parent 6c89efeb5e
commit 7ad21ea5a9
2 changed files with 34 additions and 9 deletions

View File

@@ -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"

View File

@@ -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<FirebaseConfig> {
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"
)