Bug? Fontsize changes when app is open again

Discussion in 'Bugs & wishlist' started by kohle, Sep 6, 2018.

  1. kohle

    kohle Active Member Licensed User


    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:

    Region  Project Attributes
    #ApplicationLabel: Central433 Control
    #VersionCode: 1
    '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)
    End Sub

    Sub Activity_Resume
    End Sub

    public Sub MessageFromFirebase(msg As String)
    End Sub

    Sub Activity_Pause (UserClosed As Boolean)
    End Sub

    FirebaseMessaging :

    #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
    End Sub

    Public Sub SubscribeToTopics
    End Sub

    Sub Service_Start (StartingIntent As Intent)
    If StartingIntent.IsInitialized Then fm.HandleIntent(StartingIntent)
    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
    "custom sound"Application.LabelName, "HIGH")
    File.DirAssets, "logo_trans.png"32dip32dipTrue))
    'disable the default sound
    'set custom sound
        n.CustomSound(CreateFileProviderUri(folder, FileName))
    Dim Notification As Notification = n.Build(Message.GetData.Get("title"), Message.GetData.Get("body"), "", Main)

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

    End Sub

    Sub CreateFileProviderUri (Dir As String, FileName As StringAs Object
    Dim FileProvider As JavaObject
    Dim context As JavaObject
    Dim f As JavaObject
    "java.io.File"Array(Dir, FileName))
    Return FileProvider.RunMethod("getUriForFile"Array(context, Application.PackageName & ".provider", f))
    End Sub

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

    Attached Files:

  2. Erel

    Erel Administrator Staff Member Licensed User

    Strange. It is a real device, right?

    Can you upload the project?
  3. kohle

    kohle Active Member Licensed 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: Sep 6, 2018
  4. Erel

    Erel Administrator Staff Member Licensed User

    Try to reproduce it in a small project and upload it.
  5. kohle

    kohle Active Member Licensed 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.
  6. kohle

    kohle Active Member Licensed 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 :

    'Sub CreateItem(str As String, str2 As String) As B4XView
    Sub CreateItem(str As String, str2 As StringAs Panel
        'Dim p As B4XView = xui.CreatePanel("")
        Dim p As Panel
    000, clv_main.AsView.Width, 18dip)
        p.Color = 
    '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 Stringid As Long)
    If clv_main.getSize>0 Then
    0,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
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice