Compare commits
7 Commits
dev-server
...
smi131
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2a4233923 | ||
|
|
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"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,18 @@
|
|||||||
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()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ import androidx.preference.PreferenceFragmentCompat
|
|||||||
import androidx.preference.PreferenceManager
|
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.Constants.FIREBASE_INTEGRATION
|
||||||
|
import com.example.hpostesting.data.constant.Constants.MOLBIO_INTEGRATION
|
||||||
import com.example.hpostesting.data.constant.DataHolder
|
import com.example.hpostesting.data.constant.DataHolder
|
||||||
import com.example.hpostesting.data.constant.LanguageManager
|
import com.example.hpostesting.data.constant.LanguageManager
|
||||||
import com.example.hpostesting.data.repository.DatabaseRepository
|
import com.example.hpostesting.data.repository.DatabaseRepository
|
||||||
@@ -201,11 +203,11 @@ class PrefsFragment : PreferenceFragmentCompat() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val shouldEnableCurrentServerVersion = FIREBASE_INTEGRATION && !MOLBIO_INTEGRATION
|
||||||
val appVersionPreference = Preference(requireContext()).apply {
|
val appVersionPreference = Preference(requireContext()).apply {
|
||||||
title = "App Version"
|
title = "App Version"
|
||||||
summary =
|
summary =
|
||||||
getAppVersion(requireContext()) + " [ " + getAppEnvironment(requireContext()) + "->" + currentServer + "]"
|
getAppVersion(requireContext()) + " [ " + getAppEnvironment(requireContext()) + "->" + if (shouldEnableCurrentServerVersion) currentServer else "molbio"+ "]"
|
||||||
icon = ContextCompat.getDrawable(requireContext(), R.drawable.baseline_info_24)
|
icon = ContextCompat.getDrawable(requireContext(), R.drawable.baseline_info_24)
|
||||||
|
|
||||||
setOnPreferenceClickListener {
|
setOnPreferenceClickListener {
|
||||||
|
|||||||
@@ -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