Upgrading Devoxx to Gluon Mobile 5


Gluon Mobile LogoDevoxx Logo
Devoxx is a series of international technical conferences. They use a mobile application to help organizers and attendees locate venues, browse and schedule sessions, scan badges, give feedback, and so much more. The Devoxx app is open source, and is built using Gluon Mobile, which enables it to deploy to both Android and iOS with a single code base.

A short while back Gluon released Gluon Mobile 5.0.0. With 5.0.0 our aim was to enhance Gluon Mobile from the ground up to make it easier for the developers to use. We took a very considered approach to break as little compatibility as possible, whilst ensuring that our APIs continue to be class-leading.

Around the same time, Devoxx management approached us to support their app on iPhone X. The support for iPhone X was already added to Gluon Mobile 5.0.0, and we thought it was a good time to upgrade the Devoxx code base to 5.0.0. While upgrading, it was a treat to see (and finally remove) the many lines of code no longer required, thanks to improvements in the latest Gluon Mobile release.

Here are a few examples of code changes from our Devoxx migration:

1. Upgrade from Gluon Mobile 4.x.y to 5.0.0

The upgrade required just bumping the dependencies to the latest Gluon Mobile.

In build.gradle we upgraded to the 3.8.0 release of Gluon Mobile Charm Down (our hardware abstraction API):

ext.charm_down_version = "3.8.0"

In DevoxxClientMobile/build.gradle we upgraded the glisten-afterburner and charm-glisten-connect-view dependencies to their latest release versions:

compile 'com.gluonhq:glisten-afterburner:1.4.0'
compile 'com.gluonhq:charm-glisten-connect-view:5.0.0'

2. FloatingActionButton automatically handled

Prior to Gluon Mobile 5.0.0, we had to remove all layers from the View before adding FloatingActionButton so as to make sure it was not added twice.

FloatingActionButton scan = new FloatingActionButton(...);
badgesView.setOnShowing(event -> {
    ...
    badgesView.getLayers().clear();
    ...
});
...
badgesView.getLayers().add(scan.getLayer());

With Gluon Mobile 5.0.0, this can now be simplified to the following:

FloatingActionButton scan = new FloatingActionButton(...);
scan.showOn(badgesView);

3. NavigationDrawer and SidePopupView

NavigationDrawer always had to be added to a SidePopupView before we can start using it. With Gluon Mobile 5.0.0, we have exposed open() and close() methods from the control and it is now no longer required to add it to a SidePopupView.

public static final String MENU_LAYER = "SideMenu";
...
addLayerFactory(MENU_LAYER, () -> {
    SidePopupView sidePopupView = new SidePopupView(drawerPresenter.getDrawer());
    drawerPresenter.setSidePopupView(sidePopupView);
    return sidePopupView;
});

In Gluon Mobile 5.0.0 the above code is no longer required.

4. NavigationDrawer and Item selection

In Gluon Mobile 4.x.y, we had to depend on the NavigationDrawer.ITEM_SELECTED event to close the SidePopupView and select the new Item in the control.

drawer.addEventHandler(NavigationDrawer.ITEM_SELECTED, e -> 
                             getApp().hideLayer(DevoxxApplication.MENU_LAYER));
...
getApp().viewProperty().addListener((obs, oldView, newView) -> {
    Optional.ofNullable(oldView)
        .flatMap(v -> DevoxxView.REGISTRY.getView(oldView))
        .ifPresent(otnView -> otnView.getMenuItem().setSelected(false));
    updateDrawer(newView);
});
updateDrawer(getApp().getView());
...
private void updateDrawer(View view) {
    DevoxxView.REGISTRY.getView(view).ifPresent(otnView -> {
       drawer.setSelectedItem(otnView.getMenuItem());
       otnView.selectMenuItem();
    });
}

With Gluon Mobile 5.0.0, this is handled internally by the control and we do not need to add any code for item selection.

Conclusion

Gluon Mobile 5.0.0 is a major release with numerous bug fixes and enhancements. This blog post only scratches the surface. For a complete list of changes, please check Gluon Mobile Release Notes.

We hope you enjoy migrating to Gluon Mobile 5.0.0 as much as we did!