Skip to content

Commit

Permalink
Fix #2652 Make currently used item "disabled" instead of hiding it (b…
Browse files Browse the repository at this point in the history
…ible/commentary button)
  • Loading branch information
tuomas2 committed Jun 19, 2023
1 parent c80e140 commit eb54542
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -901,8 +901,8 @@ class MainBibleActivity : CustomTitlebarActivityBase() {

override fun updateActions() {
updateTitle()
val biblesForVerse = documentControl.biblesForVerse.filter {currentDocument != it}
val commentariesForVerse = documentControl.commentariesForVerse.filter {currentDocument != it}
val biblesForVerse = documentControl.biblesForVerse
val commentariesForVerse = documentControl.commentariesForVerse

val suggestedBible = documentControl.suggestedBible
val suggestedCommentary = documentControl.suggestedCommentary
Expand Down Expand Up @@ -1088,25 +1088,25 @@ class MainBibleActivity : CustomTitlebarActivityBase() {
updateActions()
}

private fun menuForDocs(v: View, documents: List<Book>): Boolean {
private fun menuForDocs(v: View, documents: List<Book>) {
val menu = PopupMenu(this, v)
val docs = documents.sortedWith(compareBy({it.language.code}, {it.abbreviation}))
docs.forEachIndexed { i, book ->
if(currentDocument != book) {
menu.menu.add(Menu.NONE, i, Menu.NONE, getString(R.string.something_with_parenthesis, book.abbreviation, book.language.code))
val item = menu.menu.add(Menu.NONE, i, Menu.NONE, getString(R.string.something_with_parenthesis, book.abbreviation, book.language.code))
if(currentDocument == book) {
item.isEnabled = false
}
}

if (docs.size == 1) {
setCurrentDocument(docs[0])
if (docs.size == 2) {
setCurrentDocument(docs.first { it != currentDocument })
} else {
menu.setOnMenuItemClickListener { item ->
setCurrentDocument(docs[item.itemId])
true
}
menu.show()
}
return true
}

private fun setCurrentDocument(book: Book?) {
Expand Down

0 comments on commit eb54542

Please sign in to comment.