23/10/23 - Se agregó en el engrane la opción de importar una base de datos cuando el usuario es "KMTS1"

This commit is contained in:
2023-10-23 16:52:52 -06:00
parent 09ee88c0d9
commit 67298d514c
472 changed files with 856 additions and 349 deletions

View File

@@ -91,6 +91,7 @@ Sub Class_Globals
Public rutaBDBackup As String = ""
Dim MES1 As ManageExternalStorage
Dim device As Phone
Private b_importarBD As Button
End Sub
Public Sub Initialize
@@ -133,6 +134,19 @@ Private Sub B4XPage_Created (Root1 As B4XView)
historico.Initialize
B4XPages.AddPage("Historico", historico)
ruta = Starter.ruta
' Dim px As B4XView = xui.CreatePanel("")
' px.SetLayoutAnimated(0, 500, 30, 200dip, 45dip)
' px.Color = Colors.Cyan
' Dim tf As Label
' tf.Initialize("")
' tf.TextSize = 20
' tf.Color = Colors.gray
' tf.Gravity = Gravity.CENTER_VERTICAL
' tf.Text = "Hola"
' px.AddView(tf, 0, 0, px.Width - 10dip, px.Height)
' B4XPages.GetManager.ActionBar.RunMethod("setCustomView", Array(px))
' B4XPages.GetManager.ActionBar.RunMethod("setDisplayOptions", Array(16, 16))
Provider.Initialize
' Subs.borraArribaDe100Errores ' Para Websockets
@@ -692,6 +706,7 @@ Sub i_engrane_Click
If user.Text = "KMTS1" Then lv_server.AddSingleLine("http://10.0.0.205:1782")
' l_server.Text = Starter.DBReqServer
et_server.Text = Starter.DBReqServer
If user.Text = "KMTS1" Then b_importarBD.Visible = True Else b_importarBD.Visible = False
Subs.panelVisible(p_appUpdate,0,0)
End Sub
@@ -755,4 +770,13 @@ Sub CheckNotificationAccess As Boolean
pstr = r.GetStaticField("anywheresoftware.b4a.BA", "packageName")
nstr = ph.GetSettings("enabled_notification_listeners")
Return nstr.Contains(pstr)
End Sub
Private Sub b_importarBD_Click
Private FH As FileHandler
FH.Initialize
Wait For (FH.Load) Complete (Result As LoadResult) 'Abre un fileManager para seleccionar la base de datos a importar.
File.Copy(Result.Dir, Result.FileName, File.DirInternal, "kmt.db") 'Copia la base de datos seleccionada al directorio interno.
Starter.skmt.Initialize(Starter.ruta,"kmt.db", True) 'Reiniciliza la base de datos con la recien importada.
ToastMessageShow("¡BD importada!", False)
End Sub

View File

@@ -150,6 +150,7 @@ End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
B4XPages.SetTitle(Me, $"${subs.capitalizar(B4XPages.GetPageId(Me))} - ${Application.VersionName}"$)
Root = Root1
'load the layout to Root
' Activity.RemoveAllViews

View File

@@ -64,7 +64,7 @@ Private Sub B4XPage_Created (Root1 As B4XView)
End Sub
Sub B4XPage_Appear
B4XPages.SetTitle(Me, $"Clientes - ${Starter.dia_semana}"$)
B4XPages.SetTitle(Me, $"Clientes - ${Starter.dia_semana} - ${Application.VersionName}"$)
busca.Text = ""
entro ="2"
colonia = 0

View File

@@ -39,6 +39,7 @@ End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
B4XPages.SetTitle(Me, $"${subs.capitalizar(B4XPages.GetPageId(Me))} - ${Application.VersionName}"$)
Root = Root1
'load the layout to Root
ruta = File.DirInternal

View File

@@ -40,6 +40,7 @@ End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
B4XPages.SetTitle(Me, $"${subs.capitalizar(B4XPages.GetPageId(Me))} - ${Application.VersionName}"$)
Root = Root1
'load the layout to Root
Root.LoadLayout("noventa")

View File

@@ -43,6 +43,7 @@ End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
B4XPages.SetTitle(Me, $"${subs.capitalizar(B4XPages.GetPageId(Me))} - ${Application.VersionName}"$)
Root = Root1
ruta = File.DirInternal
Root.LoadLayout("nota")

View File

@@ -52,6 +52,7 @@ End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
B4XPages.SetTitle(Me, $"${subs.capitalizar(B4XPages.GetPageId(Me))} - ${Application.VersionName}"$)
Root = Root1
'load the layout to Root
Root.LoadLayout("nuevocliente")

View File

@@ -68,6 +68,7 @@ End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
B4XPages.SetTitle(Me, $"${subs.capitalizar(B4XPages.GetPageId(Me))} - ${Application.VersionName}"$)
Root = Root1
'load the layout to Root
Root.LoadLayout("pedido")

View File

@@ -238,6 +238,7 @@ Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
'load the layout to Root
Root.LoadLayout("principal")
B4XPages.SetTitle(Me, $"${Subs.capitalizar(B4XPages.GetPageId(Me))} ${Application.VersionName}"$)
s.Initialize(Me, "Subs")
p_mandaInfo.Width = Root.Width
p_mandaInfo.Height = Root.Height

View File

@@ -91,6 +91,7 @@ End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
B4XPages.SetTitle(Me, $"${subs.capitalizar(B4XPages.GetPageId(Me))} - ${Application.VersionName}"$)
Root = Root1
'load the layout to Root
' Activity.RemoveAllViews

View File

@@ -56,6 +56,7 @@ End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
B4XPages.SetTitle(Me, $"${subs.capitalizar(B4XPages.GetPageId(Me))} - ${Application.VersionName}"$)
Root = Root1
'load the layout to Root
Root.LoadLayout("promociones")

View File

@@ -25,6 +25,7 @@ End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
B4XPages.SetTitle(Me, $"Tickets Día - ${Application.VersionName}"$)
Root = Root1
'load the layout to Root
ruta = File.DirInternal

162
B4A/FileHandler.bas Normal file
View File

@@ -0,0 +1,162 @@
B4A=true
Group=Default Group
ModulesStructureVersion=1
Type=Class
Version=11
@EndOfDesignText@
'Requiere la librería "ContentResolver" y "FileProvider" o "AppUpdating"
'
'Copiar este codigo al boton_Click que se quiere que importe la base de datos.
'
' Private Sub b_importarBD_Click
' Private FH As FileHandler
' FH.Initialize
' Wait For (FH.Load) Complete (Result As LoadResult) 'Abre un fileManager para seleccionar la base de datos a importar.
' File.Copy(Result.Dir, Result.FileName, File.DirInternal, "kmt.db") 'Copia la base de datos seleccionada al directorio interno.
' Starter.skmt.Initialize(Starter.ruta,"kmt.db", True) 'Reiniciliza la base de datos con la recien importada.
' ToastMessageShow("¡BD importada!", False)
' End Sub
Sub Class_Globals
#if B4A
Private ion As Object
Private OldIntent As Intent
#end if
Type LoadResult (Success As Boolean, Dir As String, FileName As String, RealName As String, Size As Long, Modified As Long, MimeType As String)
End Sub
Public Sub Initialize
End Sub
#if B4A
Public Sub SaveAs (Source As InputStream, MimeType As String, Title As String) As ResumableSub
Dim intent As Intent
intent.Initialize("android.intent.action.CREATE_DOCUMENT", "")
intent.AddCategory("android.intent.category.OPENABLE")
intent.PutExtra("android.intent.extra.TITLE", Title)
intent.SetType(MimeType)
StartActivityForResult(intent)
Wait For ion_Event (MethodName As String, Args() As Object)
If -1 = Args(0) Then 'resultCode = RESULT_OK
Dim result As Intent = Args(1)
Dim jo As JavaObject = result
Dim ctxt As JavaObject
Dim out As OutputStream = ctxt.InitializeContext.RunMethodJO("getContentResolver", Null).RunMethod("openOutputStream", Array(jo.RunMethod("getData", Null)))
File.Copy2(Source, out)
out.Close
Return True
End If
Return False
End Sub
Public Sub Load As ResumableSub
Dim cc As ContentChooser
cc.Initialize("cc")
cc.Show("application/octet-stream", "Choose text file")
Wait For CC_Result (Success As Boolean, Dir As String, FileName As String)
Log($"***************************${CRLF}${Dir}${CRLF} ${FileName}"$)
Dim res As LoadResult = CreateLoadResult(Success, Dir, FileName)
Log($"***************************${CRLF}${res.FileName}${CRLF} ${res}"$)
If res.Success Then ExtractInformationFromURI(res.FileName, res)
Return res
End Sub
Private Sub StartActivityForResult(i As Intent)
Dim jo As JavaObject = GetBA
ion = jo.CreateEvent("anywheresoftware.b4a.IOnActivityResult", "ion", Null)
jo.RunMethod("startActivityForResult", Array(ion, i))
End Sub
Private Sub GetBA As Object
Return Me.As(JavaObject).RunMethod("getBA", Null)
End Sub
Private Sub ExtractInformationFromURI (Uri As String, res As LoadResult)
Try
Dim resolver As ContentResolver
resolver.Initialize("")
Dim u As Uri
u.Parse(Uri)
Dim rs As ResultSet = resolver.Query(u, Null, "", Null, "")
If rs.NextRow Then
Dim columns As B4XSet = B4XCollections.CreateSet
For i = 0 To rs.ColumnCount - 1
columns.Add(rs.GetColumnName(i))
Next
If columns.Contains("_display_name") Then res.RealName = rs.GetString("_display_name")
If columns.Contains("_size") Then res.Size = rs.GetLong("_size")
If columns.Contains("last_modified") Then res.Modified = rs.GetLong("last_modified")
If columns.Contains("mime_type") Then res.MimeType = rs.GetString("mime_type")
End If
rs.Close
Catch
Log("error extracting information from file provider")
Log(LastException)
End Try
End Sub
Public Sub CheckForReceivedFiles As LoadResult
Dim Activity As Activity = B4XPages.GetNativeParent(B4XPages.MainPage)
If IsRelevantIntent(Activity.GetStartingIntent) Then
Dim in As Intent = Activity.GetStartingIntent
Dim uri As String
If in.HasExtra("android.intent.extra.STREAM") Then
uri = in.As(JavaObject).RunMethod("getParcelableExtra", Array("android.intent.extra.STREAM"))
Else
uri = in.GetData
End If
Dim res As LoadResult = CreateLoadResult(True, "ContentDir", uri)
ExtractInformationFromURI(res.FileName, res)
Return res
End If
Return CreateLoadResult(False, "", "")
End Sub
Private Sub IsRelevantIntent(in As Intent) As Boolean
If in.IsInitialized And in <> OldIntent And in.Action = in.ACTION_VIEW Then
OldIntent = in
Return True
End If
Return False
End Sub
#else if B4i
Public Sub SaveAs(ParentPage As Object, AnchorView As Object, Text As String) As ResumableSub
Dim avc As ActivityViewController
avc.Initialize("avc", Array(Text))
avc.Show(B4XPages.GetNativeParent(ParentPage), AnchorView)
Wait For avc_Complete (Success As Boolean, ActivityType As String)
Return Success
End Sub
Public Sub Load (ParentPage As Object, AnchorView As Object) As ResumableSub
Dim DocumentPicker As DocumentPickerViewController
DocumentPicker.InitializeImport("picker", Array("public.text"))
DocumentPicker.Show(B4XPages.GetNativeParent(ParentPage), AnchorView)
Wait For Picker_Complete (Success As Boolean, URLs As List)
If Success And URLs.Size > 0 Then
Return UrlToLoadResult(URLs.Get(0))
End If
Return CreateLoadResult(False, "", "")
End Sub
Public Sub UrlToLoadResult(url As String) As LoadResult
Dim res As LoadResult = CreateLoadResult(IIf(File.Exists(url, ""), True, False), url, "")
res.RealName = res.Dir.SubString(res.Dir.LastIndexOf("/") + 1)
res.Size = File.Size(res.Dir, "")
Return res
End Sub
#end if
Private Sub CreateLoadResult (Success As Boolean, Dir As String, FileName As String) As LoadResult
Dim t1 As LoadResult
t1.Initialize
t1.Success = Success
t1.Dir = Dir
t1.FileName = FileName
Return t1
End Sub

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.4 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Some files were not shown because too many files have changed in this diff Show More