fmtm icon indicating copy to clipboard operation
fmtm copied to clipboard

Enable ODK Collect to launch a specific form with a specific preselected entity, from an Intent

Open zestyping opened this issue 11 months ago • 0 comments

A possible plan:

  1. Change the Android Manifest to permit a web browser to deep-link into FormFillingActivity.

  2. Change FormLoaderTask to accept a URI that specifies the form by its XForm ID (e.g. trowein_new_kru_town_v2_224_buildings, not by its local ID (e.g. "forms/2"). The local ID will not be known to FMTM because it depends on what forms are loaded on the phone, so we'll need a way for FMTM to specify the form by its XForm ID.

  3. In FormLoaderTask, add a method to prefill the entity based on query parameters in the URI (e.g. preselectEntity(FormEntryController fec, Uri uri)). It should look for a query parameter in the URI (e.g. ?entity=...) and call FormEntryController.answerQuestion to fill in the entity question with a SelectOneData answer, based on the entity UUID provided as the query parameter.

  4. At the end of FormLoaderTask.doInBackground, call preselectEntity.

  5. In FMTM, get hold of the form's global UUID.

  6. Populate the ODK Central server with the entities corresponding to the buildings to be mapped.

  7. In FMTM, deep link to the ODK Collect app using the selected building's entity UUID.

(Or, as an alternative to Step 3, construct an instance XML data structure that contains the prefilled answer.)

Example of FormIndex pointing to the first question (the entity selection question):

image

Example of the data in the answer to the first question (after an entity is selected):

image

zestyping avatar Mar 15 '24 12:03 zestyping