Other B4A v13.7 BETA - targetSdkVersion = 36 + Edge to Edge

Status
Not open for further replies.

Erel

B4X founder
Staff member
Licensed User
Longtime User
I'm happy to release a new BETA version of B4A.
The main improvements in this version are related to new requirements enforced with targetSdkVersion=36. Apps running on new devices now run in edge to edge mode (E2E). This means that the activity fills the whole screen and other elements, such as the system bars, are overlaid on top of it. The way to deal with this change is to add a "root" panel that is positioned in the content area and add any layout that shouldn't be covered by the non-app elements to this panel.
In B4XPages, each page is made of a panel and this panel is resized based on the content area, so no changes are needed.
For non-B4XPages projects, you can adapt the code from the default template:
B4X:
Sub Globals
    Private ime As IME
    Private root As B4XView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    ime.Initialize("ime")
    root = xui.CreatePanel("")
    Dim Content As Rect = ime.GetContentRect
    Activity.AddView(root, Content.Left, Content.Top, Content.Width, Content.Height)
    ime.UpdatePercentageReference(root.Width, root.Height)
    root.LoadLayout("Layout")
End Sub
Note that this code will also work properly on devices not running in E2E mode.

There is a new attribute named #EdgeToEdgeOldDevices. It enables E2E mode on older devices and is recommended for better compatibility.
Note that the IME library was updated with features related to this mode. The handling of keyboard height changes is implemented differently when running in E2E and I expect it to work better than the previous non-E2E implementation.

The enableOnBackInvokedCallback attribute is set to false by default: https://developer.android.com/guide/topics/manifest/activity-element#enableOnBackInvokedCallback.

The light and dark theme macros were updated. You can find the updated snippets inside libraries\Themes.jar. The now disabled enforcement of non-E2E was removed and windowLightStatusBar was added to the light theme.

Additional changes:

- Exception.StackTrace property.
- ThrowException keyword
- Bug fixes and other minor changes.

1785398330828.png


B4X:
Root.Color = xui.Color_Gray
B4XPages.GetNativeParent(Me).Color = xui.Color_Magenta


Download link: https://www.b4x.com/android/files/beta.exe
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Tip: the system action bar is non-transparent and also affects the system bar color. You can make it transparent as in the screenshot above with:
B4X:
SetApplicationAttribute(android:theme, "@style/LightTheme")

CreateResource(values, colors.xml,
<resources>
    <color name="actionbar">@android:color/transparent</color>
</resources>
)

CreateResource(values, theme.xml,
<resources>
    <style name="LightTheme" parent="@android:style/Theme.Material.Light">
        <item name="android:colorPrimary">@color/actionbar</item>
        <item name="android:windowActionBarOverlay">true</item>
    </style>
</resources>
)
And remove this line:
B4X:
CreateResourceFromFile(Macro, Themes.LightTheme)
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
Thanks for the update Erel,

Using the non B4X pages template, I have noticed that the 'show title' flag for the Activity in the designer seems ineffective. We have an existing, Atlas SOS, it's not been converted to B4X pages yet. I have put :
B4X:
' // 2026.07.30 - SDK 36 Upgrade
    Try       
        ime.Initialize("ime")
        root = xui.CreatePanel("")
        Dim Content As Rect = ime.GetContentRect
        Activity.AddView(root, Content.Left, Content.Top, Content.Width, Content.Height)
        ime.UpdatePercentageReference(root.Width, root.Height)
        root.LoadLayout("Layout")       
        ime.AddHeightChangedEvent
        ime.HideKeyboard
    Catch
        mod_functions.writelog($"main::Activity_Create::SDK36 Upgrade:: -error- ${LastException.Message}"$)
    End Try
in main::activity_create and the app still covers the whole screen, so the effect is the system bar at the top is overlayed on the app.


1785411023749.png
 
Last edited:
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
In B4XPages, each page is made of a panel and this panel is resized based on the content area, so no changes are needed.
Does this mean that with B4XPages it's not possible to make a full screen app using even the space of the system bar and the bottom soft touch?
 
Upvote 0

ema01

Active Member
Licensed User
Longtime User
Thanks Erel, i've begun updating all my apps.

enableOnBackInvokedCallback attribute is set to false by default
Much appreciated.

Re: Fullscreen, i make non-pages app exclusively (though they are simillar in concept, multiple panels instead of multiple activities).
I already had edge-to-edge implemented a long ago.
The IME method is interesting, before i was using the
B4X:
Private Sub GetSystemWindowInsets(gInsetsType As String) As Int()
you could find here: https://www.b4x.com/android/forum/t...oid-version-15-and-higher.166267/post-1025229

and loaded the activity layout in a panel that stayed inside the insets, more or less what we were making for iphones already.

In the manifest i added the following for the theme
XML:
SetApplicationAttribute(android:theme, "@style/LightTheme")
CreateResource(values, colors.xml,
<resources>
    <color name="actionbar">#00212121</color>
    <color name="statusbar">#00212121</color>
    <color name="textColorPrimary">#ffffffff</color>
    <color name="navigationBar">#00000000</color>
</resources>
)
CreateResource(values-v20, theme.xml,
<resources>
    <style name="LightTheme" parent="@android:style/Theme.Material.NoActionBar.Fullscreen">
        <item name="android:windowLayoutInDisplayCutoutMode">never</item>
        <item name="android:colorPrimary">@color/actionbar</item>
        <item name="android:colorPrimaryDark">@color/statusbar</item>
        <item name="android:textColorPrimary">@color/textColorPrimary</item>
        <item name="android:navigationBarColor">@color/navigationBar</item>
        <item name="android:enforceNavigationBarContrast">false</item>
        <item name="android:enforceStatusBarContrast">false</item>
    </style>
</resources>
)
with the appropriate colors for the background.. i think i have them transparent with an image somewhere, i will update later when i get to those apps

In the meantime some things that i found:
during the DEX process
B4X:
Dex: C:\android\tools\..\extras\b4a_remote\androidx\collection\collection\1.5.0\collection-1.5.0    (0.90s)
    WARNING: generated classes.zip is too small!

EDIT: Unable to connect to BLE Devices if the screen is off. Will investigate further and make a thread if necessary
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Does this mean that with B4XPages it's not possible to make a full screen app using even the space of the system bar and the bottom soft touch?
It is possible and there are several ways to do it. The simplest one is to add B4XPages.HandleInsets = False at the beginning of Activity_Create. It will skip the insets-based resizing.

@Jmu5667 please start a new thread for this. And post smaller images.
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
It is possible and there are several ways to do it. The simplest one is to add B4XPages.HandleInsets = False at the beginning of Activity_Create. It will skip the insets-based resizing.

@Jmu5667 please start a new thread for this. And post smaller images.
 
Upvote 0

Markos

Well-Known Member
Licensed User
Longtime User
Tip: the system action bar is non-transparent and also affects the system bar color. You can make it transparent as in the screenshot above with:
B4X:
SetApplicationAttribute(android:theme, "@style/LightTheme")

CreateResource(values, colors.xml,
<resources>
    <color name="actionbar">@android:color/transparent</color>
</resources>
)

CreateResource(values, theme.xml,
<resources>
    <style name="LightTheme" parent="@android:style/Theme.Material.Light">
        <item name="android:colorPrimary">@color/actionbar</item>
        <item name="android:windowActionBarOverlay">true</item>
    </style>
</resources>
)
And remove this line:
B4X:
CreateResourceFromFile(Macro, Themes.LightTheme)
Thanks Erel one additional line from your manifest example and everything works as it should. I had complied with E2E prior and it still works seamlessly with this b4a beta. Should we wait a bit till the beta goes final before submitting our new builds to the app store?

is this the correct settings for the sdk
B4X:
<uses-sdk android:minSdkVersion="21" android:compileSdkVersion="33" android:targetSdkVersion="36"/>
 
Upvote 0

mcqueccu

Expert
Licensed User
Longtime User
Is the new Release Material3 compatible? Can we use the material3 Theme with it?

Also, since every B4A Releases comes with a NEW THREAD that explains the changes, can we have a link in the about section pointing to the new threads?
It will save time for anyone wanting to go back and look up new code code or changes, rather than going to do full search for the thread.

1785653774038.png
 
Upvote 0

Cebuvi

Active Member
Licensed User
Longtime User
I have several apps in standard B4A, without B4XPages, and my question is whether I need to add the code from post #1 to all the activities.

Would it be possible to share a short, complete example to clarify these concepts, which I think are complicated for those of us who aren't experts?
 
Upvote 0

sirjo66

Well-Known Member
Licensed User
Longtime User
Better to wait a few days so we see that there is no significant issue.

Yeah !!!
We will wait, but in the meaningful,
if you want to try it with B4A 13.40 you can use this:

B4X:
Sub Globals
    Dim root As B4XView
    Dim xui As XUI
End Sub

Sub Activity_Create(FirstTime As Boolean)
    root = xui.CreatePanel("")
    Dim statusBarHeight As Int = GetStatusBarHeight
    Dim navBarHeight As Int = GetNavigationBarHeight
    Activity.AddView(root, 0, statusBarHeight, 100%x, Activity.Height - statusBarHeight - navBarHeight)
    root.LoadLayout("Layout")
End Sub

Public Sub GetNavigationBarHeight As Int
    Dim jo As JavaObject
    Dim resources As JavaObject = jo.InitializeStatic("android.content.res.Resources").RunMethod("getSystem", Null)
    Dim resourceId As Int = resources.RunMethod("getIdentifier", Array As Object("navigation_bar_height", "dimen", "android"))
    If resourceId > 0 Then
        Return resources.RunMethod("getDimensionPixelSize", Array As Object(resourceId))
    End If
    Return 0
End Sub

Public Sub GetStatusBarHeight As Int
    Dim jo As JavaObject
    Dim resources As JavaObject = jo.InitializeStatic("android.content.res.Resources").RunMethod("getSystem", Null)
    Dim resourceId As Int = resources.RunMethod("getIdentifier", Array As Object("status_bar_height", "dimen", "android"))
    If resourceId > 0 Then
        Return resources.RunMethod("getDimensionPixelSize", Array As Object(resourceId))
    End If
    Return 0
End Sub

I hope that this can help you

@Erel : if you think that this code is not useful, I will delete it
 
Last edited:
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
I'm happy to release a new BETA version of B4A.
The main improvements in this version are related to new requirements enforced with targetSdkVersion=36. Apps running on new devices now run in edge to edge mode (E2E). This means that the activity fills the whole screen and other elements, such as the system bars, are overlaid on top of it. The way to deal with this change is to add a "root" panel that is positioned in the content area and add any layout that shouldn't be covered by the non-app elements to this panel.
In B4XPages, each page is made of a panel and this panel is resized based on the content area, so no changes are needed.
For non-B4XPages projects, you can adapt the code from the default template:
B4X:
Sub Globals
    Private ime As IME
    Private root As B4XView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    ime.Initialize("ime")
    root = xui.CreatePanel("")
    Dim Content As Rect = ime.GetContentRect
    Activity.AddView(root, Content.Left, Content.Top, Content.Width, Content.Height)
    ime.UpdatePercentageReference(root.Width, root.Height)
    root.LoadLayout("Layout")
End Sub
Note that this code will also work properly on devices not running in E2E mode.

There is a new attribute named #EdgeToEdgeOldDevices. It enables E2E mode on older devices and is recommended for better compatibility.
Note that the IME library was updated with features related to this mode. The handling of keyboard height changes is implemented differently when running in E2E and I expect it to work better than the previous non-E2E implementation.

The enableOnBackInvokedCallback attribute is set to false by default: https://developer.android.com/guide/topics/manifest/activity-element#enableOnBackInvokedCallback.

The light and dark theme macros were updated. You can find the updated snippets inside libraries\Themes.jar. The now disabled enforcement of non-E2E was removed and windowLightStatusBar was added to the light theme.

Additional changes:

- Exception.StackTrace property.
- ThrowException keyword
- Bug fixes and other minor changes.

View attachment 172670

B4X:
Root.Color = xui.Color_Gray
B4XPages.GetNativeParent(Me).Color = xui.Color_Magenta


Download link: https://www.b4x.com/android/files/beta.exe
thanks Erel
after installing the beta there was no issue with Back key or any other
even didn't change one single line or add one line
i just recompiled and all is perfect
looking forwart for closing that with release version and upload to google and get rid of it
thanks again
 
Upvote 0
Status
Not open for further replies.
Top