Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add display/enable conditions to buttons in AddWordDialogFragment #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

qminlh
Copy link

@qminlh qminlh commented May 3, 2023

Description

There are cases where some of AddWordDialogFragment's buttons are not expected - for example, the Move up button when adding a new key. To combat this, this pull request introduces conditions for some of these buttons - the following conditions have been added:

  • Move up: visible if index > -1 (when editing existing key), disabled if index == 0 (when the topmost key is chosen)
  • Delete: disabled if keyCount <= 1 (to avoid making the list empty)

As a bonus, dialog title has also been changed to "Add Key" when adding a key.

Screenshots

Before After
Adding a new key add-before add-after
Editing the topmost key edit-first-before edit-first-after
Editing the only key edit-only-before edit-only-after

Additional notes

  • The reason why I added a condition for Delete button is to keep already implemented logic - currently it is impossible to delete the last key, as the key with index 0 can't be removed (this change also makes it possible to remove it, as long as the list will not be empty afterwards). By the way, keep in mind that it's still possible to delete all keys by importing a file containing empty array.
  • Changing the state of the buttons needs to be done in onStart, as the getButton method returns null if the dialog is not fully created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant