Project configuration

Charm Down

The minimum charm down version has been bumped to 3.8.0.

jfxmobile {
    downConfig {
        version '3.8.0'
        plugins 'display', 'lifecycle', 'statusbar', 'storage'
    }
}

Code Changes

Gluon Mobile

Significant changes have been made to the Gluon Mobile framework. Most of the changes are towards our continual effort to make it easier for developers to create mobile applications using Java. We have tried to maintain backward compatibility, however, some tweaking might be needed when you upgrade existing projects to Gluon Mobile 5.

Here are a list of changes that one needs to keep in mind while upgrading to 5.0.0.

MobileApplication

MobileApplication exposes a new method getDrawer() which should be used to access the application wide NavigationDrawer.

Prior to 5.0.0

public class MyApplication extends MobileApplication {
    ...
    addLayerFactory(MENU_LAYER, () -> new SidePopupView(new NavigationDrawer()));
    appBar.setNavIcon(MaterialDesignIcon.MENU.button(e ->
                            showLayer(UserAuthentication.MENU_LAYER)));
    ...
}

With 5.0.0

public class MyApplication extends MobileApplication {
    ...
    appBar.setNavIcon(MaterialDesignIcon.MENU.button(e -> getDrawer().open()));
    ...
}

As it can be noted in the above snippets, there is no need to create a new instance of NavigationDrawer or a new instance of layer to install the drawer. However, customizing the drawer (header, items, footer) is still responsibility of the developer.

MobileLayoutPane

MobileLayoutPane no longer exists. If you had a class extending MobileLayoutPane, we advise you to extend it from View instead.

GlassPane

GlassPane no longer extends from MobileLayoutPane and therefore doesn’t expose getLayers(). Layers can be shown directly without adding them to GlassPane. Refer to Layer section below.

View

View no longer has a name property. The constructors which accepted view’s name as an argument have been removed. Similar to GlassPane, View no longer extends from MobileLayoutPane and therefore doesn’t expose getLayers(). Layers can be shown directly without adding them to View. Refer to Layer section below.

The show transition factory has been changed from Function<View,Transition> to Function<View,MobileTransition>. MobileTransition helps Gluon Mobile to have better control over the transitions while the application is either paused or resumed.

Layer

Layers can now be shown on MobileApplication without adding them to GlassPane or View. Previously exposed list of layers on these classes no longer exist. In order to show/hide a layer, call show() and hide() respectively.

Prior to 5.0.0

Layer layer = new Layer();
MobileApplication.getInstance().getGlassPane().getLayers().add(layer);

With 5.0.0

Layer layer = new Layer();
layer.show();

showingProperty is now read only and cannot be changed by the user.

dispose() has been removed from Layer. This is taken care by Gluon Mobile and the developer doesn’t need to worry about it.

Layers are now managed using a life-cycle. Events are fired during every transition. Layers have the following life-cycle events:

  • showing

  • shown

  • hiding

  • hidden

These life-cycles can be used by the developers to perform additional tasks while showing or hiding a layer.

NavigationDrawer

NavigationDrawer has been improved to automatically show and hide without the need to add it to a SidePopupView. New methods open() and close() have been added and can be used to open and close the drawer respectively.

Prior to 5.0.0

MobileApplication.getInstance().addLayerFactory(MENU_LAYER, () ->
                                    new SidePopupView(new NavigationDrawer()));
MobileApplication.getInstance().showLayer(UserAuthentication.MENU_LAYER)));

With 5.0.0

NavigationDrawer drawer = MobileApplication.getInstance().getDrawer();
drawer.open();

Also, we have improved the NavigationDrawer to close automatically when an item is selected. To prevent this behavior, NavigationDrawer.Item has a new autoClose property which can be set to false to prevent the drawer from closing automatically when the item is selected.

Prior to 5.0.0

NavigationDrawer drawer = new NavigationDrawer();
MobileApplication.getInstance().addLayerFactory(MENU_LAYER, () -> new SidePopupView(drawer));
drawer.addEventHandler(NavigationDrawer.ITEM_SELECTED,
                e -> MobileApplication.getInstance().hideLayer(MENU_LAYER));

With 5.0.0

NavigationDrawer drawer = MobileApplication.getInstance().getDrawer();
// No need of adding an event handler to close the drawer

BottomNavigation

ActionItems in BottomNavigation only accept instances of BottomNavigationButton instead of Node. This change was required for proper functioning of the control under different conditions. Also, previously deprecated method createButton() has been removed.

Prior to 5.0.0

BottomNavigation bottomNavigation = new BottomNavigation();
ToggleButton recent = bottomNavigation.createButton("Recent",
           MaterialDesignIcon.RECENT_ACTORS.graphic(), e -> title.setText("Recent"));
bottomNavigation.getActionItems().add(recent);

With 5.0.0

BottomNavigation bottomNavigation = new BottomNavigation();
BottomNavigationButton recent = new BottomNavigationButton("Recent",
           MaterialDesignIcon.RECENT_ACTORS.graphic(), e -> title.setText("Recent"));
bottomNavigation.getActionItems().add(recent);

FloatingActionButton

Prior to 5.0.0, it was required to always add FloatingActionButton(FAB)'s layer to the list of layers exposed by either GlassPane or View and the visibility of the control was toggled using the visibility property. This complex behavior has been replaced by simple show() and hide() methods.

Prior to 5.0.0

public class MyView extends View {

    private FloatingActionButton fab;
    ...

    public MyView() {
        super("MyView");
        fab = new FloatingActionButton();
        getLayers().add(floatingActionButton.getLayer());
    }

    ...

    public void hideFAB() {
        floatingActionButton.setVisible(false);
    }
}

With 5.0.0

public class MyView extends View {

    private FloatingActionButton fab;
    ...

    public MyView() {
        super();
        fab = new FloatingActionButton();
        fab.show();
    }

    ...

    public void hideFAB() {
        floatingActionButton.hide();
    }
}

FAB can also be linked to a View such that it automatically shows when the View is shown and hides when the View is hidden. This can be achieved by calling showOn(View view) on the FAB.

public class MyView extends View {

    private FloatingActionButton fab;
    ...

    public MyView() {
        super("MyView");
        fab = new FloatingActionButton();
        fab.showOn(this);
    }

    ...
}

FAB control has also been moved from com.gluonhq.charm.glisten.layout.layer to com.gluonhq.charm.glisten.control.

SnackbarPopupView

SnackbarPopupView has been removed. A new control Snackbar has been added as a replacement.