mirror of
https://github.com/cheveguerra/Pusher_2.0.git
synced 2026-04-20 04:39:14 +00:00
Initial commit
This commit is contained in:
765
pusher.chv.com.b4a
Normal file
765
pusher.chv.com.b4a
Normal file
@@ -0,0 +1,765 @@
|
||||
Build1=Default,pusher.chv.com
|
||||
File1=96761371-car-icon-white-icon-with-shadow-on-transparent-background.jpg
|
||||
File10=marker-rojo-0.png
|
||||
File11=marker-rojo-coche.png
|
||||
File12=waze.png
|
||||
File13=waze-moving.png
|
||||
File14=waze-moving-2.png
|
||||
File15=waze-moving-small.png
|
||||
File16=waze-sleeping.png
|
||||
File17=waze-sleeping-small.png
|
||||
File18=zzz.png
|
||||
File2=ballon280.png
|
||||
File3=ballon50.png
|
||||
File4=balloon_overlay_close.png
|
||||
File5=datetimelayout.bal
|
||||
File6=icon-transit.png
|
||||
File7=icon-transit-small.png
|
||||
File8=infowindow.bal
|
||||
File9=Layout.bal
|
||||
FileGroup1=Default Group
|
||||
FileGroup10=Default Group
|
||||
FileGroup11=Default Group
|
||||
FileGroup12=Default Group
|
||||
FileGroup13=Default Group
|
||||
FileGroup14=Default Group
|
||||
FileGroup15=Default Group
|
||||
FileGroup16=Default Group
|
||||
FileGroup17=Default Group
|
||||
FileGroup18=Default Group
|
||||
FileGroup2=Default Group
|
||||
FileGroup3=Default Group
|
||||
FileGroup4=Default Group
|
||||
FileGroup5=Default Group
|
||||
FileGroup6=Default Group
|
||||
FileGroup7=Default Group
|
||||
FileGroup8=Default Group
|
||||
FileGroup9=Default Group
|
||||
Group=Default Group
|
||||
Library1=administrator
|
||||
Library10=googlemapsextras
|
||||
Library11=gps
|
||||
Library12=ime
|
||||
Library13=javaobject
|
||||
Library14=json
|
||||
Library15=okhttputils2
|
||||
Library16=phone
|
||||
Library17=randomaccessfile
|
||||
Library18=runtimepermissions
|
||||
Library19=xcustomlistview
|
||||
Library2=byteconverter
|
||||
Library20=xui
|
||||
Library21=reflection
|
||||
Library3=compressstrings
|
||||
Library4=core
|
||||
Library5=dateutils
|
||||
Library6=firebaseanalytics
|
||||
Library7=firebasenotifications
|
||||
Library8=fusedlocationprovider
|
||||
Library9=googlemaps
|
||||
ManifestCode='This code will be applied to the manifest file during compilation.~\n~'You do not need to modify it in most cases.~\n~'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136~\n~AddManifestText(~\n~<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="27"/>~\n~<supports-screens android:largeScreens="true" ~\n~ android:normalScreens="true" ~\n~ android:smallScreens="true" ~\n~ android:anyDensity="true"/>)~\n~SetApplicationAttribute(android:icon, "@drawable/icon")~\n~SetApplicationAttribute(android:label, "$LABEL$")~\n~CreateResourceFromFile(Macro, Themes.LightTheme)~\n~'End of default text~\n~CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)~\n~CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)~\n~CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)~\n~AddPermission(android.permission.ACCESS_FINE_LOCATION)~\n~AddPermission(android.permission.WRITE_EXTERNAL_STORAGE) ' Allows an application to write to external storage.~\n~'Lo siguiente es para la api de google maps, para mostrar un mapa en la app~\n~AddApplicationText(~\n~<uses-library~\n~ android:name="org.apache.http.legacy"~\n~ android:required="false" />~\n~<meta-data~\n~ android:name="com.google.android.geo.API_KEY"~\n~ android:value="AIzaSyCjm5WyRxaLGPvp-zD-OlAZqQjpqWb2VK0"/>~\n~) 'Obtener la llave del API en https://console.cloud.google.com/~\n~'SetServiceAttribute(Tracker, android:foregroundServiceType, "location")~\n~~\n~AddApplicationText(<receiver android:name="anywheresoftware.b4a.objects.AdminReceiver2"~\n~ android:permission="android.permission.BIND_DEVICE_ADMIN">~\n~ <meta-data android:name="android.app.device_admin"~\n~ android:resource="@xml/device_admin" />~\n~ <intent-filter>~\n~ <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />~\n~ </intent-filter>~\n~</receiver>)~\n~~\n~CreateResource(xml, device_admin.xml,~\n~<device-admin xmlns:android="http://schemas.android.com/apk/res/android">~\n~ <uses-policies>~\n~ <limit-password />~\n~ <reset-password />~\n~ <force-lock />~\n~ </uses-policies>~\n~</device-admin>~\n~)~\n~~\n~SetActivityAttribute(main, android:windowSoftInputMode, adjustPan|stateHidden)~\n~'SetActivityAttribute(main, android:windowSoftInputMode, adjustResize|stateHidden) 'Para que suba al abrir el teclado junto con la libreria IME
|
||||
Module1=DBRequestManager
|
||||
Module2=FirebaseMessaging
|
||||
Module3=Mods
|
||||
Module4=MyPopup
|
||||
Module5=Starter
|
||||
Module6=Subs
|
||||
NumberOfFiles=18
|
||||
NumberOfLibraries=21
|
||||
NumberOfModules=6
|
||||
Version=12.5
|
||||
@EndOfDesignText@
|
||||
#Region Project Attributes
|
||||
#ApplicationLabel: Pusher-ML
|
||||
#VersionCode: 1
|
||||
#VersionName: 3.09.18
|
||||
'Ver. 3.09.18 - Se agregó la posibilidad de mostrar puntos internedios en la ruta y muestra icono diferente si esta en movimiento o parado.
|
||||
'SupportedOrientations possible values: unspecified, landscape or portrait.
|
||||
#SupportedOrientations: portrait
|
||||
#CanInstallToExternalStorage: False
|
||||
#BridgeLogger: True
|
||||
'###########################################################################################################
|
||||
'###################### PULL #############################################################
|
||||
'Ctrl + click ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=git&Args=pull
|
||||
'###########################################################################################################
|
||||
'###################### PUSH #############################################################
|
||||
'Ctrl + click ide://run?file=%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe&Args=github&Args=..\..\
|
||||
'###########################################################################################################
|
||||
#End Region
|
||||
#AdditionalJar: com.android.support:support-v4
|
||||
#AdditionalJar: com.google.android.gms:play-services-location
|
||||
|
||||
#Region Activity Attributes
|
||||
#FullScreen: False
|
||||
#IncludeTitle: True
|
||||
#End Region
|
||||
|
||||
Sub Process_Globals
|
||||
'These global variables will be declared once when the application starts.
|
||||
'These variables can be accessed from all modules.
|
||||
'Api
|
||||
Private const API_KEY As String = "AAAAv1qt3Lk:APA91bECIR-pHn6ul53eYyoVlpPuOo85RO-0zcAgEXwE7vqw8DFSbBtCaCINiqWQAkBBZXxHtQMdpU6B-jHIqgFKVL196UgwHv0Gw6_IgmipfV_NiItjzlH9d2QNpGLp9y_JUKVjUEhP"
|
||||
Private rp As RuntimePermissions
|
||||
Dim phn As Phone
|
||||
Dim devModel As String
|
||||
Dim dUbicados As Int 'Dispositivos con ubicacion
|
||||
Dim dispositivos As Map
|
||||
Public GZip As GZipStrings
|
||||
Dim base64 As String
|
||||
Dim rutaGPS, rRuta, fechaInicioRutaGPS, fechaFinRutaGPS As String
|
||||
Dim rutasGPS As Map
|
||||
' Dim topics As List
|
||||
Dim clientes As List
|
||||
Dim dispLVClic As Map
|
||||
Dim rutaClic, rutaAnt As String 'ignore
|
||||
Dim colorAnt As Int = 1
|
||||
Dim line, lineAnt As Polyline 'ignore
|
||||
Dim tracker As String = "Trckr"
|
||||
Dim wifi, montoTotal As String
|
||||
Dim reqManager As DBRequestManager
|
||||
Dim mapaDestino As Int = 1
|
||||
Private hInicio, hFinal As String
|
||||
Private distanciaRecorrida As String = "0"
|
||||
Private usuario As String
|
||||
End Sub
|
||||
|
||||
Sub Globals
|
||||
'These global variables will be redeclared each time the activity is created.
|
||||
Private gmap As GoogleMap
|
||||
Dim MapFragment1 As MapFragment
|
||||
Dim latmarker As String
|
||||
Dim longmarker As String
|
||||
Dim timemarker As Long
|
||||
Dim batt As Int
|
||||
Dim ListView1 As ListView
|
||||
Private MapPanel As Panel
|
||||
Dim InfoWindowPanel As Panel
|
||||
Private TitleLabel As Label
|
||||
Private SnippetLabel As Label
|
||||
Private ThumbImage As ImageView
|
||||
Private cuantos As Label
|
||||
Private ubicados As Label
|
||||
Private L_RutaInfo As Label
|
||||
Private et_buscador As EditText
|
||||
Private b_buscar As Button
|
||||
'/////// Popup
|
||||
Dim const popupItemSettings As String = Chr(0xF05B) & " Borrar Ruta"
|
||||
Dim const popupItemContactUs As String = Chr(0xF1D9) & " Limpiar Mapa"
|
||||
Dim const popupItemBorraTodosGPS As String = Chr(0xF059) & " Borrar GPS Todos"
|
||||
|
||||
Dim popExample As MyPopup
|
||||
Private b_dameRuta As Button
|
||||
Dim IME As IME
|
||||
Private p_buscador As Panel
|
||||
Dim topInicialBuscador As Int
|
||||
Private L_RutaInfo As Label
|
||||
Private s_tracker As Spinner
|
||||
Dim aBuscar As String
|
||||
Private p_principal As Panel
|
||||
Private p_ruta As Panel
|
||||
Private b_regresar As Button
|
||||
Private b_getRuta As Button
|
||||
Private MapFragment2 As MapFragment
|
||||
' Private lv_hora As ListView
|
||||
' Private s_hora As Spinner
|
||||
Private b_limpiaMapa, b_inicioMenos, b_inicioMas, b_finalMenos, b_finalMas As Button
|
||||
Private l_periodo As Label
|
||||
Private et_inicio, et_final As EditText
|
||||
Private p_periodoInfo As Panel
|
||||
Private p_mapa2 As Panel
|
||||
Private l_periodoTitulo As Label
|
||||
Private l_distanciaRecorrida As Label
|
||||
Private s_rutas As Spinner
|
||||
Private l_rutas As Label 'ignore
|
||||
Private rutaSeleccionada As String = ""
|
||||
Private p_contenedor1 As Panel
|
||||
Private cb_puntosIntermedios As CheckBox
|
||||
End Sub
|
||||
|
||||
Sub Activity_Create(FirstTime As Boolean)
|
||||
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
|
||||
' Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
|
||||
Dim p As String
|
||||
If File.ExternalWritable Then
|
||||
p = File.DirRootExternal
|
||||
Else
|
||||
p = File.DirInternal
|
||||
End If
|
||||
Log("rootExternal="&p)
|
||||
Log("File.DirInternal="&File.DirInternal)
|
||||
Log("File.DirRootExternal="&File.DirRootExternal)
|
||||
|
||||
Activity.LoadLayout("Layout")
|
||||
clientes.Initialize
|
||||
clientes.AddAll(Array As String("Trckr","Trckr-ML","Trckr-This","Trckr-Cedex","Trckr-GunaReparto","Trckr-Durakelo"))
|
||||
IME.Initialize("IME")
|
||||
dispLVClic.Initialize
|
||||
Wait For MapFragment1_Ready
|
||||
gmap.IsInitialized
|
||||
gmap = MapFragment1.GetMap
|
||||
rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
|
||||
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
|
||||
If Result Then
|
||||
gmap.MyLocationEnabled = True
|
||||
Else
|
||||
Log("Sin permisos de ubicacion")
|
||||
End If
|
||||
' For android_id
|
||||
devModel = phn.Model
|
||||
dispositivos.Initialize
|
||||
rutaClic = ""
|
||||
rutasGPS = CreateMap("r" : rRuta)
|
||||
popExample.Initialize( Activity, Me, "popExample", Array As String( popupItemSettings, popupItemContactUs, popupItemBorraTodosGPS ), 100%x, 100%y, Typeface.FONTAWESOME )
|
||||
IME.AddHeightChangedEvent
|
||||
' Log(" BT="&b_buscar.Top)
|
||||
topInicialBuscador = p_buscador.top
|
||||
s_tracker.AddAll(clientes)
|
||||
cb_puntosIntermedios.Checked = True
|
||||
' reqManager.Initialize(Me, "http://10.0.0.205:1782")
|
||||
' s_hora.AddAll(Array As String("00", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"))
|
||||
End Sub
|
||||
|
||||
Sub Activity_Resume
|
||||
Subs.panelVisible(p_principal, 0, 0)
|
||||
p_principal.Width = Activity.Width
|
||||
p_principal.Height = Activity.Height
|
||||
Subs.centraPanel(p_contenedor1, p_principal.Width)
|
||||
devModel = phn.Model
|
||||
reqManager.Initialize(Me, "http://keymon.lat:1782")
|
||||
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
|
||||
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
|
||||
' If Result Then
|
||||
' StartService(Tracker)
|
||||
' Log("Start Tracker")
|
||||
' Else
|
||||
' ToastMessageShow("Sin permisos de ubicacion", True)
|
||||
' End If
|
||||
' Dim p As Period
|
||||
' p.Hours = -2
|
||||
' p.Minutes = -30
|
||||
' Dim x As String = DateUtils.AddPeriod(DateTime.Now, p)
|
||||
'' x = DateUtils.SetDateAndTime(2022, 2, 24, 20, 20, 20)
|
||||
' Log(Subs.fechaKMT(x))
|
||||
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "seleccionaRutasGPS"
|
||||
reqManager.ExecuteQuery(cmd , 0, "seleccionaRutasGPS", 0)
|
||||
calculaPeriodo
|
||||
End Sub
|
||||
|
||||
Sub Activity_Pause (UserClosed As Boolean)
|
||||
'Starter.StopFLP
|
||||
' CallSub(Tracker, "StopFLP")
|
||||
End Sub
|
||||
|
||||
Sub Button1_Click
|
||||
Log("Peticion enviada")
|
||||
Dim tipos As String
|
||||
tipos="pu,ping"
|
||||
ToastMessageShow("Solicitud Enviada : "&tipos,True)
|
||||
Mensaje(tracker, "Peticion","DameUbicacion", tipos)
|
||||
' Message("Trckr", "Ping","ping", "ping")
|
||||
' gmap.Clear 'Limpiamos mapa
|
||||
ListView1.Clear ' Limpiamos Listview
|
||||
dispositivos.Initialize
|
||||
End Sub
|
||||
|
||||
'Mandamos mensaje
|
||||
Sub Mensaje(Topic As String, Title As String, Body As String, Tipos As String)
|
||||
LogColor("Mandamos mensaje", Colors.Magenta)
|
||||
Dim Job As HttpJob
|
||||
Job.Initialize("fcm", Me)
|
||||
Dim m As Map = CreateMap("to": $"/topics/${Topic}"$)
|
||||
Dim data As Map = CreateMap("title": Title, "body": Body, "t": Tipos)
|
||||
m.Put("data", data)
|
||||
Dim jg As JSONGenerator
|
||||
jg.Initialize(m)
|
||||
Job.PostString("https://fcm.googleapis.com/fcm/send", jg.ToString)
|
||||
Job.GetRequest.SetContentType("application/json;charset=UTF-8")
|
||||
Job.GetRequest.SetHeader("Authorization", "key=" & API_KEY)
|
||||
Log(m)
|
||||
End Sub
|
||||
|
||||
Sub JobDone(Job As HttpJob)
|
||||
If Job.Success = False Then
|
||||
ToastMessageShow("Error: " & Job.ErrorMessage, True)
|
||||
Else
|
||||
If Job.JobName = "DBRequest" Then
|
||||
LogColor("JobDone: '" & reqManager.HandleJob(Job).tag & "' - Registros: " & reqManager.HandleJob(Job).Rows.Size, Colors.Green) 'Mod por CHV - 211027
|
||||
Dim result As DBResult = reqManager.HandleJob(Job)
|
||||
If result.Tag = "seleccionaRutaGPS2" Then 'query tag
|
||||
rutaGPS = ""
|
||||
Private estasCoords, coordsAnt As Location
|
||||
estasCoords.Initialize
|
||||
coordsAnt.Initialize
|
||||
Private cont As Int = 0
|
||||
Subs.SetDateFormat("es", "MX", "MMM d")
|
||||
distanciaRecorrida = 0
|
||||
cont = 0
|
||||
For Each records() As Object In result.Rows
|
||||
If cont = 0 Then
|
||||
usuario = records(result.Columns.Get("RUTA"))
|
||||
fechaInicioRutaGPS = Subs.fechaKMT2Ticks(records(result.Columns.Get("FECHA")))
|
||||
DateTime.timeformat = "HH:mm"
|
||||
fechaInicioRutaGPS = DateTime.Date(fechaInicioRutaGPS) & ", " & DateTime.Time(fechaInicioRutaGPS)
|
||||
End If
|
||||
Private d As String = records(result.Columns.Get("DATOS")) & "," & records(result.Columns.Get("FECHA"))
|
||||
Private l As List = Regex.Split(",", d)
|
||||
estasCoords.Initialize
|
||||
estasCoords.Latitude = l.Get(0)
|
||||
estasCoords.Longitude = l.Get(1)
|
||||
Private acc0 As List = Regex.Split(":", l.Get(2))
|
||||
' Log(acc0)
|
||||
Private acc As String
|
||||
If acc0.Size = 1 Then acc = acc0.Get(0) Else acc = acc0.Get(1)
|
||||
If acc < 20 Then
|
||||
rutaGPS = rutaGPS & d & CRLF
|
||||
If cont > 0 Then
|
||||
distanciaRecorrida = distanciaRecorrida + coordsAnt.DistanceTo(estasCoords)
|
||||
' Log($"Distancia: $1.0{coordsAnt.DistanceTo(estasCoords)} mts, Total: $1.0{distanciaRecorrida} mts"$)
|
||||
End If
|
||||
End If
|
||||
cont = cont + 1
|
||||
coordsAnt.Latitude = estasCoords.Latitude
|
||||
coordsAnt.Longitude = estasCoords.Longitude
|
||||
fechaFinRutaGPS = Subs.fechaKMT2Ticks(records(result.Columns.Get("FECHA")))
|
||||
DateTime.timeformat = "HH:mm"
|
||||
fechaFinRutaGPS = DateTime.Date(fechaFinRutaGPS) & ", " & DateTime.Time(fechaFinRutaGPS)
|
||||
Next
|
||||
ToastMessageShow("Recibimos ruta con " & reqManager.HandleJob(Job).Rows.Size & " puntos.", False)
|
||||
' Log(rutaGPS)
|
||||
LogColor($"Distancia recorrida: $1.1{distanciaRecorrida/1000} kms."$, Colors.Magenta)
|
||||
l_distanciaRecorrida.Text = $"Dist. recorrida: $1.1{distanciaRecorrida/1000} kms."$
|
||||
muestraRuta
|
||||
End If
|
||||
End If
|
||||
If Job.JobName = "DBRequest" Then
|
||||
If result.Tag = "seleccionaRutasGPS" Then 'query tag
|
||||
s_rutas.Clear
|
||||
s_rutas.Add("Selecciona")
|
||||
For Each records() As Object In result.Rows
|
||||
For Each k As String In result.Columns.Keys
|
||||
Log(result.Tag & ": " & k & ": " & records(result.Columns.Get(k)))
|
||||
s_rutas.Add(records(result.Columns.Get(k)))
|
||||
Next
|
||||
Next
|
||||
End If
|
||||
End If
|
||||
End If
|
||||
Job.Release
|
||||
End Sub
|
||||
|
||||
public Sub ubicacionRecibida(message As Map)
|
||||
'Aqui mostramos la ubicacion recibida en el mapa
|
||||
Dim coords As List = Regex.Split(",",message.Get("body"))
|
||||
latmarker=coords.Get(0)
|
||||
longmarker=coords.Get(1)
|
||||
devModel=message.Get("d")
|
||||
wifi=message.Get("w")
|
||||
montoTotal =message.Get("mt")
|
||||
batt=message.Get("b")
|
||||
Dim v As String = message.Get("v")
|
||||
Log("Ubicacion recibida : "&message.Get("d")&","&message.Get("t")&","&message.Get("body"))
|
||||
If message.Get("t") = "au" Then 'Si es actualizacion
|
||||
' For i=0 To message.Size-1
|
||||
' Log(message.GetKeyAt(i)&"="&message.GetValueAt(i))
|
||||
' Next
|
||||
L_RutaInfo.Text = "Ruta: "&rutaClic&CRLF&"Bateria: "&message.Get("b")&"%"&CRLF& _
|
||||
"Monto Total: $"&message.Get("mt")&CRLF&"Wifi: "&wifi&CRLF& _
|
||||
"Version: "&message.Get("v")&CRLF
|
||||
Subs.mueveCamaraMapa(MapFragment1, latmarker, longmarker)
|
||||
End If
|
||||
If coords.Size > 2 And IsNumber(coords.Get(2)) Then 'Si hay fecha en coordenadas ...
|
||||
Dim timemarker As Long=coords.Get(2)
|
||||
Else
|
||||
Dim timemarker As Long=0
|
||||
End If
|
||||
Dim dispData As Map = CreateMap("coords" : coords.Get(0)&","&coords.Get(1), "tm" : timemarker, "d" : message.Get("d"), "b" : batt, "w" : wifi, "mt" : montoTotal, "v" : v)
|
||||
dispositivos.Put(message.Get("d"), dispData)
|
||||
' Log("dispositvos="&dispositivos)
|
||||
Log(DateTime.Time(timemarker))
|
||||
MapFragment1_Ready
|
||||
Log("Dispositivos : "&dispositivos.Size)
|
||||
End Sub
|
||||
|
||||
Sub agregaAListview
|
||||
ListView1.Clear ' Limpiamos Listview
|
||||
ListView1.SingleLineLayout.Label.TextSize = 13
|
||||
ListView1.SingleLineLayout.ItemHeight = 30dip
|
||||
ListView1.SingleLineLayout.Label.textColor=Colors.Black
|
||||
dUbicados=0
|
||||
For i = 0 To dispositivos.Size - 1
|
||||
Dim vals As Map = dispositivos.GetValueAt(i)
|
||||
Dim thisRuta As String = dispositivos.GetKeyAt(i)
|
||||
thisRuta = thisRuta.ToUpperCase
|
||||
aBuscar = et_buscador.Text
|
||||
aBuscar = aBuscar.ToUpperCase
|
||||
' Log(vals)
|
||||
If vals.ContainsKey("tm") And vals.Get("tm") <>"" Then
|
||||
Dim located As String = " *" 'Si ya tenemos ubicacion, agregamos un asterisco
|
||||
dUbicados=dUbicados+1
|
||||
Else
|
||||
Dim located As String = ""
|
||||
End If
|
||||
If aBuscar <> "" Then
|
||||
If thisRuta.IndexOf(aBuscar) > -1 Then
|
||||
ListView1.AddSingleLine2(dispositivos.GetKeyAt(i)&located, dispositivos.GetValueAt(i))
|
||||
End If
|
||||
Else
|
||||
ListView1.AddSingleLine2(dispositivos.GetKeyAt(i)&located, dispositivos.GetValueAt(i))
|
||||
End If
|
||||
Next
|
||||
cuantos.Text = "Rutas"&CRLF&ListView1.Size
|
||||
ubicados.Text = "Ubicados"&CRLF&dUbicados
|
||||
Log("dUbicados="&dUbicados)
|
||||
End Sub
|
||||
|
||||
Sub IME_HeightChanged(NewHeight As Int, OldHeight As Int)
|
||||
If NewHeight < (topInicialBuscador + p_buscador.Height) Then ' Si el teclado tapa al buscador
|
||||
If OldHeight > NewHeight Then 'Si se redujo la pantalla
|
||||
p_buscador.Top = NewHeight - b_buscar.Height
|
||||
Else ' Si se amplio la pantalla
|
||||
p_buscador.Top = topInicialBuscador
|
||||
End If
|
||||
Else
|
||||
p_buscador.Top = topInicialBuscador
|
||||
End If
|
||||
' ToastMessageShow("Height changed", False)
|
||||
End Sub
|
||||
|
||||
Sub b_buscar_Click
|
||||
agregaAListview
|
||||
IME.HideKeyboard
|
||||
End Sub
|
||||
|
||||
Sub ListView1_ItemClick (Position As Int, Value As Object)
|
||||
dispLVClic = Value
|
||||
rutaClic = dispLVClic.Get("d")
|
||||
' Log("RutaClic="&dispLVClic.Get("d"))
|
||||
Dim w As String = dispLVClic.Get("w")
|
||||
Log("******************"&w&" - "&w.Length)
|
||||
If w <> "" And w <> Null And w <> "null" Then
|
||||
w = "Wifi: "&w&CRLF
|
||||
Else
|
||||
w = ""
|
||||
End If
|
||||
' L_RutaInfo.Text = "Ruta: "&rutaClic&CRLF
|
||||
' For i=0 To dispLVClic.Size-1
|
||||
' Log(dispLVClic.GetKeyAt(i)&"="&dispLVClic.GetValueAt(i))
|
||||
'' If dispLVClic.GetKeyAt(i)="d" Then L_RutaInfo.Text = "Ruta: "&dispLVClic.GetValueAt(i)&CRLF
|
||||
' If dispLVClic.GetKeyAt(i)="b" And dispLVClic.GetValueAt(i) <> "null" Then L_RutaInfo.Text = L_RutaInfo.Text&"Bateria: "&dispLVClic.GetValueAt(i)&"%"&CRLF
|
||||
' If dispLVClic.GetKeyAt(i)="mt" And dispLVClic.GetValueAt(i) <> "null" Then L_RutaInfo.Text = L_RutaInfo.Text&"Monto Total: $"&dispLVClic.GetValueAt(i)&CRLF
|
||||
' If dispLVClic.GetKeyAt(i)="w" And dispLVClic.GetValueAt(i) <> "null" Then L_RutaInfo.Text = L_RutaInfo.Text&"Wifi: "&dispLVClic.GetValueAt(i)&CRLF
|
||||
' If dispLVClic.GetKeyAt(i)="v" And dispLVClic.GetValueAt(i) <> "null" Then L_RutaInfo.Text = L_RutaInfo.Text&"Version: "&dispLVClic.GetValueAt(i)&CRLF
|
||||
' Next
|
||||
L_RutaInfo.Text = "Ruta: "&rutaClic&CRLF&"Bateria: "&dispLVClic.Get("b")&"%"&CRLF& _
|
||||
"Monto Total: $"&dispLVClic.Get("mt")&CRLF&w&"Version: "&dispLVClic.Get("v")&CRLF
|
||||
|
||||
Dim thisVals As Map = Value
|
||||
Log(thisVals)
|
||||
Dim coords As List = Regex.Split(",", thisVals.Get("coords"))
|
||||
|
||||
'Mueve el mapa a la posicion solicitada
|
||||
Subs.mueveCamaraMapa(MapFragment1, coords.Get(0), coords.Get(1))
|
||||
End Sub
|
||||
|
||||
Sub b_actUbic_click
|
||||
Mensaje(dispLVClic.Get("d"), "Peticion","DameUbicacion", "pu,au")
|
||||
ToastMessageShow("Solicitamos Ubicacion: "&rutaClic, True)
|
||||
End Sub
|
||||
|
||||
Sub b_dameRuta_click
|
||||
Mensaje(dispLVClic.Get("d"), "Peticion","DameRuta", "dr")
|
||||
ToastMessageShow("Solicitamos Ruta: "&rutaClic, True)
|
||||
End Sub
|
||||
|
||||
Sub b_dameRuta_LongClick
|
||||
popExample.Show(b_dameRuta) 'Show the menu, anchored to the button.
|
||||
End Sub
|
||||
|
||||
Sub MapFragment1_Ready
|
||||
gmap = MapFragment1.GetMap
|
||||
'///////////////////////////////////////////
|
||||
Dim GoogleMapsExtras1 As GoogleMapsExtras
|
||||
Dim InfoWindowAdapter1 As InfoWindowAdapter
|
||||
|
||||
InfoWindowAdapter1.Initialize("InfoWindowAdapter1")
|
||||
GoogleMapsExtras1.SetInfoWindowAdapter(gmap, InfoWindowAdapter1)
|
||||
InfoWindowPanel.Initialize("")
|
||||
InfoWindowPanel.LoadLayout("InfoWindow")
|
||||
' a hack(ish) way to set InfoWindowPanel width and height!
|
||||
MapPanel.AddView(InfoWindowPanel, 0, 0, 240dip, 90dip)
|
||||
InfoWindowPanel.RemoveView
|
||||
'/////////////////////////////////////////////
|
||||
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 wifi <> "" And wifi <> Null Then
|
||||
wifi = $"Wifi: ${wifi&CRLF}"$
|
||||
Else
|
||||
wifi = ""
|
||||
End If
|
||||
|
||||
If aBuscar <> "" Then
|
||||
If devModel.IndexOf(aBuscar) > -1 Then
|
||||
Dim Marker1 As Marker
|
||||
Marker1 = gmap.AddMarker(latmarker, longmarker, devModel)
|
||||
Marker1.Title = devModel
|
||||
Marker1.Snippet = "Last Loc: "&horasMinsSegs&CRLF&"Monto Total: "&montoTotal&CRLF&"Bateria: "&batt&"%"
|
||||
End If
|
||||
Else
|
||||
Dim Marker1 As Marker
|
||||
Marker1 = gmap.AddMarker(latmarker, longmarker, devModel)
|
||||
Marker1.Title = devModel
|
||||
Marker1.Snippet = "Last Loc: "&horasMinsSegs&CRLF&"Monto Total: "&montoTotal&CRLF&"Bateria: "&batt&"%"
|
||||
End If
|
||||
|
||||
' Subs.mueveCamaraMapa(MapFragment1, latmarker, longmarker)
|
||||
End Sub
|
||||
|
||||
Sub InfoWindowAdapter1_GetInfoContents(Marker1 As Marker) As View
|
||||
' the default InfoContent will be used if this event Sub is not defined or if it returns Null
|
||||
' Log("InfoWindowAdapter1_GetInfoContents")
|
||||
TitleLabel.Text=Marker1.Title
|
||||
SnippetLabel.Text=Marker1.Snippet
|
||||
' ThumbImage.Bitmap=? how will you store the file path/file name of the image to display?
|
||||
' it's a shame that the Marker object has no Tag property which could be used to store such info
|
||||
Return InfoWindowPanel
|
||||
End Sub
|
||||
|
||||
Sub muestraRuta
|
||||
' Log("iniciamos MuestraRuta")
|
||||
Private estasCoords, coordsAnt As Location
|
||||
coordsAnt.Initialize
|
||||
estasCoords.Initialize
|
||||
' If lineAnt.IsInitialized Then lineAnt.Visible = False 'Ocultamos ruta anterior
|
||||
If mapaDestino = 1 Then
|
||||
gmap = MapFragment1.GetMap
|
||||
Else
|
||||
gmap = MapFragment2.GetMap
|
||||
End If
|
||||
Dim points As List
|
||||
Dim point As LatLng
|
||||
Dim lat1, lon1, latIn, lonIn, latOut, lonOut As Double
|
||||
line=gmap.AddPolyline
|
||||
line.Width=10
|
||||
' Log("Color ruta")
|
||||
'Cambiamos el color de la ruta cada vez que se solicite una nueva
|
||||
If colorAnt = 1 Then line.color=Colors.RGB(255, 54, 54) ' Rojo
|
||||
If colorAnt = 2 Then line.color=Colors.RGB(78, 85, 255) ' Azul
|
||||
If colorAnt = 3 Then line.color=Colors.RGB(50, 205, 37) ' Verde
|
||||
If colorAnt = 4 Then line.color=Colors.RGB(200, 46, 176) ' Purpura
|
||||
If colorAnt = 5 Then line.color=Colors.RGB(193, 208, 0) ' Amarillo oscuro
|
||||
If colorAnt = 6 Then line.color=Colors.RGB(247, 113, 252) ' Rosa oscuro
|
||||
If colorAnt = 7 Then line.color=Colors.RGB(255, 190, 62) ' Naranja
|
||||
If colorAnt = 8 Then line.color=Colors.RGB(62, 255, 196) ' Cyan
|
||||
If colorAnt = 9 Then line.color=Colors.RGB(0, 167, 255) ' Azul claro
|
||||
If colorAnt = 10 Then line.color=Colors.RGB(255, 0, 8) ' Rojo-rosa
|
||||
colorAnt = colorAnt + 1
|
||||
If colorAnt = 11 Then colorAnt = 1
|
||||
points.Initialize
|
||||
Dim point As LatLng
|
||||
Dim listtemp As List
|
||||
' Log(rutaGPS)
|
||||
If rutaGPS.Length > 10 Then
|
||||
listtemp = Regex.Split(CRLF, rutaGPS)
|
||||
' Log(listtemp.Size)
|
||||
For i = 1 To listtemp.Size-1
|
||||
Dim coords() As String = Regex.Split(",",listtemp.Get(i))
|
||||
If i = 1 Then
|
||||
latIn = coords(0)
|
||||
lonIn = coords(1)
|
||||
End If
|
||||
latOut = coords(0)
|
||||
lonOut = coords(1)
|
||||
estasCoords.Latitude = latOut
|
||||
estasCoords.Longitude = lonOut
|
||||
' Log(coordsAnt)
|
||||
' Log(estasCoords)
|
||||
Private estaDist As String = coordsAnt.DistanceTo(estasCoords)
|
||||
' Log(estaDist)
|
||||
Dim speedOut As String = coords(4)
|
||||
Dim Marker0 As Marker
|
||||
If (i Mod 2 = 0) And estaDist > 300 And cb_puntosIntermedios.Checked Then 'Solo ponemos la mitad de los puntos y si la distancia entre puntos es mayor de 300 mts.
|
||||
Private hora As String = Subs.fechaKMT2Ticks(coords(6))
|
||||
DateTime.timeformat = "HH:mm"
|
||||
hora = DateTime.Time(hora)
|
||||
If speedOut > 0.5 Then
|
||||
Marker0 = gmap.AddMarker3(latOut, lonOut, "Fin " & usuario, LoadBitmap(File.DirAssets, "waze-moving-small.png"))
|
||||
Else
|
||||
Marker0 = gmap.AddMarker3(latOut, lonOut, "Fin " & usuario, LoadBitmap(File.DirAssets, "waze-sleeping-small.png"))
|
||||
End If
|
||||
Marker0.Snippet = "Hora: " & hora & ", Vel.: " & NumberFormat2((speedOut * 3.6), 1, 2, 2, True) & " km/h"
|
||||
End If
|
||||
lat1 = coords(0)
|
||||
lon1 = coords(1)
|
||||
point.Initialize(lat1,lon1)
|
||||
points.Add(point)
|
||||
coordsAnt.Latitude = latOut
|
||||
coordsAnt.Longitude = lonOut
|
||||
Next
|
||||
line.Points = points ' Mapeamos la ruta en el mapa
|
||||
lineAnt = line
|
||||
Dim data As Map = CreateMap("ruta" : line)
|
||||
rutasGPS.Put(rRuta, data)
|
||||
' Log(rutasGPS)
|
||||
Log("Puntos : "&listtemp.Size)
|
||||
' ToastMessageShow("Recibimos ruta con "&listtemp.Size&" puntos", True)
|
||||
rutaAnt = rRuta ' Ponemos en rutaAnt la ruta actual
|
||||
'Mueve el mapa a las ultmas coordenadas de la ruta
|
||||
If mapaDestino = 1 Then
|
||||
Subs.mueveCamaraMapa(MapFragment1, latIn, lonIn)
|
||||
Else 'Los puntos de la ruta de la base de datos se traen en orden ascendente (los mas viejos primero)
|
||||
Subs.mueveCamaraMapa(MapFragment2, latOut, lonOut)
|
||||
Dim Marker1 As Marker
|
||||
' Marker1 = gmap.AddMarker(latOut, lonOut, "Fin " & usuario)
|
||||
If speedOut > 1 Then
|
||||
Marker1 = gmap.AddMarker3(latOut, lonOut, "Fin " & usuario, LoadBitmap(File.DirAssets, "waze-moving.png"))
|
||||
Else
|
||||
Marker1 = gmap.AddMarker3(latOut, lonOut, "Fin " & usuario, LoadBitmap(File.DirAssets, "waze-sleeping.png"))
|
||||
End If
|
||||
' Marker1.Title = "Fin " & usuario
|
||||
Marker1.Snippet = "Fecha: " & fechaFinRutaGPS & ", Vel.: " & NumberFormat2((speedOut * 3.6), 1, 2, 2, True) & " km/h"
|
||||
|
||||
Dim Marker0 As Marker
|
||||
Marker0 = gmap.AddMarker2(latIn, lonIn, "Inicio " & usuario, gmap.HUE_GREEN)
|
||||
' Marker0.Title = "Inicio " & usuario
|
||||
Marker0.Snippet = $"Fecha: ${fechaInicioRutaGPS}"$
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub popExample_BtnClick( btnText As String )
|
||||
' ToastMessageShow(btnText & " selected", False)
|
||||
If btnText.IndexOf("Borrar Ruta") <> -1 Then
|
||||
Mensaje(rutaClic, "Peticion","borraRuta", "bgps2")
|
||||
ToastMessageShow("Borramos Ruta:"&rutaClic, True)
|
||||
End If
|
||||
If btnText.IndexOf("Limpiar Mapa") <> -1 Then
|
||||
gmap.Clear 'Limpiamos mapa
|
||||
ToastMessageShow("Limpiamos mapa", True)
|
||||
End If
|
||||
If btnText.IndexOf("Borrar GPS Todos") <> -1 Then
|
||||
For c = 0 To clientes.Size-1
|
||||
Log(clientes.Get(c))
|
||||
Mensaje(clientes.Get(c), "Peticion","borraRuta", "bgps2")
|
||||
Next
|
||||
ToastMessageShow("Borrar GPS Todos", True)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub s_tracker_ItemClick (Position As Int, Value As Object)
|
||||
tracker = Value
|
||||
End Sub
|
||||
|
||||
Sub b_buscar_longClick
|
||||
mapaDestino = 2
|
||||
Subs.panelVisible(p_ruta, 0, 0)
|
||||
p_mapa2.Width = Activity.Width
|
||||
p_mapa2.Height = Activity.Height - p_periodoInfo.Height - l_periodo.Height - l_periodoTitulo.Height
|
||||
p_mapa2.GetView(0).SetLayout(10, 10, p_ruta.Width, p_mapa2.Height) 'ignore
|
||||
p_ruta.Width = Activity.Width
|
||||
p_ruta.Height = Activity.Height
|
||||
p_periodoInfo.Top = Activity.Height - p_periodoInfo.Height - 5
|
||||
b_regresar.Top = Activity.Height - b_regresar.Height - 5
|
||||
l_periodoTitulo.Top = Activity.Height - (Activity.Height - p_mapa2.Height)
|
||||
l_periodo.Top = Activity.Height - (Activity.Height - p_mapa2.Height) + 10
|
||||
s_rutas.Top = l_periodoTitulo.Top + l_periodoTitulo.Height
|
||||
l_rutas.Top = s_rutas.top
|
||||
l_distanciaRecorrida.Top = l_periodo.Top + l_periodo.Height
|
||||
End Sub
|
||||
|
||||
Sub traeRutaGPS
|
||||
Log("traemos ruta del servidor")
|
||||
Dim hi, hf As Period
|
||||
hi.Hours = et_inicio.text
|
||||
hf.Hours = et_final.text
|
||||
' hi.Minutes = -30
|
||||
' hInicio = DateUtils.AddPeriod(DateTime.Now, hi)
|
||||
' hFinal = DateUtils.AddPeriod(DateTime.Now, hf)
|
||||
Dim cmd As DBCommand
|
||||
cmd.Initialize
|
||||
cmd.Name = "seleccionaRutaGPS2"
|
||||
cmd.Parameters = Array As Object(Subs.fechaKMT(hInicio), Subs.fechaKMT(hFinal), rutaSeleccionada)
|
||||
' Log($"Inicio: ${Subs.fechaKMT(hInicio)}, Fin: ${Subs.fechaKMT(hFinal)}, ${rutaSeleccionada}"$)
|
||||
reqManager.ExecuteQuery(cmd , 0, "seleccionaRutaGPS2", 0)
|
||||
ToastMessageShow("Solicitamos ruta", False)
|
||||
End Sub
|
||||
|
||||
Private Sub b_getRuta_Click
|
||||
traeRutaGPS
|
||||
End Sub
|
||||
|
||||
Private Sub b_regresar_Click
|
||||
p_principal.Visible = True
|
||||
p_ruta.Visible = False
|
||||
mapaDestino = 1
|
||||
End Sub
|
||||
|
||||
Private Sub b_limpiaMapa_Click
|
||||
Private gmap2 As GoogleMap
|
||||
gmap2.IsInitialized
|
||||
gmap2 = MapFragment2.GetMap
|
||||
gmap2.Clear 'Limpiamos mapa
|
||||
End Sub
|
||||
|
||||
Private Sub b_inicioMenos_Click
|
||||
If et_inicio.text = "" Then et_inicio.Text = "0"
|
||||
et_inicio.text = Regex.Replace("[ ]", et_inicio.text, "") 'Quitamos espacios
|
||||
et_inicio.text = $"$1.1{et_inicio.text - 0.5}"$
|
||||
calculaPeriodo
|
||||
End Sub
|
||||
|
||||
Private Sub b_inicioMas_Click
|
||||
If et_inicio.text = "" Then et_inicio.Text = "0"
|
||||
et_inicio.text = Regex.Replace("[ ]", et_inicio.text, "") 'Quitamos espacios
|
||||
Log(et_inicio.text)
|
||||
et_inicio.text = $"$1.1{et_inicio.text + 0.5}"$
|
||||
calculaPeriodo
|
||||
End Sub
|
||||
|
||||
Private Sub b_finalMenos_Click
|
||||
If et_final.text = "" Then et_final.Text = "0"
|
||||
et_final.text = Regex.Replace("[ ]", et_final.text, "") 'Quitamos espacios
|
||||
et_final.text =$"$1.1{ et_final.text - 0.5}"$
|
||||
calculaPeriodo
|
||||
End Sub
|
||||
|
||||
Private Sub b_finalMas_Click
|
||||
If et_final.text = "" Then et_final.Text = "0"
|
||||
et_final.text = Regex.Replace("[ ]", et_final.text, "") 'Quitamos espacios
|
||||
et_final.text =$"$1.1{ et_final.text + 0.5}"$
|
||||
calculaPeriodo
|
||||
End Sub
|
||||
|
||||
Sub calculaPeriodo
|
||||
Dim hi, hf As Period
|
||||
Private minsInicio() As String
|
||||
Private minsFinal() As String
|
||||
minsInicio = Array As String("0","0")
|
||||
minsFinal = Array As String("0","0")
|
||||
hi.Hours = et_inicio.text
|
||||
minsInicio = Regex.Split("\.", et_inicio.text)
|
||||
If Regex.Split("\.", et_inicio.text).Length > 0 Then minsInicio = Regex.Split("\.", et_inicio.text)
|
||||
If minsInicio.Length > 1 Then
|
||||
hi.Minutes = minsInicio(1)*6
|
||||
If et_inicio.Text < 0 Then hi.Minutes = minsInicio(1)*6*-1 'Si es negativo lo multiplicamos por -1 par restar los minutos
|
||||
End If
|
||||
hf.Hours = et_final.text
|
||||
minsFinal = Regex.Split("\.", et_final.text)
|
||||
If Regex.Split("\.", et_final.text).Length > 0 Then minsFinal = Regex.Split("\.", et_final.text)
|
||||
If minsFinal.Length > 1 Then
|
||||
hf.Minutes = minsFinal(1)*6
|
||||
If et_final.Text < 0 Then hf.Minutes = minsFinal(1)*6*-1 'Si es negativo lo multiplicamos por -1 par restar los minutos
|
||||
End If
|
||||
hInicio = DateUtils.AddPeriod(DateTime.Now, hi)
|
||||
hFinal = DateUtils.AddPeriod(DateTime.Now, hf)
|
||||
l_periodo.Text = $"Del: ${Subs.diaSemanaString(DateTime.GetDayOfWeek(hInicio))} ${DateTime.Time(hInicio)}${CRLF}Al : ${Subs.diaSemanaString(DateTime.GetDayOfWeek(hFinal))} ${DateTime.Time(hFinal)}"$
|
||||
End Sub
|
||||
|
||||
Private Sub s_rutas_ItemClick (Position As Int, Value As Object)
|
||||
rutaSeleccionada = Value
|
||||
End Sub
|
||||
Reference in New Issue
Block a user