mirror of
https://github.com/KeymonSoft/Salma_Almacen.git
synced 2026-04-17 21:06:10 +00:00
23/9/23 - Commit inicial.
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
**/Objects
|
||||||
|
**/AutoBackups
|
||||||
99
B4A/B4XMainPage.bas
Normal file
99
B4A/B4XMainPage.bas
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
B4A=true
|
||||||
|
Group=Default Group
|
||||||
|
ModulesStructureVersion=1
|
||||||
|
Type=Class
|
||||||
|
Version=9.85
|
||||||
|
@EndOfDesignText@
|
||||||
|
#Region Shared Files
|
||||||
|
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
|
||||||
|
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
|
||||||
|
#End Region
|
||||||
|
|
||||||
|
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip
|
||||||
|
|
||||||
|
Sub Class_Globals
|
||||||
|
Private Root As B4XView
|
||||||
|
Private xui As XUI
|
||||||
|
Private Usuario As EditText
|
||||||
|
Private Contraseña As EditText
|
||||||
|
Private b_iniciar As Button
|
||||||
|
Dim reqManager As DBRequestManager
|
||||||
|
Dim user As String
|
||||||
|
Dim paso1 As String
|
||||||
|
|
||||||
|
Dim seleccion As C_seleccion
|
||||||
|
Dim escaneo As C_escaneo
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub Initialize
|
||||||
|
' B4XPages.GetManager.LogEvents = True
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'This event will be called once, before the page becomes visible.
|
||||||
|
Private Sub B4XPage_Created (Root1 As B4XView)
|
||||||
|
Root = Root1
|
||||||
|
Root.LoadLayout("MainPage")
|
||||||
|
reqManager.Initialize(Me, Starter.DBReqServer)
|
||||||
|
seleccion.Initialize
|
||||||
|
B4XPages.AddPage("seleccion",seleccion)
|
||||||
|
escaneo.Initialize
|
||||||
|
B4XPages.AddPage("escaneo",escaneo)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub b_iniciar_Click
|
||||||
|
If Usuario.Text <> "" Then
|
||||||
|
|
||||||
|
Dim cmd As DBCommand
|
||||||
|
cmd.Initialize
|
||||||
|
cmd.Name = "select_usuario_almacen_SALMA"
|
||||||
|
cmd.Parameters = Array As Object(Usuario.Text, Contraseña.Text)
|
||||||
|
reqManager.ExecuteQuery(cmd , 0, "usuario")
|
||||||
|
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
Sub JobDone(Job As HttpJob)
|
||||||
|
|
||||||
|
If Job.Success = False Then
|
||||||
|
|
||||||
|
ToastMessageShow("Error: " & Job.ErrorMessage, True)
|
||||||
|
|
||||||
|
Else
|
||||||
|
|
||||||
|
If Job.JobName = "DBRequest" Then
|
||||||
|
Dim result As DBResult = reqManager.HandleJob(Job)
|
||||||
|
If result.Tag = "usuario" Then 'query tag
|
||||||
|
For Each records() As Object In result.Rows
|
||||||
|
Dim status As String = records(result.Columns.Get("STATUS"))
|
||||||
|
Starter.almacen = records(result.Columns.Get("CAT_LO_AGENCIA"))
|
||||||
|
user = records(result.Columns.Get("CAT_LO_USUARIO"))
|
||||||
|
Log(user)
|
||||||
|
Next
|
||||||
|
paso1 = 1
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
If paso1 = 1 Then
|
||||||
|
If status = "OKActivo" Then
|
||||||
|
' Starter.skmt.ExecNonQuery("delete from usuarioa")
|
||||||
|
' Starter.skmt.ExecNonQuery2("INSERT INTO USUARIOA VALUES (?,?)", Array As Object(Usuario.Text, Contraseña.Text))
|
||||||
|
' Starter.skmt.ExecNonQuery("delete from cat_almacen")
|
||||||
|
' Starter.skmt.ExecNonQuery2("INSERT INTO CAT_ALMACEN(ID_ALMACEN) VALUES (?)", Array As Object (ID_ALMACEN))
|
||||||
|
B4XPages.ShowPage("seleccion")
|
||||||
|
Else If status = "OKExpirado" Then
|
||||||
|
Msgbox("Usuario Expirado llamar al administrador","") 'ignore
|
||||||
|
Else If status = "OKCancelado" Then
|
||||||
|
Msgbox("Usuario Cancelado llamar al administrador","") 'ignore
|
||||||
|
Else
|
||||||
|
Msgbox("Usuario o password No validos","") 'ignore
|
||||||
|
End If
|
||||||
|
paso1 = 0
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
End Sub
|
||||||
1270
B4A/C_escaneo.bas
Normal file
1270
B4A/C_escaneo.bas
Normal file
File diff suppressed because it is too large
Load Diff
155
B4A/C_seleccion.bas
Normal file
155
B4A/C_seleccion.bas
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
B4A=true
|
||||||
|
Group=Default Group
|
||||||
|
ModulesStructureVersion=1
|
||||||
|
Type=Class
|
||||||
|
Version=11.8
|
||||||
|
@EndOfDesignText@
|
||||||
|
Sub Class_Globals
|
||||||
|
Private Root As B4XView 'ignore
|
||||||
|
Private xui As XUI 'ignore
|
||||||
|
Dim reqManager As DBRequestManager
|
||||||
|
Private b_cargar As Button
|
||||||
|
Private cl_folios As CustomListView
|
||||||
|
Private trabajos = 0 As Int
|
||||||
|
Dim c As Cursor
|
||||||
|
Private lb_num_folio As Label
|
||||||
|
Private contenido_folio As Panel
|
||||||
|
Private Panel1 As Panel
|
||||||
|
Dim folioactual As String
|
||||||
|
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
|
||||||
|
Root.LoadLayout("seleccion")
|
||||||
|
reqManager.Initialize(Me, Starter.DBReqServer)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
||||||
|
|
||||||
|
Private Sub b_cargar_Click
|
||||||
|
|
||||||
|
If trabajos > 1 Then
|
||||||
|
trabajos = 0
|
||||||
|
End If
|
||||||
|
|
||||||
|
cl_folios.Clear
|
||||||
|
Dim cmd As DBCommand
|
||||||
|
cmd.Initialize
|
||||||
|
cmd.Name = "selec_foliosalmacen_SALMA"
|
||||||
|
cmd.Parameters = Array As Object(Starter.almacen)
|
||||||
|
reqManager.ExecuteQuery(cmd , 0, "foliosalmacen")
|
||||||
|
trabajos = trabajos + 1
|
||||||
|
|
||||||
|
cmd.Name = "select_ALMACEN_CAT_CODIGOS_SALMA"
|
||||||
|
cmd.Parameters = Array As Object(Starter.almacen)
|
||||||
|
reqManager.ExecuteQuery(cmd , 0, "cat_productos")
|
||||||
|
trabajos = trabajos + 1
|
||||||
|
|
||||||
|
cmd.Name = "select_ALMACEN_CAT_EQUIVALENCIAS_SALMA"
|
||||||
|
cmd.Parameters = Array As Object(Starter.almacen)
|
||||||
|
reqManager.ExecuteQuery(cmd , 0, "cat_equivalencias")
|
||||||
|
trabajos = trabajos + 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ProgressDialogShow ("Cargando")
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub CreateListItem(mostrar As String) As Panel
|
||||||
|
Dim p As B4XView = xui.CreatePanel("")
|
||||||
|
p.SetLayoutAnimated(0, 0, 0, 1, 115)
|
||||||
|
p.LoadLayout("cont_folio")
|
||||||
|
p.Height= 65dip
|
||||||
|
' p.Width = clv_orden.GetBase.Width
|
||||||
|
contenido_folio.Width = Panel1.Width
|
||||||
|
lb_num_folio.Height = p.Height *0.8
|
||||||
|
lb_num_folio.Text = mostrar
|
||||||
|
' Log(p.Width)
|
||||||
|
Return p
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub lb_num_folio_Click
|
||||||
|
folioactual = Sender.As(Label).Text
|
||||||
|
B4XPages.ShowPage ("escaneo")
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
Sub JobDone(Job As HttpJob)
|
||||||
|
If Not(Job.Success) Then
|
||||||
|
|
||||||
|
ToastMessageShow("Error: " & Job.ErrorMessage, True)
|
||||||
|
|
||||||
|
Else
|
||||||
|
LogColor("JobDone: '" & reqManager.HandleJob(Job).tag & "' - Registros: " & reqManager.HandleJob(Job).Rows.Size, Colors.Green)
|
||||||
|
If Job.JobName = "DBRequest" Then
|
||||||
|
Dim result As DBResult = reqManager.HandleJob(Job)
|
||||||
|
If result.Tag = "foliosalmacen" Then 'query tag
|
||||||
|
Starter.skmt.ExecNonQuery("delete from CAT_FOLIOS_ALMACEN")
|
||||||
|
For Each records() As Object In result.Rows
|
||||||
|
|
||||||
|
Dim FOLIO_ID As String = records(result.Columns.Get("HIST_EA_ID"))
|
||||||
|
Dim FOLIO_ENTREGA As String = records(result.Columns.Get("HIST_EA_FOLIO_ENTREGA"))
|
||||||
|
Dim FOLIO_REFERENCIA_FACTURA As String = records(result.Columns.Get("HIST_EA_REFERENCIA_FACTURA"))
|
||||||
|
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO CAT_FOLIOS_ALMACEN(FOLIO_ENTREGA, FOLIO_ID, FOLIO_REFERENCIA_FACTURA) VALUES (?,?,?)", Array As Object (FOLIO_ENTREGA,FOLIO_ID,FOLIO_REFERENCIA_FACTURA))
|
||||||
|
|
||||||
|
Next
|
||||||
|
|
||||||
|
c = Starter.skmt.ExecQuery("SELECT FOLIO_REFERENCIA_FACTURA FROM CAT_FOLIOS_ALMACEN")
|
||||||
|
cl_folios.Clear
|
||||||
|
For i = 0 To c.RowCount - 1
|
||||||
|
c.Position = i
|
||||||
|
cl_folios.Add(CreateListItem(c.GetString("FOLIO_REFERENCIA_FACTURA")),i)
|
||||||
|
Next
|
||||||
|
c.Close
|
||||||
|
|
||||||
|
trabajos = trabajos - 1
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
If Job.JobName = "DBRequest" Then
|
||||||
|
Dim result As DBResult = reqManager.HandleJob(Job)
|
||||||
|
If result.Tag = "cat_productos" Then 'query tag
|
||||||
|
Starter.skmt.ExecNonQuery("delete from CAT_PRODUCTOS_ALMACEN")
|
||||||
|
For Each records() As Object In result.Rows
|
||||||
|
|
||||||
|
Dim id As String = records(result.Columns.Get("CAT_GP_ID"))
|
||||||
|
Dim nombre As String = records(result.Columns.Get("CAT_GP_NOMBRE"))
|
||||||
|
Dim cb As String = records(result.Columns.Get("CAT_GP_DUN14"))
|
||||||
|
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO CAT_PRODUCTOS_ALMACEN(CAT_GP_ID, CAT_GP_NOMBRE, CAT_GP_DUN14) VALUES (?,?,?)", Array As Object (id,nombre,cb))
|
||||||
|
|
||||||
|
Next
|
||||||
|
trabajos = trabajos - 1
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
If Job.JobName = "DBRequest" Then
|
||||||
|
Dim result As DBResult = reqManager.HandleJob(Job)
|
||||||
|
If result.Tag = "cat_equivalencias" Then 'query tag
|
||||||
|
Starter.skmt.ExecNonQuery("delete from CAT_EQUIVALENCIAS_ALMACEN")
|
||||||
|
For Each records() As Object In result.Rows
|
||||||
|
|
||||||
|
Dim codigo As String = records(result.Columns.Get("CAT_EQ_CODIGO"))
|
||||||
|
Dim equivalencia As String = records(result.Columns.Get("CAT_EQ_EQUIVALENCIA"))
|
||||||
|
|
||||||
|
Starter.skmt.ExecNonQuery2("INSERT INTO CAT_EQUIVALENCIAS_ALMACEN(CAT_EQ_CODIGO, CAT_EQ_EQUIVALENCIA) VALUES (?,?)", Array As Object (codigo,equivalencia))
|
||||||
|
|
||||||
|
Next
|
||||||
|
trabajos = trabajos - 1
|
||||||
|
End If
|
||||||
|
End If
|
||||||
|
|
||||||
|
If trabajos = 0 Then
|
||||||
|
ProgressDialogHide
|
||||||
|
End If
|
||||||
|
|
||||||
|
End If
|
||||||
|
End Sub
|
||||||
402
B4A/CameraExClass.bas
Normal file
402
B4A/CameraExClass.bas
Normal file
@@ -0,0 +1,402 @@
|
|||||||
|
B4A=true
|
||||||
|
Group=Default Group
|
||||||
|
ModulesStructureVersion=1
|
||||||
|
Type=Class
|
||||||
|
Version=7.28
|
||||||
|
@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
|
||||||
|
|
||||||
|
Public PreviewOrientation As Int
|
||||||
|
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 'ignore
|
||||||
|
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 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
|
||||||
|
PreviewOrientation = (orientation + degrees) Mod 360
|
||||||
|
result = PreviewOrientation
|
||||||
|
PreviewOrientation = (360 - PreviewOrientation) Mod 360
|
||||||
|
Else
|
||||||
|
PreviewOrientation = (orientation - degrees + 360) Mod 360
|
||||||
|
result = PreviewOrientation
|
||||||
|
Log("Preview Orientation: " & PreviewOrientation)
|
||||||
|
End If
|
||||||
|
r.target = nativeCam
|
||||||
|
r.RunMethod2("setDisplayOrientation", PreviewOrientation, "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
|
||||||
|
Sleep(100)
|
||||||
|
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") 'ignore
|
||||||
|
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
|
||||||
|
|
||||||
399
B4A/CameraExClass2.bas
Normal file
399
B4A/CameraExClass2.bas
Normal file
@@ -0,0 +1,399 @@
|
|||||||
|
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
|
||||||
|
|
||||||
272
B4A/DBRequestManager.bas
Normal file
272
B4A/DBRequestManager.bas
Normal file
@@ -0,0 +1,272 @@
|
|||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
BIN
B4A/Files/camara.png
Normal file
BIN
B4A/Files/camara.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
BIN
B4A/Files/cont_folio.bal
Normal file
BIN
B4A/Files/cont_folio.bal
Normal file
Binary file not shown.
BIN
B4A/Files/detalle_folio.bal
Normal file
BIN
B4A/Files/detalle_folio.bal
Normal file
Binary file not shown.
BIN
B4A/Files/escaneo.bal
Normal file
BIN
B4A/Files/escaneo.bal
Normal file
Binary file not shown.
BIN
B4A/Files/fondoalmancen2.png
Normal file
BIN
B4A/Files/fondoalmancen2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 229 KiB |
BIN
B4A/Files/kmt.db
Normal file
BIN
B4A/Files/kmt.db
Normal file
Binary file not shown.
BIN
B4A/Files/lector.png
Normal file
BIN
B4A/Files/lector.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.8 KiB |
BIN
B4A/Files/logo-salma.png
Normal file
BIN
B4A/Files/logo-salma.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 61 KiB |
BIN
B4A/Files/lupa.png
Normal file
BIN
B4A/Files/lupa.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
BIN
B4A/Files/mainpage.bal
Normal file
BIN
B4A/Files/mainpage.bal
Normal file
Binary file not shown.
BIN
B4A/Files/seleccion.bal
Normal file
BIN
B4A/Files/seleccion.bal
Normal file
Binary file not shown.
124
B4A/SALMA-ALMACEN.b4a
Normal file
124
B4A/SALMA-ALMACEN.b4a
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
Build1=Default,b4a.example
|
||||||
|
File1=camara.png
|
||||||
|
File10=seleccion.bal
|
||||||
|
File2=cont_folio.bal
|
||||||
|
File3=detalle_folio.bal
|
||||||
|
File4=escaneo.bal
|
||||||
|
File5=fondoalmancen2.png
|
||||||
|
File6=lector.png
|
||||||
|
File7=logo-salma.png
|
||||||
|
File8=lupa.png
|
||||||
|
File9=MainPage.bal
|
||||||
|
FileGroup1=Default Group
|
||||||
|
FileGroup10=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=accessibility
|
||||||
|
Library10=okhttputils2
|
||||||
|
Library11=phone
|
||||||
|
Library12=randomaccessfile
|
||||||
|
Library13=reflection
|
||||||
|
Library14=runtimepermissions
|
||||||
|
Library15=sql
|
||||||
|
Library16=stringutils
|
||||||
|
Library17=xcustomlistview
|
||||||
|
Library18=xui views
|
||||||
|
Library19=xui
|
||||||
|
Library2=aswheelpicker
|
||||||
|
Library3=b4xpages
|
||||||
|
Library4=bctoast
|
||||||
|
Library5=byteconverter
|
||||||
|
Library6=camera
|
||||||
|
Library7=compressstrings
|
||||||
|
Library8=core
|
||||||
|
Library9=ime
|
||||||
|
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="5" android:targetSdkVersion="28"/>~\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~SetApplicationAttribute(android:usesCleartextTraffic, "true")~\n~'End of default text.~\n~AddApplicationText(~\n~<meta-data~\n~ android:name="com.google.android.geo.API_KEY"~\n~ android:value="AIzaSyBlBnx3O-DncOSv3oFIp-12wgujOYYcl-U"/>~\n~ <meta-data android:name="com.google.android.gms.version"~\n~ android:value="@integer/google_play_services_version" />~\n~)~\n~~\n~AddManifestText(~\n~<uses-permission~\n~ android:name="android.permission.ACCESS_FINE_LOCATION"~\n~ android:maxSdkVersion="30" />~\n~)~\n~AddPermission(android.permission.ACCESS_BACKGROUND_LOCATION)~\n~~\n~AddManifestText(<uses-permission~\n~android:name="android.permission.WRITE_EXTERNAL_STORAGE"~\n~android:maxSdkVersion="28" />~\n~)
|
||||||
|
Module1=|relative|..\B4XMainPage
|
||||||
|
Module2=C_escaneo
|
||||||
|
Module3=C_seleccion
|
||||||
|
Module4=CameraExClass
|
||||||
|
Module5=CameraExClass2
|
||||||
|
Module6=DBRequestManager
|
||||||
|
Module7=Starter
|
||||||
|
Module8=Subs
|
||||||
|
NumberOfFiles=10
|
||||||
|
NumberOfLibraries=19
|
||||||
|
NumberOfModules=8
|
||||||
|
Version=11.8
|
||||||
|
@EndOfDesignText@
|
||||||
|
#Region Project Attributes
|
||||||
|
#ApplicationLabel: SALMA ALMACEN
|
||||||
|
#VersionCode: 1
|
||||||
|
#VersionName:
|
||||||
|
'SupportedOrientations possible values: unspecified, landscape or portrait.
|
||||||
|
#SupportedOrientations: portrait
|
||||||
|
#CanInstallToExternalStorage: False
|
||||||
|
#End Region
|
||||||
|
|
||||||
|
#Region Activity Attributes
|
||||||
|
#FullScreen: False
|
||||||
|
#IncludeTitle: False
|
||||||
|
#End Region
|
||||||
|
#AdditionalJar: com.google.android.gms:play-services-vision
|
||||||
|
'#BridgeLogger: True
|
||||||
|
|
||||||
|
Sub Process_Globals
|
||||||
|
Public ActionBarHomeClicked As Boolean
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Globals
|
||||||
|
Type CameraInfoAndId (CameraInfo As Object, Id As Int)
|
||||||
|
Type CameraSize (Width As Int, Height As Int)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Activity_Create(FirstTime As Boolean)
|
||||||
|
Dim pm As B4XPagesManager
|
||||||
|
pm.Initialize(Activity)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Template version: B4A-1.01
|
||||||
|
#Region Delegates
|
||||||
|
|
||||||
|
Sub Activity_ActionBarHomeClick
|
||||||
|
ActionBarHomeClicked = True
|
||||||
|
B4XPages.Delegate.Activity_ActionBarHomeClick
|
||||||
|
ActionBarHomeClicked = False
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Activity_KeyPress (KeyCode As Int) As Boolean
|
||||||
|
Return B4XPages.Delegate.Activity_KeyPress(KeyCode)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Activity_Resume
|
||||||
|
B4XPages.Delegate.Activity_Resume
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Activity_Pause (UserClosed As Boolean)
|
||||||
|
B4XPages.Delegate.Activity_Pause
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Activity_PermissionResult (Permission As String, Result As Boolean)
|
||||||
|
B4XPages.Delegate.Activity_PermissionResult(Permission, Result)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Create_Menu (Menu As Object)
|
||||||
|
B4XPages.Delegate.Create_Menu(Menu)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
#if Java
|
||||||
|
public boolean _onCreateOptionsMenu(android.view.Menu menu) {
|
||||||
|
processBA.raiseEvent(null, "create_menu", menu);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
#End If
|
||||||
|
#End Region
|
||||||
|
|
||||||
|
'Program code should go into B4XMainPage and other pages.
|
||||||
30
B4A/SALMA-ALMACEN.b4a.meta
Normal file
30
B4A/SALMA-ALMACEN.b4a.meta
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
ModuleBookmarks0=
|
||||||
|
ModuleBookmarks1=
|
||||||
|
ModuleBookmarks2=
|
||||||
|
ModuleBookmarks3=
|
||||||
|
ModuleBookmarks4=
|
||||||
|
ModuleBookmarks5=
|
||||||
|
ModuleBookmarks6=
|
||||||
|
ModuleBookmarks7=
|
||||||
|
ModuleBookmarks8=
|
||||||
|
ModuleBreakpoints0=
|
||||||
|
ModuleBreakpoints1=
|
||||||
|
ModuleBreakpoints2=
|
||||||
|
ModuleBreakpoints3=
|
||||||
|
ModuleBreakpoints4=
|
||||||
|
ModuleBreakpoints5=
|
||||||
|
ModuleBreakpoints6=
|
||||||
|
ModuleBreakpoints7=
|
||||||
|
ModuleBreakpoints8=
|
||||||
|
ModuleClosedNodes0=
|
||||||
|
ModuleClosedNodes1=
|
||||||
|
ModuleClosedNodes2=
|
||||||
|
ModuleClosedNodes3=
|
||||||
|
ModuleClosedNodes4=
|
||||||
|
ModuleClosedNodes5=
|
||||||
|
ModuleClosedNodes6=
|
||||||
|
ModuleClosedNodes7=
|
||||||
|
ModuleClosedNodes8=
|
||||||
|
NavigationStack=C_escaneo,CreateListItem,621,0,C_seleccion,b_cargar_Click,52,0,C_seleccion,JobDone,84,0,Subs,revisaBD,12,0,C_escaneo,B4XPage_Appear,244,0,C_escaneo,B4XPage_CloseRequest,1251,0,C_escaneo,Class_Globals,49,0,Diseñador Visual,escaneo.bal,-100,6,Diseñador Visual,MainPage.bal,-100,1,C_escaneo,B4XPage_Created,228,6
|
||||||
|
SelectedBuild=0
|
||||||
|
VisibleModules=7,1,3,2,8,6,4,5
|
||||||
50
B4A/Starter.bas
Normal file
50
B4A/Starter.bas
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
B4A=true
|
||||||
|
Group=Default Group
|
||||||
|
ModulesStructureVersion=1
|
||||||
|
Type=Service
|
||||||
|
Version=9.85
|
||||||
|
@EndOfDesignText@
|
||||||
|
#Region Service Attributes
|
||||||
|
#StartAtBoot: False
|
||||||
|
#ExcludeFromLibrary: 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.
|
||||||
|
|
||||||
|
Public rp As RuntimePermissions
|
||||||
|
Dim reqManager As DBRequestManager
|
||||||
|
Dim DBReqServer As String = "http://11.0.0.179:1782" '"http://keymon.lat:1782" "http://10.0.0.205:1782" "http://keymon.lat:1783" "http://11.0.0.48:1783" ""' CAMBIAR HACIA AFUERA O DENTRO DE LA OFNA
|
||||||
|
' Dim server As String = "http://10.0.0.205:1782"
|
||||||
|
Dim rutaBD As String = File.DirInternal
|
||||||
|
Dim skmt As SQL
|
||||||
|
Dim almacen As String
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Service_Create
|
||||||
|
'This is the program entry point.
|
||||||
|
'This is a good place to load resources that are not specific to a single activity.
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Service_Start (StartingIntent As Intent)
|
||||||
|
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
|
||||||
|
Subs.revisaBD
|
||||||
|
reqManager.Initialize(Me, DBReqServer)
|
||||||
|
If Not(skmt.IsInitialized) Then skmt.Initialize(rutaBD, "kmt.db", True)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Service_TaskRemoved
|
||||||
|
'This event will be raised when the user removes the app from the recent apps list.
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
'Return true to allow the OS default exceptions handler to handle the uncaught exception.
|
||||||
|
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
|
||||||
|
Return True
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub Service_Destroy
|
||||||
|
|
||||||
|
End Sub
|
||||||
25
B4A/Subs.bas
Normal file
25
B4A/Subs.bas
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
B4A=true
|
||||||
|
Group=Default Group
|
||||||
|
ModulesStructureVersion=1
|
||||||
|
Type=StaticCode
|
||||||
|
Version=11.5
|
||||||
|
@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
|
||||||
|
|
||||||
|
'Revisa que exista la BD y si es necesario crea algunas tablas dentro de ella
|
||||||
|
Sub revisaBD 'ignore
|
||||||
|
If Not(File.Exists(Starter.rutaBD, "kmt.db")) Then File.Copy(File.DirAssets, "kmt.db", Starter.rutaBD, "kmt.db")
|
||||||
|
If Not(Starter.skmt.IsInitialized) Then Starter.skmt.Initialize(Starter.rutaBD, "kmt.db", True)
|
||||||
|
Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS CAT_FOLIOS_ALMACEN(FOLIO_ENTREGA TEXT, FOLIO_ID TEXT, FOLIO_REFERENCIA_FACTURA TEXT)")
|
||||||
|
Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS CAT_PRODUCTOS_ALMACEN(CAT_GP_ID TEXT, CAT_GP_NOMBRE TEXT, CAT_GP_DUN14 TEXT)")
|
||||||
|
Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS CAT_EQUIVALENCIAS_ALMACEN(CAT_EQ_CODIGO TEXT, CAT_EQ_EQUIVALENCIA TEXT)")
|
||||||
|
' Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS CAT_DETALLEFOLIO(CAT_DF_ID TEXT, CAT_DF_NOMBRE TEXT,CAT_DF_RUTA TEXT, CAT_DF_CANTINICIAL TEXT, CAT_DF_CANTIDADESCRITA TEXT)")
|
||||||
|
' Starter.skmt.ExecNonQuery("CREATE TABLE IF NOT EXISTS PICKING (CODIGO TEXT, RUTA TEXT, CANTIDAD_INICIAL TEXT, CANTIDAD_FINAL TEXT,CANTIDAD_ESCRITA TEXT)")
|
||||||
|
' Starter.skmt.ExecNonQuery("DROP TABLE IF EXISTS PICKING")
|
||||||
|
' Starter.skmt.ExecNonQuery("DROP TABLE IF EXISTS CAT_DETALLEFOLIO")
|
||||||
|
End Sub
|
||||||
1
gitpull.bat
Normal file
1
gitpull.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
git pull
|
||||||
Reference in New Issue
Block a user