Initial commit

This commit is contained in:
2023-09-18 06:43:57 -06:00
commit 63ae2cda9e
33 changed files with 3128 additions and 0 deletions

139
subs.bas Normal file
View File

@@ -0,0 +1,139 @@
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=StaticCode
Version=11
@EndOfDesignText@
'Code module
'Subs in this code module will be accessible from all modules.
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub mueveCamaraMapa(mapFragment As MapFragment, lat As String, lon As String)
'Mueve el mapa a la posicion solicitada
Private gmap As GoogleMap
gmap = mapFragment.GetMap
Dim aa As CameraPosition
aa.Initialize(lat,lon,15)
gmap.AnimateCamera(aa)
End Sub
Sub CreateNotification (Body As String) As Notification 'ignore
Dim notification As Notification
notification.Initialize2(notification.IMPORTANCE_LOW)
notification.Icon = "icon"
notification.SetInfo("Tracking location", Body, Main)
Return notification
End Sub
Sub removeFomList(myList As List, theItem As String) 'ignore
Dim x As Int = 0
Dim myObject As List
Do While x < myList.Size
myObject = myList.get(x)
If myObject.Get(x) = theItem Then
myList.removeAt(x)
Else
x = x + 1
End If
Loop
End Sub
Sub creaMarcador(mapFragment As MapFragment, lat As String, lon As String, devModel As String, timemarker As Double) 'ignore
' Private gmap As GoogleMap
' gmap = mapFragment.GetMap
' Dim Marker1 As Marker
' Marker1 = gmap.AddMarker(lat, lon, title)
' Marker1.Title = devModel
'
' Dim horaFecha As String = timemarker
' Dim hms As String = horaFecha.SubString(6) 'Tomamos solo la parte de la hora
'' Log("hms="&hms)
' Dim horasMinsSegs As String = hms.SubString2(0,2)&":"&hms.SubString2(2,4)&":"&hms.SubString(4)
'' Log(horasMinsSegs)
' If Main.wifi <> "" And Main.wifi <> Null Then
' Main.wifi = $"Wifi: ${Main.wifi&CRLF}"$
' Else
' Main.wifi = ""
' End If
' Marker1.Snippet = "Last Loc: "&horasMinsSegs&CRLF&"Monto Total: "&montoTotal&CRLF&"Bateria: "&batt&"%"
End Sub
'Convierte una fecha al formato yyMMddHHmmss
Sub fechaKMT(fecha As String) As String 'ignore
' Log(fecha)
Dim OrigFormat As String = DateTime.DateFormat 'save orig date format
DateTime.DateFormat="yyMMddHHmmss"
Dim nuevaFecha As String=DateTime.Date(fecha)
DateTime.DateFormat=OrigFormat 'return to orig date format
' Log(nuevaFecha)
Return nuevaFecha
End Sub
'Hace visible y trae al frente el panel con los parametros "Top" y "Left" dados
Sub panelVisible(panel As Panel, top As Int, left As Int) 'ignore
panel.BringToFront
panel.Visible = True
panel.Top = top
panel.Left = left
End Sub
Sub diaSemanaString(diaSemana As Int) As String 'ignore
If diaSemana = 2 Then Return "Lun"
If diaSemana = 3 Then Return "Mar"
If diaSemana = 4 Then Return "Mie"
If diaSemana = 5 Then Return "Jue"
If diaSemana = 6 Then Return "Vie"
If diaSemana = 7 Then Return "Sab"
If diaSemana = 1 Then Return "Dom"
Return ""
End Sub
'Convierte una fecha en formato YYMMDDHHMMSS a Ticks
Sub fechaKMT2Ticks(fKMT As String) As Long 'ignore
Try
If fKMT.Length = 12 Then
Private parteFecha As String = fKMT.SubString2(0,6)
Private parteHora As String = fKMT.SubString(6)
Private OrigFormat As String = DateTime.DateFormat 'save original date format
DateTime.DateFormat="yyMMdd"
DateTime.TimeFormat="HHmmss"
Private ticks As Long = DateTime.DateTimeParse(parteFecha,parteHora)
' Log(" +++ +++ pFecha:"&parteFecha&" | pHora:"&parteHora)
DateTime.DateFormat=OrigFormat 'return to original date format
Return ticks
Else
Log("Formato de fecha incorrecto, debe de ser 'yyMMddHHmmss', no '"&fKMT&"' largo="&fKMT.Length)
Return 0
End If
Catch
Log(LastException)
LogColor($"Fecha dada: ${fKMT}, Parte Fecha: ${parteFecha}, Parte Hora: ${parteHora}"$, Colors.Red)
Return 0
End Try
End Sub
Sub SetDateFormat(Language As String, Country As String, format As String)
#if B4A or B4J
Dim locale As JavaObject
locale.InitializeNewInstance("java.util.Locale", Array(Language, Country))
Dim DateFormat As JavaObject
DateFormat.InitializeNewInstance("java.text.SimpleDateFormat", Array(format, locale))
Dim r As Reflector
r.Target = r.RunStaticMethod("anywheresoftware.b4a.keywords.DateTime", "getInst", Null, Null)
r.SetField2("dateFormat", DateFormat)
#else if B4i
Dim locale As NativeObject
locale = locale.Initialize("NSLocale").RunMethod("alloc", Null).RunMethod("initWithLocaleIdentifier:", Array(Language & "_" & Country))
DateTime.As(NativeObject).GetField("dateFormat").SetField("locale", locale)
DateTime.DateFormat = format
#End if
End Sub
'Centra un panel dentro de un elemento superior
Sub centraPanel(elemento As Panel, anchoElementoSuperior As Int) 'ignore
elemento.Left = Round(anchoElementoSuperior/2)-(elemento.Width/2)
End Sub