- Se agregó la opcion de importar la base de datos directamente desde Whatsapp, hay que ingresar al engrane con el usuario KMTS1.

This commit is contained in:
2024-05-17 05:01:25 -06:00
parent bad642477c
commit 26b7213792
5 changed files with 69 additions and 4 deletions

View File

@@ -22,6 +22,8 @@ Sub Class_Globals
Dim RD_Init_IsInitialized As Boolean = False
Dim btAdmin As BluetoothAdmin
Private khdb As SQL
Dim in As Intent
Dim intentUsado As Boolean = False
End Sub
'Inicializa la clase "kms_helperSubs".
@@ -451,6 +453,51 @@ Sub CheckNotificationAccess As Boolean
Return nstr.Contains(pstr)
End Sub
'Regresa si se debe de usar el intent de importar la base d datos desde Whatsapp.
Sub traeUsarIntentBDWA As Boolean 'ignore
Private BDWA As Boolean = False
Private x As Cursor = Starter.skmt.ExecQuery($"select CAT_VA_VALOR from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'IMPORTAR_BD_WA'"$)
If x.RowCount > 0 Then
x.Position = 0
If x.GetString("CAT_VA_VALOR") = "true" Then BDWA = True
End If
' Log($"cb_importarBDWA = ${BDWA}"$)
Return BDWA
End Sub
' Se revisa si hay una intención (intent) de abrir una base de datos y si es así, entonces se importa esa base de datos.
Sub importaBDDesdeWhatsApp
Private tmpBDWA As Boolean = traeUsarIntentBDWA
If Not(in.IsInitialized) Then in = B4XPages.GetNativeParent(B4XPages.MainPage).GetStartingIntent ' Si se usa esta funcion en Mainpage, se pone "Me" en lugar de B4XPages.MainPage.
If Not(intentUsado) And in <> Null Then
' Log(in)
intentUsado = True
' Log(in.As(String))
If in.GetData <> Null Then
Dim XmlData As String
XmlData = in.GetData
Try
Dim OutStr As OutputStream = File.OpenOutput(File.DirInternal,"kmt.db",False)
Dim InStr As InputStream = File.OpenInput("ContentDir",XmlData)
File.Copy2(InStr,OutStr)
LogColor("BD copiada a interna.", Colors.Blue)
OutStr.Close
If in.As(String).Contains("whatsapp") Then ToastMessageShow("BD cargada desde Whatsapp", False)
Catch
Log(LastException)
End Try
' ExitApplication
khdb.ExecNonQuery("delete from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'IMPORTAR_BD_WA'")
khdb.ExecNonQuery($"insert into CAT_VARIABLES (CAT_VA_DESCRIPCION, CAT_VA_VALOR) values ('IMPORTAR_BD_WA', '${tmpBDWA}')"$)
Private a As Cursor = khdb.ExecQuery($"select CAT_VA_VALOR from CAT_VARIABLES where CAT_VA_DESCRIPCION = 'APP_NAME'"$)
If a.RowCount > 0 Then
a.Position = 0
ToastMessageShow($"BD de "${a.GetString("CAT_VA_VALOR")}" cargada."$, True)
End If
End If
End If
End Sub
'################ Manage External Storage (MES) #########################
'
''Inicializa "Manage External Storage" (MES), que nos da acceso a la tarjeta de memoria en Android 11+