- VERSION 4.10.11

- Encuesta Pedrigree Cajitas Act II
- Actualizacion Forzosa
This commit is contained in:
Jose Alberto Guerra Ugalde
2024-10-16 10:22:00 -06:00
parent b7c9be5201
commit 828527ea5f
13 changed files with 306 additions and 158 deletions

View File

@@ -78,7 +78,7 @@ Sub Process_Globals
'These variables can be accessed from all modules.
'Aqui va la liga al archivo .ver en el servidor que contiene la información de la aplicacion
Public lnk As String = "https://keymon.lat/movil/guna/cedex.ver"
Public lnk As String = "https://keymon.lat/movil/guna/gunaPreventa.ver"
' Public lnk As String = "https://10.0.0.205/Movil/Guna/cedex.ver"
'##########################################
'## La ruta en el servidor es: ##
@@ -97,12 +97,11 @@ Sub Process_Globals
'Para Download
Dim nativeMe As JavaObject
Dim n2 As Notification
Dim n2ID As Int = 16
Dim n2ID As Int = 16
'Para fileProvider
Public SharedFolder As String
Public UseFileProvider As Boolean
Private rp As RuntimePermissions
Type mNewVersion(update As Boolean, nonewAPP As Boolean, notifyUser As Boolean, _
version As String, newMsg As String, okMsg As String, appLink As String)
Public newApp As mNewVersion
@@ -119,43 +118,43 @@ End Sub
Sub Service_Start (StartingIntent As Intent)
Log("appUpdater(), Service_Start")
' CallSubDelayed2(Main, "muestraProgreso", "Buscando actualización")
B4XPages.MainPage.muestraProgreso("Buscando actualización")
B4XPages.MainPage.muestraProgreso("Buscando actualizaciones, un momento por favor.")
Log("Buscando actualización")
fileProvider_init
Wait For (Download(Me, lnk)) JobDone (j As HttpJob)
If j.Success Then
Try
Dim app() As String = Regex.Split(Chr(9),j.GetString)
' // Set the data
newApp.appLink = app(3) 'Liga a nueva app
newApp.newMsg = app(1) 'Texto de que hay actualizacion
newApp.okMsg = app(2) 'Texto de app al corriente
newApp.version = app(0) 'Version actual
Log($"Application.VersionName=${Application.VersionName}, newApp=${newApp}"$)
' // App version check
If newApp.version = Application.VersionName Then
newApp.update = False
Log("No new app")
B4XPages.ShowPage("updateAvailable")
'Se puede mandar tambien una notificacion avisando que NO hay actualizaciones
CreateNotification2("Aplicacion al corriente","No hay actualizaciones disponibles","ic_file_download_white_24dp",Main,True,True,nNewApp,nNewAppnID)
End If
If newApp.version <> Application.VersionName Then
newApp.update = True
Log("New app true")
B4XPages.ShowPage("updateAvailable")
'Se puede mandar tambien una notificacion avisando que hay actualizacion disponible
' CreateNotification2("Nueva aplicación disponible","Haga clic para descargar.","ic_file_download_white_24dp",C_UpdateAvailable,True,True,nNewApp,nNewAppnID)
End If
Catch
Log("appUpdater(), Job Failed, error " & LastException.Message)
End Try
Else
Log("appUpdater(), Job Failed " & lnk)
End If
j.Release
' Wait For (Download(Me, lnk)) JobDone (j As HttpJob)
' If j.Success Then
' Try
' Dim app() As String = Regex.Split(Chr(9),j.GetString)
' ' // Set the data
' newApp.appLink = app(3) 'Liga a nueva app
' newApp.newMsg = app(1) 'Texto de que hay actualizacion
' newApp.okMsg = app(2) 'Texto de app al corriente
' newApp.version = app(0) 'Version actual
'
' Log($"Application.VersionName=${Application.VersionName}, newApp=${newApp}"$)
'
' ' // App version check
' If newApp.version = Application.VersionName Then
' newApp.update = False
' Log("No new app")
' B4XPages.ShowPage("updateAvailable")
' 'Se puede mandar tambien una notificacion avisando que NO hay actualizaciones
'' CreateNotification2("Aplicacion al corriente","No hay actualizaciones disponibles","ic_file_download_white_24dp",Main,True,True,nNewApp,nNewAppnID)
' End If
' If newApp.version <> Application.VersionName Then
' newApp.update = True
' Log("New app true")
' B4XPages.ShowPage("updateAvailable")
' 'Se puede mandar tambien una notificacion avisando que hay actualizacion disponible
'' CreateNotification2("Nueva aplicación disponible","Haga clic para descargar.","ic_file_download_white_24dp",C_UpdateAvailable,True,True,nNewApp,nNewAppnID)
' End If
' Catch
' Log("appUpdater(), Job Failed, error " & LastException.Message)
' End Try
' Else
' Log("appUpdater(), Job Failed " & lnk)
' End If
' j.Release
' StopService(Me)
End Sub
@@ -167,22 +166,28 @@ Sub download_newApk
' CreateNotification("Descargando actualización", "Descargando apk", "ic_file_download_white_24dp", Main, False, True)
' CallSubDelayed2(Main, "muestraProgreso", "Descargando actualización")
Log("Descargando actualización")
B4XPages.ShowPage("login")
' B4XPages.ShowPage("login")
Starter.muestraProgreso = 1
B4XPages.MainPage.muestraProgreso("Descargando nueva versión, un momento por favor.")
Dim job_newAPP As HttpJob
If job_newAPP.IsInitialized Then job_newAPP.Release
' Log(">>>> LOGIN LINK : " & Starter.newApp.appLink)
If Starter.newApp.appLink <> "" Then newApp = Starter.newApp
job_newAPP.Initialize("job_newAPP",Me)
job_newAPP.Download(newApp.appLink)
' Log(newApp.appLink & "?dummy=" & DateTime.Now)
job_newAPP.Download(newApp.appLink & "?dummy=" & DateTime.Now)
Wait for (job_newAPP) JobDone (job_newAPP As HttpJob)
If job_newAPP.Success = True Then
' // Delete existing file
If File.Exists(SharedFolder,"newapp.apk") Then
' Log(">>>>>> Borramos achivo anterior")
File.Delete(SharedFolder,"newapp.apk")
End If
' // Save new file
Dim outNewAPK As OutputStream = File.OpenOutput(SharedFolder,"newapp.apk", False)
File.Copy2(job_newAPP.GetInputStream, outNewAPK)
outNewAPK.Close
If Starter.Logger Then Log("APK dir: "&SharedFolder)
Log("APK dir: "&SharedFolder)
End If
job_newAPP.Release
' // Install the app