From 24ab38a66146b871aa92e358e29390e4ea722be7 Mon Sep 17 00:00:00 2001 From: cheveguerra Date: Sun, 17 Sep 2023 17:14:02 -0600 Subject: [PATCH] 17/9/23 - Permisos de notificacion y timeout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Se puso codigo para que al iniciar la aplicación pida el acceso a notificaciones. - Se cambió el timeout por default a 11 segs. --- B4A/B4XMainPage.bas | 5 +++++ B4A/C_Subs.bas | 4 ++-- B4A/Monitor-Keymon.b4a | 4 ++-- B4A/NotificationService.bas | 3 ++- B4A/monitor.bas | 4 +++- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/B4A/B4XMainPage.bas b/B4A/B4XMainPage.bas index 2433f34..9bbda8c 100644 --- a/B4A/B4XMainPage.bas +++ b/B4A/B4XMainPage.bas @@ -85,6 +85,11 @@ Sub B4XPage_Appear s.centraPanel(p_intervalo, Root.Width) s.centraEtiqueta(Label1, Root.Width) If Not(CheckNotificationAccess) Then + Msgbox2Async($"Se necesita acceso a las notificaciones, haga clic en "Aceptar" y en la siguiente pantalla permita el acceso a la aplicación "${Application.LabelName}"."$, "Permisos necesarios", "Aceptar", "Cancelar", "", Null, True) + Wait For Msgbox_Result (resultado As Int) + If resultado = DialogResponse.POSITIVE Then + b_notifAccess_Click + End If Private cd1 As ColorDrawable cd1.Initialize(Colors.red, 10dip) b_notifAccess.Background = cd1 diff --git a/B4A/C_Subs.bas b/B4A/C_Subs.bas index 110004d..a3e1e67 100644 --- a/B4A/C_Subs.bas +++ b/B4A/C_Subs.bas @@ -399,9 +399,9 @@ Sub traeIntervaloDeBD As String 'ignore Return intrvl End Sub -'Regresa el timeout desde la base de datos o "9000" si no existe. +'Regresa el timeout desde la base de datos o "11000" si no existe. Sub traeTimeoutDeBD As String 'ignore - Dim tmout As String = "9000" + Dim tmout As String = "11000" Dim rs As ResultSet = Starter.skmt.ExecQuery("select valor from cat_variables where nombre = 'timeout'") If rs.RowCount > 0 Then rs.NextRow diff --git a/B4A/Monitor-Keymon.b4a b/B4A/Monitor-Keymon.b4a index 74a70eb..666b194 100644 --- a/B4A/Monitor-Keymon.b4a +++ b/B4A/Monitor-Keymon.b4a @@ -31,12 +31,12 @@ Module7=Starter NumberOfFiles=4 NumberOfLibraries=12 NumberOfModules=7 -Version=12.2 +Version=12.5 @EndOfDesignText@ #Region Project Attributes #ApplicationLabel: Monitor Keymon #VersionCode: 1 - #VersionName: 3.09.10 + #VersionName: 3.09.17 'SupportedOrientations possible values: unspecified, landscape or portrait. #SupportedOrientations: portrait #CanInstallToExternalStorage: False diff --git a/B4A/NotificationService.bas b/B4A/NotificationService.bas index 914cfeb..cc34528 100644 --- a/B4A/NotificationService.bas +++ b/B4A/NotificationService.bas @@ -26,10 +26,11 @@ Sub Service_Create End Sub Sub Service_Start (StartingIntent As Intent) +' Log("NotificationService Start") If rp.HandleIntent(StartingIntent) Then Return DateTime.DateFormat = "mm" ultimaNoti = DateTime.Date(DateTime.now) - If logger Then LogColor($"Ultima noti en el minuto ${ultimaNoti}"$, Colors.green) + If logger Then LogColor($"Ultima notificación en el minuto ${ultimaNoti}"$, Colors.green) End Sub Sub Service_Destroy diff --git a/B4A/monitor.bas b/B4A/monitor.bas index f50177f..3cc3b79 100644 --- a/B4A/monitor.bas +++ b/B4A/monitor.bas @@ -41,9 +41,10 @@ Sub Service_Create End Sub Sub Service_Start (StartingIntent As Intent) + Log("Monitor Start") Service.StopAutomaticForeground 'Call this when the background task completes (if there is one) Service.StartForeground(nid, s.CreateNotification("...")) - StartServiceAt(Me, DateTime.Now + 1 * DateTime.TicksPerMinute, True) + StartServiceAt(Me, DateTime.Now + 10 * DateTime.TicksPerMinute, True) reqManager.Initialize(Me, Starter.DBReqServer) Timer1_Tick If logger Then LogColor("*************** Monitor Iniciado 👍🏽 **********", Colors.red) @@ -55,6 +56,7 @@ End Sub Sub Timer1_Tick ' Log("Next run " & DateTime.Time(DateTime.Now + Interval * 1000)) +' Log("Monitor Timer_Tick") If Starter.monitorActivo Then DateTime.DateFormat = "dd/MM HH:mm:ss" If B4XPages.IsInitialized Then B4XPages.MainPage.l_ultimoPing.Text = $"Último ping: ${DateTime.Date(DateTime.now)}"$