Commit inicial

This commit is contained in:
2023-09-03 14:24:27 -06:00
parent d228bb8310
commit d267efd961
13 changed files with 2107 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
**/Objects
**/AutoBackups
*.meta

271
DBRequestManager.bas Normal file
View File

@@ -0,0 +1,271 @@
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=6.8
@EndOfDesignText@
'Class module
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 - 211027
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.
'Timeout - The http request timeout in ms, or 0 if default (30 secs)
Public Sub ExecuteQuery(Command As DBCommand, Limit As Int, Tag As Object, Timeout As Int) 'Mod por CHV, agregué el parametro Timeout - 211229
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)
If Timeout <> 0 Then j.GetRequest.Timeout = Timeout
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
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 - 211023
jobTagAnterior = Job.Tag 'Mod por CHV - 211023
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))
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

149
DBRequestManagerV2.bas Normal file
View File

@@ -0,0 +1,149 @@
B4J=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=5.45
@EndOfDesignText@
'Requires support for resumable subs
'Class module
Sub Class_Globals
Private mTarget As Object
Private link As String
Private VERSION As Float = 2
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, Timeout As Int) As HttpJob
Dim ser As B4XSerializator
Dim data() As Byte = ser.ConvertObjectToBytes(CreateMap("command": Command, "limit": Limit, "version": VERSION))
Return SendJob(CreateJob, data, Tag, "query2", Timeout)
End Sub
Private Sub SendJob(j As HttpJob, Data() As Byte, Tag As Object, Method As String, Timeout As Int) As HttpJob
j.Tag = Tag
j.PostBytes(link & "?method=" & Method , Data)
If Timeout <> 0 Then j.GetRequest.Timeout = Timeout
Return j
End Sub
Private Sub CreateJob As HttpJob
Dim j As HttpJob
j.Initialize("DBRequest", mTarget)
Return j
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) As HttpJob
Dim j As HttpJob = CreateJob
ExecuteBatchImpl(j, ListOfCommands, Tag)
Return j
End Sub
Private Sub ExecuteBatchImpl(Job As HttpJob, ListOfCommands As List, Tag As Object)
Dim ser As B4XSerializator
ser.ConvertObjectToBytesAsync(CreateMap("commands": ListOfCommands, "version": VERSION), "ser")
Wait For (ser) ser_ObjectToBytes (Success As Boolean, Bytes() As Byte)
If Success = False Then
Log("Error building command: " & LastException)
Return
End If
Dim ser As B4XSerializator = Sender
SendJob(Job, Bytes, Tag, "batch2", 0)
End Sub
'Similar to ExecuteBatch. Sends a single command.
Public Sub ExecuteCommand(Command As DBCommand, Tag As Object) As HttpJob
Return ExecuteBatch(Array As DBCommand(Command), Tag)
End Sub
'Handles the Job result and returns a DBResult.
'It is recommended to use HandleJobAsync instead.
Public Sub HandleJob(Job As HttpJob) As DBResult
Dim ser As B4XSerializator
Dim data() As Byte = Bit.InputStreamToBytes(Job.GetInputStream)
Dim res As DBResult = ser.ConvertBytesToObject(data)
res.Tag = Job.Tag
Return res
End Sub
'Handles the Job result and raises the Result event when the data is ready.
Public Sub HandleJobAsync(Job As HttpJob, EventName As String)
Dim ser As B4XSerializator
Dim data() As Byte = Bit.InputStreamToBytes(Job.GetInputStream)
ser.ConvertBytesToObjectAsync(data, "ser")
Wait For (ser) ser_BytesToObject (Success As Boolean, NewObject As Object)
If Success = False Then
Log("Error reading response: " & LastException)
Return
End If
Dim res As DBResult = NewObject
res.Tag = Job.Tag
CallSubDelayed2(mTarget, EventName & "_result", res)
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
#if Not(B4J)
'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
#End If
'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
Log(sb.ToString)
Next
End Sub

BIN
Files/cat.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

1
Files/conf.ini Normal file
View File

@@ -0,0 +1 @@
mayusculasDesbloqueo=1

BIN
Files/ew.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
Files/kelloggs.bal Normal file

Binary file not shown.

BIN
Files/layout1.bal Normal file

Binary file not shown.

BIN
Files/logo_keymon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

50
Starter.bas Normal file
View File

@@ -0,0 +1,50 @@
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Service
Version=8.8
@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.
Dim citas As List
Dim confMap As Map
Dim mayusculasDesbloqueo As String = "0"
Dim ruta As String
Dim rp As RuntimePermissions
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.
LogColor("///////////////////////////////////////////////////////////////////////////////////", Colors.Green)
LogColor("////////////////////////////// Iniciamos Starter ///////////////////////////////", Colors.Green)
LogColor("///////////////////////////////////////////////////////////////////////////////////", Colors.Green)
End Sub
Sub Service_Start (StartingIntent As Intent)
citas.Initialize
confMap.Initialize
ruta = File.DirInternal 'Ruta de la configuracion por defecto.
If File.ExternalWritable Then ruta = rp.GetSafeDirDefaultExternal("") 'Si podemos escribir a la tarjeta, cambiamos la ruta.
If Not(File.Exists(ruta, "conf.ini")) Then File.Copy(File.DirAssets, "conf.ini", ruta, "conf.ini") 'Copiamos el archivo de configuracion a la ruta especificada.
Subs.procesaConfiguracion
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

171
Subs.bas Normal file
View File

@@ -0,0 +1,171 @@
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=StaticCode
Version=11.2
@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
'Hace visible el panel con los parametros "Top" y "Left" dados
'y lo hace del ancho y alto de la pantalla
Sub panelVisible(panel As Panel, top As Int, left As Int, actividad As Activity) 'ignore
' panel.BringToFront
panel.Width=actividad.Width
panel.Height=actividad.Height '-(WobbleMenu1.GetHeight-20)
panel.Visible = True
panel.Top = top
panel.Left = left
End Sub
'Oculta el panel especificado y lo manda al fondo
Sub panelOculto(panel As Panel) 'ignore
panel.SendToBack
panel.Visible = False
End Sub
'Centra un boton horizontalmente en el panel superior
Sub centraBotonEnPanel(boton As Button, panel As Panel)
boton.left = (panel.Width/2)-(boton.Width/2)
End Sub
'Centra una etiqueta horizontalmente en el panel superior
Sub centraEtiquetaEnPanel(etiqueta As Label, panel As Panel)
etiqueta.left = (panel.Width/2)-(etiqueta.Width/2)
End Sub
'Centra un campo de texto horizontalmente en el panel superior
Sub centraETEnPanel(et As EditText, panel As Panel)
et.left = (panel.Width/2)-(et.Width/2)
End Sub
'Centra un panel horizontalmente en el panel superior
Sub centraPanelEnPanel(p1 As Panel, panel As Panel)
p1.left = (panel.Width/2)-(p1.Width/2)
End Sub
'Regresa una cita al azar, va borrando cada cita que regresa para que no se repitan, y cuando quedan pocas vuelve a llenar la lista.
Sub dameCita(citas As List) As String
If citas.Size < 2 Then
citas.Add("No les hagas a tus hijos la vida difícil, haciéndoles la vida fácil.")
citas.Add("Nunca subestimes el poder de la estupidez humana.")
citas.Add("Se vive y se aprende ... o no se vive mucho.")
citas.Add("La verdad de una afirmación no tiene nada que ver con su credibilidad ... y viceversa.")
citas.Add("Nunca apeles al ''buen corazón'' de un hombre, puede que no tenga, saldrás ganando si invocas su interés.")
citas.Add("La teología de uno es la carcajada de otro.")
citas.Add("¡Todo en exceso! Para saborear la vida hay que tomarla a grandes tragos, la moderación es para los monjes.")
citas.Add("La generación que ignora la historia no tiene pasado … ni futuro.")
citas.Add("Si no puede expresarse en cifras, no es ciencia, es opinión.")
citas.Add("Escucha siempre a los expertos, te dirán lo que no se puede hacer, y por qué ... entonces ve y hazlo!!")
citas.Add("El juego está arreglado, naturalmente, pero no te detengas por eso: si no apuestas, no puedes ganar.")
citas.Add("Conservarse joven exige el cultivar con tenacidad la capacidad de desaprender las viejas falsedades.")
citas.Add("El dinero es veraz, si un hombre habla de su honor, hazle pagar en efectivo.")
citas.Add("Cuando la tentación se cruce en tu camino, aprovéchala, puede que no vuelva a presentarse.")
citas.Add("La libertad empieza cuando uno manda a la gente a freír espárragos.")
citas.Add("Cuando la tentación se cruce en tu camino, aprovéchala, puede que no vuelva a presentarse.")
End If
Private citaNum As Int = Rnd(1, citas.Size)
' Log(citas.Size & "|" & (citaNum-1))
Private laCita As String = citas.Get(citaNum-1)
citas.RemoveAt(citaNum-1)
Return laCita
End Sub
'Compara dos versiones (string) con el formato "1.10.09", regresa 1 si la primera es mayor, 0 si es igual y -1 si es menor
Sub comparaVersiones(ver1 As String, ver2 As String) As Int
' Logcolor($"${ver1} - ${ver2}"$, Colors.Magenta)
Private m1(), m2() As String
Private pri1, pri2, sec1, sec2, ter1, ter2 As String
m1 = Regex.Split("\.", ver1)
m2 = Regex.Split("\.", ver2)
pri1 = m1(0)
pri2 = m2(0)
' Log(pri1 & "|" & pri2)
If pri1 > pri2 Then Return 1 'Si el primer numero es mayor, regresamos 1
If pri1 < pri2 Then Return -1 'Si el primer numero es menor, regresamos -1
'Si son iguales entones revisamos el segundo numero
If m1.Length > 1 And m2.Length > 1 Then
sec1 = "1." & m1(1)
sec2 = "1." & m2(1)
' Log(sec1 & "|" & sec2)
If sec1 > sec2 Then Return 1 'Si el segundo numero es mayor, regresamos 1
If sec1 < sec2 Then Return -1 'Si el segundo numero es menor, regresamos -1
End If
'Si son iguales entones revisamos el tercer numero
If m1.Length > 2 And m2.Length > 2 Then
ter1 = "1." & m1(2)
ter2 = "1." & m2(2)
' Log(ter1 & "|" & ter2)
If ter1 > ter2 Then Return 1 'Si el tercer numero es mayor, regresamos 1
If ter1 < ter2 Then Return -1 'Si el tercer numero es menor, regresamos -1
End If
Return 0 'Regersamos 0 porque son iguales
End Sub
'Lee un arhchivo de texto y lo convierte en un mapa.
Sub procesaConfiguracion
Private t As String
Private c As List = File.ReadList(Starter.ruta, "conf.ini")
For i = 0 To c.Size - 1
t = c.get(i)
Log(t.IndexOf("="))
If t.IndexOf("=") > -1 Then
Starter.confMap.Put(t.SubString2(0, t.IndexOf("=")), t.SubString(t.IndexOf("=")+1))
Log(Starter.confMap)
End If
Next
If Starter.confMap.ContainsKey("mayusculasDesbloqueo") Then Starter.mayusculasDesbloqueo = Starter.confMap.Get("mayusculasDesbloqueo")
End Sub
'Guarda la configuracion (mapa) en un archivo de texto.
Sub escribreConf
Private l As List
l.Initialize
For Each k As Object In Starter.confMap.Keys
l.Add($"${k}=${Starter.confMap.Get(k)}"$)
Next
Log(l)
File.WriteList(Starter.ruta, "conf.ini", l)
End Sub
'Centra horizontalmente una vista en otra vista.
Sub centraVistaEnVista(v As View, p As View) 'ignore
v.Left = (p.Width/2) - (v.Width/2)
End Sub
'Sets the elevation of a view
Sub SetElevation(v As View, e As Float)
Dim jo As JavaObject
Dim p As Phone
If p.SdkVersion >= 21 Then
jo = v
jo.RunMethod("setElevation", Array As Object(e))
End If
End Sub
'Regresa buenos dias, tardes o noches dependiendo de la hora.
Sub generaSaludo As String
Private saludo As String = ""
If DateTime.GetHour(DateTime.Now) > 4 And DateTime.GetHour(DateTime.Now) < 12 Then saludo = "Buenos dias, "
If DateTime.GetHour(DateTime.Now) >= 12 And DateTime.GetHour(DateTime.Now) < 19 Then saludo = "Buenas tardes, "
If DateTime.GetHour(DateTime.Now) >= 19 Or DateTime.GetHour(DateTime.Now) < 4 Then saludo = "Buenas noches, "
' Log(DateTime.GetHour(DateTime.Now)&"|"&saludo&"|")
Return saludo
End Sub
'Muestra en el Log los campos y valores que regresan en el JobDone.
Sub logJobDoneResultados(resultado As DBResult)
For Each records() As Object In resultado.Rows
LogColor($"====== ${resultado.Tag} - REGISTROS = ${resultado.Rows.Size}"$, Colors.RGB(215,37,0))
For Each k As String In resultado.Columns.Keys
LogColor(k & " = " & records(resultado.Columns.Get(k)), Colors.RGB(215,37,0))
Next
Next
End Sub

37
notis.bas Normal file
View File

@@ -0,0 +1,37 @@
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Service
Version=11.5
@EndOfDesignText@
#Region Service Attributes
#StartAtBoot: False
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Service_Create
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StopAutomaticForeground 'Call this when the background task completes (if there is one)
Service.StartForeground(12345, CreateNotification("..."))
End Sub
Sub Service_Destroy
End Sub
Sub CreateNotification (Body As String) As Notification
Dim notification As Notification
notification.Initialize2(notification.IMPORTANCE_LOW)
notification.Icon = "icon"
notification.SetInfo("Soporte", Body, Main)
Return notification
End Sub

1425
soporteKMS.b4a Normal file

File diff suppressed because it is too large Load Diff