Skip to content

Commit

Permalink
Respect short label forms (#2186)
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek2010 authored and lognaturel committed May 15, 2018
1 parent 2e5ed36 commit 3715f90
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public void refreshView() {
case FormEntryController.EVENT_QUESTION:

FormEntryPrompt fp = formController.getQuestionPrompt();
String label = fp.getLongText();
String label = getLabel(fp);
if (!fp.isReadOnly() || (label != null && label.length() > 0)) {
// show the question if it is an editable field.
// or if it is read-only and the label is not blank.
Expand Down Expand Up @@ -338,17 +338,17 @@ public void refreshView() {
if (fc.getMultiplicity() == 0) {
// Display the repeat header for the group.
HierarchyElement group =
new HierarchyElement(fc.getLongText(), null, ContextCompat
new HierarchyElement(getLabel(fc), null, ContextCompat
.getDrawable(getApplicationContext(), R.drawable.expander_ic_minimized),
COLLAPSED, fc.getIndex());
formList.add(group);
}
String repeatLabel = mIndent + fc.getLongText();
String repeatLabel = mIndent + getLabel(fc);
if (fc.getFormElement().getChildren().size() == 1 && fc.getFormElement().getChild(0) instanceof GroupDef) {
formController.stepToNextEvent(FormController.STEP_INTO_GROUP);
FormEntryCaption fc2 = formController.getCaptionPrompt();
if (fc2.getLongText() != null) {
repeatLabel = fc2.getLongText();
if (getLabel(fc2) != null) {
repeatLabel = getLabel(fc2);
}
}
repeatLabel += " (" + (fc.getMultiplicity() + 1) + ")";
Expand Down Expand Up @@ -403,4 +403,9 @@ public void onClick(DialogInterface dialog, int i) {
alertDialog.setButton(getString(R.string.ok), errorListener);
alertDialog.show();
}

private String getLabel(FormEntryCaption formEntryCaption) {
return formEntryCaption.getShortText() != null && !formEntryCaption.getShortText().isEmpty()
? formEntryCaption.getShortText() : formEntryCaption.getLongText();
}
}

0 comments on commit 3715f90

Please sign in to comment.