mirror of
https://github.com/KeymonSoft/Kelloggs_v4.git
synced 2026-04-17 18:26:11 +00:00
184 lines
5.1 KiB
QBasic
184 lines
5.1 KiB
QBasic
B4A=true
|
|
Group=Default Group
|
|
ModulesStructureVersion=1
|
|
Type=Class
|
|
Version=11.5
|
|
@EndOfDesignText@
|
|
Sub Class_Globals
|
|
Private Root As B4XView 'ignore
|
|
Private xui As XUI 'ignore
|
|
'//Process Globals
|
|
Dim ruta As String
|
|
Dim g As GPS
|
|
Private frontCamera As Boolean = False
|
|
Dim quien_llamo As String
|
|
Dim foto_g () As Byte
|
|
Dim foto_g1 () As Byte
|
|
Dim foto_g2 () As Byte
|
|
Dim foto_g3 () As Byte
|
|
Dim foto_g4 () As Byte
|
|
'//Globals
|
|
Dim btnTakePicture As Button
|
|
Dim Panel1 As Panel
|
|
Dim c As Cursor
|
|
Dim cuenta As String
|
|
Dim lat_gps As String
|
|
Dim lon_gps As String
|
|
Private camEx As CameraExClass
|
|
Private i_foto As ImageView
|
|
Private b_guardar As Button
|
|
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.LoadLayout("foto")
|
|
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_CAMERA)
|
|
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
|
|
ruta = File.DirInternal
|
|
End Sub
|
|
|
|
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
|
|
|
|
|
|
Sub Camera1_Ready (Success As Boolean)
|
|
If Success Then
|
|
' camEx.SetJpegQuality(90)
|
|
' camEx.CommitParameters
|
|
Dim ps As CameraSize
|
|
ps.Width =640'480 '1280
|
|
ps.Height =480'360 '960
|
|
camEx.SetPictureSize(ps.Width, ps.Height)
|
|
camEx.CommitParameters
|
|
Try
|
|
camEx.StartPreview
|
|
Catch
|
|
camEx.Release
|
|
Subs.iniciaActividad("CHECKLIST_AUTO")
|
|
End Try
|
|
' Dim ps As CameraSize
|
|
' ps.Width =640 '1280
|
|
' ps.Height =480 '960
|
|
' camEx.SetPictureSize(ps.Width, ps.Height)
|
|
' camEx.CommitParameters
|
|
|
|
' Log(camEx.GetPreviewSize)
|
|
'Msgbox(camEx.GetPreviewSize,"aviso") 'ignore
|
|
Else
|
|
Subs.iniciaActividad("CHECKLIST_AUTO")
|
|
'ToastMessageShow("Cannot open camera.", True)
|
|
End If
|
|
End Sub
|
|
|
|
Sub Activity_Resume
|
|
i_foto.Visible = False
|
|
' If g.GPSEnabled=False Then
|
|
' ToastMessageShow("Habilitar el GPS", True)
|
|
' StartActivity(g.LocationSettingsIntent)
|
|
' Else
|
|
' g.Start(0,0)
|
|
' End If
|
|
InitializeCamera
|
|
btnTakePicture.Enabled = True
|
|
b_guardar.Enabled = False
|
|
End Sub
|
|
|
|
Sub Activity_Pause (UserClosed As Boolean)
|
|
camEx.Release
|
|
End Sub
|
|
|
|
Sub GPS_LocationChanged (Location1 As Location)
|
|
' lat_gps=Location1.ConvertToSeconds(Location1.Latitude)
|
|
' lon_gps=Location1.ConvertToSeconds(Location1.Longitude)
|
|
' 'btnTakePicture.Enabled = True
|
|
' 's.ExecNonQuery2("INSERT INTO HIST_GPS (HGDATE,HGLAT, HGLON) VALUES(?,?,?) ", Array As Object (sDate & sTime, lat_gps, lon_gps))
|
|
End Sub
|
|
|
|
Private Sub InitializeCamera
|
|
camEx.Initialize(Panel1, frontCamera, Me, "Camera1")
|
|
frontCamera = camEx.Front
|
|
End Sub
|
|
|
|
Sub Camera1_PictureTaken (Data() As Byte)
|
|
btnTakePicture.Enabled = True
|
|
Dim filename As String = "2.jpg"
|
|
Dim dir As String = File.DirRootExternal
|
|
camEx.SavePictureToFile(Data, dir, filename)
|
|
camEx.StartPreview 'restart preview
|
|
i_foto.Visible = True
|
|
i_foto.Bitmap = LoadBitmap(File.DirRootExternal, "2.jpg")
|
|
If B4XPages.MainPage.cliente.TOMAR_FOTO = 1 Then
|
|
Dim InputStream1 As InputStream
|
|
InputStream1 = File.OpenInput(File.DirRootExternal, "2.jpg")
|
|
Dim OutputStream1 As OutputStream
|
|
OutputStream1.InitializeToBytesArray(500)
|
|
File.Copy2(InputStream1, OutputStream1)
|
|
foto_g = OutputStream1.ToBytesArray
|
|
End If
|
|
b_guardar.Enabled = True
|
|
camEx.Release
|
|
InitializeCamera
|
|
btnTakePicture.Enabled = True
|
|
End Sub
|
|
|
|
Sub Activity_KeyPress (key As Int) As Boolean
|
|
' BACK key pressed
|
|
If key=KeyCodes.KEYCODE_BACK Then
|
|
' I want to capture the key here so I return True
|
|
B4XPages.ShowPage("Principal")
|
|
'Return True
|
|
End If
|
|
' Returning False signals the system to handle the key
|
|
Return False
|
|
End Sub
|
|
|
|
Sub b_guardar_Click
|
|
camEx.Release
|
|
'If quien_llamo = "1" Then
|
|
Try
|
|
If quien_llamo = "1" Then
|
|
File.Copy(File.DirRootExternal, "2.jpg",File.DirRootExternal, "FOTO1.jpg")
|
|
Subs.iniciaActividad("CHECKLIST_AUTO")
|
|
else if quien_llamo = "2" Then
|
|
File.Copy(File.DirRootExternal, "2.jpg",File.DirRootExternal, "FOTO2.jpg")
|
|
Subs.iniciaActividad("CHECKLIST_AUTO")
|
|
else if quien_llamo = "3" Then
|
|
File.Copy(File.DirRootExternal, "2.jpg",File.DirRootExternal, "FOTO3.jpg")
|
|
Subs.iniciaActividad("CHECKLIST_AUTO")
|
|
else if quien_llamo = "4" Then
|
|
File.Copy(File.DirRootExternal, "2.jpg",File.DirRootExternal, "FOTO4.jpg")
|
|
Subs.iniciaActividad("CHECKLIST_AUTO")
|
|
End If
|
|
If B4XPages.MainPage.cliente.TOMAR_FOTO = 1 Then
|
|
c=Starter.skmt.ExecQuery("select cuenta from cuentaa")
|
|
c.Position = 0
|
|
cuenta = c.GetString("CUENTA")
|
|
c.Close
|
|
Starter.skmt.ExecNonQuery2("INSERT INTO HIST_FOTOS (HF_FOTO, HF_CUENTA, HF_IDENCUESTA) VALUES(?,?,?) ", Array As Object (foto_g,cuenta, B4XPages.MainPage.cliente.id_encuesta ))
|
|
Subs.iniciaActividad("fila")
|
|
End If
|
|
Catch
|
|
Msgbox("ERROR EN FOTO","") 'ignore
|
|
If B4XPages.MainPage.cliente.TOMAR_FOTO = 1 Then
|
|
Subs.iniciaActividad("fila")
|
|
Else
|
|
Subs.iniciaActividad("CHECKLIST_AUTO")
|
|
End If
|
|
End Try
|
|
End Sub
|
|
|
|
Sub btnTakePicture_Click
|
|
btnTakePicture.Enabled = False
|
|
Dim ps As CameraSize
|
|
ps.Width =640'480 '1280
|
|
ps.Height =480'360 '960
|
|
camEx.SetPictureSize(ps.Width, ps.Height)
|
|
camEx.CommitParameters
|
|
camEx.TakePicture
|
|
End Sub |