Skip to content

Commit

Permalink
Fix #261 (disable index creation for book types other than bible or c…
Browse files Browse the repository at this point in the history
…ommentary)
  • Loading branch information
tuomas2 committed Jan 31, 2019
1 parent 8595e35 commit 7617edd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ class DocumentControl @Inject constructor(
val isBibleBook: Boolean
get () = currentDocument.bookCategory == BookCategory.BIBLE

val isCommentary: Boolean
get () = currentDocument.bookCategory == BookCategory.COMMENTARY

val currentPage: CurrentPageManager
get () = activeWindowPageManagerProvider.activeWindowPageManager

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public String getSearchResultVerseText(Key key) {
// There is similar functionality in BookmarkControl
String verseText = "";
try {
verseText = swordContentFacade.getPlainText(activeWindowPageManagerProvider.getActiveWindowPageManager().getCurrentBible().getCurrentDocument(), key);
verseText = swordContentFacade.getPlainText(activeWindowPageManagerProvider.getActiveWindowPageManager().getCurrentPage().getCurrentDocument(), key);
verseText = CommonUtils.limitTextLength(verseText);
} catch (Exception e) {
Log.e(TAG, "Error getting verse text", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@ abstract class CustomTitlebarActivityBase(private val optionsMenuId: Int = NO_OP
super.onConfigurationChanged(newConfig)

// the title bar has different widths depending on the orientation
updateActionBarButtons()
updateActions()
}

/** update the quick links in the title bar
*/
open fun updateActionBarButtons() {
open fun updateActions() {
actionBarManager.updateButtons()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ class MainBibleActivity : CustomTitlebarActivityBase(), VerseActionModeMediator.
private val titleSplitter = TitleSplitter()
private val actionButtonMaxChars = CommonUtils.getResourceInteger(R.integer.action_button_max_chars)

override fun updateActionBarButtons() {
override fun updateActions() {
updateTitle()

val suggestedBible = documentControl.suggestedBible
Expand All @@ -370,6 +370,9 @@ class MainBibleActivity : CustomTitlebarActivityBase(), VerseActionModeMediator.
val maxWidth = (screenWidth * 0.5).roundToInt()
val maxButtons: Int = (maxWidth / approximateSize).toInt()
val isMyNotes = documentControl.currentPage.isMyNoteShown
val showSearch = documentControl.isBibleBook || documentControl.isCommentary


bibleButton.visibility = if (visibleButtonCount < maxButtons && suggestedBible != null) {
bibleButton.text = titleSplitter.shorten(suggestedBible.abbreviation, actionButtonMaxChars)
bibleButton.setOnLongClickListener { menuForDocs(it, documentControl.biblesForVerse) }
Expand All @@ -391,7 +394,7 @@ class MainBibleActivity : CustomTitlebarActivityBase(), VerseActionModeMediator.


fun addSearch() {
searchButton.visibility = if (visibleButtonCount < maxButtons && !isMyNotes)
searchButton.visibility = if (visibleButtonCount < maxButtons && showSearch && !isMyNotes)
{
visibleButtonCount += 1
View.VISIBLE
Expand Down Expand Up @@ -432,6 +435,9 @@ class MainBibleActivity : CustomTitlebarActivityBase(), VerseActionModeMediator.
View.VISIBLE
} else View.GONE
invalidateOptionsMenu()

val btn = navigationView.menu.findItem(R.id.searchButton)
btn.isEnabled = showSearch
}

fun onEventMainThread(passageEvent: CurrentVerseChangedEvent) {
Expand All @@ -442,7 +448,7 @@ class MainBibleActivity : CustomTitlebarActivityBase(), VerseActionModeMediator.
if(!speakEvent.isTemporarilyStopped) {
updateSpeakTransportVisibility()
}
updateActionBarButtons()
updateActions()
}

private fun menuForDocs(v: View, documents: List<Book>): Boolean {
Expand Down Expand Up @@ -490,7 +496,7 @@ class MainBibleActivity : CustomTitlebarActivityBase(), VerseActionModeMediator.
toolbar.animate().translationY(topOffset1)
.setInterpolator(DecelerateInterpolator())
.start()
updateActionBarButtons()
updateActions()
} else {
Log.d(TAG, "Fullscreen on")
hideSystemUI()
Expand Down Expand Up @@ -607,7 +613,7 @@ class MainBibleActivity : CustomTitlebarActivityBase(), VerseActionModeMediator.
mWholeAppWasInBackground = true
}
else {
updateActionBarButtons()
updateActions()
}
}

Expand Down Expand Up @@ -709,7 +715,7 @@ class MainBibleActivity : CustomTitlebarActivityBase(), VerseActionModeMediator.
preferenceSettingsChanged()
ABEventBus.getDefault().post(SynchronizeWindowsEvent())
}
mainMenuCommandHandler.isDocumentChanged(requestCode) -> updateActionBarButtons()
mainMenuCommandHandler.isDocumentChanged(requestCode) -> updateActions()
}

}
Expand Down Expand Up @@ -765,7 +771,7 @@ class MainBibleActivity : CustomTitlebarActivityBase(), VerseActionModeMediator.
}

fun onEvent(event: CurrentWindowChangedEvent) {
updateActionBarButtons()
updateActions()
}

/**
Expand All @@ -779,7 +785,7 @@ class MainBibleActivity : CustomTitlebarActivityBase(), VerseActionModeMediator.
* called by PassageChangeMediator after a new passage has been changed and displayed
*/
fun onEventMainThread(event: PassageChangedEvent) {
updateActionBarButtons()
updateActions()
}

override fun onResume() {
Expand Down

0 comments on commit 7617edd

Please sign in to comment.