Skip to content

Commit

Permalink
Implement #3101 (When speaking, show "Jump to [passage]" in Window Menu)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuomas2 committed Dec 9, 2023
1 parent 145cfbd commit cdb79e5
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ class CurrentGeneralBookPage internal constructor(

override val currentPageContent: Document
get() {
val key = key
return when(key) {
return when(val key = key) {
is StudyPadKey -> {
val bookmarks = pageManager.bookmarkControl.getBibleBookmarksWithLabel(key.label, addData = true)
val genericBookmarks = pageManager.bookmarkControl.getGenericBookmarksWithLabel(key.label, addData = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package net.bible.android.control.page
import kotlinx.serialization.Serializable
import net.bible.android.view.activity.base.ActivityBase
import net.bible.android.view.activity.page.MainBibleActivity
import net.bible.service.sword.BookAndKey
import org.crosswire.jsword.book.Book
import org.crosswire.jsword.passage.Key

Expand Down Expand Up @@ -46,6 +47,7 @@ interface CurrentPage {

val documentCategory: DocumentCategory
val pageManager: CurrentPageManager
val bookAndKey: BookAndKey? get() = singleKey?.let {BookAndKey(it, currentDocument, anchorOrdinal, htmlId)}

fun startKeyChooser(context: ActivityBase)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class SpeakControl @Inject constructor(
}


private val speakPageManager: CurrentPageManager
val speakPageManager: CurrentPageManager
get() {
var pageManager = _speakPageManager
if(pageManager == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package net.bible.android.view.activity.page.screen

import android.annotation.SuppressLint
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.content.Intent
import android.content.res.ColorStateList
Expand Down Expand Up @@ -55,14 +54,14 @@ import net.bible.android.BibleApplication
import net.bible.android.activity.R
import net.bible.android.activity.databinding.SplitBibleAreaBinding
import net.bible.android.control.event.ABEventBus
import net.bible.android.control.event.ToastEvent
import net.bible.android.control.event.passage.CurrentVerseChangedEvent
import net.bible.android.control.event.window.CurrentWindowChangedEvent
import net.bible.android.control.page.MultiFragmentDocument
import net.bible.android.control.page.MyNotesDocument
import net.bible.android.control.page.StudyPadDocument
import net.bible.android.control.page.window.Window
import net.bible.android.control.page.window.WindowControl
import net.bible.android.control.speak.SpeakControl
import net.bible.android.database.SettingsBundle
import net.bible.android.view.activity.page.BibleView
import net.bible.android.view.activity.page.BibleViewFactory
Expand All @@ -78,18 +77,14 @@ import net.bible.android.view.activity.settings.getPrefItem
import net.bible.android.view.util.widget.AddNewWindowButtonWidget
import net.bible.android.view.util.widget.WindowButtonWidget
import net.bible.service.common.CommonUtils
import net.bible.service.common.firstBibleDoc
import net.bible.service.common.shortName
import net.bible.service.common.tinyName
import net.bible.service.device.ScreenSettings
import net.bible.service.download.isStudyPad
import net.bible.service.sword.BookAndKey
import net.bible.service.sword.StudyPadKey
import org.crosswire.jsword.book.BookCategory
import org.crosswire.jsword.versification.BookName
import java.lang.IndexOutOfBoundsException
import java.util.*
import kotlin.collections.ArrayList
import kotlin.math.max
import kotlin.math.roundToInt

Expand All @@ -116,6 +111,7 @@ var clipboardKey: BookAndKey? = null
class SplitBibleArea(private val mainBibleActivity: MainBibleActivity): FrameLayout(mainBibleActivity) {
private val isSplitVertically get() = mainBibleActivity.isSplitVertically
private val windowControl: WindowControl get() = mainBibleActivity.windowControl
private val speakControl: SpeakControl get() = mainBibleActivity.speakControl
private val bibleViewFactory: BibleViewFactory get() = mainBibleActivity.bibleViewFactory

private val res = BibleApplication.application.resources
Expand Down Expand Up @@ -858,6 +854,25 @@ class SplitBibleArea(private val mainBibleActivity: MainBibleActivity): FrameLay
launch = { _, _, _ -> windowControl.closeWindow(window)},
visible = windowControl.isWindowRemovable(window) && !isMaximised
)
R.id.goToSpeak -> CommandPreference(
title = application.getString(R.string.go_to_ref, speakControl.speakPageManager.currentPage.bookAndKey?.let {
if (it.document?.bookCategory == BookCategory.BIBLE && window.pageManager.isVersePageShown) {
it.key.shortName
} else {
it.shortName
}
}),
launch = { _, _, _ ->
speakControl.speakPageManager.currentPage.bookAndKey?.let {
if (it.document?.bookCategory == BookCategory.BIBLE && window.pageManager.isVersePageShown) {
window.pageManager.setCurrentDocumentAndKey(null, it.key)
} else {
window.pageManager.setCurrentDocumentAndKey(it.document, it)
}
}
},
visible = !speakControl.isStopped
)
R.id.goToReference -> CommandPreference(
title = application.getString(R.string.go_to_ref, clipboardKey?.let {
if (it.document?.bookCategory == BookCategory.BIBLE && window.pageManager.isVersePageShown) {
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/menu/window_popup_menu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
<item android:id="@+id/goToReference"
android:title=""
android:icon="@drawable/baseline_content_paste_24"/>
<item android:id="@+id/goToSpeak"
android:title=""
android:icon="@drawable/ic_baseline_headphones_24"/>
<item android:id="@+id/windowClose"
android:title="@string/windowClose"
android:orderInCategory="1001"
Expand Down

0 comments on commit cdb79e5

Please sign in to comment.