mirror of
https://github.com/cheveguerra/FLP_2.0.git
synced 2026-04-17 19:36:42 +00:00
- Se paso la logica y restricciones de Tracker.FLP_LocationChanged a Subs.mandaLoc2.
- Se puso que con cualquier notificacion revise si puede mandar la ubicacion. - Se puso que cuando se solicite la ubicacion con FirebaseMessaging, se mande tambien a PUSH_INFO.
This commit is contained in:
63
Tracker.bas
63
Tracker.bas
@@ -40,7 +40,7 @@ Sub Process_Globals
|
||||
Private flpStarted As Boolean
|
||||
Dim minAccuracy As Int = 50
|
||||
Dim killerCalled As Int = 0
|
||||
Dim locReqSmall As LocationRequest
|
||||
Dim locReqSmall, locReqNormal As LocationRequest
|
||||
End Sub
|
||||
|
||||
Sub Service_Create
|
||||
@@ -50,12 +50,13 @@ Sub Service_Create
|
||||
flp.Connect
|
||||
lock.PartialLock
|
||||
StartFLP
|
||||
If Starter.logger Then Log("FLP initialized")
|
||||
' If Starter.logger Then Log("FLP initialized")
|
||||
Subs.bitacora($"Iniciamos Tracker"$)
|
||||
End Sub
|
||||
|
||||
Sub Service_Start (StartingIntent As Intent)
|
||||
locReqSmall = CreateLocationRequest2(1000, 0) 'ignore
|
||||
locReqNormal = CreateLocationRequest2(30000, 30) 'ignore
|
||||
Service.StopAutomaticForeground
|
||||
Service.StartForeground(nid, Subs.CreateNotification("..."))
|
||||
Track
|
||||
@@ -81,7 +82,7 @@ Sub flpReConnect
|
||||
End Sub
|
||||
|
||||
Sub flp_ConnectionSuccess
|
||||
If Starter.logger Then Log("FLP - Connected to location provider")
|
||||
' If Starter.logger Then Log("FLP - Connected to location provider")
|
||||
Subs.bitacora("FLP - Connection Success")
|
||||
End Sub
|
||||
|
||||
@@ -106,7 +107,7 @@ Public Sub StartFLP
|
||||
Private cont As Int = 0
|
||||
Do While flp.IsConnected = False
|
||||
Sleep(500)
|
||||
If Starter.logger Then Log($"FLP Sleeping - ${cont}"$)
|
||||
' If Starter.logger Then Log($"FLP Sleeping - ${cont}"$)
|
||||
Subs.bitacora($"Sleeping - ${cont}"$)
|
||||
cont = cont + 1
|
||||
If cont > 70 Then
|
||||
@@ -151,31 +152,37 @@ Public Sub StopFLP
|
||||
End Sub
|
||||
|
||||
Sub flp_LocationChanged (Location1 As Location)
|
||||
If Starter.logger Then LogColor($"Location Changed - Acc: ${Location1.Accuracy}"$, Colors.blue)
|
||||
Private minsTranscurridos As String = Subs.ticksAMins(DateTime.Now - Subs.traeUltimaUbicacionGuardada.Time) 'Minutos transcurridos desde la ultima ubicacion guardada.
|
||||
If Starter.logger Then LogColor(">>>>>>>>>>>>>>>>>>>>>>> " & minsTranscurridos, Colors.red)
|
||||
If Not(IsPaused(Main)) Then
|
||||
Main.laUbicacion = Location1
|
||||
If Starter.logger Then Log("Main.laubicacion actializada")
|
||||
End If
|
||||
Dim el_texto As String = ""
|
||||
Starter.UUC = Location1
|
||||
If Starter.logger Then LogColor("FLP_LocationChanged", Colors.Red)
|
||||
If Starter.logger Then Log(Location1.Accuracy&" - "&Location1.AccuracyValid)
|
||||
If minsTranscurridos > 1 Then ' Para que no mande mensajes constantes, minimo 1 minuto entre mensajes.
|
||||
flp.RequestLocationUpdates(CreateLocationRequest)
|
||||
'Solo mandamos la ubicacion si la precision es dentro de XX mts
|
||||
el_texto = $"LocChange - Coords NO enviadas (Acc:${Location1.Accuracy})."$
|
||||
If Location1.Accuracy < minAccuracy Then
|
||||
Subs.mandaLoc2(Location1, Starter.devModel)
|
||||
el_texto = $"LocChange - Coords enviadas (Acc:${Location1.Accuracy})."$
|
||||
End If
|
||||
' If Starter.logger Then Log("Loc changed : "&Location1.Latitude&","&Location1.Longitude&"|"&Starter.devModel&"|")
|
||||
Subs.bitacora($"${el_texto}"$)
|
||||
' ToastMessageShow("LocChanged MORE than a min.", False)
|
||||
Else
|
||||
' ToastMessageShow("Locatin changed but less than a min!.", False)
|
||||
End If
|
||||
' If Starter.logger Then LogColor("FLP_LocationChanged", Colors.Red)
|
||||
If Starter.logger Then LogColor($"FLP_LocationChanged - Acc: ${Location1.Accuracy}"$, Colors.Red)
|
||||
Private vel As String = (Location1.Speed * 60 * 60) / 1000 ' Kms x hora de ultima ubicacion.
|
||||
' If Starter.logger Then Log((Location1.time & " - " & Starter.locAntTime))
|
||||
If Starter.logger Then Log(((Location1.time - Subs.traeVar("locAntTime", 0)) / 1000) & " segs")
|
||||
' Private minsTranscurridosLoc As String = Subs.ticksAMins(Location1.time - Starter.locAntTime) 'Minutos transcurridos desde la ultima ubicacion ACTUALIZADA.
|
||||
' Private minsTranscurridos As String = Subs.ticksAMins(DateTime.Now - Subs.traeUltimaUbicacionGuardada.Time) 'Minutos transcurridos desde la ultima ubicacion guardada.
|
||||
' If Starter.logger Then LogColor(">>>>>>>> Guardada: " & minsTranscurridos & " mins., Actualizada: " & minsTranscurridosLoc & " mins.", Colors.red)
|
||||
' If Not(IsPaused(Main)) Then
|
||||
' Main.laUbicacion = Location1 ' Actualizamos la etiqueta de ubicacion en la pantalla principal.
|
||||
' If Starter.logger Then Log("Main.laubicacion actializada")
|
||||
' End If
|
||||
' Dim el_texto As String = ""
|
||||
' If Starter.logger Then Log(Location1.Accuracy&" - "&Starter.UUC.AccuracyValid)
|
||||
' If minsTranscurridosLoc > 1 Or minsTranscurridos >= 15 Then ' Para que no mande mensajes constantes, minimo 1 minuto entre mensajes.
|
||||
' flp.RequestLocationUpdates(CreateLocationRequest)
|
||||
' 'Solo mandamos la ubicacion si la precision es dentro de XX mts
|
||||
' el_texto = $"LocChange - Coords NO enviadas (Acc:${Location1.Accuracy})."$
|
||||
' If Location1.Accuracy < minAccuracy Then
|
||||
' If Starter.logger Then LogColor("Guardamos y enviamos ubicacion.", Colors.green)
|
||||
Subs.mandaLoc2(Location1, Starter.devModel)
|
||||
' el_texto = $"LocChange - Coords enviadas (Acc:${Location1.Accuracy})."$
|
||||
' End If
|
||||
' ' If Starter.logger Then Log("Loc changed : "&Location1.Latitude&","&Location1.Longitude&"|"&Starter.devModel&"|")
|
||||
' Subs.bitacora($"${el_texto}"$)
|
||||
'' ToastMessageShow("LocChanged MORE than a min.", False)
|
||||
' Else
|
||||
'' ToastMessageShow("Locatin changed but less than a min!.", False)
|
||||
' End If
|
||||
' Subs.actualizaVar("locAntTime", Location1.time)
|
||||
End Sub
|
||||
|
||||
Sub flp_ConnectionSuspended(SuspendedCause1 As Int)
|
||||
|
||||
Reference in New Issue
Block a user