Compare commits
9 Commits
dev-server
...
dev-server
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e3435f2182 | ||
|
|
f6cdd64ef6 | ||
|
|
7ad21ea5a9 | ||
|
|
6c89efeb5e | ||
|
|
63eaf1cadc | ||
|
|
c180f7be31 | ||
|
|
c243ec6c8f | ||
|
|
7c9238591b | ||
|
|
5c843ca232 |
@@ -21,7 +21,7 @@ android {
|
|||||||
minSdk 30
|
minSdk 30
|
||||||
targetSdk 34
|
targetSdk 34
|
||||||
versionCode 134
|
versionCode 134
|
||||||
versionName "2.1.132"
|
versionName "2.1.131"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 = false
|
var MOLBIO_INTEGRATION = true
|
||||||
const val FIREBASE_INTEGRATION = true
|
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"
|
||||||
|
|||||||
@@ -243,9 +243,10 @@ object AppModule {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun provideNetworkMonitor(@ApplicationContext context: Context): NetworkMonitor {
|
fun provideNetworkMonitor(
|
||||||
return NetworkMonitor(context)
|
@ApplicationContext context: Context
|
||||||
|
): NetworkMonitor {
|
||||||
|
return NetworkMonitor(context).apply { startMonitoring() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -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) {
|
||||||
saveSelectedServer(firebaseConfig)
|
if (firebaseConfig.serverName =="molbio" ||firebaseConfig.apiKey == "molbio"){
|
||||||
val firebaseApp = getOrInitializeFirebaseApp(firebaseConfig)
|
saveSelectedServer(firebaseConfig)
|
||||||
currentFirestore = FirebaseFirestore.getInstance(firebaseApp)
|
makeMolbioAsBackEnd()
|
||||||
currentStorage = FirebaseStorage.getInstance(firebaseApp)
|
}else {
|
||||||
updateStatus = true
|
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 }
|
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"
|
||||||
|
)
|
||||||
@@ -1,16 +1,21 @@
|
|||||||
package com.example.hpostesting.presentation.main_base
|
package com.example.hpostesting.presentation.main_base
|
||||||
|
|
||||||
|
import com.example.hpostesting.data.constant.Constants.FIREBASE_INTEGRATION
|
||||||
|
import com.example.hpostesting.data.constant.Constants.MOLBIO_INTEGRATION
|
||||||
|
|
||||||
class AppVersionTapManager {
|
class AppVersionTapManager {
|
||||||
|
|
||||||
private var tapCount = 0
|
private var tapCount = 0
|
||||||
private val maxTapCount = 5
|
private val maxTapCount = 5
|
||||||
|
val shouldEnable = FIREBASE_INTEGRATION && !MOLBIO_INTEGRATION
|
||||||
|
val notEnable = MOLBIO_INTEGRATION && !FIREBASE_INTEGRATION
|
||||||
|
|
||||||
fun registerTap(onMaxTapsReached: () -> Unit) {
|
fun registerTap(onMaxTapsReached: () -> Unit) {
|
||||||
tapCount++
|
tapCount++
|
||||||
if (tapCount >= maxTapCount) {
|
if (tapCount >= maxTapCount && shouldEnable) {
|
||||||
onMaxTapsReached()
|
onMaxTapsReached()
|
||||||
reset()
|
reset()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private fun reset() {
|
private fun reset() {
|
||||||
tapCount = 0
|
tapCount = 0
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import androidx.fragment.app.Fragment
|
|||||||
import androidx.preference.ListPreference
|
import androidx.preference.ListPreference
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
import androidx.preference.PreferenceManager
|
|
||||||
import androidx.preference.SwitchPreferenceCompat
|
import androidx.preference.SwitchPreferenceCompat
|
||||||
import com.example.hpostesting.data.constant.Constants
|
import com.example.hpostesting.data.constant.Constants
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
@@ -201,7 +200,6 @@ class PrefsFragment : PreferenceFragmentCompat() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
val appVersionPreference = Preference(requireContext()).apply {
|
val appVersionPreference = Preference(requireContext()).apply {
|
||||||
title = "App Version"
|
title = "App Version"
|
||||||
summary =
|
summary =
|
||||||
@@ -212,11 +210,10 @@ class PrefsFragment : PreferenceFragmentCompat() {
|
|||||||
tapManager.registerTap {
|
tapManager.registerTap {
|
||||||
firebaseManager.setDevModeOn(true)
|
firebaseManager.setDevModeOn(true)
|
||||||
|
|
||||||
val devConfig = servers.find { it.serverName == "dev" }
|
|
||||||
if (firebaseManager.getDevMode() && currentServer != "dev") {
|
if (firebaseManager.getDevMode() && currentServer != "dev") {
|
||||||
Toast.makeText(requireContext(), "Now you are a Developer", Toast.LENGTH_SHORT).show()
|
Toast.makeText(requireContext(), "Now you are a Developer", Toast.LENGTH_SHORT).show()
|
||||||
Toast.makeText(requireContext(), "Setting Up developer Environmnet", Toast.LENGTH_SHORT).show()
|
Toast.makeText(requireContext(), "Setting Up developer Environmnet", Toast.LENGTH_SHORT).show()
|
||||||
switchFirebaseServer(devConfig!!)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preferenceScreen.findPreference<SwitchPreferenceCompat>("developer_options") == null) {
|
if (preferenceScreen.findPreference<SwitchPreferenceCompat>("developer_options") == null) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.example.hpostesting.util
|
package com.example.hpostesting.util
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.net.ConnectivityManager
|
import android.net.ConnectivityManager
|
||||||
import android.net.Network
|
import android.net.Network
|
||||||
@@ -12,6 +13,8 @@ import kotlinx.coroutines.CoroutineScope
|
|||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.SupervisorJob
|
import kotlinx.coroutines.SupervisorJob
|
||||||
import kotlinx.coroutines.cancel
|
import kotlinx.coroutines.cancel
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
|
import kotlinx.coroutines.isActive
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.net.HttpURLConnection
|
import java.net.HttpURLConnection
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
@@ -23,7 +26,7 @@ import javax.inject.Singleton
|
|||||||
class NetworkMonitor @Inject constructor(
|
class NetworkMonitor @Inject constructor(
|
||||||
@ApplicationContext private val context: Context
|
@ApplicationContext private val context: Context
|
||||||
) {
|
) {
|
||||||
|
private var isMonitoringStarted = false
|
||||||
private val connectivityManager =
|
private val connectivityManager =
|
||||||
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||||
|
|
||||||
@@ -49,7 +52,10 @@ class NetworkMonitor @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("NewApi")
|
||||||
fun startMonitoring() {
|
fun startMonitoring() {
|
||||||
|
if (isMonitoringStarted) return // Already started, do nothing.
|
||||||
|
isMonitoringStarted = true
|
||||||
// Check initial connectivity status
|
// Check initial connectivity status
|
||||||
val network = connectivityManager.activeNetwork
|
val network = connectivityManager.activeNetwork
|
||||||
val capabilities = connectivityManager.getNetworkCapabilities(network)
|
val capabilities = connectivityManager.getNetworkCapabilities(network)
|
||||||
@@ -66,6 +72,8 @@ class NetworkMonitor @Inject constructor(
|
|||||||
.build()
|
.build()
|
||||||
|
|
||||||
connectivityManager.registerNetworkCallback(networkRequest, networkCallback)
|
connectivityManager.registerNetworkCallback(networkRequest, networkCallback)
|
||||||
|
// Start periodic checks:
|
||||||
|
startPeriodicPingCheck()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stopMonitoring() { // never needed to call
|
fun stopMonitoring() { // never needed to call
|
||||||
@@ -96,4 +104,14 @@ class NetworkMonitor @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun startPeriodicPingCheck(intervalMillis: Long = 1 * 60_000L) {
|
||||||
|
networkScope.launch {
|
||||||
|
while (isActive) {
|
||||||
|
performPingCheck()
|
||||||
|
delay(intervalMillis)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -25,6 +25,7 @@
|
|||||||
<item>ka</item>
|
<item>ka</item>
|
||||||
<!-- Use language codes (e.g., en, kn) as values -->
|
<!-- Use language codes (e.g., en, kn) as values -->
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="district">
|
<string-array name="district">
|
||||||
<item>Mysuru</item>
|
<item>Mysuru</item>
|
||||||
<item>Kodagu</item>
|
<item>Kodagu</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user