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
 

Markos

Well-Known Member
Licensed User
Longtime User
If this is not a B4XPages project then there are some changes that you must do. Otherwise the layout will be broken on new devices.
Good point raises a question. I implemented the manifest changes where in my case was just on 1 line inclusion as rest was compliant. The E2E was previously compliant via code usin % axis relativity. Now on an S21 with new build using sdk 36 on new B4a beta and the layout is not broken is that a clear indicator all new devices should conform?
 
Upvote 0

Markos

Well-Known Member
Licensed User
Longtime User
This means that you tested your app in E2E mode and you are good to go. I do recommend you to see the recommended changes in the first post and make sure that you are doing something similar.
Many thanks Erel and yes def all changes in manifest are mirrored. As I complied with E2E using prior coding capability to this b4a beta and it appears that I do not immediately need b4xpages support. I will use the coding recommended under the Activity Sub for new Apps. Which would make compliance to E2E way easier if my understanding is correct.
 
Upvote 0

EstasPerplejo

Member
Licensed 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.

Using pages, this does not seem to work. The screen stays with the insets as defined by the system. it did not show the desired effect in my app.
 
Upvote 0

EstasPerplejo

Member
Licensed User
Maybe before I dig any further into this, let me clarify if I understood this right:
B4xpages.Handleinsets =true/false means we can put this at any page and insets will be set/ignored on this specific page only?
Or is it meant to be a general choice that goes for the entire app, either insets are set or completely ignored?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Or is it meant to be a general choice that goes for the entire app, either insets are set or completely ignored?
This is a global setting. Most apps should keep it with the default value (True).

I'm not sure what you are trying to do, however you can resize the root view in B4XPage_Appear if you want it to go behind the bars.
 
Upvote 0

EstasPerplejo

Member
Licensed User
okay - got it. We can wrap this up as being misunderstood - accept my apologies.
I thought we might use e2e with insets set globally AND/BUT if desired, we can declare not to use insets at specific pages.
Thanks for clearing this up.
 
Upvote 0

Zeev Goldstein

Well-Known Member
Licensed User
Longtime User
If this is not a B4XPages project then there are some changes that you must do. Otherwise the layout will be broken on new devices.
i see - can you please give an example?
as i changed to 36 and all my layouts looks fine as with 35
 
Upvote 0

nima_fun_code

New Member
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
Hello Erel,

First of all, thank you for adding the Edge-to-Edge solution for Android 16. It works well in most cases, but after applying it in one of my published products, I encountered an issue that I think is worth investigating.

In my application, the user interface is created at the very beginning of Activity_Create based on the size of ContentRect.

The issue is that, in some cases (which happen rarely), it seems that IME.GetContentRect does not return the final value yet because the window is not fully ready. This usually happens when the device is briefly slow or busy processing while opening an Activity. I have received reports of this behavior from some users, and I have also observed it once on a newer device myself, so I don't think it is limited only to older devices.

In this situation, the size of root and consequently the %x and %y values are calculated incorrectly, and the user interface is created based on incorrect dimensions.

Since this issue happens only occasionally, collecting logs or reproducing it consistently is not easy.
 
Upvote 0

delgadol

Member
I try all day to fix the problems with edgetoedge border, with appcompact library; i have some simple application that it change theme day/night; with the change e2e and SDK 36, statusbar show icon white ( pure ) in day o night theme, i found some solutions for app with app compact library

- No change if you implement NavigationDrawer Native (desing lib)

- if you use only appcompact lib , you can check this code on manifest

Declare Theme for AppComapct App:
CreateResource(values, themes.xml,
<resources>
    <style name="MyAppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
        <item name="colorPrimary">#FF9800</item>
        <item name="colorPrimaryDark">#E65100</item>
        <item name="colorAccent">#FF9800</item>
        
        <!-- Status Bar -->
        <item name="android:statusBarColor">@android:color/transparent</item>


        <!-- Iconos/texto de Status Bar oscuros -->
        <item name="android:windowLightStatusBar">true</item>

        <!-- Fondo claro -->
        <item name="android:windowBackground">#FFFFFF</item>
        <item name="android:colorBackground">#FFFFFF</item>

        <!-- Texto -->
        <item name="android:textColorPrimary">#212121</item>
        <item name="android:textColorSecondary">#757575</item>

        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="windowActionModeOverlay">true</item>
        <item name="windowActionBarOverlay">true</item>
    </style>
</resources>
)

CreateResource(values-night, themes.xml,
<resources>
    <style name="MyAppTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
        <item name="colorPrimary">#FF9800</item>
        <item name="colorPrimaryDark">#E65100</item>
        <item name="colorAccent">#FFB74D</item>
        
        <!-- Status Bar -->
        <item name="android:statusBarColor">@android:color/transparent</item>

        <!-- Iconos claros -->
        <item name="android:windowLightStatusBar">false</item>

        <!-- Fondo oscuro -->
        <item name="android:windowBackground">#121212</item>
        <item name="android:colorBackground">#121212</item>

        <!-- Texto -->
        <item name="android:textColorPrimary">#FFFFFF</item>
        <item name="android:textColorSecondary">#BDBDBD</item>

        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="windowActionModeOverlay">true</item>
        <item name="windowActionBarOverlay">true</item>
    </style>
</resources>
)

- if you no want change your themes; use this java code

Change Icon On status Bar:
#if java

import androidx.core.view.WindowInsetsControllerCompat;

public void _onCreate() {
    // Inicializa el controlador compatible con versiones anteriores
    WindowInsetsControllerCompat windowInsetsController =
            new WindowInsetsControllerCompat(getWindow(), getWindow().getDecorView());
    
    // true  = Iconos oscuros (ideal para fondos claros de la app)
    // false = Iconos claros/blancos (ideal para fondos oscuros o Modo Noche)
   windowInsetsController.setAppearanceLightStatusBars(true);
}

#end if


this code really works for default app + appcompact

erel E2E fix:
    ime.Initialize("ime")
    root = xui.CreatePanel("")
    Dim Content As Rect = ime.GetContentRect
    Activity.AddView(root, Content.Left, Content.Top, Content.Width, Content.Height)
    Activity.Color = xui.Color_Transparent
    ime.UpdatePercentageReference(root.Width, root.Height)
    root.LoadLayout("main")



I hope this helps you as it has helped me, since it was something laborious to find.
 

Attachments

  • appcompact_app.png
    appcompact_app.png
    26.4 KB · Views: 92
Upvote 0

Steve Addy

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

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
I have B4A apps with this SDK 36 problem. What do I have to do to fix them? This discussion seems to be all about B4X.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Don't worry. B4XView is just a cross platform (and better designed) API similar to View.
As an example, a Button can be a Button, a View, or a B4XView.
B4X:
Dim b As Button
Dim v As View = b
Dim x As B4XView = v
b = x
You need to add references to IME and XUI. Don't add a reference to B4XPages. This is the cause of that error.
 
Upvote 0
Status
Not open for further replies.
Top