Agent in screens.xml does not work in some phones

Hi,
I am using cuba 6.10.3, and I have below config in my screen.xml:

    <screen id="mainWindow" template="cn/com/dataocean/cip/web/main/ext-mainwindow.xml"/>
    <screen id="mainWindow" agent="PHONE" template="cn/com/dataocean/cip/web/main/ext-mainwindow-mobile.xml"/>

So while using mobile phone access the web, it will use differerent layout xml.

But on “SamSung Galaxy S9+” or “HuaWei Hornor v10”, it shows the default xml layout, not the one I configured for PHONE agent.

And I found that below code works correnct on the two phones:

    private boolean isMobile() {
        WebBrowser webBrowser = Page.getCurrent().getWebBrowser();
        return !webBrowser.isWindows() && !webBrowser.isMacOSX() && !webBrowser.isLinux() && !webBrowser.isIPad();
    }

So it’s only ‘AGENT’ logic works wrong on the two phones.

Could you help check? Below are the introductions of the phones;
Maybe SamSung Galaxy S9+ has “Infinity Display”? But “HuaWei Hornor v10” does not have “Infinity Display”.

Hi,

I’d recommend that you use DeviceInfoProvider and DeviceInfo directly instead of the standard agent profiles. Unfortunately, we cannot take into account all possible devices in standard profiles. Also, you should know that Screen Agent feature is deprecated and removed since version 7.0.

Thanks Yuriy.
Do you mean set xml file in code level? Could you suggest how?

You can use the same XML and show / hide UI component programmatically depending on DeviceInfo.

@Inject
private DeviceInfoProvider deviceInfoProvider;

@Override
public void init(Map<String, Object> params) {
    super.init(params);

    DeviceInfo deviceInfo = deviceInfoProvider.getDeviceInfo();
    if (deviceInfo != null) {
        if (deviceInfo.getAspectRatio() > 0.2) {
            usersTable.setVisible(false);
        }
    }

Thanks, but that way seems not suit to my project. I have many screens have totally different layout in phone but same component id in java code, there are many logic with the component id. Simply hide/show does not work for me.
AGENT is a good way, it seems hard without it. Could you suggest a way that I can implement similar agent feature in cuba7? I mainly need to have different layout in phone but with same component id in java.

You could use different fragments for different devices and insert them to a screen dynamically.

It still need a lots of rework for exists screens. Why can’t keep screen agent in V7.

Please advice whether I understood correctly:

  1. create an “empty” host xml.
  2. create two fragments, one for mobile one for default.
  3. In the host java, add fragments in programmatic way base on deviceInfo.

Both fragments can have same component id, so java logic can remain no change, right?

Unfortunately, we have decided not to support them any more during the complexity of device detection and limitations that cannot be implemented with new Screen API. Agents are not supported in 7.0 and will not be implemented in the future.

We recommend using CssLayout, responsive property and HtmlAttributes.

You can implement all UI logic in screen, your fragments will only contain different XML layouts.

ok. And for mainWindow, I can use same way, right?

Thanks ,i got it.