Merge branch 'master' of https://github.com/KeymonSoft/Nuevo_Torrado_V2
@@ -1,74 +0,0 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=12.2
|
||||
@EndOfDesignText@
|
||||
Sub Class_Globals
|
||||
Private Root As B4XView 'ignore
|
||||
Private xui As XUI 'ignore
|
||||
End Sub
|
||||
|
||||
'You can add more parameters here.
|
||||
Public Sub Initialize As Object
|
||||
Return Me
|
||||
End Sub
|
||||
|
||||
'This event will be called once, before the page becomes visible.
|
||||
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||
Root = Root1
|
||||
'load the layout to Root
|
||||
Root.Color = Colors.Transparent
|
||||
End Sub
|
||||
|
||||
Sub B4XPage_Appear
|
||||
Try
|
||||
Do While Not(CanRequestPackageInstalls)
|
||||
MsgboxAsync($"Por favor permita que ${Application.PackageName} instale actualizaciones"$, "Instalar actualización")
|
||||
Wait For Msgbox_Result(Result As Int)
|
||||
Dim in As Intent
|
||||
in.Initialize("android.settings.", "package:" & Application.PackageName)
|
||||
StartActivity(in)
|
||||
Loop
|
||||
Catch
|
||||
Log("updateAvailable() Error - " & LastException.Message)
|
||||
End Try
|
||||
If appUpdater.newApp.update Then
|
||||
ofreceActualizacion
|
||||
Else
|
||||
sinActualizacion
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'////////////////////////////////////////////////////////////////////////////////////////////
|
||||
'//// Esta es una actividad usada por el servicio appUpdater para mostrar notificaciones
|
||||
'//// cuando hay alguna actualizacion de apk.
|
||||
'////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public Sub CanRequestPackageInstalls As Boolean
|
||||
' // https://www.b4x.com/android/forum/threads/version-safe-apk-installation.87667/#content
|
||||
Dim ctxt As JavaObject
|
||||
ctxt.InitializeContext
|
||||
Dim PackageManager As JavaObject = ctxt.RunMethod("getPackageManager", Null)
|
||||
Return PackageManager.RunMethod("canRequestPackageInstalls", Null)
|
||||
End Sub
|
||||
|
||||
Sub ofreceActualizacion
|
||||
If Msgbox2(appUpdater.newApp.newMsg,"Actualización disponible","Si","","No",Null) = DialogResponse.Positive Then 'ignore
|
||||
' StartService(DownloadService)
|
||||
CallSubDelayed(appUpdater, "download_newApk")
|
||||
' ToastMessageShow("Descargando actualización", True)
|
||||
End If
|
||||
B4XPages.MainPage.ocultaProgreso
|
||||
StartActivity(Main)
|
||||
' Activity.Finish
|
||||
B4XPages.ShowPage("Mainpage")
|
||||
End Sub
|
||||
|
||||
Sub sinActualizacion
|
||||
Msgbox(appUpdater.newApp.okMsg, "Aplicación al corriente") 'ignore
|
||||
' StartActivity(Main)
|
||||
B4XPages.MainPage.ocultaProgreso
|
||||
B4XPages.ShowPage("Mainpage")
|
||||
End Sub
|
||||
@@ -1,399 +0,0 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=6
|
||||
@EndOfDesignText@
|
||||
'Class module
|
||||
'version 1.30
|
||||
'See this page for the list of constants:
|
||||
'http://developer.android.com/intl/fr/reference/android/hardware/Camera.Parameters.html
|
||||
'Note that you should use the constant values instead of the names.
|
||||
Sub Class_Globals
|
||||
Private nativeCam As Object
|
||||
Private cam As Camera
|
||||
Private r As Reflector
|
||||
Private target As Object
|
||||
Private event As String
|
||||
Public Front As Boolean
|
||||
Private parameters As Object
|
||||
End Sub
|
||||
|
||||
Public Sub Initialize (Panel1 As Panel, FrontCamera As Boolean, TargetModule As Object, EventName As String)
|
||||
target = TargetModule
|
||||
event = EventName
|
||||
Front = FrontCamera
|
||||
Dim id As Int
|
||||
id = FindCamera(Front).id
|
||||
If id = -1 Then
|
||||
Front = Not(Front) 'try different camera
|
||||
id = FindCamera(Front).id
|
||||
If id = -1 Then
|
||||
ToastMessageShow("No camera found.", True)
|
||||
Return
|
||||
End If
|
||||
End If
|
||||
cam.Initialize2(Panel1, "camera", id)
|
||||
End Sub
|
||||
|
||||
Private Sub FindCamera (frontCamera As Boolean) As CameraInfoAndId
|
||||
Dim ci As CameraInfoAndId
|
||||
Dim cameraInfo As Object
|
||||
Dim cameraValue As Int
|
||||
Log("findCamera")
|
||||
If frontCamera Then cameraValue = 1 Else cameraValue = 0
|
||||
cameraInfo = r.CreateObject("android.hardware.Camera$CameraInfo")
|
||||
Dim numberOfCameras As Int = r.RunStaticMethod("android.hardware.Camera", "getNumberOfCameras", Null, Null)
|
||||
Log(r.target)
|
||||
Log(numberOfCameras)
|
||||
For i = 0 To numberOfCameras - 1
|
||||
r.RunStaticMethod("android.hardware.Camera", "getCameraInfo", Array As Object(i, cameraInfo), _
|
||||
Array As String("java.lang.int", "android.hardware.Camera$CameraInfo"))
|
||||
r.target = cameraInfo
|
||||
Log("facing: " & r.GetField("facing") & ", " & cameraValue)
|
||||
If r.GetField("facing") = cameraValue Then
|
||||
ci.cameraInfo = r.target
|
||||
ci.Id = i
|
||||
Return ci
|
||||
End If
|
||||
Next
|
||||
ci.id = -1
|
||||
Return ci
|
||||
End Sub
|
||||
|
||||
Private Sub SetDisplayOrientation
|
||||
r.target = r.GetActivity
|
||||
r.target = r.RunMethod("getWindowManager")
|
||||
r.target = r.RunMethod("getDefaultDisplay")
|
||||
r.target = r.RunMethod("getRotation")
|
||||
Dim previewResult, result, degrees As Int = r.target * 90
|
||||
Dim ci As CameraInfoAndId = FindCamera(Front)
|
||||
r.target = ci.CameraInfo
|
||||
Dim orientation As Int = r.GetField("orientation")
|
||||
If Front Then
|
||||
previewResult = (orientation + degrees) Mod 360
|
||||
result = previewResult
|
||||
previewResult = (360 - previewResult) Mod 360
|
||||
Else
|
||||
previewResult = (orientation - degrees + 360) Mod 360
|
||||
result = previewResult
|
||||
Log(previewResult)
|
||||
End If
|
||||
r.target = nativeCam
|
||||
r.RunMethod2("setDisplayOrientation", previewResult, "java.lang.int")
|
||||
r.target = parameters
|
||||
r.RunMethod2("setRotation", result, "java.lang.int")
|
||||
CommitParameters
|
||||
End Sub
|
||||
|
||||
Private Sub Camera_Ready (Success As Boolean)
|
||||
If Success Then
|
||||
r.target = cam
|
||||
nativeCam = r.GetField("camera")
|
||||
r.target = nativeCam
|
||||
parameters = r.RunMethod("getParameters")
|
||||
SetDisplayOrientation
|
||||
Else
|
||||
Log("success = false, " & LastException)
|
||||
End If
|
||||
CallSub2(target, event & "_ready", Success)
|
||||
End Sub
|
||||
'Uncomment this sub if you need to handle the Preview event
|
||||
'Sub Camera_Preview (Data() As Byte)
|
||||
' If SubExists(target, event & "_preview") Then
|
||||
' CallSub2(target, event & "_preview", Data)
|
||||
' End If
|
||||
'End Sub
|
||||
|
||||
Public Sub TakePicture
|
||||
cam.TakePicture
|
||||
End Sub
|
||||
|
||||
Private Sub Camera_PictureTaken (Data() As Byte)
|
||||
CallSub2(target, event & "_PictureTaken", Data)
|
||||
End Sub
|
||||
|
||||
Public Sub StartPreview
|
||||
cam.StartPreview
|
||||
End Sub
|
||||
|
||||
Public Sub StopPreview
|
||||
cam.StopPreview
|
||||
End Sub
|
||||
|
||||
Public Sub Release
|
||||
cam.Release
|
||||
End Sub
|
||||
|
||||
'Saves the data received from PictureTaken event
|
||||
Public Sub SavePictureToFile(Data() As Byte, Dir As String, FileName As String)
|
||||
Dim out As OutputStream = File.OpenOutput(Dir, FileName, False)
|
||||
out.WriteBytes(Data, 0, Data.Length)
|
||||
out.Close
|
||||
End Sub
|
||||
|
||||
Public Sub SetParameter(Key As String, Value As String)
|
||||
r.target = parameters
|
||||
r.RunMethod3("set", Key, "java.lang.String", Value, "java.lang.String")
|
||||
End Sub
|
||||
|
||||
Public Sub GetParameter(Key As String) As String
|
||||
r.target = parameters
|
||||
Return r.RunMethod2("get", Key, "java.lang.String")
|
||||
End Sub
|
||||
|
||||
Public Sub CommitParameters
|
||||
'Try
|
||||
r.target = nativeCam
|
||||
r.RunMethod4("setParameters", Array As Object(parameters), Array As String("android.hardware.Camera$Parameters"))
|
||||
'Catch
|
||||
' ToastMessageShow("Error setting parameters.", True)
|
||||
' Log(LastException)
|
||||
' End Try
|
||||
End Sub
|
||||
|
||||
Public Sub GetColorEffect As String
|
||||
Return GetParameter("effect")
|
||||
End Sub
|
||||
|
||||
Public Sub SetColorEffect(Effect As String)
|
||||
SetParameter("effect", Effect)
|
||||
End Sub
|
||||
|
||||
Public Sub GetSupportedPreviewSizes As CameraSize()
|
||||
r.target = parameters
|
||||
Dim list1 As List = r.RunMethod("getSupportedPreviewSizes")
|
||||
Dim cs(list1.Size) As CameraSize
|
||||
For i = 0 To list1.Size - 1
|
||||
r.target = list1.get(i)
|
||||
cs(i).Width = r.GetField("width")
|
||||
cs(i).Height = r.GetField("height")
|
||||
Next
|
||||
Return cs
|
||||
End Sub
|
||||
|
||||
Public Sub SetPreviewSize(Width As Int, Height As Int)
|
||||
r.target = parameters
|
||||
r.RunMethod3("setPreviewSize", Width, "java.lang.int", Height, "java.lang.int")
|
||||
End Sub
|
||||
Public Sub GetSupportedPicturesSizes As CameraSize()
|
||||
r.target = parameters
|
||||
Dim list1 As List = r.RunMethod("getSupportedPictureSizes")
|
||||
Dim cs(list1.Size) As CameraSize
|
||||
For i = 0 To list1.Size - 1
|
||||
r.target = list1.get(i)
|
||||
cs(i).Width = r.GetField("width")
|
||||
cs(i).Height = r.GetField("height")
|
||||
Next
|
||||
Return cs
|
||||
End Sub
|
||||
|
||||
Public Sub SetPictureSize(Width As Int, Height As Int)
|
||||
r.target = parameters
|
||||
r.RunMethod3("setPictureSize", Width, "java.lang.int", Height, "java.lang.int")
|
||||
End Sub
|
||||
|
||||
Public Sub SetJpegQuality(Quality As Int)
|
||||
r.target = parameters
|
||||
r.RunMethod2("setJpegQuality", Quality, "java.lang.int")
|
||||
End Sub
|
||||
|
||||
Public Sub SetFlashMode(Mode As String)
|
||||
r.target = parameters
|
||||
r.RunMethod2("setFlashMode", Mode, "java.lang.String")
|
||||
End Sub
|
||||
|
||||
Public Sub GetFlashMode As String
|
||||
r.target = parameters
|
||||
Return r.RunMethod("getFlashMode")
|
||||
End Sub
|
||||
|
||||
Public Sub GetSupportedFlashModes As List
|
||||
r.target = parameters
|
||||
Return r.RunMethod("getSupportedFlashModes")
|
||||
End Sub
|
||||
|
||||
Public Sub GetSupportedColorEffects As List
|
||||
r.target = parameters
|
||||
Return r.RunMethod("getSupportedColorEffects")
|
||||
End Sub
|
||||
|
||||
'Returns a list with the supported preview fps. Each item in the list is an array of two ints (minimum value and maximum value).
|
||||
Public Sub GetSupportedPreviewFpsRange As List
|
||||
r.target = parameters
|
||||
Return r.RunMethod("getSupportedPreviewFpsRange")
|
||||
End Sub
|
||||
'Returns the current preview fps range.
|
||||
'Range is a two elements array. The minimum value and maximum value will be stored in this array.
|
||||
Public Sub GetPreviewFpsRange(Range() As Int)
|
||||
r.target = parameters
|
||||
r.RunMethod4("getPreviewFpsRange", Array As Object(Range), Array As String("[I"))
|
||||
End Sub
|
||||
|
||||
Public Sub SetPreviewFpsRange(MinValue As Int, MaxValue As Int)
|
||||
r.target = parameters
|
||||
r.RunMethod4("setPreviewFpsRange", Array As Object(MinValue, MaxValue), _
|
||||
Array As String("java.lang.int", "java.lang.int"))
|
||||
End Sub
|
||||
|
||||
Public Sub GetPreviewSize As CameraSize
|
||||
r.target = parameters
|
||||
r.target = r.RunMethod("getPreviewSize")
|
||||
Dim cs As CameraSize
|
||||
cs.Width = r.GetField("width")
|
||||
cs.Height = r.GetField("height")
|
||||
Return cs
|
||||
End Sub
|
||||
|
||||
Public Sub GetPictureSize As CameraSize
|
||||
r.target = parameters
|
||||
r.target = r.RunMethod("getPictureSize")
|
||||
Dim cs As CameraSize
|
||||
cs.Width = r.GetField("width")
|
||||
cs.Height = r.GetField("height")
|
||||
Return cs
|
||||
End Sub
|
||||
|
||||
'Converts a preview image formatted in YUV format to JPEG.
|
||||
'Note that you should not save every preview image as it will slow down the whole process.
|
||||
Public Sub PreviewImageToJpeg(data() As Byte, quality As Int) As Byte()
|
||||
Dim size, previewFormat As Object
|
||||
r.target = parameters
|
||||
size = r.RunMethod("getPreviewSize")
|
||||
previewFormat = r.RunMethod("getPreviewFormat")
|
||||
r.target = size
|
||||
Dim width = r.GetField("width"), height = r.GetField("height") As Int
|
||||
Dim yuvImage As Object = r.CreateObject2("android.graphics.YuvImage", _
|
||||
Array As Object(data, previewFormat, width, height, Null), _
|
||||
Array As String("[B", "java.lang.int", "java.lang.int", "java.lang.int", "[I"))
|
||||
r.target = yuvImage
|
||||
Dim rect1 As Rect
|
||||
rect1.Initialize(0, 0, r.RunMethod("getWidth"), r.RunMethod("getHeight"))
|
||||
Dim out As OutputStream
|
||||
out.InitializeToBytesArray(100)
|
||||
r.RunMethod4("compressToJpeg", Array As Object(rect1, quality, out), _
|
||||
Array As String("android.graphics.Rect", "java.lang.int", "java.io.OutputStream"))
|
||||
Return out.ToBytesArray
|
||||
End Sub
|
||||
|
||||
Public Sub GetSupportedFocusModes As List
|
||||
r.target = parameters
|
||||
Return r.RunMethod("getSupportedFocusModes")
|
||||
End Sub
|
||||
|
||||
Public Sub SetContinuousAutoFocus
|
||||
Dim modes As List = GetSupportedFocusModes
|
||||
If modes.IndexOf("continuous-picture") > -1 Then
|
||||
SetFocusMode("continuous-picture")
|
||||
Else If modes.IndexOf("continuous-video") > -1 Then
|
||||
SetFocusMode("continuous-video")
|
||||
Else
|
||||
Log("Continuous focus mode is not available")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub SetFocusMode(Mode As String)
|
||||
r.target = parameters
|
||||
r.RunMethod2("setFocusMode", Mode, "java.lang.String")
|
||||
End Sub
|
||||
|
||||
Public Sub GetFocusDistances As Float()
|
||||
Dim F(3) As Float
|
||||
r.target = parameters
|
||||
r.RunMethod4("getFocusDistances", Array As Object(F), Array As String("[F"))
|
||||
Return F
|
||||
End Sub
|
||||
|
||||
Public Sub GetSupportedPictureFormats As List
|
||||
r.target = parameters
|
||||
Return r.RunMethod("getSupportedPictureFormats")
|
||||
End Sub
|
||||
'This method should only be called if you need to immediately release the camera.
|
||||
'For example if you need to start another application that depends on the camera.
|
||||
Public Sub CloseNow
|
||||
cam.Release
|
||||
r.target = cam
|
||||
r.RunMethod2("releaseCameras", True, "java.lang.boolean")
|
||||
End Sub
|
||||
'Calls AutoFocus and then takes the picture if focus was successfull.
|
||||
Public Sub FocusAndTakePicture
|
||||
cam.AutoFocus
|
||||
End Sub
|
||||
|
||||
|
||||
Private Sub Camera_FocusDone (Success As Boolean)
|
||||
If Success Then
|
||||
TakePicture
|
||||
Else
|
||||
Log("AutoFocus error.")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub IsZoomSupported As Boolean
|
||||
r.target = parameters
|
||||
Return r.RunMethod("isZoomSupported")
|
||||
End Sub
|
||||
|
||||
Public Sub GetMaxZoom As Int
|
||||
r.target = parameters
|
||||
Return r.RunMethod("getMaxZoom")
|
||||
End Sub
|
||||
|
||||
Public Sub getZoom() As Int
|
||||
r.target = parameters
|
||||
Return r.RunMethod("getZoom")
|
||||
End Sub
|
||||
|
||||
Public Sub setZoom(ZoomValue As Int)
|
||||
r.target = parameters
|
||||
r.RunMethod2("setZoom", ZoomValue, "java.lang.int")
|
||||
End Sub
|
||||
|
||||
Public Sub getExposureCompensation As Int
|
||||
r.target = parameters
|
||||
Return r.RunMethod("getExposureCompensation")
|
||||
End Sub
|
||||
|
||||
Public Sub setExposureCompensation(v As Int)
|
||||
r.target = parameters
|
||||
r.RunMethod2("setExposureCompensation", v, "java.lang.int")
|
||||
End Sub
|
||||
|
||||
Public Sub getMinExposureCompensation As Int
|
||||
r.target = parameters
|
||||
Return r.RunMethod("getMinExposureCompensation")
|
||||
End Sub
|
||||
|
||||
Public Sub getMaxExposureCompensation As Int
|
||||
r.target = parameters
|
||||
Return r.RunMethod("getMaxExposureCompensation")
|
||||
End Sub
|
||||
|
||||
Public Sub SetFaceDetectionListener
|
||||
Dim jo As JavaObject = nativeCam
|
||||
Dim e As Object = jo.CreateEvent("android.hardware.Camera.FaceDetectionListener", "FaceDetection", Null)
|
||||
jo.RunMethod("setFaceDetectionListener", Array(e))
|
||||
End Sub
|
||||
|
||||
Private Sub FaceDetection_Event (MethodName As String, Args() As Object) As Object
|
||||
Dim faces() As Object = Args(0)
|
||||
For Each f As Object In faces
|
||||
Dim jo As JavaObject = f
|
||||
Dim faceRect As Rect = jo.GetField("rect")
|
||||
Log(faceRect)
|
||||
Next
|
||||
Return Null
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
Public Sub StartFaceDetection
|
||||
Dim jo As JavaObject = nativeCam
|
||||
jo.RunMethod("startFaceDetection", Null)
|
||||
End Sub
|
||||
|
||||
Public Sub StopFaceDetection
|
||||
Dim jo As JavaObject = nativeCam
|
||||
jo.RunMethod("stopFaceDetection", Null)
|
||||
End Sub
|
||||
|
||||
@@ -1,272 +0,0 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Class
|
||||
Version=6.8
|
||||
@EndOfDesignText@
|
||||
''Class module
|
||||
|
||||
'' Requiere accesRandom File y requiere compressStrings, byte converter y okhhtputuils2
|
||||
Sub Class_Globals
|
||||
Private mTarget As Object
|
||||
Type DBResult (Tag As Object, Columns As Map, Rows As List)
|
||||
Type DBCommand (Name As String, Parameters() As Object)
|
||||
Private link As String
|
||||
Private bc As ByteConverter
|
||||
Private T_NULL = 0, T_STRING = 1, T_SHORT = 2, T_INT = 3, T_LONG = 4, T_FLOAT = 5 _
|
||||
,T_DOUBLE = 6, T_BOOLEAN = 7, T_BLOB = 8 As Byte
|
||||
Private VERSION As Float = 0.9
|
||||
Private tempArray(1) As Object
|
||||
Dim jobTagAnterior As String = "" 'Mod por CHV - 211109
|
||||
End Sub
|
||||
|
||||
'Target - The module that handles JobDone (usually Me).
|
||||
'ConnectorLink - URL of the Java server.
|
||||
Public Sub Initialize (Target As Object, ConnectorLink As String)
|
||||
mTarget = Target
|
||||
link = ConnectorLink
|
||||
End Sub
|
||||
|
||||
'Sends a query request.
|
||||
'Command - Query name and parameters.
|
||||
'Limit - Maximum rows to return or 0 for no limit.
|
||||
'Tag - An object that will be returned in the result.
|
||||
Public Sub ExecuteQuery(Command As DBCommand, Limit As Int, Tag As Object)
|
||||
Dim j As HttpJob
|
||||
Dim ms As OutputStream
|
||||
Dim out2 As OutputStream = StartJob(j,ms, Tag)
|
||||
|
||||
WriteObject(Command.Name, out2)
|
||||
WriteInt(Limit, out2)
|
||||
WriteList(Command.Parameters, out2)
|
||||
out2.Close
|
||||
j.PostBytes(link & "?method=query", ms.ToBytesArray)
|
||||
End Sub
|
||||
|
||||
'Executes a batch of (non-select) commands.
|
||||
'ListOfCommands - List of the commands that will be executes.
|
||||
'Tag - An object that will be returned in the result.
|
||||
Public Sub ExecuteBatch(ListOfCommands As List, Tag As Object)
|
||||
Dim j As HttpJob
|
||||
Dim ms As OutputStream
|
||||
Dim out2 As OutputStream = StartJob(j,ms, Tag)
|
||||
WriteInt(ListOfCommands.Size, out2)
|
||||
For Each Command As DBCommand In ListOfCommands
|
||||
WriteObject(Command.Name, out2)
|
||||
WriteList(Command.Parameters, out2)
|
||||
Next
|
||||
out2.Close
|
||||
j.PostBytes(link & "?method=batch", ms.ToBytesArray)
|
||||
End Sub
|
||||
|
||||
'Similar to ExecuteBatch. Sends a single command.
|
||||
Public Sub ExecuteCommand(Command As DBCommand, Tag As Object)
|
||||
ExecuteBatch(Array As DBCommand(Command), Tag)
|
||||
End Sub
|
||||
|
||||
Private Sub StartJob(j As HttpJob, MemoryStream As OutputStream, Tag As Object) As OutputStream
|
||||
j.Initialize("DBRequest", mTarget)
|
||||
j.Tag = Tag
|
||||
MemoryStream.InitializeToBytesArray(0)
|
||||
Dim compress As CompressedStreams
|
||||
Dim out As OutputStream = compress.WrapOutputStream(MemoryStream, "gzip")
|
||||
WriteObject(VERSION, out)
|
||||
Return out
|
||||
End Sub
|
||||
|
||||
Private Sub WriteList(Parameters As List, out As OutputStream)
|
||||
Dim data() As Byte
|
||||
If Parameters = Null Or Parameters.IsInitialized = False Then
|
||||
Dim Parameters As List
|
||||
Parameters.Initialize
|
||||
End If
|
||||
data = bc.IntsToBytes(Array As Int(Parameters.Size))
|
||||
out.WriteBytes(data, 0, data.Length)
|
||||
For Each o As Object In Parameters
|
||||
WriteObject(o, out)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Sub WriteObject(o As Object, out As OutputStream)
|
||||
Dim data() As Byte
|
||||
tempArray(0) = o
|
||||
If tempArray(0) = Null Then
|
||||
out.WriteBytes(Array As Byte(T_NULL), 0, 1)
|
||||
Else If tempArray(0) Is Short Then
|
||||
out.WriteBytes(Array As Byte(T_SHORT), 0, 1)
|
||||
data = bc.ShortsToBytes(Array As Short(o))
|
||||
Else If tempArray(0) Is Int Then
|
||||
out.WriteBytes(Array As Byte(T_INT), 0, 1)
|
||||
data = bc.IntsToBytes(Array As Int(o))
|
||||
Else If tempArray(0) Is Float Then
|
||||
out.WriteBytes(Array As Byte(T_FLOAT), 0, 1)
|
||||
data = bc.FloatsToBytes(Array As Float(o))
|
||||
Else If tempArray(0) Is Double Then
|
||||
out.WriteBytes(Array As Byte(T_DOUBLE), 0, 1)
|
||||
data = bc.DoublesToBytes(Array As Double(o))
|
||||
Else If tempArray(0) Is Long Then
|
||||
out.WriteBytes(Array As Byte(T_LONG), 0, 1)
|
||||
data = bc.LongsToBytes(Array As Long(o))
|
||||
Else If tempArray(0) Is Boolean Then
|
||||
out.WriteBytes(Array As Byte(T_BOOLEAN), 0, 1)
|
||||
Dim b As Boolean = 0
|
||||
Dim data(1) As Byte
|
||||
If b Then data(0) = 1 Else data(0) = 0
|
||||
Else If GetType(tempArray(0)) = "[B" Then
|
||||
data = o
|
||||
out.WriteBytes(Array As Byte(T_BLOB), 0, 1)
|
||||
WriteInt(data.Length, out)
|
||||
Else 'If o Is String Then (treat all other values as string)
|
||||
out.WriteBytes(Array As Byte(T_STRING), 0, 1)
|
||||
data = bc.StringToBytes(o, "UTF8")
|
||||
WriteInt(data.Length, out)
|
||||
End If
|
||||
If data.Length > 0 Then out.WriteBytes(data, 0, data.Length)
|
||||
End Sub
|
||||
|
||||
Private Sub ReadObject(In As InputStream) As Object
|
||||
Dim data(1) As Byte
|
||||
In.ReadBytes(data, 0, 1)
|
||||
Select data(0)
|
||||
Case T_NULL
|
||||
Return Null
|
||||
Case T_SHORT
|
||||
Dim data(2) As Byte
|
||||
Return bc.ShortsFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||
Case T_INT
|
||||
Dim data(4) As Byte
|
||||
Return bc.IntsFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||
Case T_LONG
|
||||
Dim data(8) As Byte
|
||||
Return bc.LongsFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||
Case T_FLOAT
|
||||
Dim data(4) As Byte
|
||||
Return bc.FloatsFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||
Case T_DOUBLE
|
||||
Dim data(8) As Byte
|
||||
Return bc.DoublesFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||
Case T_BOOLEAN
|
||||
Dim b As Byte = ReadByte(In)
|
||||
Return b = 1
|
||||
Case T_BLOB
|
||||
Dim len As Int = ReadInt(In)
|
||||
Dim data(len) As Byte
|
||||
Return ReadBytesFully(In, data, data.Length)
|
||||
Case Else
|
||||
Dim len As Int = ReadInt(In)
|
||||
Dim data(len) As Byte
|
||||
ReadBytesFully(In, data, data.Length)
|
||||
Return BytesToString(data, 0, data.Length, "UTF8")
|
||||
End Select
|
||||
End Sub
|
||||
|
||||
Private Sub ReadBytesFully(In As InputStream, Data() As Byte, Len As Int) As Byte()
|
||||
Dim count = 0, read As Int
|
||||
Do While count < Len And read > -1
|
||||
read = In.ReadBytes(Data, count, Len - count)
|
||||
count = count + read
|
||||
Loop
|
||||
Return Data
|
||||
End Sub
|
||||
|
||||
Private Sub WriteInt(i As Int, out As OutputStream)
|
||||
Dim data() As Byte
|
||||
data = bc.IntsToBytes(Array As Int(i))
|
||||
out.WriteBytes(data, 0, data.Length)
|
||||
End Sub
|
||||
|
||||
Private Sub ReadInt(In As InputStream) As Int
|
||||
Dim data(4) As Byte
|
||||
Return bc.IntsFromBytes(ReadBytesFully(In, data, data.Length))(0)
|
||||
End Sub
|
||||
|
||||
Private Sub ReadByte(In As InputStream) As Byte
|
||||
Dim data(1) As Byte
|
||||
In.ReadBytes(data, 0, 1)
|
||||
Return data(0)
|
||||
End Sub
|
||||
|
||||
'Handles the Job result and returns a DBResult.
|
||||
Public Sub HandleJob(Job As HttpJob) As DBResult
|
||||
Dim start As Long = DateTime.Now 'ignore
|
||||
Dim In As InputStream = Job.GetInputStream
|
||||
Dim cs As CompressedStreams
|
||||
In = cs.WrapInputStream(In, "gzip")
|
||||
Dim serverVersion As Float = ReadObject(In) 'ignore
|
||||
Dim method As String = ReadObject(In)
|
||||
Dim table As DBResult
|
||||
table.Initialize
|
||||
table.Columns.Initialize
|
||||
table.rows.Initialize
|
||||
table.Tag = Job.Tag
|
||||
If jobTagAnterior <> Job.Tag Then LogColor("HandleJob: '"&Job.Tag&"'", Colors.Blue) 'Mod por CHV - 211109
|
||||
jobTagAnterior = Job.Tag 'Mod por CHV - 211109
|
||||
If method = "query" Then
|
||||
Dim numberOfColumns As Int = ReadInt(In)
|
||||
For i = 0 To numberOfColumns - 1
|
||||
table.Columns.Put(ReadObject(In), i)
|
||||
Next
|
||||
Do While ReadByte(In) = 1
|
||||
Dim rowObjects(numberOfColumns) As Object
|
||||
table.rows.Add(rowObjects)
|
||||
For col = 0 To numberOfColumns - 1
|
||||
Dim o As Object = ReadObject(In)
|
||||
rowObjects(col) = o
|
||||
Next
|
||||
Loop
|
||||
Else If method = "batch" Then
|
||||
table.Columns.Put("AffectedRows", 0)
|
||||
Dim rows As Int = ReadInt(In)
|
||||
For i = 0 To rows - 1
|
||||
table.rows.Add(Array As Object(ReadInt(In)))
|
||||
Next
|
||||
End If
|
||||
In.Close
|
||||
' Log("HandleJob: " & (DateTime.Now - start))'Comentado por CHV - 211112
|
||||
Return table
|
||||
End Sub
|
||||
'Reads a file and returns the file as a bytes array.
|
||||
Public Sub FileToBytes(Dir As String, FileName As String) As Byte()
|
||||
Dim out As OutputStream
|
||||
out.InitializeToBytesArray(0)
|
||||
Dim In As InputStream = File.OpenInput(Dir, FileName)
|
||||
File.Copy2(In, out)
|
||||
out.Close
|
||||
Return out.ToBytesArray
|
||||
End Sub
|
||||
'Converts an image to a bytes array (for BLOB fields).
|
||||
Public Sub ImageToBytes(Image As Bitmap) As Byte()
|
||||
Dim out As OutputStream
|
||||
out.InitializeToBytesArray(0)
|
||||
Image.WriteToStream(out, 100, "JPEG")
|
||||
out.Close
|
||||
Return out.ToBytesArray
|
||||
End Sub
|
||||
'Converts a bytes array to an image (for BLOB fields).
|
||||
Public Sub BytesToImage(bytes() As Byte) As Bitmap
|
||||
Dim In As InputStream
|
||||
In.InitializeFromBytesArray(bytes, 0, bytes.Length)
|
||||
Dim bmp As Bitmap
|
||||
bmp.Initialize2(In)
|
||||
Return bmp
|
||||
End Sub
|
||||
'Prints the table to the logs.
|
||||
Public Sub PrintTable(Table As DBResult)
|
||||
Log("Tag: " & Table.Tag & ", Columns: " & Table.Columns.Size & ", Rows: " & Table.Rows.Size)
|
||||
Dim sb As StringBuilder
|
||||
sb.Initialize
|
||||
For Each col In Table.Columns.Keys
|
||||
sb.Append(col).Append(TAB)
|
||||
Next
|
||||
Log(sb.ToString)
|
||||
For Each row() As Object In Table.Rows
|
||||
Dim sb As StringBuilder
|
||||
sb.Initialize
|
||||
For Each record As Object In row
|
||||
sb.Append(record).Append(TAB)
|
||||
Next
|
||||
ToastMessageShow(sb.ToString, True)
|
||||
Next
|
||||
End Sub
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 632 B |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 2.7 KiB |
|
Before Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 11 KiB |
BIN
B4A/Files/kmt.db
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 3.9 KiB |
|
Before Width: | Height: | Size: 17 KiB |
218
B4A/Tracker.bas
@@ -1,218 +0,0 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Service
|
||||
Version=11
|
||||
@EndOfDesignText@
|
||||
#Region Service Attributes
|
||||
#StartAtBoot: True
|
||||
#End Region
|
||||
'******************************************************************************
|
||||
'No olvidar agregar esta linea al editor de manifiesto:
|
||||
' SetServiceAttribute(Tracker, android:foregroundServiceType, "location")
|
||||
'
|
||||
'En Starter agregar estas lineas en Process_Globals
|
||||
' Public rp As RuntimePermissions
|
||||
' Public FLP As FusedLocationProvider
|
||||
' Private flpStarted As Boolean
|
||||
'
|
||||
'En Main agregar estas lineas a Activity_Resume
|
||||
' 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("No permission", True)
|
||||
' End If
|
||||
'
|
||||
'Se necesitan las librerias FusedLocationProvider, GPS, Phone y RunTimePermissions
|
||||
'
|
||||
'Y en Main agregar estas dos lineas:
|
||||
'#AdditionalJar: com.android.support:support-v4
|
||||
'#AdditionalJar: com.google.android.gms:play-services-location
|
||||
|
||||
Sub Process_Globals
|
||||
' Private nid As Int = 1
|
||||
Private Tracking As Boolean
|
||||
Private lock As PhoneWakeState
|
||||
'Para FusedLocationProvider (2 lineas)
|
||||
Public FLP As FusedLocationProvider
|
||||
Dim actualLR As LocationRequest
|
||||
Private flpStarted As Boolean
|
||||
' Dim locRequest As String
|
||||
Dim UUGCoords As Location 'Ultima Ubicacion Guardada
|
||||
' Dim trackerActividad, pushServiceActividad As String
|
||||
Dim logger As Boolean = True
|
||||
End Sub
|
||||
|
||||
Sub Service_Create
|
||||
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER 'we are handling it ourselves
|
||||
UUGCoords.Initialize
|
||||
logger = False
|
||||
'Para FusedLocationProvider (2 lineas)
|
||||
FLP.Initialize("flp")
|
||||
FLP.Connect
|
||||
lock.PartialLock
|
||||
StartFLP
|
||||
End Sub
|
||||
|
||||
Sub flp_ConnectionSuccess
|
||||
' If logger Then Log("Connected to location provider")
|
||||
'FLP.GetLastKnownLocation
|
||||
End Sub
|
||||
|
||||
Sub flp_ConnectionFailed(ConnectionResult1 As Int)
|
||||
If logger Then Log("Failed to connect to location provider")
|
||||
End Sub
|
||||
|
||||
Sub flp_ConnectionSuspended(ConnectionResult1 As Int)
|
||||
If logger Then Log("FLP conection suspended")
|
||||
StartFLP
|
||||
End Sub
|
||||
|
||||
Sub Service_Start (StartingIntent As Intent)
|
||||
LogColor("Iniciando Tracker ...", Colors.Green)
|
||||
Service.StopAutomaticForeground
|
||||
' Service.StartForeground(51042, Subs.notiLowReturn("Kelloggs", "Activo", 51042))
|
||||
StartServiceAt(Me, DateTime.Now + 10 * DateTime.TicksPerMinute, True)
|
||||
Track
|
||||
End Sub
|
||||
|
||||
Public Sub Track
|
||||
Log("Inicia Track - Tracking : "&Tracking)
|
||||
If Tracking Then
|
||||
' Log(actualLR.GetSmallestDisplacement)
|
||||
Return 'Si ya estamos "rastreando" no hacemos nada (return)
|
||||
End If
|
||||
If Starter.rp.Check(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION) = False Then
|
||||
If logger Then Log("Sin permisos de ublicación.")
|
||||
Return
|
||||
End If
|
||||
StartFLP 'Iniciamos FusedLocationProvider
|
||||
Tracking = True
|
||||
End Sub
|
||||
|
||||
Public Sub StartFLP
|
||||
Log("StartFLP - flpStarted="&flpStarted)
|
||||
Do While FLP.IsConnected = False
|
||||
Sleep(500)
|
||||
If logger Then Log("sleeping")
|
||||
Loop
|
||||
' If flpStarted = False Then
|
||||
' If logger Then Log("RequestLocationUpdates")
|
||||
' FLP.RequestLocationUpdates(CreateLocationRequest) 'Buscamos ubicacion
|
||||
If logger Then LogColor("Buscamos ubicacion (movimientoMinimo = "&actualLR.GetSmallestDisplacement&")", Colors.Magenta)
|
||||
' If logger Then Log(actualLR.GetSmallestDisplacement)
|
||||
flpStarted = True
|
||||
' End If
|
||||
End Sub
|
||||
|
||||
Public Sub StartFLP2
|
||||
If logger Then Log("StartFLP2 - flpStarted="&flpStarted)
|
||||
Do While FLP.IsConnected = False
|
||||
Sleep(500)
|
||||
If logger Then Log("sleeping")
|
||||
Loop
|
||||
dameUltimaUbicacionConocida 'Regresamos ultima ubicacion conocida
|
||||
FLP.RequestLocationUpdates(CreateLocationRequest2) 'Buscamos ubicacion 2 peticiones
|
||||
If logger Then LogColor("Buscamos ubicacion (movimientoMinimo = "&actualLR.GetSmallestDisplacement&")", Colors.Magenta)
|
||||
' If logger Then Log(actualLR.GetSmallestDisplacement)
|
||||
End Sub
|
||||
|
||||
Private Sub CreateLocationRequest As LocationRequest
|
||||
If logger Then Log("CreateLocationRequest")
|
||||
Dim lr As LocationRequest
|
||||
lr.Initialize
|
||||
lr.SetInterval(10000) 'Intervalo deseado para actualizaciones de ubicacion
|
||||
lr.SetFastestInterval(lr.GetInterval / 2) 'Intervalo minimo para actualizaciones de ubicacion
|
||||
lr.SetSmallestDisplacement(75) 'Solo registra cambio de ubicacion si es mayor a XX mts
|
||||
lr.SetPriority(lr.Priority.PRIORITY_HIGH_ACCURACY)
|
||||
actualLR=lr
|
||||
Return lr
|
||||
End Sub
|
||||
|
||||
Private Sub CreateLocationRequest2 As LocationRequest
|
||||
If logger Then Log("Iniciamos CreateLocationRequest2")
|
||||
Dim lr As LocationRequest
|
||||
lr.Initialize
|
||||
lr.SetInterval(2000) 'Intervalo deseado para actualizaciones de ubicacion
|
||||
lr.SetFastestInterval(lr.GetInterval / 2) 'Intervalo minimo para actualizaciones de ubicacion
|
||||
lr.setNumUpdates(2) 'Solicitamos solo 2 actualizaciones con estos parametros
|
||||
lr.SetSmallestDisplacement(1) 'Solo registra cambio de ubicacion si es mayor a XX mts
|
||||
lr.SetPriority(lr.Priority.PRIORITY_HIGH_ACCURACY)
|
||||
actualLR=lr
|
||||
Return lr
|
||||
End Sub
|
||||
|
||||
Sub dameUltimaUbicacionConocida
|
||||
If FLP.GetLastKnownLocation.IsInitialized Then 'Mandamos ultima ubicacion guardada
|
||||
' If 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)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Sub StopFLP
|
||||
'Log("StopFLP")
|
||||
If flpStarted Then
|
||||
FLP.RemoveLocationUpdates 'Eliminamos todas las solicitudes de ubicacion
|
||||
flpStarted = False
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub flp_LocationChanged (Location1 As Location)
|
||||
Starter.latitud = Location1.Latitude
|
||||
Starter.longitud = Location1.Longitude
|
||||
LogColor($"Location changed lat=${Location1.Latitude}, lon=${Location1.Longitude}, Acc=${Location1.Accuracy}, SD=$1.0{actualLR.GetSmallestDisplacement}"$, Colors.green)
|
||||
UUGCoords = Location1
|
||||
' If logger Then Log("SmallestDisplacement="&actualLR.GetSmallestDisplacement)
|
||||
' CallSub2(Starter, "GPS_LocationChanged", Location1)
|
||||
' CallSub2(gestion, "GPS_LocationChanged", Location1)
|
||||
' Starter.ubicacionActual.Latitude = Starter.lat_gps
|
||||
' Starter.ubicacionActual.Longitude = Starter.lon_gps
|
||||
' Starter.ubicacionActual.Accuracy = Location1.Accuracy
|
||||
|
||||
'/////// para la ultima ubicacion FL
|
||||
Dim sDate,sTime As String
|
||||
DateTime.DateFormat = "MM/dd/yyyy"
|
||||
sDate=DateTime.Date(DateTime.Now)
|
||||
sTime=DateTime.Time(DateTime.Now)
|
||||
' If Starter.lat_gps <> 0 And Starter.lat_gps <> Null Then
|
||||
' Try
|
||||
' Starter.skmt.ExecNonQuery("DELETE FROM HIST_GPS")
|
||||
' Starter.skmt.ExecNonQuery2("INSERT INTO HIST_GPS (HGDATE, HGLAT, HGLON) VALUES(?,?,?) ", Array As Object (sDate & sTime, Starter.lat_gps, Starter.lon_gps))
|
||||
' Catch
|
||||
' If logger Then Log("Error al borrar o insertar nuevas coordendas en HIST_GPS")
|
||||
' End Try
|
||||
' End If
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Sub CreateNotification (Body As String) As Notification 'ignore
|
||||
Dim notification As Notification
|
||||
notification.Initialize2(notification.IMPORTANCE_LOW)
|
||||
notification.Icon = "icon"
|
||||
notification.SetInfo("This", Body, Main)
|
||||
Return notification
|
||||
End Sub
|
||||
|
||||
Sub Service_Destroy
|
||||
If Tracking Then
|
||||
StopFLP
|
||||
End If
|
||||
Tracking = False
|
||||
lock.ReleasePartialLock
|
||||
End Sub
|
||||
|
||||
Sub formatoFecha(fecha As String) As String 'ignore 'Convierte una fecha al formato yyMMddHHmmss
|
||||
' Log(fecha)
|
||||
Dim OrigFormat As String = DateTime.DateFormat 'save orig date format
|
||||
DateTime.DateFormat="yyMMddHHmmss"
|
||||
Dim lastUpdate As String=DateTime.Date(fecha)
|
||||
DateTime.DateFormat=OrigFormat 'return to orig date format
|
||||
' Log(lastUpdate)
|
||||
Return lastUpdate
|
||||
End Sub
|
||||
@@ -1,282 +0,0 @@
|
||||
B4A=true
|
||||
Group=Default Group
|
||||
ModulesStructureVersion=1
|
||||
Type=Service
|
||||
Version=10.2
|
||||
@EndOfDesignText@
|
||||
#Region Service Attributes
|
||||
#StartAtBoot: False
|
||||
#End Region
|
||||
|
||||
'////////////////////////////////////////////////////////////////////////////////////////////
|
||||
'//// Servicio para revisar si hay actualizacion de aplicación, usa la
|
||||
'//// actividad "updateAvailable" para mostrar mensajes.
|
||||
'////
|
||||
'//// https://www.b4x.com/android/forum/threads/update-your-app-without-using-the-gplaystore.109720/#content
|
||||
'////
|
||||
'//// En la actividad del la cual se va a llamar la revision de actualizacion
|
||||
'//// hay que agregar los siguientes Subs:
|
||||
'////
|
||||
' Sub boton_que_llama_revision_Click
|
||||
' StartService(appUpdater)
|
||||
' End Sub
|
||||
'
|
||||
' appUpdater - Mostramos el anuncio de que se esta descargando el nuevo apk
|
||||
' Sub muestraProgreso
|
||||
' ProgressDialogShow("Descargando actualización")
|
||||
' End Sub
|
||||
'
|
||||
' appUpdater - Ocultamos el anuncio de que se esta descargando el nuevo apk
|
||||
' Sub ocultaProgreso
|
||||
' ProgressDialogHide
|
||||
' End Sub
|
||||
'////
|
||||
'//// Requiere las siguientes librerias:
|
||||
'////
|
||||
'//// * appUpdating
|
||||
'//// * JavaObject
|
||||
'//// * OkHttpUtils2
|
||||
'//// * Phone
|
||||
'//// * RuntimePermissions
|
||||
'////
|
||||
'//// Requiere las siguientes lineas en el manifiesto:
|
||||
'////
|
||||
' AddManifestText(<uses-permission
|
||||
' android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
' android:maxSdkVersion="18" />
|
||||
' )
|
||||
' AddApplicationText(
|
||||
' <provider
|
||||
' android:name="android.support.v4.content.FileProvider"
|
||||
' android:authorities="$PACKAGE$.provider"
|
||||
' android:exported="false"
|
||||
' android:grantUriPermissions="true">
|
||||
' <meta-data
|
||||
' android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
' android:resource="@xml/provider_paths"/>
|
||||
' </provider>
|
||||
' )
|
||||
' CreateResource(xml, provider_paths,
|
||||
' <paths>
|
||||
' <external-files-path name="name" path="" />
|
||||
' <files-path name="name" path="" />
|
||||
' <files-path name="name" path="shared" />
|
||||
' </paths>
|
||||
' )
|
||||
' AddPermission(android.permission.REQUEST_INSTALL_PACKAGES)
|
||||
' AddPermission(android.permission.INTERNET)
|
||||
' AddPermission(android.permission.INSTALL_PACKAGES)
|
||||
' AddPermission(android.permission.READ_EXTERNAL_STORAGE)
|
||||
' AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)
|
||||
' AddPermission(android.permission.READ_PHONE_STATE)
|
||||
' AddPermission(android.permission.WAKE_LOCK)
|
||||
'////
|
||||
'////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Sub Process_Globals
|
||||
'These global variables will be declared once when the application starts.
|
||||
'These variables can be accessed from all modules.
|
||||
|
||||
'Aqui va la liga al archivo .ver en el servidor que contiene la información de la aplicacion
|
||||
Public lnk As String = "https://keymon.lat/movil/Arlete/ARE.ver"
|
||||
|
||||
'/// En el servidor se necesita un archivo de texto (.ver) que tenga los siguientes
|
||||
'/// datos separados por un tabulador
|
||||
'/// contents of ver file, each field is seperated by a tab
|
||||
' Field 0 = 2.226.19.09.19.01a <-- Esta es la version de la aplicación disponible
|
||||
' Field 1 = A new version of the MyAPP is available, Download and update now ? <-- Mensaje para cuando hay actualización
|
||||
' Field 2 = MyApp is up to date <--- Mensaje para cuando no hay actualización
|
||||
' Field 3 = http://www.mydomain.com/Public/myapp.apk <--- Liga al apk de la actualización
|
||||
|
||||
Public nNewApp As Notification
|
||||
Public nNewAppnID As Int = 16
|
||||
'Para Download
|
||||
Dim nativeMe As JavaObject
|
||||
Dim n2 As Notification
|
||||
Dim n2ID As Int = 16
|
||||
'Para fileProvider
|
||||
Public SharedFolder As String
|
||||
Public UseFileProvider As Boolean
|
||||
Private rp As RuntimePermissions
|
||||
|
||||
Type mNewVersion(update As Boolean, nonewAPP As Boolean, notifyUser As Boolean, _
|
||||
version As String, newMsg As String, okMsg As String, appLink As String)
|
||||
Public newApp As mNewVersion
|
||||
End Sub
|
||||
|
||||
Sub Service_Create
|
||||
Log("appUpdater(), Service_Create")
|
||||
newApp.Initialize
|
||||
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER
|
||||
n2.Initialize
|
||||
nativeMe.InitializeContext
|
||||
End Sub
|
||||
|
||||
Sub Service_Start (StartingIntent As Intent)
|
||||
Log("appUpdater(), Service_Start")
|
||||
' CallSubDelayed2(Main, "muestraProgreso", "Buscando actualización")
|
||||
B4XPages.MainPage.muestraProgreso("Buscando actualización")
|
||||
Log("Buscando actualización")
|
||||
fileProvider_init
|
||||
Wait For (Download(Me, lnk)) JobDone (j As HttpJob)
|
||||
If j.Success Then
|
||||
Try
|
||||
Dim app() As String = Regex.Split(Chr(9),j.GetString)
|
||||
' // Set the data
|
||||
newApp.appLink = app(3) 'Liga a nueva app
|
||||
newApp.newMsg = app(1) 'Texto de que hay actualizacion
|
||||
newApp.okMsg = app(2) 'Texto de app al corriente
|
||||
newApp.version = app(0) 'Version actual
|
||||
|
||||
Log($"Application.VersionName=${Application.VersionName}, newApp=${newApp}"$)
|
||||
|
||||
' // App version check
|
||||
If newApp.version = Application.VersionName Then
|
||||
newApp.update = False
|
||||
Log("No new app")
|
||||
B4XPages.ShowPage("updateAvailable")
|
||||
'Se puede mandar tambien una notificacion avisando que NO hay actualizaciones
|
||||
CreateNotification2("Aplicacion al corriente","No hay actualizaciones disponibles","ic_file_download_white_24dp",Main,True,True,nNewApp,nNewAppnID)
|
||||
End If
|
||||
If newApp.version <> Application.VersionName Then
|
||||
newApp.update = True
|
||||
Log("New app true")
|
||||
B4XPages.ShowPage("updateAvailable")
|
||||
'Se puede mandar tambien una notificacion avisando que hay actualizacion disponible
|
||||
' CreateNotification2("Nueva aplicación disponible","Haga clic para descargar.","ic_file_download_white_24dp",C_UpdateAvailable,True,True,nNewApp,nNewAppnID)
|
||||
End If
|
||||
Catch
|
||||
Log("appUpdater(), Job Failed, error " & LastException.Message)
|
||||
End Try
|
||||
Else
|
||||
Log("appUpdater(), Job Failed " & lnk)
|
||||
End If
|
||||
j.Release
|
||||
' StopService(Me)
|
||||
End Sub
|
||||
|
||||
Sub download_Start (StartingIntent As Intent)
|
||||
download_newApk
|
||||
End Sub
|
||||
|
||||
Sub download_newApk
|
||||
' CreateNotification("Descargando actualización", "Descargando apk", "ic_file_download_white_24dp", Main, False, True)
|
||||
' CallSubDelayed2(Main, "muestraProgreso", "Descargando actualización")
|
||||
Log("Descargando actualización")
|
||||
B4XPages.ShowPage("Mainpage")
|
||||
Starter.muestraProgreso = 1
|
||||
Dim job_newAPP As HttpJob
|
||||
job_newAPP.Initialize("job_newAPP",Me)
|
||||
job_newAPP.Download(newApp.appLink)
|
||||
Wait for (job_newAPP) JobDone (job_newAPP As HttpJob)
|
||||
If job_newAPP.Success = True Then
|
||||
' // Delete existing file
|
||||
If File.Exists(SharedFolder,"newapp.apk") Then
|
||||
File.Delete(SharedFolder,"newapp.apk")
|
||||
End If
|
||||
' // Save new file
|
||||
Dim outNewAPK As OutputStream = File.OpenOutput(SharedFolder,"newapp.apk", False)
|
||||
File.Copy2(job_newAPP.GetInputStream, outNewAPK)
|
||||
outNewAPK.Close
|
||||
If Starter.Logger Then Log("APK dir: "&SharedFolder)
|
||||
End If
|
||||
job_newAPP.Release
|
||||
' // Install the app
|
||||
Dim in As Intent
|
||||
in.Initialize(in.ACTION_VIEW,"" )
|
||||
SetFileUriAsIntentData(in, "newapp.apk")
|
||||
' // Type must be set after calling SetFileUriAsIntentData
|
||||
in.SetType("application/vnd.android.package-archive")
|
||||
StartActivity(in)
|
||||
n2.Cancel(nNewAppnID)
|
||||
B4XPages.MainPage.ocultaProgreso
|
||||
' Service.StopForeground(nNewAppnID)
|
||||
StopService(Me)
|
||||
' CallSubDelayed(Main,"ocultaProgreso")
|
||||
End Sub
|
||||
|
||||
Sub download_Destroy
|
||||
n2.Cancel(n2ID)
|
||||
Service.StopForeground(n2ID)
|
||||
End Sub
|
||||
|
||||
Sub Download (Callback As Object, link As String) As HttpJob
|
||||
Dim j As HttpJob
|
||||
j.Initialize("", Callback)
|
||||
j.Download(link)
|
||||
Return j
|
||||
End Sub
|
||||
|
||||
Private Sub CreateNotification2(Title As String, Content As String, _ 'ignore
|
||||
Icon As String, TargetActivity As Object, Sound As Boolean, _
|
||||
Vibrate As Boolean, pN As Notification,pNID As Int) As Notification
|
||||
pN.Initialize2(pN.IMPORTANCE_HIGH)
|
||||
' pN.Number = pNID
|
||||
' pN.Light = False
|
||||
pN.Vibrate = Vibrate
|
||||
pN.Sound = Sound
|
||||
' pN.OnGoingEvent = False
|
||||
pN.Icon = Icon
|
||||
pN.AutoCancel = True
|
||||
pN.SetInfo(Title, Content, TargetActivity)
|
||||
pN.Notify(pNID)
|
||||
Return pN
|
||||
End Sub
|
||||
|
||||
Private Sub CreateNotification(Title As String, Content As String, Icon As String, TargetActivity As Object, Sound As Boolean, Vibrate As Boolean) As Notification 'ignore
|
||||
n2.Initialize
|
||||
n2.Light = False
|
||||
n2.Vibrate = Vibrate
|
||||
n2.Sound = Sound
|
||||
n2.OnGoingEvent = True
|
||||
n2.Icon = Icon
|
||||
n2.SetInfo(Title, Content, TargetActivity)
|
||||
n2.Notify(nNewAppnID)
|
||||
End Sub
|
||||
|
||||
Sub Service_Destroy
|
||||
Log("appUpdater(), Service_Destroy")
|
||||
End Sub
|
||||
|
||||
Sub fileProvider_init
|
||||
Dim p As Phone
|
||||
If p.SdkVersion >= 24 Or File.ExternalWritable = False Then
|
||||
UseFileProvider = True
|
||||
SharedFolder = File.Combine(File.DirInternal, "shared")
|
||||
If Not(File.IsDirectory(File.DirInternal,"shared")) Then
|
||||
File.MakeDir("", SharedFolder)
|
||||
End If
|
||||
Else
|
||||
UseFileProvider = False
|
||||
SharedFolder = rp.GetSafeDirDefaultExternal("shared")
|
||||
End If
|
||||
Log($"Using FileProvider? ${UseFileProvider}"$)
|
||||
End Sub
|
||||
|
||||
'Returns the file uri.
|
||||
Sub GetFileUri (FileName As String) As Object
|
||||
Try
|
||||
If Not(UseFileProvider) Then
|
||||
Dim uri As JavaObject
|
||||
Return uri.InitializeStatic("android.net.Uri").RunMethod("parse", Array("file://" & File.Combine(SharedFolder, FileName)))
|
||||
End If
|
||||
Dim f As JavaObject
|
||||
f.InitializeNewInstance("java.io.File", Array(SharedFolder, FileName))
|
||||
Dim fp As JavaObject
|
||||
Dim context As JavaObject
|
||||
context.InitializeContext
|
||||
fp.InitializeStatic("android.support.v4.content.FileProvider")
|
||||
Return fp.RunMethod("getUriForFile", Array(context, Application.PackageName & ".provider", f))
|
||||
Catch
|
||||
Log("FileProvider::GetFileUri - error - " & LastException.Message)
|
||||
Return ""
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
'Replaces the intent Data field with the file uri.
|
||||
'Resets the type field. Make sure to call Intent.SetType after calling this method
|
||||
Sub SetFileUriAsIntentData (Intent As Intent, FileName As String)
|
||||
Dim jo As JavaObject = Intent
|
||||
jo.RunMethod("setData", Array(GetFileUri(FileName)))
|
||||
Intent.Flags = Bit.Or(Intent.Flags, 1) 'FLAG_GRANT_READ_URI_PERMISSION
|
||||
End Sub
|
||||
@@ -1,53 +0,0 @@
|
||||
AppType=JavaFX
|
||||
Build1=Default,b4j.example
|
||||
File1=MainPage.bjl
|
||||
FileGroup1=New Group
|
||||
Group=Default Group
|
||||
Library1=jcore
|
||||
Library2=jfx
|
||||
Library3=b4xpages
|
||||
Module1=|relative|..\B4XMainPage
|
||||
NumberOfFiles=1
|
||||
NumberOfLibraries=3
|
||||
NumberOfModules=1
|
||||
Version=8.31
|
||||
@EndOfDesignText@
|
||||
#Region Project Attributes
|
||||
#MainFormWidth: 600
|
||||
#MainFormHeight: 600
|
||||
#End Region
|
||||
|
||||
Sub Process_Globals
|
||||
Private fx As JFX
|
||||
Private MainForm As Form
|
||||
End Sub
|
||||
|
||||
Sub AppStart (Form1 As Form, Args() As String)
|
||||
MainForm = Form1
|
||||
MainForm.Show
|
||||
Dim PagesManager As B4XPagesManager
|
||||
PagesManager.Initialize(MainForm)
|
||||
End Sub
|
||||
|
||||
'Template version: B4J-1.0
|
||||
#Region Delegates
|
||||
Sub MainForm_FocusChanged (HasFocus As Boolean)
|
||||
B4XPages.Delegate.MainForm_FocusChanged(HasFocus)
|
||||
End Sub
|
||||
|
||||
Sub MainForm_Resize (Width As Double, Height As Double)
|
||||
B4XPages.Delegate.MainForm_Resize(Width, Height)
|
||||
End Sub
|
||||
|
||||
Sub MainForm_Closed
|
||||
B4XPages.Delegate.MainForm_Closed
|
||||
End Sub
|
||||
|
||||
Sub MainForm_CloseRequest (EventData As Event)
|
||||
B4XPages.Delegate.MainForm_CloseRequest(EventData)
|
||||
End Sub
|
||||
|
||||
Public Sub MainForm_IconifiedChanged (Iconified As Boolean)
|
||||
B4XPages.Delegate.MainForm_IconifiedChanged(Iconified)
|
||||
End Sub
|
||||
#End Region
|
||||
@@ -1,9 +0,0 @@
|
||||
ModuleBookmarks0=
|
||||
ModuleBookmarks1=
|
||||
ModuleBreakpoints0=
|
||||
ModuleBreakpoints1=
|
||||
ModuleClosedNodes0=1,4
|
||||
ModuleClosedNodes1=1
|
||||
NavigationStack=Main,MainForm_IconifiedChanged,37,0,Main,AppStart,14,6,B4XMainPage,Button1_Click,19,0,B4XMainPage,Initialize,9,0,B4XMainPage,B4XPage_Created,18,0,B4XMainPage,Class_Globals,7,0
|
||||
SelectedBuild=0
|
||||
VisibleModules=1
|
||||
@@ -1,46 +0,0 @@
|
||||
Build1=Default,b4i.example
|
||||
File1=MainPage.bil
|
||||
FileGroup1=Default Group
|
||||
Group=Default Group
|
||||
Library1=icore
|
||||
Library2=b4xpages
|
||||
Module1=|relative|..\B4XMainPage
|
||||
NumberOfFiles=1
|
||||
NumberOfLibraries=2
|
||||
NumberOfModules=1
|
||||
Version=6.5
|
||||
@EndOfDesignText@
|
||||
'Code module
|
||||
#Region Project Attributes
|
||||
#ApplicationLabel: B4i Example
|
||||
#Version: 1.0.0
|
||||
'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
|
||||
#iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
|
||||
#iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
|
||||
#Target: iPhone, iPad
|
||||
#ATSEnabled: True
|
||||
#MinVersion: 8
|
||||
#End Region
|
||||
|
||||
Sub Process_Globals
|
||||
Public App As Application
|
||||
Public NavControl As NavigationController
|
||||
|
||||
End Sub
|
||||
|
||||
Private Sub Application_Start (Nav As NavigationController)
|
||||
NavControl = Nav
|
||||
Dim PagesManager As B4XPagesManager
|
||||
PagesManager.Initialize(NavControl)
|
||||
End Sub
|
||||
|
||||
'Template version: B4i-1.0
|
||||
#Region Delegates
|
||||
Private Sub Application_Background
|
||||
B4XPages.Delegate.Activity_Pause
|
||||
End Sub
|
||||
|
||||
Private Sub Application_Foreground
|
||||
B4XPages.Delegate.Activity_Resume
|
||||
End Sub
|
||||
#End Region
|
||||
@@ -1,9 +0,0 @@
|
||||
ModuleBookmarks0=
|
||||
ModuleBookmarks1=
|
||||
ModuleBreakpoints0=
|
||||
ModuleBreakpoints1=
|
||||
ModuleClosedNodes0=1,4
|
||||
ModuleClosedNodes1=1
|
||||
NavigationStack=Main,Application_Start,25,4,Main,Application_Foreground,34,0,Main,Process_Globals,13,0,Visual Designer,MainPage.bil,-100,1,B4XMainPage,Initialize,9,0,B4XMainPage,Button1_Click,19,0,B4XMainPage,B4XPage_Created,10,1,B4XMainPage,Class_Globals,11,0
|
||||
SelectedBuild=0
|
||||
VisibleModules=1
|
||||
|
Before Width: | Height: | Size: 3.8 KiB |
27
ar.txt
@@ -1,27 +0,0 @@
|
||||
##########
|
||||
########## ARESTRATEGICAS
|
||||
##########
|
||||
|
||||
sql.select_usuario_AREstrategicas = select 'OK' || cat_lo_estatus as usuario, cat_lo_agencia from ARESTRATEGICAS.cat_logins where cat_lo_usuario = (?) and cat_lo_contrasena = (?)
|
||||
|
||||
sql.select_datosgenerales_AR = SELECT PR_KT_CREDITO, PR_CD_NOMBRE, PR_CD_RFC, PR_CD_CURP, PR_CD_CALLE, PR_CD_NUM_EXT, PR_CD_NUM_INT, PR_CD_ALCALDIA, PR_CD_MUNICIPIO, PR_CD_ENTIDAD, PR_CD_CP, PR_CD_SEXO, PR_CD_FECHA_NAC, PR_CD_EDAD, PR_CD_EMAIL FROM ARESTRATEGICAS.vi_informacion WHERE PR_KT_ESTATUS <> 'Retirada' and PR_KT_UASIGNADOV is not null and PR_KT_CREDITO IN (SELECT PR_KT_CREDITO FROM ARESTRATEGICAS.pr_kmt_gral WHERE PR_KT_ESTATUS<>'Retirada' and PR_KT_UASIGNADOV = ?)
|
||||
|
||||
sql.select_datosfinancieros_AR = SELECT PR_KT_CREDITO, PR_KT_PRODUCTO, PR_KT_AGENCIA, PR_CF_SALDO_TOTAL, PR_CF_LIQUIDACION, PR_CF_TOTAL_A_PAGAR_DESC, PR_CF_LIQUIDACION, PR_CA_DIAS_VENCIDOS, PR_CA_DIAS_ATRASO_ACT, PR_CA_FECHA_ATRASO, PR_CA_REFERENCIA1, PR_CA_REFERENCIA2 FROM ARESTRATEGICAS.vi_informacion WHERE PR_KT_ESTATUS <> 'Retirada' and PR_KT_UASIGNADOV is not null and PR_KT_CREDITO IN (SELECT PR_KT_CREDITO FROM ARESTRATEGICAS.pr_kmt_gral WHERE PR_KT_ESTATUS<> 'Retirada' and PR_KT_UASIGNADOV = ?)
|
||||
|
||||
sql.select_fuentes_AR = SELECT * FROM ARESTRATEGICAS.CAT_FUENTE
|
||||
|
||||
sql.select_parentesco_AR = SELECT * FROM ARESTRATEGICAS.CAT_PARENTESCO
|
||||
|
||||
sql.select_accion_AR = select distinct CAT_CO_ACCION, CAT_CO_ADESCRIPCION from ARESTRATEGICAS.cat_codigos where CAT_CO_TIPO in (2,3) order by 2
|
||||
|
||||
sql.select_resultado_MA_AR = select distinct CAT_CO_ACCION, CAT_CO_RESULTADO, CAT_CO_RDESCRIPCION from cat_codigos where CAT_CO_ACCION ='MA' order by 1
|
||||
|
||||
sql.select_resultado_VC_AR = select distinct CAT_CO_ACCION, CAT_CO_RESULTADO, CAT_CO_RDESCRIPCION from cat_codigos where CAT_CO_ACCION = 'VC' order by 1
|
||||
|
||||
sql.select_resultado_CA_AR = select distinct CAT_CO_ACCION, CAT_CO_RESULTADO, CAT_CO_RDESCRIPCION from cat_codigos where CAT_CO_ACCION ='CA' order by 1
|
||||
|
||||
sql.select_resultado_BR_AR = select distinct CAT_CO_ACCION, CAT_CO_RESULTADO, CAT_CO_RDESCRIPCION from cat_codigos where CAT_CO_ACCION ='BR' order by 1
|
||||
|
||||
sql.insert_fotos_cliente_nuevo_MARIANA = insert into MARIANA.HIST_FOTO_CLIENTES_NUEVOS (HIST_FCM_CODIGO, HIST_FCM_ALMACEN, HIST_FCM_RUTA, HIST_FCM_FOTO) VALUES(?,?,?,?)
|
||||
|
||||
sql.insert_gestion_AR = insert into ARESTRATEGICAS.TMP_HIST_VISITAS(TMP_HIST_VI_CREDITO, TMP_HIST_VI_PRODUCTO, TMP_HIST_VI_VISITADOR, TMP_HIST_VI_RESULTADO, TMP_HIST_VI_CODIGO, TMP_HIST_VI_PARENTESCO, TMP_HIST_VI_COMENTARIO, TMP_HIST_VI_DTEVISITA, TMP_HIST_VI_LONGITUD, TMP_HIST_VI_LATITUD, TMP_HIST_VI_DTECAPTURA, TMP_HIST_VI_AGENCIA, TMP_HIST_VI_DPROM, TMP_HIST_VI_MPROM, HIST_VI_TIPODOMICILIO, HIST_VI_NIVELSOCIO, HIST_VI_CARACTERISTICA, HIST_VI_NIVELES, TMP_HIST_VI_IMAGEN, TMP_HIST_VI_IMAGEN2, TMP_HIST_VI_IMAGEN3, TMP_HIST_VI_IMAGEN4, HIST_VI_NATIENDE, TMP_HIST_VI_ACCION_CODIGO, TMP_HIST_VI_ACCION, TMP_HIST_VI_DIAS_ACCION, TMP_HIST_VI_PUNTOS_REF) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
|
||||
BIN
datos-varios.png
|
Before Width: | Height: | Size: 2.1 KiB |
BIN
engranes.png
|
Before Width: | Height: | Size: 2.7 KiB |
@@ -1 +0,0 @@
|
||||
git pull
|
||||