Commit iniical.

This commit is contained in:
2023-09-24 03:29:06 -06:00
commit 9312a24446
50 changed files with 5153 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
**/Objects
**/AutoBackups

24
B4A/B4AProject.b4a.meta Normal file
View File

@@ -0,0 +1,24 @@
ModuleBookmarks0=
ModuleBookmarks1=
ModuleBookmarks2=
ModuleBookmarks3=
ModuleBookmarks4=
ModuleBookmarks5=
ModuleBookmarks6=
ModuleBreakpoints0=
ModuleBreakpoints1=
ModuleBreakpoints2=
ModuleBreakpoints3=
ModuleBreakpoints4=
ModuleBreakpoints5=
ModuleBreakpoints6=
ModuleClosedNodes0=2,6
ModuleClosedNodes1=
ModuleClosedNodes2=
ModuleClosedNodes3=
ModuleClosedNodes4=
ModuleClosedNodes5=
ModuleClosedNodes6=1
NavigationStack=B4XMainPage,b_test_Click,57,0,NotificationService,getGroupName,191,0,NotificationService,getNumberWA,178,0,NotificationService,getGroupName2,200,6,NotificationService,ReplyAuto_NotificationPosted,47,6,NotificationService,regexSimple,121,0,NotificationService,isGroupWA,136,0,NotificationService,isGroupWA2,140,6,NotificationService,isPersonWA,145,6,NotificationService,isPersonWA2,154,6,NotificationService,getPersonFromGroup,205,0
SelectedBuild=0
VisibleModules=1,5,2,3,4

77
B4A/B4XImagenes.bas Normal file
View File

@@ -0,0 +1,77 @@
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=9.86
@EndOfDesignText@
Sub Class_Globals
Private Root As B4XView 'ignore
Private xui As XUI 'ignore
Public cvs As B4XCanvas
Public Panel1 As B4XView
Private i_waImg As ImageView
Private l_imgData As Label
Private clv_imagenes As CustomListView
End Sub
'You can add more parameters here.
Public Sub Initialize
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("Imagenes")
cvs.Initialize(Panel1)
B4XPages.SetTitle(Me, "Imagenes disponibles")
End Sub
Sub B4XPage_Appear
Private losDatos As List = Subs.traeImgMsjData
Private bmp As Bitmap
clv_imagenes.Clear
For i = 0 To losDatos.Size - 1
' Log(losDatos.Get(i).As(Map))
' Log(losDatos.Get(i).As(Map).Get("imgData").As(Map).Get("file_path"))
Private theDir As String = Starter.waDir & "/" & losDatos.Get(i).As(Map).Get("imgData").As(Map).Get("file_path")
' Log(theDir.SubString2(0, theDir.LastIndexOf("/")+1))
' Log(theDir.SubString(theDir.LastIndexOf("/")+1))
If theDir.EndsWith("jpg") Or theDir.EndsWith("png") Then
bmp = LoadBitmap(theDir.SubString2(0, theDir.LastIndexOf("/")+1), theDir.SubString(theDir.LastIndexOf("/")+1))
clv_imagenes.Add(createImgItem(bmp, losDatos.Get(i).As(Map).Get("msjData").As(Map).Get("media_caption"), 386dip, 90dip), losDatos.Get(i))
End If
Next
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Private Sub btnClear_Click
End Sub
Sub btnSet_Click
B4XPages.ClosePage(Me)
End Sub
Sub createImgItem(img As Bitmap, text As String, Width As Int, Height As Int) As Panel
Dim p As B4XView = xui.CreatePanel("")
' Private pLeft = p_rules.left
p.SetLayoutAnimated(0, 0, 0, Width, Height)
p.LoadLayout("imgItem")
i_waImg.Bitmap = img
l_imgData.Text = text
Return p
End Sub
Private Sub clv_imagenes_ItemClick (Index As Int, Value As Object)
If Starter.Logger Then Log(Value)
End Sub
Sub clv_imagenes_ItemLongClick (Index As Int, Value As Object)
B4XPages.MainPage.phv.Vibrate(100)
Subs.mandaWAImageRoot(Null, "Alo Papagena … Tore bella com la papaia", Value)
ToastMessageShow("Imagen mandada.",False)
If starter.Logger Then Log(Value)
End Sub

410
B4A/B4XMainPage.bas Normal file
View File

@@ -0,0 +1,410 @@
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=9.85
@EndOfDesignText@
Sub Class_Globals
Private Root As B4XView 'ignore
Private xui As XUI 'ignore
Public c_reglas As B4XReglas
Public c_imagenes As B4XImagenes
Public Page4 As B4XPage4
Dim rp As RuntimePermissions
Dim phv As PhoneVibrate
Public manager As AdminManager
Dim reqManager As DBRequestManager
Dim cmd As DBCommand
Type lasNotis(numero As String, notif As StatusBarNotification)
' Dim rp As ReplyAuto
Private et_mensaje As EditText
Private lv_notificaciones As ListView
Private EditText1 As EditText
Private b_activo As Button
Private b_p2 As Button
Private b_respaldaBD As Button
Private b_notifAccess As Button
Dim writePermission As Boolean
' Dim Su As SuShell
' Dim Process As SuProcess
' Dim lt As List
Dim notiIcon As Bitmap
Dim OldIntent As Intent
Private b_imgWA As Button
Dim b_config As Button
Dim Timer1 As Timer
Dim interval As Int = 15
Private p_notisDisponibles As Panel
Private b_NotisDisp As Button
Private p_botones As Panel
Private b_cierra As Button
End Sub
'You can add more parameters here.
Public Sub Initialize
StartService(NotificationService)
If Not(NotificationService.notisMap2.IsInitialized) Then NotificationService.notisMap2.Initialize
#if not(DEBUG)
Starter.logger = False
#end if
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Timer1.Initialize("Timer1", interval * 1000)
Timer1.Enabled = True
notiIcon = LoadBitmapResize(File.DirAssets, "chatbot7_191x191.png", 24dip, 24dip, False)
Root = Root1
'load the layout to Root
Root.LoadLayout("mainPage")
B4XPages.SetTitle(Me, "Bow 2.0")
c_reglas.Initialize
B4XPages.AddPage("Reglas", c_reglas)
c_imagenes.Initialize
B4XPages.AddPage("Imagenes", c_imagenes)
#end region
If Starter.logger Then B4XPages.GetManager.LogEvents = True
getWritePermission
getcontactsPermission
End Sub
Sub b4xpage_appear
Dim in As Intent = B4XPages.GetNativeParent(Me).GetStartingIntent 'Traemos en StartingIntent de Main.
If in.IsInitialized And in <> OldIntent Then
OldIntent = in
If in.HasExtra("Notification_Tag") Then 'Revisamos que traiga el tag.
If Starter.logger Then Log("Activity started from notification. Tag: " & in.GetExtra("Notification_Tag"))
Private waChat, nombre As String
Private ts() As String = Regex.Split("\|", in.GetExtra("Notification_Tag"))
waChat = ts(0)
nombre = ts(1)
If Starter.logger Then LogColor($"ts=${ts}, ts.Length=${ts.Length}, waChat=${waChat}, nombre=${nombre}"$, Colors.green)
Starter.historicoDB.ExecNonQuery2("update historico set clic = '1' where clic = '0' and nombre = ?", Array As Object(nombre)) 'Ponemos en 1 las notificacion a las que ya se les dió clic.
CallSubDelayed2(Main, "Activity_KeyPress", KeyCodes.KEYCODE_BACK)
Subs.abreWAChat(waChat)
End If
End If
Subs.centraPanel(p_botones, Root.Width)
If NotificationService.notisMap2.IsInitialized Then llenaLV
If Not(CheckNotificationAccess) Then
Private cd1 As ColorDrawable
cd1.Initialize(Colors.red, 10dip)
b_notifAccess.Background = cd1
b_notifAccess.TextColor = Colors.White
b_notifAccess.Text = "Activar Permisos"
Else
Private cd1 As ColorDrawable
cd1.Initialize(Colors.RGB(109, 221, 101), 10dip)
b_notifAccess.Background = cd1
b_notifAccess.TextColor = Colors.White
b_notifAccess.Text = "Permisos Activos"
End If
' Dim Su As SuShell
' If Su.DeviceRooted Then
' If Starter.logger Then LogColor("Rooted", Colors.Green)
' Private suCmd As String = $"sqlite3 /data/data/com.whatsapp/databases/msgstore.db 'SELECT _id FROM messages WHERE data="Test 2"';"$
'' Private suCmd As String = $"ls"$
' If Su.ExecuteWithEvent(suCmd, "Su").WaitForCompletion Then
' If starter.Logger Then Log("Root - Done")
' Else
' If starter.Logger Then Log("Root - Permissions Error")
' End If
' Else
' If Starter.logger Then LogColor("Root - Device not rooted", Colors.red)
' End If
If Starter.logger Then LogColor("Cola de notificaciones="&NotificationService.notificacionesPorContestar, Colors.RGB(168,0,0))
getAdminRights
End Sub
Sub B4XPage_CloseRequest As ResumableSub
'Return True to close, False to cancel
Return True
End Sub
Sub Su_Start
If Starter.logger Then Log("Su: Start")
End Sub
Sub Su_Command(Command As String, Response() As String)
If Starter.logger Then Log("Su: Command")
Dim Lines As String
For i=0 To Response.Length-1
Lines = Lines & Response(i) & CRLF
Next
' Msgbox(Lines.Trim, Command)
If Starter.logger Then Log(Lines & CRLF)
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Sub b_notifAccess_Click
Dim In As Intent
In.Initialize("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS", "")
StartActivity(In)
End Sub
Sub b_notifAccess_LongClick
Subs.abreWAChat("5215554192439@s.whatsapp.net")
End Sub
Private Sub b_activo_Click
If NotificationService.status = "Servicio Activo" Then
NotificationService.status = "Servicio Apagado"
Private cd1 As ColorDrawable
cd1.Initialize(Colors.red, 10dip)
b_activo.Background = cd1
b_activo.Text = "Servicio Apagado"
NotificationService.cont = 101
StopService(NotificationService)
Else
NotificationService.status = "Servicio Activo"
Private cd1 As ColorDrawable
cd1.Initialize(Colors.RGB(109, 221, 101), 10dip)
b_activo.Background = cd1
b_activo.Text = "Servicio Activo"
NotificationService.cont = 101
StartService(NotificationService)
End If
End Sub
Private Sub b_test_Click
If starter.Logger Then Log("Test clicked")
' If NotificationService.notisMap2.IsInitialized Then EditText1.Text = NotificationService.notisMap2.As(JSON).ToString
' Subs.mandaWAMsjSBN("+52 55 1661 1480", $"Prueba - ${DateTime.Time(DateTime.now)}"$)
' If Starter.logger Then LogColor($"starterStatus=${Starter.starterStatus}, nsStatus=${NotificationService.nsStatus}"$, Colors.Blue)
' CallSubDelayed(NotificationService, "procesaColaDeNotificaciones")
' Private jid As String = "5215516611480"
' Subs.mandaWAMsjRoot("1.- Hola", jid)
reqManager.Initialize(Me, Starter.DBRServer)
cmd.Initialize
cmd.Name = "select_revisaBorrarVenta" 'Intentamos conectarnos al servido publico y si no responde cambiamos al interno.
cmd.Parameters = Array As Object("525554192439","16","4","16","4","16","4","16","4","16","4","525554192439")
reqManager.ExecuteQuery(cmd , 0, "revisaVenta", 750) 'request con timeout corto en ms.
' cmd.Name = "proc_recuperaClientesNuevos"
' cmd.Parameters = Array As Object("35","634","CHATBOT")
' reqManager.ExecuteCommand(cmd ,"procRecuperaClientes")
End Sub
Private Sub b_test_LongClick
' desbloqueaUsuario("CDAZA")
Private cont As Int = 0
For j = 1 To 4
For i = cont To cont+5
cont = cont + 1
If Starter.logger Then LogColor("cont="&cont, Colors.Blue)
If Starter.logger Then LogColor("Mandamos mensaje " & cont, Colors.Magenta)
Subs.mandaWAMsjRoot(cont & ".- Hola", "5215516611480")
' Subs.hazRootQuery("killall com.whatsapp", "KillWA")
Next
If Starter.logger Then LogColor("Iniciamos WA", Colors.Blue)
Subs.hazRootQuery("am start -n com.whatsapp/com.whatsapp.Main", "iniciaWA")
' Try
' Dim Intent1 As Intent
' Dim pm As PackageManager
' Intent1 = pm.GetApplicationIntent("com.whatsapp")
' StartActivity (Intent1)
' Catch
' Log ("Failed to launch app! Is it installed?")
' End Try
If Starter.logger Then LogColor("Esperamos 5 segs", Colors.red)
Sleep(5000)
Next
cont = 0
If Starter.logger Then Log("TERMINAMOS")
' Subs.copyWADB
' Subs.mandaWAImageRoot_0(1)
' Subs.traeImgMsjData
End Sub
Sub llenaLV
' Log("llenaLV")
' lv_notificaciones.Initialize("lv_notificaciones")
lv_notificaciones.Color = Colors.LightGray
lv_notificaciones.Clear
Dim label1 As Label
label1 = lv_notificaciones.SingleLineLayout.Label
label1.TextSize = 16
label1.TextColor = Colors.Black
lv_notificaciones.SingleLineLayout.ItemHeight = 110 'Alto de la opcion de la lista.
label1.Height = 40dip 'Alto de la etiqueta dentro de la opcion de la lista.
' Log(NotificationService.notisMap2.Keys)
For Each k As String In NotificationService.notisMap2.Keys
lv_notificaciones.AddSingleLine(k)
Next
End Sub
Sub lv_notificaciones_ItemClick (Position As Int, Value As Object)
' Log($"posicion: ${Position}, valor: ${Value}, sender: ${Sender}"$)
Private t0 As Map = NotificationService.notisMap2.Get(Value)
Dim t1 As StatusBarNotification = t0.Get(Value).As(lasNotis).notif
' Dim t2 As StatusBarNotification = t1.notif
Subs.abreWAChat(Subs.getShortcut(t1))
End Sub
Private Sub lv_notificaciones_ItemLongClick (Position As Int, Value As Object)
If Starter.logger Then Log($"posicion: ${Position}, valor: ${Value}, sender: ${Sender}"$)
Private tempMap As Map = NotificationService.notisMap2.Get(Value) 'Valeria Guerra Rivera
Private t1 As lasNotis = tempMap.Get(Value)
Private t2 As StatusBarNotification = t1.notif
' Log(t2)
If et_mensaje.Text = "" Then ToastMessageShow("El texto del mensaje no debe estar en blanco.", False)
If t2.IsInitialized And et_mensaje.Text <> "" Then
NotificationService.rp.reply(t2.Notification, t2.PackageName, et_mensaje.text)
' CallSubDelayed3(NotificationService, "guardaMsjSalida", t2, et_mensaje.text)
ToastMessageShow("Mensaje enviado!", False)
End If
End Sub
Private Sub b_p2_Click
B4XPages.ShowPage("Reglas")
End Sub
Private Sub b_respaldaBD_Click
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result Then
Subs.copiaDB
Else
ToastMessageShow("Sin permisos", False)
End If
End Sub
Sub b_respaldaBD_LongClick
Try
File.Copy(File.DirRootExternal&"/Bow2.0","bow.db",File.DirInternal,"bow.db")
ToastMessageShow("Listo, reglas restauradas " & File.DirRootExternal&"/Bow2.0", False)
If Starter.logger Then Log("Listo, reglas restauradas " & File.DirRootExternal&"/Bow2.0")
Subs.traeReglas
Starter.reglasDB.Initialize(Starter.ruta, "bow.db", True)
B4XPages.MainPage.c_reglas.muestraReglas
Catch
ToastMessageShow("No se pudo hacer la copia: "&LastException, True)
End Try
End Sub
Sub CheckNotificationAccess As Boolean
Dim ph As Phone
Dim nstr, pstr As String
Dim r As Reflector
pstr = r.GetStaticField("anywheresoftware.b4a.BA", "packageName")
nstr = ph.GetSettings("enabled_notification_listeners")
Return nstr.Contains(pstr)
End Sub
Sub getcontactsPermission
If Starter.logger Then Log("getcontactsPermission")
rp.CheckAndRequest(rp.PERMISSION_READ_CONTACTS)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
Dim p2 As B4XReglas = B4XPages.GetManager.GetPage("Reglas")
If Result Then
p2.contactsPermission = True
If Starter.logger Then Log(p2.contactsPermission)
Else
p2.contactsPermission = False
If Starter.logger Then Log(p2.contactsPermission)
ToastMessageShow("Sin permisos de contactos", False)
End If
End Sub
Sub getWritePermission
If Starter.logger Then Log("getcontactsPermission")
rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
If Result Then
writePermission = True
If Starter.logger Then Log(writePermission)
Else
writePermission = False
If Starter.logger Then Log(writePermission)
ToastMessageShow("Sin permisos de escritura", False)
End If
End Sub
Private Sub b_imgWA_Click
B4XPages.ShowPage("Imagenes")
End Sub
Sub getAdminRights
If manager.Enabled = False Then
manager.Enable("Please enable in order to get access to the secured server.")
End If
End Sub
Private Sub b_config_Click
Private cd1 As ColorDrawable
cd1.Initialize(Colors.Gray, 10dip)
B4XPages.MainPage.b_config.Background = cd1
NotificationService.pruebaPaso = 0
CallSubDelayed(NotificationService, "revisaConexion")
End Sub
Private Sub Timer1_Tick
' ToastMessageShow("Timer",False)
' ENVIA_ULTIMA_GPS 'Comentado para que no estorbe hasta que no esten los queries correctos en el config.properties
NotificationService.pruebaPaso = 0
CallSubDelayed(NotificationService, "revisaConexion")
End Sub
Private Sub Panel1_Click
If p_notisDisponibles.Visible Then p_notisDisponibles.Visible = False
End Sub
Private Sub p_notisDisponibles_Click
End Sub
Private Sub b_NotisDisp_Click
p_notisDisponibles.Width = Root.Width * 0.9
Subs.centraPanel(p_notisDisponibles, Root.Width)
p_notisDisponibles.Top = (Root.Height/2) - (p_notisDisponibles.Height/2)
lv_notificaciones.Width = p_notisDisponibles.Width * 0.9
lv_notificaciones.Left = (p_notisDisponibles.Width/2) - (lv_notificaciones.Width/2)
b_cierra.Left = p_notisDisponibles.Width - (b_cierra.Width + 10)
et_mensaje.Width = p_notisDisponibles.Width * 0.8
p_notisDisponibles.BringToFront
p_botones.SendToBack
p_notisDisponibles.Visible = True
End Sub
Private Sub b_cierra_Click
p_notisDisponibles.Visible = False
End Sub
Sub JobDone(Job As HttpJob) 'ignore
If Starter.logger Then LogColor("jobDone: " & Job.Tag, Colors.Magenta)
If Job.Success = False Then
If Starter.Logger Then LogColor("***** jobDone Error *****", Colors.Red)
If Starter.Logger Then LogColor(Job.ErrorMessage, Colors.Red)
Else
If Starter.Logger Then LogColor("JobDone: '" & reqManager.HandleJob(Job).tag & "' - Registros: " & reqManager.HandleJob(Job).Rows.Size, Colors.Green) 'Mod por CHV - 211027
If Job.JobName = "DBRequest" Then 'Para desbloquear un usuario Guna.
Dim result As DBResult = reqManager.HandleJob(Job)
If Starter.Logger Then Log("******************************************************")
If Starter.Logger Then Log($"************ ${result.Tag} ***********"$)
If Starter.Logger Then Log("******************************************************")
If result.Tag=="revisaVenta" Then 'query tag
Private num As String = result.Tag
num = num.SubString(num.IndexOf("_")+1)
If Starter.logger Then Log(num)
For Each records() As Object In result.Rows
For Each k As String In result.Columns.Keys
If Starter.logger Then LogColor(result.Tag & ": " & k & "=" & records(result.Columns.Get(k)), Colors.blue)
Next
' Dim autorizado As String = records(result.Columns.Get("AUTORIZADO"))
' Dim existe_venta As String = records(result.Columns.Get("EXISTE_VENTA"))
' Dim impresa As String = records(result.Columns.Get("IMPRESA"))
' Dim comercial As String = records(result.Columns.Get("COMERCIAL"))
' Dim condescuento As String = records(result.Columns.Get("CONDESCUENTO"))
Next
End If
End If
Job.Release
End If
End Sub

598
B4A/B4XPage2.bas Normal file
View File

@@ -0,0 +1,598 @@
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=9.86
@EndOfDesignText@
Sub Class_Globals
Private Root As B4XView 'ignore
Private xui As XUI 'ignore
Dim ime As IME 'ignore
' Private lblHello As B4XView
Private ImageView1 As B4XView 'ignore
' Private Page3 As B4XPage3
Private CustomListView1 As CustomListView 'ignore
' Private Tree As CLVTree
' Private b_colapsa As Button
' Private b_expande As Button
' Private Panel2 As Panel
Private clv_reglas2 As CustomListView
Private et_regla As EditText
Private p_rules As Panel
Private l_tit As Label
' Private l_rule As Label
Private p_reglas As Panel
Private l_tit2 As Label
Private et_regla2 As EditText
Private cb_activa As CheckBox
Private l_regla As Label
Private p_editarRegla As Panel
Private et_nombre As EditText
Private b_cancelar As Button
Private et_entra As EditText
Private et_sale As EditText
Private l_sale As Label
Private l_regla_1 As Label
Private l_regla_2 As Label
Private p_separador As Panel
Private r_destinatario_p As RadioButton
Private r_destinatario_g As RadioButton
Private r_destinatario_a As RadioButton
Dim destinatario As String = "Personas"
Private l_flecha As Label
Private fb_add As cvFloatingBtn
Private p_msgBox As Panel
Private l_msgBoxTitle As Label
Private l_msgBoxText As Label
Private b_msgBoxYes As Button
Private b_msgBoxNo As Button
Private p_sombra As Panel
Private p_contestacion As Panel
Private l_sale2 As Label
Private et_sale2 As EditText
Private p_recibimos As Panel
Private l_entra As Label
Private p_contactosEspecificos As Panel
Private et_contEsp As EditText
Private l_contEsp As Label
Dim contactsPermission As Boolean = False
Private clv_contactPicker As CustomListView
Private PCLV As PreoptimizedCLV
Private l_contact As Label
Private cb_selectContact As CheckBox
Private p_contacts As Panel
Private p_contactPicker As Panel
Dim contactosEspecificos As List
Private p_conEsp As Panel
Private b_guardaConEsp As Button
Private et_conEsp As EditText
Private et_conEsp2 As EditText
Private b_getContacts As Button
Dim listaReglasContestaciones As List
Private b_addET As Button
Private ScrollView1 As ScrollView
End Sub
'You can add more parameters here.
Public Sub Initialize
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("Page2")
' Root.LoadLayout("floatbutton_layout")
B4XPages.SetTitle(Me, "Reglas")
' Page3 = B4XPages.GetPage("Page 3")
contactosEspecificos.Initialize
PCLV.Initialize(Me, "PCLV", clv_contactPicker)
PCLV_AddItems
muestraReglas
End Sub
Private Sub B4XPage_Appear
' NotificationService.mapReglas = Subs.traeReglas
' clv_reglas2.Clear
' clv_reglas2.PressedColor = Colors.Transparent
' For Each m As Map In NotificationService.mapReglas.Values
' clv_reglas2.Add(CreateListItem(m.get("id"), m.get("nombre"), "Recibimos:", m.Get("recibe"), "Contestamos:", m.Get("contesta"), m.Get("activa"), 386dip, 90dip), m.get("id"))
' Next
' p_editarRegla.Visible = False
' p_sombra.Visible = False
' p_reglas.Width = Root.Width - 20
' Subs.centraPanel(p_editarRegla, Root.Width)
End Sub
Sub clv_contactPicker_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
For Each i As Int In PCLV.VisibleRangeChanged(FirstIndex, LastIndex)
Dim item As CLVItem = clv_contactPicker.GetRawListItem(i)
Dim pnl As B4XView = xui.CreatePanel("")
pnl.Color = Colors.White
item.Color = Colors.White
item.Panel.AddView(pnl, 0, 0, item.Panel.Width, item.Panel.Height)
'Create the item layout
pnl.LoadLayout("contactItem")
cb_selectContact.Tag = item.Value
l_contact.Text = item.Value
Next
End Sub
Sub PCLV_AddItems
For Each contact As String In Subs.getContactos
PCLV.AddItem(40dip, xui.Color_White, contact)
Next
PCLV.Commit
End Sub
'Return the hint that will be displayed when the user fast scrolls the list. It can be a string or CSBuilder.
Sub PCLV_HintRequested (Index As Int) As Object
Dim word As String = clv_contactPicker.GetValue(Index)
Return word
End Sub
Sub muestraReglas
NotificationService.mapReglas = Subs.traeReglas
' Log("mapReglas=" & NotificationService.mapReglas)
clv_reglas2.Clear
clv_reglas2.PressedColor = Colors.Transparent
' clv_reglas2.AsView.Color = Colors.red
For Each m As Map In NotificationService.mapReglas.Values
clv_reglas2.Add(CreateListItem(m.get("id"), m.get("nombre"), "Recibimos:", m.Get("recibe"), "Contestamos:", m.Get("contesta"), m.Get("activa"), 386dip, 90dip), m.get("id"))
Next
p_editarRegla.Visible = False
p_sombra.Visible = False
p_reglas.Width = Root.Width - 20
p_sombra.Width = Root.Width
p_sombra.Height = Root.Height
Subs.centraPanel(p_editarRegla, Root.Width)
Subs.centraPanel(p_sombra, Root.Width)
End Sub
Sub CreateListItem(id As Int, nom As String, tit As String, rule As String, tit2 As String, rule2 As String, activa As Int, Width As Int, Height As Int) As Panel
Dim p As B4XView = xui.CreatePanel("")
Dim active As Boolean = False
' Private pLeft = p_rules.left
If activa = 1 Then active = True
p.SetLayoutAnimated(0, 0, 0, Width, Height)
p.LoadLayout("ruleItem")
l_tit.Text = tit
l_regla_1.Text = rule
l_tit2.Text = tit2
l_regla_2.Text = rule2
Subs.SetButtonTintList(cb_activa, Colors.red, Colors.RGB(7, 183, 0))
If nom.IndexOf(".") > -1 Then
Private cuantos As Int = Subs.CountChars(nom, ".")
' Log(cuantos)
Private leftOffs As Int = 15
If cuantos > 0 Then leftOffs = leftOffs * cuantos
p_rules.Left = p_rules.Left + leftOffs
p_rules.Width = p_rules.Width - leftOffs
l_regla_1.Width = l_regla_1.Width - leftOffs
l_regla_2.Width = l_regla_2.Width - leftOffs
cb_activa.Left = cb_activa.Left - leftOffs
Dim cd1 As ColorDrawable
cd1.Initialize2(Colors.White, 30, 5, Colors.Red)
l_regla.TextColor = Colors.red
' l_flecha.TextColor = Colors.red
' p_rules.Color = Colors.RGB(209, 0, 0)
p_rules.Background = cd1
If cuantos > 0 Then
l_flecha.Visible = True
l_regla.Left = l_regla.Left + 40
' If cuantos = 2 Then p_rules.Color = Colors.RGB(134, 246, 126)
' If cuantos > 2 Then p_rules.Color = Colors.RGB(217, 217, 217)
If cuantos = 2 Then
cd1.Initialize2(Colors.White, 30, 5, Colors.Gray)
l_regla.TextColor = Colors.Gray
' l_flecha.TextColor = Colors.Gray
End If
If cuantos = 3 Then
cd1.Initialize2(Colors.White, 30, 6, Colors.RGB(255, 140, 125))
l_regla.TextColor = Colors.RGB(255, 140, 125)
' l_flecha.TextColor = Colors.RGB(255, 140, 125)
End If
If cuantos > 3 Then
cd1.Initialize2(Colors.White, 30, 6, Colors.RGB(250, 161, 38))
l_regla.TextColor = Colors.RGB(250, 161, 38)
' l_regla.TextColor = Colors.RGB(250, 161, 38)
End If
p_rules.Background = cd1
End If
End If
Dim su As StringUtils
' recalculate new heights
' Dim prhTemp As Int = p_rules.Height
l_regla_1.height = su.MeasureMultilineTextHeight(l_regla_1, l_regla_1.Text)
l_regla_2.height = su.MeasureMultilineTextHeight(l_regla_2, l_regla_2.Text)
p_separador.Top = l_regla_1.Top + l_regla_1.Height + 10
l_tit2.Top = p_separador.Top + 20
l_regla_2.Top = l_tit2.top
p_rules.Height = l_regla_1.Height + l_regla_2.Height + 110
p.SetLayoutAnimated(0, 0, 0, Width, p_rules.Height +10)
cb_activa.Checked = active
cb_activa.Tag = id
l_regla.Text = nom
l_regla.Tag = id
Return p
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Sub b_1_Click
' B4XPages.ShowPage("Page 3")
End Sub
Sub btnSignOut_Click
' Page3.ClearImage
' UpdateImage
' B4XPages.ShowPageAndRemovePreviousPages("MainPage")
End Sub
Private Sub cb_activa_CheckedChange(Checked As Boolean)
Dim chk As CheckBox = Sender
' if starter.showLogs then Log(Checked & " | " & chk.tag )
If chk.Tag <> Null And chk.Tag <> "" Then
Dim p_regla As Panel = Sender.As(View).Parent.As(Panel)
' if starter.showLogs then Log("|"&p_regla.NumberOfViews)
Private idRegla As Int = chk.tag
Private activa As Boolean = Checked
' Private recibimos As String = p_regla.GetView(1).as(Label).text
' Private mandamos As String = p_regla.GetView(3).as(Label).text
If Starter.showLogs Then Log("|"&p_regla.GetView(5))
Subs.guardaRegla(idRegla, activa)
NotificationService.mapReglas = Subs.traeReglas
End If
' Log(NotificationService.mapReglas)
End Sub
'Borramos la regla.
Sub cb_activa_LongClick
Private chk As CheckBox = Sender
If Starter.showLogs Then Log(chk.tag)
p_msgBox.Top = (Root.Height/2) - (p_msgBox.Height/2)
Subs.centraPanel(p_msgBox, Root.Width)
l_msgBoxTitle.Text = "Borrar regla"
l_msgBoxText.text = $"¿Seguro que desea borrar la regla ${chk.tag}?"$
p_msgBox.Visible = True
b_msgBoxYes.Tag = chk.tag
p_msgBox.Tag = clv_reglas2.GetItemFromView(Sender.As(View))
If Starter.showLogs Then LogColor(p_msgBox.tag, Colors.Magenta)
' if starter.showLogs then LogColor(clv_reglas2.Size,Colors.Magenta)
End Sub
Private Sub b_msgBoxYes_Click
p_msgBox.Visible = False
If Starter.showLogs Then Log(Sender.As(Button).tag)
Subs.borrarRegla(Sender.As(Button).tag)
NotificationService.mapReglas = Subs.traeReglas
' B4XPage_Appear
clv_reglas2.RemoveAt(p_msgBox.Tag)
' muestraReglas
End Sub
Private Sub b_msgBoxNo_Click
p_msgBox.Visible = False
End Sub
Sub p_msgBox_Click
'Do nothing
End Sub
Private Sub et_regla_TextChanged (Old As String, New As String)
Dim p_regla As Panel = Sender.As(View).Parent.As(Panel)
Private cb As CheckBox = p_regla.GetView(2)
cb.Checked = False
' Log(cb.checked)
End Sub
Private Sub et_regla2_TextChanged (Old As String, New As String)
Dim p_regla As Panel = Sender.As(View).Parent.As(Panel)
Private cb As CheckBox = p_regla.GetView(2)
cb.Checked = False
' Log(cb.checked)
End Sub
Private Sub L_regla_LongClick
' et_nombre.Text = Sender.As(Label).text
' et_nombre.Tag = Sender.As(Label).tag
' Log(Sender.As(Label))
'' Log(Sender.As(Label).Tag & "|"&NotificationService.mapReglas)
' Private d As Map = NotificationService.mapReglas.Get(Sender.As(Label).tag)
'' Log(d)
' et_entra.Text = d.Get("recibe")
' et_sale.Text = d.Get("contesta")
' p_editarRegla.visible = True
' RecalculateHeightViews
End Sub
Private Sub b_guardar_Click
For i = 0 To listaReglasContestaciones.Size -1
et_sale.Text = et_sale.Text & "//" & listaReglasContestaciones.Get(i).As(EditText).text
Next
if starter.showLogs then Log(et_sale.text)
Subs.actualizaRegla(et_nombre.Tag, et_nombre.text, et_entra.Text, et_sale.text, r_destinatario_p.tag, et_contEsp.text)
' NotificationService.mapReglas = Subs.traeReglas
muestraReglas
p_editarRegla.Visible = False
p_sombra.Visible = False
ime.HideKeyboard
End Sub
Private Sub b_cancelar_Click
p_editarRegla.Visible = False
p_editarRegla.SendToBack
' ScrollView1.Visible = False
p_sombra.Visible = False
ime.HideKeyboard
End Sub
Sub RecalculateHeightViews
' Log("Recalcula")
Dim su As StringUtils
'Recalculate new heights
et_entra.height = su.MeasureMultilineTextHeight(et_entra, et_entra.Text) + 60
et_sale.height = su.MeasureMultilineTextHeight(et_sale, et_sale.Text)+ 60
et_contEsp.Height = su.MeasureMultilineTextHeight(et_contEsp, et_contEsp.Text)+ 60
p_recibimos.Height = et_entra.Height + 20
p_contestacion.Height = et_sale.Height + 20
p_contactosEspecificos.Height = et_contEsp.Height + 20
' Recalculate new vertical positions
p_recibimos.Top =l_entra.Top + l_entra.Height + 5
l_sale.Top = p_recibimos.Top + p_recibimos.height + 5
p_contestacion.Top = l_sale.Top + l_sale.height + 5
If listaReglasContestaciones.Size > 0 Then
For j = 0 To listaReglasContestaciones.Size - 1
listaReglasContestaciones.Get(j).As(EditText).Height = su.MeasureMultilineTextHeight(listaReglasContestaciones.Get(j).As(EditText), listaReglasContestaciones.Get(j).As(EditText).Text) + 60
p_contestacion.Height = p_contestacion.Height + listaReglasContestaciones.Get(j).As(EditText).Height - 15
Next
End If
ScrollView1.Panel.Height = p_recibimos.Height + p_contestacion.Height + p_contactosEspecificos.Height + 500
For n = 0 To listaReglasContestaciones.Size - 1
If n = 0 Then
listaReglasContestaciones.Get(n).As(EditText).Top = et_sale.Top + et_sale.Height - 15
Else if n > 0 Then
listaReglasContestaciones.Get(n).As(EditText).Top = listaReglasContestaciones.Get(n-1).As(EditText).Top + listaReglasContestaciones.Get(n-1).As(EditText).Height - 15
End If
' LogColor(listaReglasContestaciones.Get(n).As(EditText).Top, Colors.red)
Next
r_destinatario_p.Top = p_contestacion.Top + p_contestacion.Height
r_destinatario_g.Top = r_destinatario_p.top
r_destinatario_a.Top = r_destinatario_p.top
l_contEsp.Top = r_destinatario_p.Top + r_destinatario_p.Height
b_addET.Top = l_sale.top - 1
b_getContacts.Top = l_contEsp.top - 5
p_contactosEspecificos.Top = l_contEsp.Top + l_contEsp.Height
End Sub
Private Sub et_entra_TextChanged (Old As String, New As String)
RecalculateHeightViews
End Sub
Private Sub et_sale_TextChanged (Old As String, New As String)
RecalculateHeightViews
End Sub
Private Sub et_sale2_TextChanged (Old As String, New As String)
RecalculateHeightViews
End Sub
Private Sub et_contEsp_TextChanged (Old As String, New As String)
RecalculateHeightViews
End Sub
Private Sub clv_reglas2_ItemClick (Index As Int, Value As Object)
If Starter.showLogs Then Log(Index &"|" & Value)
listaReglasContestaciones.Initialize
' p_editarRegla.Visible = True
' p_editarRegla.BringToFront
ScrollView1.Panel.RemoveAllViews
ScrollView1.Panel.LoadLayout("editaRegla")
ScrollView1.Height = p_editarRegla.Height * 0.9
ScrollView1.Panel.Height = ScrollView1.Height
Private et_sale As EditText
et_sale.Initialize("et_sale")
et_sale.TextColor = Colors.Black
et_sale.TextSize = 12
p_contestacion.RemoveAllViews
p_contestacion.AddView(et_sale, 10, 10, (p_contestacion.Width*0.95), 30dip)
Private d As Map = NotificationService.mapReglas.Get(Value)
If Starter.showLogs Then Log(d)
et_entra.InputType = Bit.Or(0x00080000, 0x00000090) 'TYPE_TEXT_FLAG_NO_SUGGESTIONS | TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
et_entra.SingleLine = False
et_sale.InputType = Bit.Or(0x00080000, 0x00000090) 'TYPE_TEXT_FLAG_NO_SUGGESTIONS | TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
et_sale.SingleLine = False
et_contEsp.InputType = Bit.Or(0x00080000, 0x00000090) 'TYPE_TEXT_FLAG_NO_SUGGESTIONS | TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
et_contEsp.SingleLine = False
et_nombre.Tag = Value
et_nombre.Text = d.Get("nombre")
et_entra.Text = d.Get("recibe")
Private ets() As String = Regex.Split("//", d.Get("contesta")) 'Dividimos el regla en sus multiples respuestas.
' et_sale.Text = d.Get("contesta")
et_sale.Text = ets(0).trim
If ets.Length > 1 Then
For x = 1 To ets.Length - 1
addET(ets(x).Trim)
Next
End If
destinatario = "Personas"
If d.Get("destinatario") <> Null Then destinatario = d.Get("destinatario")
If destinatario = "Personas" Then r_destinatario_p.Checked = True
If destinatario = "Grupos" Then r_destinatario_g.Checked = True
If destinatario = "Ambos" Then r_destinatario_a.Checked = True
et_contEsp.Text = d.Get("contactoEspecifico")
r_destinatario_p.Tag = destinatario
p_editarRegla.visible = True
p_sombra.Visible = True
If Starter.showLogs Then Log(contactsPermission)
' If contactsPermission Then
' Dim res As List = InputMultiList(Subs.getContactos, "Select")
' Log(res)
' End If
RecalculateHeightViews
End Sub
Private Sub r_destinatario_p_CheckedChange(Checked As Boolean)
If Starter.showLogs Then Log(Sender.As(RadioButton).text & "|" &Checked)
destinatario = Sender.As(RadioButton).text
r_destinatario_p.Tag = destinatario
End Sub
Private Sub r_destinatario_g_CheckedChange(Checked As Boolean)
If Starter.showLogs Then Log(Sender.As(RadioButton).text & "|" &Checked)
destinatario = Sender.As(RadioButton).text
r_destinatario_p.Tag = destinatario
End Sub
Private Sub r_destinatario_a_CheckedChange(Checked As Boolean)
' Log(Sender.As(RadioButton).text & "|" &Checked)
destinatario = Sender.As(RadioButton).text
r_destinatario_p.Tag = destinatario
End Sub
'Agregamos regla.
Sub fb_add_Clicked(X As Float,Y As Float)
' ToastMessageShow("Button Clicked",False)
Subs.agregaRegla
NotificationService.mapReglas = Subs.traeReglas
' B4XPage_Appear
muestraReglas
End Sub
Private Sub B4XPage_CloseRequest As ResumableSub
Sleep(0)
If Starter.showLogs Then Log("B4XPage_CloseRequest")
' if starter.showLogs then Log(p_contactPicker.Visible)
If p_contactPicker.Visible = True Then
p_contactPicker.Visible = False
Return False
End If
If p_editarRegla.Visible Then
p_editarRegla.Visible = False
p_sombra.Visible = False
Return False
End If
Return True
End Sub
Private Sub p_editarRegla_Click
'Nothing here.
End Sub
Private Sub p_sombra_Click
'Nothing here.
End Sub
Sub muestraContactos
If Starter.showLogs Then Log("muestraContactos")
p_contactPicker.Visible = True
ime.HideKeyboard
p_contactPicker.left = 0
p_contactPicker.Top = 0
p_contactPicker.Width = Root.Width
p_contactPicker.Height = Root.Height
clv_contactPicker.GetBase.SetLayoutAnimated(0, 5dip, 30dip, Root.Width - 10, Root.Height * 0.68) 'Cambiamos el tamaño y posición de la lista de productos
clv_contactPicker.Base_Resize(clv_contactPicker.GetBase.Width, clv_contactPicker.GetBase.Height) 'Cambiamos el tamaño del panel interno de la lista para que ajuste al nuevo tamaño.
p_conEsp.Top = clv_contactPicker.GetBase.Top + clv_contactPicker.GetBase.Height + 20
b_guardaConEsp.top = p_conEsp.Top + p_conEsp.Height + 20
End Sub
Sub CreateContactsItem(nom As String, Width As Int, Height As Int) As Panel 'ignore
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, Width, Height)
p.LoadLayout("contactItem")
l_contact.Text = nom
p_contacts.Height = Height
' Log($"${p_contacts.Height}, ${l_contact.Height}"$)
cb_selectContact.Top = (p_contacts.Height/2) - (cb_selectContact.Height/2)
l_contact.Top = (p_contacts.Height/2) - (l_contact.Height/2)
Subs.SetButtonTintList(cb_selectContact, Colors.red, Colors.RGB(7, 183, 0))
cb_selectContact.Tag = nom
l_contact.Text = nom
Return p
End Sub
Private Sub clv_contactPicker_ItemClick (Index As Int, Value As Object)
' Log($"${Index}, ${Value}"$ )
Dim cb As CheckBox = clv_contactPicker.GetPanel(Index).GetView(0).GetView(0)
If cb.Checked Then cb.Checked = False Else cb.Checked = True
End Sub
Private Sub et_contEsp_FocusChanged (HasFocus As Boolean)
' If HasFocus Then
' muestraContactos
' End If
End Sub
Private Sub cb_selectContact_CheckedChange(Checked As Boolean)
if starter.showLogs then Log(Sender.As(CheckBox).tag)
et_conEsp2.Text = ""
If Checked Then
contactosEspecificos.Add(Sender.As(CheckBox).tag) 'Si no está en la lista, lo agregamos.
Else
If contactosEspecificos.IndexOf(Sender.As(CheckBox).tag) > -1 Then
contactosEspecificos.RemoveAt(contactosEspecificos.IndexOf(Sender.As(CheckBox).tag)) 'Si ya esta en la lista lo quitamos.
End If
End If
' if starter.showLogs then Log(contactosEspecificos)
For Each c In contactosEspecificos
If et_conEsp2.Text <> "" Then et_conEsp2.Text = et_conEsp2.Text & ", " & c Else et_conEsp2.Text = c
Next
End Sub
Private Sub b_guardaConEsp_Click
Dim l As List
l.initialize
Dim t() As String = Regex.Split(",", et_contEsp.text)
For i = 0 To t.Length-1
l.add(t(i).trim)
Next
contactosEspecificos.AddAll(l)
contactosEspecificos = Subs.removeListDuplicates(contactosEspecificos)
et_contEsp.Text = ""
For Each c In contactosEspecificos
If et_contEsp.Text <> "" Then et_contEsp.Text = et_contEsp.Text & ", " & c Else et_contEsp.Text = c
Next
et_contEsp.text = et_contEsp.text.Replace(", ,", ",")
p_contactPicker.Visible = False
et_conEsp2.Text = ""
contactosEspecificos.Clear
clv_contactPicker.Clear
PCLV_AddItems
End Sub
Private Sub b_getContacts_Click
muestraContactos
End Sub
Sub addET(texto As String)
Dim etX As EditText
etX.Initialize("etX")
etX.TextColor = Colors.Black
etX.TextSize = 12
etX.Tag = listaReglasContestaciones.size
listaReglasContestaciones.add(etX)
Dim newTop As Int = et_sale.top + et_sale.Height
If listaReglasContestaciones.Size > 0 Then
For k = 0 To listaReglasContestaciones.Size - 1
newTop = newTop + listaReglasContestaciones.Get(k).As(EditText).Height
Next
End If
p_contestacion.AddView(etX, et_sale.left, newTop, et_sale.Width, 35dip)
etX.Text = texto
End Sub
Private Sub b_addET_Click
addET("")
' Log("Agregamos ET, " & listaReglasContestaciones.size & "|" & etX.Tag & ", top=" & newTop)
RecalculateHeightViews
' Log(etX.top)
End Sub
Sub etX_TextChanged (Old As String, New As String)
' Log(Sender.As(EditText).tag)
RecalculateHeightViews
End Sub

77
B4A/B4XPage3.bas Normal file
View File

@@ -0,0 +1,77 @@
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=9.86
@EndOfDesignText@
Sub Class_Globals
Private Root As B4XView 'ignore
Private xui As XUI 'ignore
Public cvs As B4XCanvas
Public Panel1 As B4XView
End Sub
'You can add more parameters here.
Public Sub Initialize
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("Page3")
cvs.Initialize(Panel1)
B4XPages.SetTitle(Me, "Draw Something")
#if B4A
B4XPages.AddMenuItem(Me, "Random Background")
#End If
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Sub Panel1_Touch (Action As Int, X As Float, Y As Float)
If Action <> Panel1.TOUCH_ACTION_MOVE_NOTOUCH Then
cvs.DrawCircle(X, Y, 10dip, Rnd(xui.Color_Black, xui.Color_White), True, 0)
cvs.Invalidate
End If
End Sub
Private Sub btnClear_Click
ClearImage
End Sub
Public Sub ClearImage
If Panel1.IsInitialized Then
cvs.ClearRect(cvs.TargetRect)
cvs.Invalidate
End If
End Sub
Sub btnSet_Click
B4XPages.ClosePage(Me)
End Sub
Sub B4XPage_Resize (Width As Int, Height As Int)
ClearImage
cvs.Resize(Width, Height)
End Sub
Sub B4XPage_MenuClick (Tag As String)
If Tag = "Random Background" Then
cvs.DrawRect(cvs.TargetRect, Rnd(xui.Color_Black, xui.Color_White), True, 0)
cvs.Invalidate
End If
End Sub
#if B4J
'Delegate the native menu action to B4XPage_MenuClick.
Sub MenuBar1_Action
Dim mi As MenuItem = Sender
Dim t As String
If mi.Tag = Null Then t = mi.Text.Replace("_", "") Else t = mi.Tag
B4XPage_MenuClick(t)
End Sub
#End If

24
B4A/B4XPage4.bas Normal file
View File

@@ -0,0 +1,24 @@
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=11.45
@EndOfDesignText@
Sub Class_Globals
Private Root As B4XView 'ignore
Private xui As XUI 'ignore
End Sub
'You can add more parameters here.
Public Sub Initialize As Object
Return Me
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
'load the layout to Root
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

609
B4A/B4XReglas.bas Normal file
View File

@@ -0,0 +1,609 @@
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=9.86
@EndOfDesignText@
Sub Class_Globals
Private Root As B4XView 'ignore
Private xui As XUI 'ignore
Dim ime As IME 'ignore
' Private lblHello As B4XView
Private ImageView1 As B4XView 'ignore
' Private Page3 As B4XPage3
Private CustomListView1 As CustomListView 'ignore
' Private Tree As CLVTree
' Private b_colapsa As Button
' Private b_expande As Button
' Private Panel2 As Panel
Private clv_reglas2 As CustomListView
Private et_regla As EditText
Private p_rules As Panel
Private l_tit As Label
' Private l_rule As Label
Private p_reglas As Panel
Private l_tit2 As Label
Private et_regla2 As EditText
Private cb_activa As CheckBox
Private l_regla As Label
Private p_editarRegla As Panel
Private et_nombre As EditText
Private b_cancelar As Button
Private et_entra As EditText
Private et_sale As EditText
Private l_sale As Label
Private l_regla_1 As Label
Private l_regla_2 As Label
Private p_separador As Panel
Private r_destinatario_p As RadioButton
Private r_destinatario_g As RadioButton
Private r_destinatario_a As RadioButton
Dim destinatario As String = "Personas"
Private l_flecha As Label
Private fb_add As cvFloatingBtn
Private p_msgBox As Panel
Private l_msgBoxTitle As Label
Private l_msgBoxText As Label
Private b_msgBoxYes As Button
Private b_msgBoxNo As Button
Private p_sombra As Panel
Private p_contestacion As Panel
Private l_sale2 As Label
Private et_sale2 As EditText
Private p_recibimos As Panel
Private l_entra As Label
Private p_contactosEspecificos As Panel
Private et_contEsp As EditText
Private l_contEsp As Label
Dim contactsPermission As Boolean = False
Private clv_contactPicker As CustomListView
Private PCLV As PreoptimizedCLV
Private l_contact As Label
Private cb_selectContact As CheckBox
Private p_contacts As Panel
Private p_contactPicker As Panel
Dim contactosEspecificos As List
Private p_conEsp As Panel
Private b_guardaConEsp As Button
Private et_conEsp As EditText
Private et_conEsp2 As EditText
Private b_getContacts As Button
Dim listaReglasContestaciones As List
Private b_addET As Button
Private ScrollView1 As ScrollView
Private l_idRegla As Label
End Sub
'You can add more parameters here.
Public Sub Initialize
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("Reglas")
' Root.LoadLayout("floatbutton_layout")
B4XPages.SetTitle(Me, "Reglas")
' Page3 = B4XPages.GetPage("Page 3")
contactosEspecificos.Initialize
PCLV.Initialize(Me, "PCLV", clv_contactPicker)
PCLV_AddItems
muestraReglas
End Sub
Private Sub B4XPage_Appear
If Starter.logger Then Log("======================= REGLAS =====================")
Subs.traeReglas
' NotificationService.mapReglas = Subs.traeReglas
' clv_reglas2.Clear
' clv_reglas2.PressedColor = Colors.Transparent
' For Each m As Map In NotificationService.mapReglas.Values
' clv_reglas2.Add(CreateListItem(m.get("id"), m.get("nombre"), "Recibimos:", m.Get("recibe"), "Contestamos:", m.Get("contesta"), m.Get("activa"), 386dip, 90dip), m.get("id"))
' Next
' p_editarRegla.Visible = False
' p_sombra.Visible = False
' p_reglas.Width = Root.Width - 20
' Subs.centraPanel(p_editarRegla, Root.Width)
End Sub
Sub clv_contactPicker_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
For Each i As Int In PCLV.VisibleRangeChanged(FirstIndex, LastIndex)
Dim item As CLVItem = clv_contactPicker.GetRawListItem(i)
Dim pnl As B4XView = xui.CreatePanel("")
pnl.Color = Colors.White
item.Color = Colors.White
item.Panel.AddView(pnl, 0, 0, item.Panel.Width, item.Panel.Height)
'Create the item layout
pnl.LoadLayout("contactItem")
cb_selectContact.Tag = item.Value
l_contact.Text = item.Value
Next
End Sub
Sub PCLV_AddItems
For Each contact As String In Subs.getContactos
PCLV.AddItem(40dip, xui.Color_White, contact)
Next
PCLV.Commit
End Sub
'Return the hint that will be displayed when the user fast scrolls the list. It can be a string or CSBuilder.
Sub PCLV_HintRequested (Index As Int) As Object
Dim word As String = clv_contactPicker.GetValue(Index)
Return word
End Sub
Sub muestraReglas
NotificationService.mapReglas = Subs.traeReglas
' Log("mapReglas=" & NotificationService.mapReglas)
clv_reglas2.Clear
clv_reglas2.PressedColor = Colors.Transparent
' clv_reglas2.AsView.Color = Colors.red
For Each m As Map In NotificationService.mapReglas.Values
clv_reglas2.Add(CreateListItem(m.get("id"), m.get("nombre"), "Recibimos:", m.Get("recibe"), "Contestamos:", m.Get("contesta"), m.Get("activa"), 386dip, 90dip), m.get("id"))
Next
p_editarRegla.Visible = False
p_sombra.Visible = False
p_reglas.Width = Root.Width
p_reglas.Height = Root.Height - 20
fb_add.Top = p_reglas.Height - 50dip
fb_add.Left = p_reglas.Width - 50dip
clv_reglas2.GetBase.SetLayoutAnimated(0, 5dip, 5dip, Root.Width + 10, Root.Height) 'Cambiamos el tamaño y posición de la lista de reglas
clv_reglas2.Base_Resize(clv_reglas2.GetBase.Width, clv_reglas2.GetBase.Height) 'Cambiamos el tamaño del panel interno de la lista para que ajuste al nuevo tamaño.
p_sombra.Width = Root.Width
p_sombra.Height = Root.Height
If Starter.logger Then Log($"${Root.Width}, ${p_reglas.Width}, ${p_sombra.Width}, ${clv_reglas2.AsView.Width }"$)
Subs.centraPanel(p_editarRegla, Root.Width)
' Subs.centraPanel(p_sombra, Root.Width)
End Sub
Sub CreateListItem(id As Int, nom As String, tit As String, rule As String, tit2 As String, rule2 As String, activa As Int, Width As Int, Height As Int) As Panel
Dim p As B4XView = xui.CreatePanel("")
Dim active As Boolean = False
' Private pLeft = p_rules.left
If activa = 1 Then active = True
p.SetLayoutAnimated(0, 0, 0, Width, Height)
p.LoadLayout("ruleItem")
l_tit.Text = tit
l_regla_1.Text = rule
l_tit2.Text = tit2
l_regla_2.Text = rule2
p_rules.Width = Root.Width - 10dip
Subs.SetButtonTintList(cb_activa, Colors.red, Colors.RGB(7, 183, 0))
If nom.IndexOf(".") > -1 Then
Private cuantos As Int = Subs.CountChars(nom, ".")
' Log(cuantos)
Private leftOffs As Int = 15
If cuantos > 0 Then leftOffs = leftOffs * cuantos
p_rules.Left = p_rules.Left + leftOffs
p_rules.Width = p_rules.Width - leftOffs
l_regla_1.Width = l_regla_1.Width - leftOffs
l_regla_2.Width = l_regla_2.Width - leftOffs
cb_activa.Left = cb_activa.Left - leftOffs
Dim cd1 As ColorDrawable
cd1.Initialize2(Colors.White, 30, 5, Colors.Red)
l_regla.TextColor = Colors.red
' l_flecha.TextColor = Colors.red
' p_rules.Color = Colors.RGB(209, 0, 0)
p_rules.Background = cd1
If cuantos > 0 Then
l_flecha.Visible = True
l_regla.Left = l_regla.Left + 40
' If cuantos = 2 Then p_rules.Color = Colors.RGB(134, 246, 126)
' If cuantos > 2 Then p_rules.Color = Colors.RGB(217, 217, 217)
If cuantos = 2 Then
cd1.Initialize2(Colors.White, 30, 5, Colors.Gray)
l_regla.TextColor = Colors.Gray
' l_flecha.TextColor = Colors.Gray
End If
If cuantos = 3 Then
cd1.Initialize2(Colors.White, 30, 6, Colors.RGB(255, 140, 125))
l_regla.TextColor = Colors.RGB(255, 140, 125)
' l_flecha.TextColor = Colors.RGB(255, 140, 125)
End If
If cuantos > 3 Then
cd1.Initialize2(Colors.White, 30, 6, Colors.RGB(250, 161, 38))
l_regla.TextColor = Colors.RGB(250, 161, 38)
' l_regla.TextColor = Colors.RGB(250, 161, 38)
End If
p_rules.Background = cd1
End If
End If
Dim su As StringUtils
' recalculate new heights
' Dim prhTemp As Int = p_rules.Height
l_regla_1.height = su.MeasureMultilineTextHeight(l_regla_1, l_regla_1.Text)
l_regla_2.height = su.MeasureMultilineTextHeight(l_regla_2, l_regla_2.Text)
p_separador.Top = l_regla_1.Top + l_regla_1.Height + 10
l_tit2.Top = p_separador.Top + 20
l_regla_2.Top = l_tit2.top
p_rules.Height = l_regla_1.Height + l_regla_2.Height + 110
p.SetLayoutAnimated(0, 0, 0, Width, p_rules.Height +10)
cb_activa.Checked = active
cb_activa.Tag = id
l_regla.Text = nom
l_regla.Tag = id
Return p
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Sub b_1_Click
' B4XPages.ShowPage("Page 3")
End Sub
Sub btnSignOut_Click
' Page3.ClearImage
' UpdateImage
' B4XPages.ShowPageAndRemovePreviousPages("MainPage")
End Sub
Private Sub cb_activa_CheckedChange(Checked As Boolean)
Dim chk As CheckBox = Sender
' if starter.showLogs then Log(Checked & " | " & chk.tag )
If chk.Tag <> Null And chk.Tag <> "" Then
Dim p_regla As Panel = Sender.As(View).Parent.As(Panel)
' if starter.showLogs then Log("|"&p_regla.NumberOfViews)
Private idRegla As Int = chk.tag
Private activa As Boolean = Checked
' Private recibimos As String = p_regla.GetView(1).as(Label).text
' Private mandamos As String = p_regla.GetView(3).as(Label).text
If Starter.showLogs Then Log("|"&p_regla.GetView(5))
Subs.guardaRegla(idRegla, activa)
NotificationService.mapReglas = Subs.traeReglas
End If
' Log(NotificationService.mapReglas)
End Sub
'Borramos la regla.
Sub cb_activa_LongClick
Private chk As CheckBox = Sender
If Starter.showLogs Then Log(chk.tag)
p_msgBox.Top = (Root.Height/2) - (p_msgBox.Height/2)
Subs.centraPanel(p_msgBox, Root.Width)
l_msgBoxTitle.Text = "Borrar regla"
l_msgBoxText.text = $"¿Seguro que desea borrar la regla ${chk.tag}?"$
p_msgBox.Visible = True
b_msgBoxYes.Tag = chk.tag
p_msgBox.Tag = clv_reglas2.GetItemFromView(Sender.As(View))
If Starter.showLogs Then LogColor(p_msgBox.tag, Colors.Magenta)
' if starter.showLogs then LogColor(clv_reglas2.Size,Colors.Magenta)
End Sub
Private Sub b_msgBoxYes_Click
p_msgBox.Visible = False
If Starter.showLogs Then Log(Sender.As(Button).tag)
Subs.borrarRegla(Sender.As(Button).tag)
NotificationService.mapReglas = Subs.traeReglas
' B4XPage_Appear
clv_reglas2.RemoveAt(p_msgBox.Tag)
' muestraReglas
End Sub
Private Sub b_msgBoxNo_Click
p_msgBox.Visible = False
End Sub
Sub p_msgBox_Click
'Do nothing
End Sub
Private Sub et_regla_TextChanged (Old As String, New As String)
Dim p_regla As Panel = Sender.As(View).Parent.As(Panel)
Private cb As CheckBox = p_regla.GetView(2)
cb.Checked = False
' Log(cb.checked)
End Sub
Private Sub et_regla2_TextChanged (Old As String, New As String)
Dim p_regla As Panel = Sender.As(View).Parent.As(Panel)
Private cb As CheckBox = p_regla.GetView(2)
cb.Checked = False
' Log(cb.checked)
End Sub
Private Sub L_regla_LongClick
' et_nombre.Text = Sender.As(Label).text
' et_nombre.Tag = Sender.As(Label).tag
' Log(Sender.As(Label))
'' Log(Sender.As(Label).Tag & "|"&NotificationService.mapReglas)
' Private d As Map = NotificationService.mapReglas.Get(Sender.As(Label).tag)
'' Log(d)
' et_entra.Text = d.Get("recibe")
' et_sale.Text = d.Get("contesta")
' p_editarRegla.visible = True
' RecalculateHeightViews
End Sub
Private Sub b_guardar_Click
For i = 0 To listaReglasContestaciones.Size -1
et_sale.Text = et_sale.Text & "//" & listaReglasContestaciones.Get(i).As(EditText).text
Next
If Starter.showLogs Then Log(et_sale.text)
Subs.actualizaRegla(et_nombre.Tag, et_nombre.text, et_entra.Text, et_sale.text, r_destinatario_p.tag, et_contEsp.text)
' NotificationService.mapReglas = Subs.traeReglas
muestraReglas
p_editarRegla.Visible = False
p_sombra.Visible = False
ime.HideKeyboard
End Sub
Private Sub b_cancelar_Click
p_editarRegla.Visible = False
p_editarRegla.SendToBack
' ScrollView1.Visible = False
p_sombra.Visible = False
ime.HideKeyboard
End Sub
Sub RecalculateHeightViews
' Log("Recalcula")
Dim su As StringUtils
'Recalculate new heights
et_entra.height = su.MeasureMultilineTextHeight(et_entra, et_entra.Text) + 60
et_sale.height = su.MeasureMultilineTextHeight(et_sale, et_sale.Text)+ 60
et_contEsp.Height = su.MeasureMultilineTextHeight(et_contEsp, et_contEsp.Text)+ 60
p_recibimos.Height = et_entra.Height + 20
p_contestacion.Height = et_sale.Height + 20
p_contactosEspecificos.Height = et_contEsp.Height + 20
' Recalculate new vertical positions
p_recibimos.Top =l_entra.Top + l_entra.Height + 5
l_sale.Top = p_recibimos.Top + p_recibimos.height + 5
p_contestacion.Top = l_sale.Top + l_sale.height + 5
If listaReglasContestaciones.Size > 0 Then
For j = 0 To listaReglasContestaciones.Size - 1
listaReglasContestaciones.Get(j).As(EditText).Height = su.MeasureMultilineTextHeight(listaReglasContestaciones.Get(j).As(EditText), listaReglasContestaciones.Get(j).As(EditText).Text) + 60
p_contestacion.Height = p_contestacion.Height + listaReglasContestaciones.Get(j).As(EditText).Height - 15
Next
End If
ScrollView1.Panel.Height = p_recibimos.Height + p_contestacion.Height + p_contactosEspecificos.Height + 500
For n = 0 To listaReglasContestaciones.Size - 1
If n = 0 Then
listaReglasContestaciones.Get(n).As(EditText).Top = et_sale.Top + et_sale.Height - 15
Else if n > 0 Then
listaReglasContestaciones.Get(n).As(EditText).Top = listaReglasContestaciones.Get(n-1).As(EditText).Top + listaReglasContestaciones.Get(n-1).As(EditText).Height - 15
End If
' LogColor(listaReglasContestaciones.Get(n).As(EditText).Top, Colors.red)
Next
r_destinatario_p.Top = p_contestacion.Top + p_contestacion.Height
r_destinatario_g.Top = r_destinatario_p.top
r_destinatario_a.Top = r_destinatario_p.top
l_contEsp.Top = r_destinatario_p.Top + r_destinatario_p.Height
b_addET.Top = l_sale.top - 1
b_getContacts.Top = l_contEsp.top - 5
p_contactosEspecificos.Top = l_contEsp.Top + l_contEsp.Height
End Sub
Private Sub et_entra_TextChanged (Old As String, New As String)
RecalculateHeightViews
End Sub
Private Sub et_sale_TextChanged (Old As String, New As String)
RecalculateHeightViews
End Sub
Private Sub et_sale2_TextChanged (Old As String, New As String)
RecalculateHeightViews
End Sub
Private Sub et_contEsp_TextChanged (Old As String, New As String)
RecalculateHeightViews
End Sub
Private Sub clv_reglas2_ItemClick (Index As Int, Value As Object)
If Starter.showLogs Then Log(Index &"|" & Value)
listaReglasContestaciones.Initialize
' p_editarRegla.Visible = True
' p_editarRegla.BringToFront
ScrollView1.Panel.RemoveAllViews
ScrollView1.Panel.LoadLayout("editaRegla")
ScrollView1.Height = p_editarRegla.Height * 0.9
ScrollView1.Panel.Height = ScrollView1.Height
Private et_sale As EditText
et_sale.Initialize("et_sale")
et_sale.TextColor = Colors.Black
et_sale.TextSize = 15
p_contestacion.RemoveAllViews
p_contestacion.AddView(et_sale, 10, 10, (p_contestacion.Width*0.95), 30dip)
Private d As Map = NotificationService.mapReglas.Get(Value)
If Starter.showLogs Then Log(d)
et_entra.InputType = Bit.Or(0x00080000, 0x00000090) 'TYPE_TEXT_FLAG_NO_SUGGESTIONS | TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
et_entra.SingleLine = False
et_sale.InputType = Bit.Or(0x00080000, 0x00000090) 'TYPE_TEXT_FLAG_NO_SUGGESTIONS | TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
et_sale.SingleLine = False
et_contEsp.InputType = Bit.Or(0x00080000, 0x00000090) 'TYPE_TEXT_FLAG_NO_SUGGESTIONS | TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
et_contEsp.SingleLine = False
et_nombre.Tag = Value
et_nombre.Text = d.Get("nombre")
l_idRegla.Text = "(" & d.Get("id") & ")"
et_entra.Text = d.Get("recibe")
Private ets() As String = Regex.Split("//", d.Get("contesta")) 'Dividimos el regla en sus multiples respuestas.
' et_sale.Text = d.Get("contesta")
et_sale.Text = ets(0).trim
If ets.Length > 1 Then
For x = 1 To ets.Length - 1
addET(ets(x).Trim)
Next
End If
destinatario = "Personas"
If d.Get("destinatario") <> Null Then destinatario = d.Get("destinatario")
If destinatario = "Personas" Then r_destinatario_p.Checked = True
If destinatario = "Grupos" Then r_destinatario_g.Checked = True
If destinatario = "Ambos" Then r_destinatario_a.Checked = True
et_contEsp.Text = d.Get("contactoEspecifico")
r_destinatario_p.Tag = destinatario
p_editarRegla.visible = True
p_sombra.Visible = True
If Starter.showLogs Then Log(contactsPermission)
' If contactsPermission Then
' Dim res As List = InputMultiList(Subs.getContactos, "Select")
' Log(res)
' End If
RecalculateHeightViews
End Sub
Private Sub r_destinatario_p_CheckedChange(Checked As Boolean)
If Starter.showLogs Then Log(Sender.As(RadioButton).text & "|" &Checked)
destinatario = Sender.As(RadioButton).text
r_destinatario_p.Tag = destinatario
End Sub
Private Sub r_destinatario_g_CheckedChange(Checked As Boolean)
If Starter.showLogs Then Log(Sender.As(RadioButton).text & "|" &Checked)
destinatario = Sender.As(RadioButton).text
r_destinatario_p.Tag = destinatario
End Sub
Private Sub r_destinatario_a_CheckedChange(Checked As Boolean)
' Log(Sender.As(RadioButton).text & "|" &Checked)
destinatario = Sender.As(RadioButton).text
r_destinatario_p.Tag = destinatario
End Sub
'Agregamos regla.
Sub fb_add_Clicked(X As Float,Y As Float)
' ToastMessageShow("Button Clicked",False)
Subs.agregaRegla
NotificationService.mapReglas = Subs.traeReglas
' B4XPage_Appear
muestraReglas
End Sub
Private Sub B4XPage_CloseRequest As ResumableSub
Sleep(0)
If Starter.showLogs Then Log("B4XPage_CloseRequest")
' if starter.showLogs then Log(p_contactPicker.Visible)
If p_contactPicker.Visible = True Then
p_contactPicker.Visible = False
Return False
End If
If p_editarRegla.Visible Then
p_editarRegla.Visible = False
p_sombra.Visible = False
Return False
End If
Return True
End Sub
Private Sub p_editarRegla_Click
'Nothing here.
End Sub
Private Sub p_sombra_Click
'Nothing here.
End Sub
Sub muestraContactos
If Starter.showLogs Then Log("muestraContactos")
p_contactPicker.Visible = True
ime.HideKeyboard
p_contactPicker.left = 0
p_contactPicker.Top = 0
p_contactPicker.Width = Root.Width
p_contactPicker.Height = Root.Height
clv_contactPicker.GetBase.SetLayoutAnimated(0, 5dip, 30dip, Root.Width - 10, Root.Height * 0.68) 'Cambiamos el tamaño y posición de la lista de productos
clv_contactPicker.Base_Resize(clv_contactPicker.GetBase.Width, clv_contactPicker.GetBase.Height) 'Cambiamos el tamaño del panel interno de la lista para que ajuste al nuevo tamaño.
p_conEsp.Top = clv_contactPicker.GetBase.Top + clv_contactPicker.GetBase.Height + 20
b_guardaConEsp.top = p_conEsp.Top + p_conEsp.Height + 20
End Sub
Sub CreateContactsItem(nom As String, Width As Int, Height As Int) As Panel 'ignore
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, Width, Height)
p.LoadLayout("contactItem")
l_contact.Text = nom
p_contacts.Height = Height
' Log($"${p_contacts.Height}, ${l_contact.Height}"$)
cb_selectContact.Top = (p_contacts.Height/2) - (cb_selectContact.Height/2)
l_contact.Top = (p_contacts.Height/2) - (l_contact.Height/2)
Subs.SetButtonTintList(cb_selectContact, Colors.red, Colors.RGB(7, 183, 0))
cb_selectContact.Tag = nom
l_contact.Text = nom
Return p
End Sub
Private Sub clv_contactPicker_ItemClick (Index As Int, Value As Object)
' Log($"${Index}, ${Value}"$ )
Dim cb As CheckBox = clv_contactPicker.GetPanel(Index).GetView(0).GetView(0)
If cb.Checked Then cb.Checked = False Else cb.Checked = True
End Sub
Private Sub et_contEsp_FocusChanged (HasFocus As Boolean)
' If HasFocus Then
' muestraContactos
' End If
End Sub
Private Sub cb_selectContact_CheckedChange(Checked As Boolean)
If Starter.showLogs Then Log(Sender.As(CheckBox).tag)
et_conEsp2.Text = ""
If Checked Then
contactosEspecificos.Add(Sender.As(CheckBox).tag) 'Si no está en la lista, lo agregamos.
Else
If contactosEspecificos.IndexOf(Sender.As(CheckBox).tag) > -1 Then
contactosEspecificos.RemoveAt(contactosEspecificos.IndexOf(Sender.As(CheckBox).tag)) 'Si ya esta en la lista lo quitamos.
End If
End If
' if starter.showLogs then Log(contactosEspecificos)
For Each c In contactosEspecificos
If et_conEsp2.Text <> "" Then et_conEsp2.Text = et_conEsp2.Text & ", " & c Else et_conEsp2.Text = c
Next
End Sub
Private Sub b_guardaConEsp_Click
Dim l As List
l.initialize
Dim t() As String = Regex.Split(",", et_contEsp.text)
For i = 0 To t.Length-1
l.add(t(i).trim)
Next
contactosEspecificos.AddAll(l)
contactosEspecificos = Subs.removeListDuplicates(contactosEspecificos)
et_contEsp.Text = ""
For Each c In contactosEspecificos
If et_contEsp.Text <> "" Then et_contEsp.Text = et_contEsp.Text & ", " & c Else et_contEsp.Text = c
Next
et_contEsp.text = et_contEsp.text.Replace(", ,", ",")
p_contactPicker.Visible = False
et_conEsp2.Text = ""
contactosEspecificos.Clear
clv_contactPicker.Clear
PCLV_AddItems
End Sub
Private Sub b_getContacts_Click
muestraContactos
End Sub
Sub addET(texto As String)
Dim etX As EditText
etX.Initialize("etX")
etX.TextColor = Colors.Black
etX.TextSize = 12
etX.Tag = listaReglasContestaciones.size
listaReglasContestaciones.add(etX)
Dim newTop As Int = et_sale.top + et_sale.Height
If listaReglasContestaciones.Size > 0 Then
For k = 0 To listaReglasContestaciones.Size - 1
newTop = newTop + listaReglasContestaciones.Get(k).As(EditText).Height
Next
End If
p_contestacion.AddView(etX, et_sale.left, newTop, et_sale.Width, 35dip)
etX.Text = texto
End Sub
Private Sub b_addET_Click
addET("")
' Log("Agregamos ET, " & listaReglasContestaciones.size & "|" & etX.Tag & ", top=" & newTop)
RecalculateHeightViews
' Log(etX.top)
End Sub
Sub etX_TextChanged (Old As String, New As String)
' Log(Sender.As(EditText).tag)
RecalculateHeightViews
End Sub

271
B4A/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)
If Starter.logger Then 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
If Starter.logger Then 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

271
B4A/DBRequestManagerV1.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
B4A/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
B4A/Files/add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

BIN
B4A/Files/add2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
B4A/Files/contactitem.bal Normal file

Binary file not shown.

BIN
B4A/Files/editaregla.bal Normal file

Binary file not shown.

BIN
B4A/Files/errores.db Normal file

Binary file not shown.

Binary file not shown.

BIN
B4A/Files/imagenes.bal Normal file

Binary file not shown.

BIN
B4A/Files/imgitem.bal Normal file

Binary file not shown.

BIN
B4A/Files/mainpage.bal Normal file

Binary file not shown.

BIN
B4A/Files/page2.bal Normal file

Binary file not shown.

BIN
B4A/Files/page3.bal Normal file

Binary file not shown.

BIN
B4A/Files/reglas.bal Normal file

Binary file not shown.

BIN
B4A/Files/reglas.db Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

BIN
B4A/Files/robot_192x192.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

BIN
B4A/Files/ruleitem.bal Normal file

Binary file not shown.

1042
B4A/NotificationService.bas Normal file

File diff suppressed because it is too large Load Diff

154
B4A/ReplyAuto.b4a Normal file
View File

@@ -0,0 +1,154 @@
Build1=Default,chv.bow2
File1=add.png
File10=imgItem.bal
File11=mainPage.bal
File12=Page2.bal
File13=Page3.bal
File14=Reglas.bal
File15=reglas.db
File16=robot_192x192.png
File17=robot3_191x191.png
File18=robot4_191x191.png
File19=robot8_191x191.png
File2=add2.png
File20=robotic_191x191.png
File21=robot-icons_2_191x191.png
File22=ruleItem.bal
File3=chatbot6_191x191.png
File4=chatbot7_191x191.png
File5=contactItem.bal
File6=editaRegla.bal
File7=errores.db
File8=floatButton_layout.bal
File9=Imagenes.bal
FileGroup1=Default Group
FileGroup10=Default Group
FileGroup11=Default Group
FileGroup12=Default Group
FileGroup13=Default Group
FileGroup14=Default Group
FileGroup15=Default Group
FileGroup16=Default Group
FileGroup17=Default Group
FileGroup18=Default Group
FileGroup19=Default Group
FileGroup2=Default Group
FileGroup20=Default Group
FileGroup21=Default Group
FileGroup22=Default Group
FileGroup3=Default Group
FileGroup4=Default Group
FileGroup5=Default Group
FileGroup6=Default Group
FileGroup7=Default Group
FileGroup8=Default Group
FileGroup9=Default Group
Group=Default Group
Library1=administrator
Library10=phone
Library11=preoptimizedclv
Library12=randomaccessfile
Library13=reflection
Library14=runtimepermissions
Library15=sql
Library16=stringutils
Library17=xui views
Library18=replyauto
Library2=b4xpages
Library3=byteconverter
Library4=contentresolver
Library5=core
Library6=javaobject
Library7=json
Library8=nb6
Library9=okhttputils2
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="26"/>~\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~SetApplicationAttribute(android:usesCleartextTraffic, "true")~\n~CreateResourceFromFile(Macro, Themes.LightTheme)~\n~'End of default text.~\n~SetActivityAttribute(main, android:windowSoftInputMode, adjustPan|stateHidden)~\n~AddPermission("android.permission.READ_CONTACTS")~\n~SetApplicationAttribute(android:theme, "@style/LightTheme")~\n~CreateResource(values, colors.xml,~\n~<resources>~\n~ <color name="actionbar">#FFE30000</color>~\n~ <color name="statusbar">#FFE30000</color>~\n~ <color name="textColorPrimary">#FFFFFFFF</color>~\n~ <color name="navigationBar">#FFE30000</color>~\n~</resources>~\n~)~\n~CreateResource(values-v20, theme.xml,~\n~<resources>~\n~ <style name="LightTheme" parent="@android:style/Theme.Material.Light">~\n~ <item name="android:colorPrimary">#FFE30000</item>~\n~ <item name="android:colorPrimaryDark">#FFE30000</item>~\n~ <item name="android:textColorPrimary">@color/textColorPrimary</item>~\n~ <item name="android:navigationBarColor">@color/navigationBar</item>~\n~ </style>~\n~</resources>~\n~)~\n~~\n~AddApplicationText(~\n~<service android:name="b4a.jsaplication.com.br.ReplyAuto"~\n~ android:label="Bow2"~\n~ android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">~\n~ <intent-filter>~\n~ <action android:name="android.service.notification.NotificationListenerService" />~\n~ </intent-filter>~\n~ </service>)~\n~AddManifestText(~\n~<uses-permission~\n~ android:name="android.permission.WRITE_EXTERNAL_STORAGE"~\n~ android:maxSdkVersion="28" />~\n~)~\n~AddPermission("android.permission.ACCESS_SUPERUSER")~\n~~\n~AddApplicationText(<receiver android:name="anywheresoftware.b4a.objects.AdminReceiver2"~\n~ android:permission="android.permission.BIND_DEVICE_ADMIN">~\n~ <meta-data android:name="android.app.device_admin"~\n~ android:resource="@xml/device_admin" />~\n~ <intent-filter>~\n~ <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />~\n~ </intent-filter>~\n~</receiver>)~\n~~\n~CreateResource(xml, device_admin.xml,~\n~<device-admin xmlns:android="http://schemas.android.com/apk/res/android">~\n~ <uses-policies>~\n~ <limit-password />~\n~ <reset-password />~\n~ <force-lock />~\n~ </uses-policies>~\n~</device-admin>~\n~)~\n~
Module1=B4XImagenes
Module10=Subs
Module2=B4XMainPage
Module3=B4XPage4
Module4=B4XReglas
Module5=cvFloatingBtn
Module6=DBRequestManager
Module7=NotificationService
Module8=reglas
Module9=Starter
NumberOfFiles=22
NumberOfLibraries=18
NumberOfModules=10
Version=12.5
@EndOfDesignText@
#Region Project Attributes
#ApplicationLabel: Bow 2.0
#VersionCode: 1
#VersionName: 3.06.09
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#BridgeLogger: false
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
End Sub
Sub Globals
End Sub
Sub Activity_Create(FirstTime As Boolean) 'ignore
Dim pm As B4XPagesManager
pm.Initialize(Activity)
End Sub
'Template version: B4A-1.0
#Region Delegates
Sub Activity_ActionBarHomeClick
B4XPages.Delegate.Activity_ActionBarHomeClick
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
'Sub btISend_Click
' Dim myIntent As Intent
' myIntent.Initialize("chv.bow2.setstatus.NEW_STATUS", "bow2://6")
' Dim p As Phone
' p.SendBroadcastIntent(myIntent)
' If starter.Logger Then Log("IntentTester: Intent sent.")
'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.

36
B4A/ReplyAuto.b4a.meta Normal file
View File

@@ -0,0 +1,36 @@
ModuleBookmarks0=
ModuleBookmarks1=
ModuleBookmarks10=
ModuleBookmarks2=
ModuleBookmarks3=
ModuleBookmarks4=
ModuleBookmarks5=
ModuleBookmarks6=
ModuleBookmarks7=231
ModuleBookmarks8=
ModuleBookmarks9=
ModuleBreakpoints0=
ModuleBreakpoints1=
ModuleBreakpoints10=
ModuleBreakpoints2=
ModuleBreakpoints3=
ModuleBreakpoints4=
ModuleBreakpoints5=
ModuleBreakpoints6=
ModuleBreakpoints7=
ModuleBreakpoints8=
ModuleBreakpoints9=
ModuleClosedNodes0=
ModuleClosedNodes1=
ModuleClosedNodes10=
ModuleClosedNodes2=1
ModuleClosedNodes3=
ModuleClosedNodes4=
ModuleClosedNodes5=
ModuleClosedNodes6=
ModuleClosedNodes7=
ModuleClosedNodes8=
ModuleClosedNodes9=
NavigationStack=NotificationService,revisaContactosEspecificos,922,0,NotificationService,procesaNotificacion,911,0,Main,Create_Menu,61,0,B4XMainPage,b4xpage_appear,107,0,B4XMainPage,llenaLV,219,0,B4XImagenes,clv_imagenes_ItemClick,62,0,B4XImagenes,clv_imagenes_ItemLongClick,69,0,B4XMainPage,Class_Globals,0,0,B4XMainPage,B4XPage_Created,67,0,B4XMainPage,Initialize,48,0
SelectedBuild=0
VisibleModules=2,4,7,10,9,1,3,6

102
B4A/Starter.bas Normal file
View File

@@ -0,0 +1,102 @@
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 'ignore
Dim cmd As DBCommand 'ignore
' Dim DBRServer As String = "http://10.0.0.205:1782"
Dim DBRServer As String = "http://keymon.lat:1782"
' Dim DBRServer As String = "http://192.168.137.5:1782"
Dim ultimoServidorConectado As String = ""
' Dim DBRChecked As Boolean = False
' Dim pruebaPaso As Int = 0
Dim desbloqueoUsrs As Map
' Dim ultimaReglaCumplida As Map
'Para los Logs
Dim logs As StringBuilder
Private logcat As LogCat
Dim ruta As String
Dim starterStatus, nsStatus As Map
Dim notisMap2 As Map
Dim reglasDB, historicoDB, colaNotifs, waDB As SQL
Dim waPackage As String = "com.gbwhatsapp"
Dim waApp As String = "GBWhatsApp"
Dim waDir As String = $"/sdcard/Android/media/${waPackage}/${waApp}"$
Dim Logger As Boolean = True
Dim showLogs As Boolean = False
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.
'Para los Logs
#if RELEASE
logcat.LogCatStart(Array As String("-v","raw","*:F","B4A:v"), "logcat")
Logger = False
#end if
logs.Initialize
' Logger = True
End Sub
Sub Service_Start (StartingIntent As Intent)
Service.StopAutomaticForeground 'Starter service can start in the foreground state in some edge cases.
desbloqueoUsrs.Initialize
Subs.revisaBD
ruta = File.DirInternal
' If Not(reglasDB.IsInitialized) Then
reglasDB.Initialize(ruta, "bow.db", True)
colaNotifs.Initialize(ruta, "colaNotifs.db", True)
' End If
If Logger Then LogColor(ruta, Colors.Red)
notisMap2.Initialize
starterStatus.Initialize
If NotificationService.starterStatus.IsInitialized Then starterStatus = NotificationService.starterStatus
starterStatus.Put(Subs.fechaKMT(DateTime.now),"inicia")
If NotificationService.nsStatus.IsInitialized Then
nsStatus.Initialize
nsStatus = NotificationService.nsStatus
Else If Not(NotificationService.nsStatus.IsInitialized) And nsStatus.IsInitialized Then
NotificationService.nsStatus.Initialize
NotificationService.nsStatus = nsStatus
Else
nsStatus.Initialize
NotificationService.nsStatus.Initialize
nsStatus.Put(Subs.fechaKMT(DateTime.now),"inicia")
NotificationService.nsStatus.Put(Subs.fechaKMT(DateTime.now),"inicia")
End If
If Logger Then Log($"starterStatus=${starterStatus}"$)
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. 'Para los Logs
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
'wait for 500ms to allow the logs to be updated.
Dim jo As JavaObject
Dim l As Long = 500: jo.InitializeStatic("java.lang.Thread").RunMethod("sleep", Array(l)) 'Sleep 500ms
logcat.LogCatStop
logs.Initialize
logs.Append("Ver " & Application.VersionName & CRLF)
logs.Append(StackTrace)
Subs.revisaBD
Subs.errorLog.ExecNonQuery2("INSERT INTO errores(fecha, error) VALUES (?,?)", Array As Object (Subs.fechaKMT(DateTime.now), logs))
' StartActivity(errorManager) 'errorManager despliega una pantalla con el error y manda el mensaje de error al servidor.
Return True
End Sub
Sub Service_Destroy
starterStatus.put(Subs.fechaKMT(DateTime.now),"termina")
End Sub

1092
B4A/Subs.bas Normal file

File diff suppressed because it is too large Load Diff

89
B4A/cvFloatingBtn.bas Normal file
View File

@@ -0,0 +1,89 @@
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=10.5
@EndOfDesignText@
'Custom View class
#Event: ExampleEvent (Value As Int)
'#DesignerProperty: Key: Width, DisplayName: Width, FieldType: int, DefaultValue: 55, Description: Width of button.
'#DesignerProperty: Key: Height, DisplayName: Height, FieldType: int, DefaultValue: 55, Description: Height of button.
#DesignerProperty: Key: ImageFile, DisplayName: Image File, FieldType: String, DefaultValue: , Description: Image for button.
'#DesignerProperty: Key: BooleanExample, DisplayName: Boolean Example, FieldType: Boolean, DefaultValue: True, Description: Example of a boolean property.
'#DesignerProperty: Key: IntExample, DisplayName: Int Example, FieldType: Int, DefaultValue: 10, MinRange: 0, MaxRange: 100, Description: Note that MinRange and MaxRange are optional.
'#DesignerProperty: Key: StringWithListExample, DisplayName: String With List, FieldType: String, DefaultValue: Sunday, List: Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday
'#DesignerProperty: Key: StringExample, DisplayName: String Example, FieldType: String, DefaultValue: Text
'#DesignerProperty: Key: ColorExample, DisplayName: Color Example, FieldType: Color, DefaultValue: 0xFFCFDCDC, Description: You can use the built-in color picker to find the color values.
'#DesignerProperty: Key: DefaultColorExample, DisplayName: Default Color Example, FieldType: Color, DefaultValue: Null, Description: Setting the default value to Null means that a nullable field will be displayed.
Sub Class_Globals
Private mEventName As String 'ignore
Private mCallBack As Object 'ignore
Private mBase As Panel
Private Const DefaultColorConstant As Int = -984833 'ignore
Private Const ACTION_DOWN=0,ACTION_UP=1 As Int
Private downx, downy As Float 'ignore
Private S1,S2,Diff As Long
End Sub
Public Sub Initialize (Callback As Object, EventName As String)
mEventName = EventName
mCallBack = Callback
End Sub
Public Sub DesignerCreateView (Base As Panel, Lbl As Label, Props As Map)
mBase = Base
Private ImgFl As String
ImgFl = Props.Get("ImageFile")
If ImgFl <> "" Then mBase.SetBackgroundImage(LoadBitmap(File.DirAssets,ImgFl))
SetOnTouchListener(mBase)
End Sub
Public Sub GetBase As Panel
Return mBase
End Sub
Public Sub setLeft(Left As Int)
mBase.Left = Left
End Sub
Public Sub setTop(Top As Int)
mBase.Top = Top
End Sub
Public Sub setVisible(Flag As Boolean)
mBase.Visible = Flag
End Sub
Private Sub SetOnTouchListener(MyView As View)
Dim ref As Reflector
ref.Target = MyView
ref.SetOnTouchListener("Panel_Touch")
End Sub
Private Sub Panel_Touch(ViewTag As Object, Action As Int, X As Float, Y As Float, MotionEvent As Object) As Boolean
If Action = ACTION_DOWN Then
downx = x
downy = y
S1 = DateTime.Now
else If Action = ACTION_UP Then
S2 = DateTime.Now
Diff = S2 - S1
If Diff <= 199 Then
If SubExists(mCallBack,mEventName.Trim & "_Clicked") Then CallSub3(mCallBack,mEventName.Trim & "_Clicked",X,Y)
End If
Else
' Log(mBase.left& " + " & x & " - " & downx)
If mBase.Left >= 14 And mBase.Left <= 900 Then mBase.Left = mBase.Left + x - downx
If mBase.Left < 14 And (X-downx) > 0 Then mBase.Left = mBase.Left + x - downx
' If mBase.Left < 900 Then mBase.Left = mBase.Left + x - downx
If mBase.Left > 900 And (X-downx) < 0 Then mBase.Left = mBase.Left + x - downx
' mBase.Top = mBase.Top + y - downy
mBase.Left = mBase.Left
If mBase.Left < 10 Then mBase.Left = 14 'ignore
If mBase.Left > 910 Then mBase.Left = 900 'ignore
' mBase.Top = mBase.Top
End If
Return True
End Sub

13
B4A/reglas.bas Normal file
View File

@@ -0,0 +1,13 @@
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=StaticCode
Version=11.45
@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

44
B4A/startWA.bas Normal file
View File

@@ -0,0 +1,44 @@
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Activity
Version=11.5
@EndOfDesignText@
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim OldIntent As Intent
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
End Sub
Sub Activity_Resume
Dim in As Intent = B4XPages.GetNativeParent(Me).GetStartingIntent
If in.IsInitialized And in <> OldIntent Then
OldIntent = in
If in.HasExtra("Notification_Tag") Then
Log("Activity started from notification. Tag: " & in.GetExtra("Notification_Tag"))
Starter.historicoDB.ExecNonQuery2("update historico set clic = 1 where clic = 0 and nombre = ?", Array As Object(in.GetExtra("Notification_Tag"))) 'Ponemos en 1 las notificacion a las que ya se les dió clic.
Subs.abreWAChat(in.GetExtra("Notification_Tag"))
End If
End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub

53
B4i/B4iProject.b4i Normal file
View File

@@ -0,0 +1,53 @@
Build1=Default,b4i.example2
File1=Login.bil
File2=Page2.bil
File3=Page3.bil
FileGroup1=Default Group
FileGroup2=Default Group
FileGroup3=Default Group
Group=Default Group
Library1=icore
Library2=b4xpages
Library3=xui views
Module1=|relative|..\B4XMainPage
Module2=|relative|..\B4XPage2
Module3=|relative|..\B4XPage3
NumberOfFiles=3
NumberOfLibraries=3
NumberOfModules=3
Version=6.5
@EndOfDesignText@
'Code module
#Region Project Attributes
#ApplicationLabel: B4i Example
#Version: 1.0.0
'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
#iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
#iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
#Target: iPhone, iPad
#ATSEnabled: True
#MinVersion: 8
#End Region
Sub Process_Globals
Public App As Application
Public NavControl As NavigationController
End Sub
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Dim PagesManager As B4XPagesManager
PagesManager.Initialize(NavControl)
End Sub
'Template version: B4i-1.0
#Region Delegates
Private Sub Application_Background
B4XPages.Delegate.Activity_Pause
End Sub
Private Sub Application_Foreground
B4XPages.Delegate.Activity_Resume
End Sub
#End Region

15
B4i/B4iProject.b4i.meta Normal file
View File

@@ -0,0 +1,15 @@
ModuleBookmarks0=
ModuleBookmarks1=
ModuleBookmarks2=
ModuleBookmarks3=
ModuleBreakpoints0=
ModuleBreakpoints1=
ModuleBreakpoints2=
ModuleBreakpoints3=
ModuleClosedNodes0=1
ModuleClosedNodes1=
ModuleClosedNodes2=
ModuleClosedNodes3=
NavigationStack=B4XPage2,B4XPage_Appear,22,0,B4XMainPage,Class_Globals,0,0,B4XMainPage,txtUser_TextChanged,36,0,B4XMainPage,txtUser_EnterPressed,37,6,B4XPage2,btnSignOut_Click,39,1,Main,Application_Background,25,0,Main,Application_Foreground,34,0,B4XPage3,Class_Globals,0,0,B4XPage3,Panel1_Touch,27,0,Visual Designer,Page3.bil,-100,3,B4XPage3,B4XPage_Created,14,0
SelectedBuild=0
VisibleModules=1,2,3

Binary file not shown.

Binary file not shown.

BIN
B4i/Files/login.bil Normal file

Binary file not shown.

BIN
B4i/Files/page2.bil Normal file

Binary file not shown.

BIN
B4i/Files/page3.bil Normal file

Binary file not shown.

BIN
ReplyAuto.lnk Normal file

Binary file not shown.

1
gitpull.bat Normal file
View File

@@ -0,0 +1 @@
git pull