simplify undo/redo menu button visibility checks

This commit is contained in:
tibbi 2023-01-30 12:15:58 +01:00
parent ee3abd2577
commit 1acda068af

View File

@ -167,16 +167,13 @@ class MainActivity : SimpleActivity() {
val isCurrentItemChecklist = isCurrentItemChecklist()
main_toolbar.menu.apply {
val areButtonsVisible = (showRedoButton || showUndoButton) && mCurrentNote.type == NoteType.TYPE_TEXT.value
findItem(R.id.undo).apply {
isVisible = areButtonsVisible
isEnabled = showUndoButton && mCurrentNote.type == NoteType.TYPE_TEXT.value
isVisible = showUndoButton && mCurrentNote.type == NoteType.TYPE_TEXT.value
icon?.alpha = if (isEnabled) 255 else 127
}
findItem(R.id.redo).apply {
isVisible = areButtonsVisible
isEnabled = showRedoButton && mCurrentNote.type == NoteType.TYPE_TEXT.value
isVisible = showRedoButton && mCurrentNote.type == NoteType.TYPE_TEXT.value
icon?.alpha = if (isEnabled) 255 else 127
}