Skip to content

Commit

Permalink
PR fix: Clean up menu button toggling logic
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperka committed Jan 23, 2019
1 parent 6951d48 commit c48fbde
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,28 +221,28 @@ private void updateOptionsMenu() {
boolean isInRepeat = !isAtBeginning && screenIndex != null && formController.getEvent(screenIndex) == FormEntryController.EVENT_REPEAT;

boolean shouldShowDelete = isInRepeat && !shouldShowPicker;
toggleDeleteButton(shouldShowDelete);
showDeleteButton(shouldShowDelete);

boolean shouldShowAdd = shouldShowPicker;
toggleAddButton(shouldShowAdd);
showAddButton(shouldShowAdd);

boolean shouldShowGoUp = !isAtBeginning || shouldShowPicker;
toggleGoUpButton(shouldShowGoUp);
showGoUpButton(shouldShowGoUp);
}

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

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

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ void configureButtons(FormController formController) {
}

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

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

Expand Down

0 comments on commit c48fbde

Please sign in to comment.