131-STABLE-super-server
This commit is contained in:
@@ -28,8 +28,8 @@ object Constants {
|
|||||||
const val DOCUMENT_ID_FOR_UPDATE ="2o71vBKLqdgEKYtFG8Lb"
|
const val DOCUMENT_ID_FOR_UPDATE ="2o71vBKLqdgEKYtFG8Lb"
|
||||||
const val ABHA_APP_PACKAGE = "in.ndhm.phr"
|
const val ABHA_APP_PACKAGE = "in.ndhm.phr"
|
||||||
|
|
||||||
const val MOLBIO_INTEGRATION = true
|
var MOLBIO_INTEGRATION = true
|
||||||
const val FIREBASE_INTEGRATION = false
|
var FIREBASE_INTEGRATION = false
|
||||||
const val deviceProvisionEmail = "HPOS_provisioner@bigtec.co.in"
|
const val deviceProvisionEmail = "HPOS_provisioner@bigtec.co.in"
|
||||||
const val deviceProvisionPassword = "f2ab0e7f9d69"
|
const val deviceProvisionPassword = "f2ab0e7f9d69"
|
||||||
const val DEVICE_ID_API = "deviceIDAPI"
|
const val DEVICE_ID_API = "deviceIDAPI"
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Process
|
import android.os.Process
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.google.firebase.FirebaseApp
|
import com.google.firebase.FirebaseApp
|
||||||
import com.google.firebase.FirebaseOptions
|
import com.google.firebase.FirebaseOptions
|
||||||
import com.google.firebase.firestore.FirebaseFirestore
|
import com.google.firebase.firestore.FirebaseFirestore
|
||||||
@@ -37,7 +38,8 @@ class FirebaseManager @Inject constructor(private val context: Context) {
|
|||||||
|
|
||||||
private val defaultServers = listOf(
|
private val defaultServers = listOf(
|
||||||
// i have it in different place look down
|
// i have it in different place look down
|
||||||
firebaseConfigProd, firebaseConfigDev , firebaseConfigQaQc, firebaseConfigPreProd
|
firebaseConfigProd, firebaseConfigDev , firebaseConfigQaQc, firebaseConfigPreProd,
|
||||||
|
configMolbio //not a firebase config
|
||||||
)
|
)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
@@ -61,11 +63,17 @@ class FirebaseManager @Inject constructor(private val context: Context) {
|
|||||||
fun getCurrentStorage(): FirebaseStorage = currentStorage
|
fun getCurrentStorage(): FirebaseStorage = currentStorage
|
||||||
|
|
||||||
fun switchServer(firebaseConfig: FirebaseConfig) {
|
fun switchServer(firebaseConfig: FirebaseConfig) {
|
||||||
|
if (firebaseConfig.serverName =="molbio" ||firebaseConfig.apiKey == "molbio"){
|
||||||
|
saveSelectedServer(firebaseConfig)
|
||||||
|
makeMolbioAsBackEnd()
|
||||||
|
}else {
|
||||||
|
makeSMIBackEnd()
|
||||||
saveSelectedServer(firebaseConfig)
|
saveSelectedServer(firebaseConfig)
|
||||||
val firebaseApp = getOrInitializeFirebaseApp(firebaseConfig)
|
val firebaseApp = getOrInitializeFirebaseApp(firebaseConfig)
|
||||||
currentFirestore = FirebaseFirestore.getInstance(firebaseApp)
|
currentFirestore = FirebaseFirestore.getInstance(firebaseApp)
|
||||||
currentStorage = FirebaseStorage.getInstance(firebaseApp)
|
currentStorage = FirebaseStorage.getInstance(firebaseApp)
|
||||||
updateStatus = true
|
updateStatus = true
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +81,6 @@ class FirebaseManager @Inject constructor(private val context: Context) {
|
|||||||
val existingApp = FirebaseApp.getApps(context).find { it.name == firebaseConfig.serverName }
|
val existingApp = FirebaseApp.getApps(context).find { it.name == firebaseConfig.serverName }
|
||||||
|
|
||||||
return if (existingApp != null) {
|
return if (existingApp != null) {
|
||||||
|
|
||||||
existingApp
|
existingApp
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@@ -125,6 +132,16 @@ class FirebaseManager @Inject constructor(private val context: Context) {
|
|||||||
fun getAvailableServers(): List<FirebaseConfig> {
|
fun getAvailableServers(): List<FirebaseConfig> {
|
||||||
return defaultServers
|
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) {
|
fun restartApp(context: Context) {
|
||||||
@@ -172,3 +189,11 @@ private val firebaseConfigPreProd = FirebaseConfig(
|
|||||||
projectId = "hpos-preprod",
|
projectId = "hpos-preprod",
|
||||||
storageBucket = "hpos-preprod.appspot.com"
|
storageBucket = "hpos-preprod.appspot.com"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private val configMolbio = FirebaseConfig(
|
||||||
|
serverName = "molbio",
|
||||||
|
apiKey = "molbio",
|
||||||
|
appId = "molbio",
|
||||||
|
projectId = "molbio",
|
||||||
|
storageBucket = "molbio"
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user