Additional UI Frameworks

Nuxeo Layout in Android

Updated: October 16, 2020

Nuxeo Android Connector SDK allows fetch the Documents layout definition from the server. This allows to reuse on the Android side the layouts that are present by default in Nuxeo, or the custom ones that can be done via Nuxeo Studio.

Basically, the Layout definitions (as well as Widgets definitions and some vocabularies) are exported in JSON by the Nuxeo server. On the Android side this definition is cached and used to build an Android View from it.

This implies to bind Nuxeo widgets to Android native Widgets. The current SDK version provides support for basic fields (Text, TextArea, Date, File, SelectOne, SelectMany).


// get a ScrollView that will contains the Form generated from the Nuxeo Layout
layoutContainer = (ScrollView) findViewById(R.id.layoutContainer);

// get the service
NuxeoLayoutService nls = getNuxeoSession().getAdapter(NuxeoLayoutService.class);

// get the layout definition for the current document.
NuxeoLayout layout = nls.getLayout(this, getCurrentDocument(), layoutContainer, getMode());

LayoutMode argument can be create/edit/view.

When you wan to change back the modifications to the document :


Document doc = getCurrentDocument();
layout.applyChanges(doc);

Because some widgets can start new Activity, the activity responsible to handle the display of the form will need to implment some additional callback.


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    layout.onActivityResult(requestCode, resultCode, data);
    super.onActivityResult(requestCode, resultCode, data);
}

See sample code and base classes for more details.