Bug? Fontsize changes when app is open again

kohle

Active Member
Licensed User
Longtime User
Hi,

I made a simple app for receiving notifications. It worked well. After I intergrated the nb6 v1.01
Now I have the following problem, you can see in the screen shots.
Sometimes the font size of the views in the main layout is getting bigger when I click on a notfication
and the app opens. The icon of the notifcation is getting smaller and the text of all views bigger.

Code main:

B4X:
Region  Project Attributes
    #ApplicationLabel: Central433 Control
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

#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.

End Sub

Sub Globals
    'Private Switch1 As Switch
    Private lblMessage As Label
    Private lv2 As ListView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
End Sub

Sub Activity_Resume
End Sub

public Sub MessageFromFirebase(msg As String)
    lv2.AddSingleLine(msg)
End Sub

Sub Activity_Pause (UserClosed As Boolean)
 
End Sub


FirebaseMessaging :

B4X:
#Region Module Attributes
    '#StartAtBoot: False
#End Region

'Service module
'Version 0.9
Sub Process_Globals
'Dim sNotif As Notification
    Private fm As FirebaseMessaging
End Sub
Sub Service_Create
    fm.Initialize("fm")
    
    
    
End Sub

Public Sub SubscribeToTopics
    fm.SubscribeToTopic("ios_general")
    fm.SubscribeToTopic("alarm1")
End Sub


Sub Service_Start (StartingIntent As Intent)
    If StartingIntent.IsInitialized Then fm.HandleIntent(StartingIntent)
    Sleep(0)
    Service.StopAutomaticForeground 'remove if not using B4A v8+.
End Sub


'Sub fm_MessageArrived (Message As RemoteMessage)
'    Log("Message arrived")
'    Log($"Message data: ${Message.GetData}"$)
'    Dim n As Notification
'    n.Initialize
'    n.Icon = "icon"
'    n.Sound = True
'    n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Main)
'   
'    CallSubDelayed2(Main, "MessageFromFirebase",Message.GetData.Get("body") & " " & Message.GetData.Get("title"))
'   
'    n.Notify(1)
'End Sub
    


Sub fm_MessageArrived (Message As RemoteMessage)
    Log("Message arrived")
    Log($"Message data: ${Message.GetData}"$)

    'n.SetInfo(Message.GetData.Get("title"), Message.GetData.Get("body"), Main)
    

    Dim rp As RuntimePermissions
    Dim folder As String = rp.GetSafeDirDefaultExternal("shared")
    Dim FileName As String = "shotgun.mp3"
    'copy the file to the shared folder
    File.Copy(File.DirAssets, FileName, folder, FileName)
    Dim n As NB6
    n.Initialize("custom sound", Application.LabelName, "HIGH")
    n.SmallIcon(LoadBitmapResize(File.DirAssets, "logo_trans.png", 32dip, 32dip, True))
    'disable the default sound
    n.SetDefaults(False, True, True)
    'set custom sound
    n.CustomSound(CreateFileProviderUri(folder, FileName))
    Dim Notification As Notification = n.Build(Message.GetData.Get("title"), Message.GetData.Get("body"), "", Main)
    Notification.Notify(9)

    CallSubDelayed2(Main, "MessageFromFirebase",Message.GetData.Get("body") & " " & Message.GetData.Get("title"))


End Sub

Sub CreateFileProviderUri (Dir As String, FileName As String) As Object
    Dim FileProvider As JavaObject
    Dim context As JavaObject
    context.InitializeContext
    FileProvider.InitializeStatic("android.support.v4.content.FileProvider")
    Dim f As JavaObject
    f.InitializeNewInstance("java.io.File", Array(Dir, FileName))
    Return FileProvider.RunMethod("getUriForFile", Array(context, Application.PackageName & ".provider", f))
End Sub

Starter:

B4X:
#Region  Service Attributes
    #StartAtBoot: False
    #ExcludeFromLibrary: True
#End Region

Sub Process_Globals
    
'    Public sNotif As Notification
    
    
End Sub

Sub Service_Create
    
    
    
'    sNotif.Initialize
'    sNotif.Icon = "icon"
'    'sNotif.Sound = False
'   
'   
'   
'   
'    sNotif.SetInfo("JK Central433","Service Running",Main)
'    'sNotif.Notify(1)
    
    
    CallSubDelayed(FirebaseMessaging, "SubscribeToTopics")
    
    
    
End Sub



Sub Service_Start (StartingIntent As Intent)
'    Sleep(0)
'    Service.StopAutomaticForeground
'    Service.StartForeground(1,sNotif)
End Sub


Sub Service_Destroy
    Log("Service destroyed")
End Sub
 

Attachments

  • Screenshot_20180905-161816.png
    Screenshot_20180905-161816.png
    47 KB · Views: 181
  • Screenshot_20180905-161702.png
    Screenshot_20180905-161702.png
    91.6 KB · Views: 185

kohle

Active Member
Licensed User
Longtime User
Yes its a real device a HTC11, Android 8.0
Without the NB6 class it worked in my 2 week test without problems.

The upload file has 7mb, without apk file. Where can I upload it ?
 
Last edited:

kohle

Active Member
Licensed User
Longtime User
the app is receiving notification and adding them to a sqllite database. In the resume of the main activity the
data is added to a xcustomlistview. For showing the notification I use nb6 with custom sound.
The font change happens over night when the phone is in no disturb mode and receiving notifications.
When the fone wakes up the notification icon in the status is 1/4 of the size of the original normally shown and when
open the app the fonts of all views are much bigger.

I will make some more tests.
 

kohle

Active Member
Licensed User
Longtime User
For test I changed from class xCustomListView v1.64 / XUI library 1.70 to class CustomListView version: 1.76.
Until now it works fine. Overnight the fone goes into no disturb mode and only pass alarm. There is nearly no battery usage.
When I click on a arrived notification and open the app all looks fine now.

My first impression is, that there is a bug in the xcustomlistview. To finish my project in time, I will stay now with the
customlistview class. I have it in many projects and no problems. Only thing is that the xcustomlistview seems to be faster :(

Minor changes from xcustomlistview to customlistview :

B4X:
'xcustom
'Sub CreateItem(str As String, str2 As String) As B4XView
Sub CreateItem(str As String, str2 As String) As Panel
    'xcustom
    'Dim p As B4XView = xui.CreatePanel("")
    Dim p As Panel
    p.Initialize("")
    
    p.SetLayoutAnimated(0, 0, 0, clv_main.AsView.Width, 18dip)
    p.Color = Colors.Black
    p.LoadLayout("item_main")
    'p.SetLayoutAnimated(0, 0, 0, p.Width, CollapsedHeight)
    lblDateTime.Text = str
    lblAlarm.Text = str2
    
    Return p
End Sub


Public Sub MessageFromDevice(msg As String, strDate As String, id As Long)
   
    If clv_main.getSize>0 Then
        clv_main.InsertAt(0,CreateItem(strDate,msg.Trim),18dip , id)
    Else
        clv_main.Add(CreateItem(strDate,msg.Trim),18dip, id)
    End If

' xcustom   
'    If clv_main.Size>0 Then
'        clv_main.InsertAt(0,CreateItem(strDate,msg.Trim), id)
'    Else
'        clv_main.Add(CreateItem(strDate,msg.Trim), id)
'    End If
   
End Sub
 
Top