Skip to content

Commit

Permalink
Never show add/delete buttons on ViewOnlyFormHierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperka committed Jan 23, 2019
1 parent f3a3713 commit 8e6ba71
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,28 @@ private void updateOptionsMenu() {
boolean isAtBeginning = formController.isCurrentQuestionFirstInForm() && !shouldShowRepeatGroupPicker();

boolean isInRepeat = !isAtBeginning && screenIndex != null && formController.getEvent(screenIndex) == FormEntryController.EVENT_REPEAT;
optionsMenu.findItem(R.id.menu_delete_child).setVisible(isInRepeat).setEnabled(isInRepeat);
toggleDeleteButton(isInRepeat);

boolean shouldShowPicker = shouldShowRepeatGroupPicker();
optionsMenu.findItem(R.id.menu_add_child).setVisible(shouldShowPicker).setEnabled(shouldShowPicker);
toggleAddButton(shouldShowPicker);

boolean shouldShowGoUp = shouldShowPicker || !isAtBeginning;
optionsMenu.findItem(R.id.menu_go_up).setVisible(shouldShowGoUp).setEnabled(shouldShowGoUp);
toggleGoUpButton(shouldShowGoUp);
}

/** Override to disable this button. */
protected void toggleDeleteButton(boolean isEnabled) {
optionsMenu.findItem(R.id.menu_delete_child).setVisible(isEnabled).setEnabled(isEnabled);
}

/** Override to disable this button. */
protected void toggleAddButton(boolean isEnabled) {
optionsMenu.findItem(R.id.menu_add_child).setVisible(isEnabled).setEnabled(isEnabled);
}

/** Override to disable this button. */
protected void toggleGoUpButton(boolean isEnabled) {
optionsMenu.findItem(R.id.menu_go_up).setVisible(isEnabled).setEnabled(isEnabled);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ void configureButtons(FormController formController) {
jumpEndButton.setVisibility(View.GONE);
}

@Override
protected void toggleDeleteButton(boolean isEnabled) {
// Disabled.
}

@Override
protected void toggleAddButton(boolean isEnabled) {
// Disabled.
}

/**
* Prevents the user from clicking on individual questions to jump into the form-filling view.
*/
Expand Down

0 comments on commit 8e6ba71

Please sign in to comment.