09/09/23 - Panel de configuración y servicio al arranque

Se agregó´un panel para cambiar algunos parametros de la aplicación y se agregó´un servicio para que el monitor arranque junto con el dispositivo, para esto es necesario darle permisos para accesar las notificaciones del sistema.
This commit is contained in:
2023-09-10 00:28:33 -06:00
parent afe26d8653
commit d342c85e15
11 changed files with 744 additions and 432 deletions

View File

@@ -2,7 +2,7 @@
Group=Default Group
ModulesStructureVersion=1
Type=Service
Version=10.2
Version=11
@EndOfDesignText@
#Region Service Attributes
#StartAtBoot: True
@@ -142,7 +142,7 @@ End Sub
Sub dameUltimaUbicacionConocida
If FLP.GetLastKnownLocation.IsInitialized Then 'Mandamos ultima ubicacion guardada
' If Main.logger Then Log("Mandamos UUC : "&formatoFecha(FLP.GetLastKnownLocation.Time))
If Starter.Logger Then LogColor($"Mandamos UUC "${Subs.fechaKMT(FLP.GetLastKnownLocation.Time)}|Acc:$0.2{FLP.GetLastKnownLocation.Accuracy}|$0.8{FLP.GetLastKnownLocation.Latitude}|$0.8{FLP.GetLastKnownLocation.Longitude}|Spd:$0.2{FLP.GetLastKnownLocation.Speed}|"$, Colors.RGB(255,112,35))
' If Starter.Logger Then LogColor($"Mandamos UUC "${Subs.fechaKMT(FLP.GetLastKnownLocation.Time)}|Acc:$0.2{FLP.GetLastKnownLocation.Accuracy}|$0.8{FLP.GetLastKnownLocation.Latitude}|$0.8{FLP.GetLastKnownLocation.Longitude}|Spd:$0.2{FLP.GetLastKnownLocation.Speed}|"$, Colors.RGB(255,112,35))
Dim coords As String = FLP.GetLastKnownLocation.Latitude&","&FLP.GetLastKnownLocation.Longitude&","&formatoFecha(FLP.GetLastKnownLocation.Time)
' CallSubDelayed2(FirebaseMessaging,"mandamosLoc",coords)
' Subs.mandamosLoc(coords)
@@ -160,8 +160,8 @@ End Sub
Sub flp_LocationChanged (Location1 As Location)
' ToastMessageShow("Loc changed", False)
' Log($"Loc changed:${Location1.Longitude},${Location1.Latitude}"$)
B4XPages.MainPage.lat_gps = Location1.Latitude
B4XPages.MainPage.lon_gps = Location1.Longitude
' B4XPages.MainPage.lat_gps = Location1.Latitude
' B4XPages.MainPage.lon_gps = Location1.Longitude
UUGCoords = Location1
' Log("SmallestDisplacement="&actualLR.GetSmallestDisplacement)
' If DateTime.Now > LastUpdateTime + 10 * DateTime.TicksPerSecond Then
@@ -174,13 +174,13 @@ Sub flp_LocationChanged (Location1 As Location)
DateTime.DateFormat = "MM/dd/yyyy"
sDate=DateTime.Date(DateTime.Now)
sTime=DateTime.Time(DateTime.Now)
If Not(B4XPages.MainPage.skmt.IsInitialized) Then B4XPages.MainPage.skmt.Initialize(Starter.ruta,"kmt.db", True)
Try
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO HIST_GPS (HGDATE, HGLAT, HGLON) VALUES(?,?,?) ", Array As Object (sDate & sTime, B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps))
B4XPages.MainPage.skmt.ExecNonQuery("DELETE FROM HIST_GPS")
Catch
LogColor(LastException, Colors.Red)
End Try
' If Not(B4XPages.MainPage.skmt.IsInitialized) Then B4XPages.MainPage.skmt.Initialize(Starter.ruta,"kmt.db", True)
' Try
' B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO HIST_GPS (HGDATE, HGLAT, HGLON) VALUES(?,?,?) ", Array As Object (sDate & sTime, B4XPages.MainPage.lat_gps, B4XPages.MainPage.lon_gps))
' B4XPages.MainPage.skmt.ExecNonQuery("DELETE FROM HIST_GPS")
' Catch
' LogColor(LastException, Colors.Red)
' End Try
'///////
Dim coords As String = Location1.Latitude&","&Location1.Longitude&","&formatoFecha(Location1.Time)
' Log("Loc changed : "&Location1.Latitude&","&Location1.Longitude&"|"&B4XPages.MainPage.usuario&"|")
@@ -225,46 +225,46 @@ End Sub
'Revisamos que el FLP (FusedLocationProvider) este inicializado y activo
Sub revisaFLP 'ignore
LogColor("**** **** Revisamos FLP **** ****", Colors.RGB(78,0,227))
Private todoBienFLP As Boolean = True
Try
If Not(FLP.IsInitialized) Then
Subs.log2DB("revisaFLP: No esta inicializado ... 'Reinicializando FLP'")
FLP.Initialize("flp")
todoBienFLP = False
End If
Catch
LogColor("If Not(Tracker.FLP.IsInitialized) --> "&LastException, Colors.Red)
End Try
Try
If FLP.IsInitialized Then
Try
If Not(FLP.IsConnected) Then
Subs.log2DB("revisaFLP: No esta conectado ... 'Reconectando FLP'")
' Tracker.FLP.Connect
StartFLP
todoBienFLP = False
End If
Catch
LogColor("If Not(Tracker.FLP.IsConnected) --> "&LastException, Colors.Red)
End Try
Try
If FLP.IsConnected And _
FLP.GetLastKnownLocation.IsInitialized And _
FLP.GetLastKnownLocation.DistanceTo(UUGCoords) > 500 Then
Subs.log2DB("revisaFLP: 'No se esta actualizando, lo reiniciamos ...'")
StartService(Me)
todoBienFLP = False
End If
Catch
LogColor("If FLP.IsConnectctd and FLP.getLKL.IsInitialized --> "&LastException, Colors.Red)
End Try
End If
If todoBienFLP Then LogColor(" +++ +++ Sin errores en FLP", Colors.Green)
Catch
LogColor("If Tracker.FLP.IsInitialized --> "&LastException, Colors.Red)
End Try
' revisar hora de lastKnownlocation y si es mayor de 10 minutos llamar StartFLP
' LogColor("**** **** Revisamos FLP **** ****", Colors.RGB(78,0,227))
' Private todoBienFLP As Boolean = True
' Try
' If Not(FLP.IsInitialized) Then
'' Subs.log2DB("revisaFLP: No esta inicializado ... 'Reinicializando FLP'")
' FLP.Initialize("flp")
' todoBienFLP = False
' End If
' Catch
' LogColor("If Not(Tracker.FLP.IsInitialized) --> "&LastException, Colors.Red)
' End Try
' Try
' If FLP.IsInitialized Then
' Try
' If Not(FLP.IsConnected) Then
'' Subs.log2DB("revisaFLP: No esta conectado ... 'Reconectando FLP'")
' ' Tracker.FLP.Connect
' StartFLP
' todoBienFLP = False
' End If
' Catch
' LogColor("If Not(Tracker.FLP.IsConnected) --> "&LastException, Colors.Red)
' End Try
' Try
' If FLP.IsConnected And _
' FLP.GetLastKnownLocation.IsInitialized And _
' FLP.GetLastKnownLocation.DistanceTo(UUGCoords) > 500 Then
'' Subs.log2DB("revisaFLP: 'No se esta actualizando, lo reiniciamos ...'")
' StartService(Me)
' todoBienFLP = False
' End If
' Catch
' LogColor("If FLP.IsConnectctd and FLP.getLKL.IsInitialized --> "&LastException, Colors.Red)
' End Try
' End If
' If todoBienFLP Then LogColor(" +++ +++ Sin errores en FLP", Colors.Green)
' Catch
' LogColor("If Tracker.FLP.IsInitialized --> "&LastException, Colors.Red)
' End Try
' ' revisar hora de lastKnownlocation y si es mayor de 10 minutos llamar StartFLP
End Sub
'Compara la UUG (Ultima Ubicacion Guardada) con FLP.LastKnowLocation y si
@@ -277,11 +277,11 @@ Sub revisaUUG 'ignore
If FLP.GetLastKnownLocation.IsInitialized Then
' Dim x As Location = FLP.GetLastKnownLocation
Dim daa As Int = UUGCoords.DistanceTo(FLP.GetLastKnownLocation) 'Distancia de la UUG a la actual de Tracker.FLP.GetLastKnownLocation
If Starter.Logger Then LogColor($"**** UUC "${Subs.fechaKMT(FLP.GetLastKnownLocation.Time)}|$0.2{FLP.GetLastKnownLocation.Accuracy}|$0.8{FLP.GetLastKnownLocation.Latitude}|$0.8{FLP.GetLastKnownLocation.Longitude}|$0.2{FLP.GetLastKnownLocation.Speed}|"$, Colors.RGB(255,112,35))
If daa > 40 And FLP.GetLastKnownLocation.Accuracy < 35 Then 'Si la distancia de la ubicacion anterior es mayor de XX y la precision es menor de XX, la guardamos ...
B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO RUTA_GPS(fecha, lat, lon) VALUES (?,?,?)", Array As Object (Subs.fechaKMT(FLP.GetLastKnownLocation.Time),FLP.GetLastKnownLocation.Latitude,FLP.GetLastKnownLocation.Longitude))
If Starter.Logger Then Log("++++ Distancia a anterior="&daa&"|"&"Precision="&FLP.GetLastKnownLocation.Accuracy)
End If
' If Starter.Logger Then LogColor($"**** UUC "${Subs.fechaKMT(FLP.GetLastKnownLocation.Time)}|$0.2{FLP.GetLastKnownLocation.Accuracy}|$0.8{FLP.GetLastKnownLocation.Latitude}|$0.8{FLP.GetLastKnownLocation.Longitude}|$0.2{FLP.GetLastKnownLocation.Speed}|"$, Colors.RGB(255,112,35))
' If daa > 40 And FLP.GetLastKnownLocation.Accuracy < 35 Then 'Si la distancia de la ubicacion anterior es mayor de XX y la precision es menor de XX, la guardamos ...
' B4XPages.MainPage.skmt.ExecNonQuery2("INSERT INTO RUTA_GPS(fecha, lat, lon) VALUES (?,?,?)", Array As Object (Subs.fechaKMT(FLP.GetLastKnownLocation.Time),FLP.GetLastKnownLocation.Latitude,FLP.GetLastKnownLocation.Longitude))
' If Starter.Logger Then Log("++++ Distancia a anterior="&daa&"|"&"Precision="&FLP.GetLastKnownLocation.Accuracy)
' End If
UUGCoords = FLP.GetLastKnownLocation
End If
Catch