Skip to content

Colota - Android GPS Location tracker

Merge branch 'feat/automatic-screenshot-generation' of https://github.com/dietrichmax/colota into feature/tracking-profiles

Max Dietrich1e3278703d5b
diff --cc apps/mobile/android/app/src/main/java/com/colota/bridge/LocationServiceModule.kt
index b89a537f,43d33f1f..af32b3fa
--- a/apps/mobile/android/app/src/main/java/com/colota/bridge/LocationServiceModule.kt
+++ b/apps/mobile/android/app/src/main/java/com/colota/bridge/LocationServiceModule.kt
@@@ -139,30 -133,28 +139,52 @@@ class LocationServiceModule(reactContex
}
}
+ /** Emits profile switch events to JS when a tracking profile activates/deactivates. */
+ @JvmStatic
+ fun sendProfileSwitchEvent(profileName: String?, profileId: Int?): Boolean {
+ val context = reactContextRef.get() ?: return false
+ if (!context.hasActiveCatalystInstance()) return false
+
+ return try {
+ val params = Arguments.createMap().apply {
+ if (profileName != null) putString("profileName", profileName)
+ else putNull("profileName")
+ if (profileId != null) putInt("profileId", profileId)
+ else putNull("profileId")
+ putBoolean("isDefault", profileName == null)
+ }
+ context
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
+ .emit("onProfileSwitch", params)
+ true
+ } catch (e: Exception) {
+ Log.e(TAG, "Failed to send profile switch event", e)
+ false
+ }
+ }
+
+ /** Emits sync progress during manual flush so JS can show "5/127 synced". */
+ @JvmStatic
+ fun sendSyncProgressEvent(sent: Int, failed: Int, total: Int): Boolean {
+ val context = reactContextRef.get() ?: return false
+ if (!context.hasActiveCatalystInstance()) return false
+
+ return try {
+ val params = Arguments.createMap().apply {
+ putInt("sent", sent)
+ putInt("failed", failed)
+ putInt("total", total)
+ }
+ context
+ .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)
+ .emit("onSyncProgress", params)
+ true
+ } catch (e: Exception) {
+ Log.e(TAG, "Failed to send sync progress event", e)
+ false
+ }
+ }
+
/** Emits pause zone entry/exit events for the JS geofence UI. */
@JvmStatic
fun sendPauseZoneEvent(entered: Boolean, zoneName: String?): Boolean {