Skip to content

Commit

Permalink
Merge pull request #2493 from AndBible/mysword-support
Browse files Browse the repository at this point in the history
Mysword support
  • Loading branch information
tuomas2 authored Feb 2, 2023
2 parents 114fb95 + 60992f0 commit fec7dbc
Show file tree
Hide file tree
Showing 15 changed files with 772 additions and 46 deletions.
35 changes: 35 additions & 0 deletions app/bibleview-js/src/components/MyBible/B.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--
- Copyright (c) 2022-2022 Martin Denham, Tuomas Airaksinen and the AndBible contributors.
-
- This file is part of AndBible: Bible Study (http://github.com/AndBible/and-bible).
-
- AndBible is free software: you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software Foundation,
- either version 3 of the License, or (at your option) any later version.
-
- AndBible is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with AndBible.
- If not, see http://www.gnu.org/licenses/.
-->

<template>
<b><slot/></b>
</template>

<script>
import {useCommon} from "@/composables";

export default {
name: "B",
setup() {
return useCommon();
},
}
</script>

<style lang="scss" scoped>
@import "~@/common.scss";
</style>
35 changes: 35 additions & 0 deletions app/bibleview-js/src/components/MyBible/Br.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--
- Copyright (c) 2022-2022 Martin Denham, Tuomas Airaksinen and the AndBible contributors.
-
- This file is part of AndBible: Bible Study (http://github.com/AndBible/and-bible).
-
- AndBible is free software: you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software Foundation,
- either version 3 of the License, or (at your option) any later version.
-
- AndBible is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with AndBible.
- If not, see http://www.gnu.org/licenses/.
-->

<template>
<br/>
</template>

<script>
import {useCommon} from "@/composables";

export default {
name: "Br",
setup() {
return useCommon();
},
}
</script>

<style lang="scss" scoped>
@import "~@/common.scss";
</style>
13 changes: 4 additions & 9 deletions app/bibleview-js/src/components/MyBible/I.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,20 @@
-->

<template>
<span v-if="show" :class="{nonCanonical: config.makeNonCanonicalItalic}"><slot/></span>
<i><slot/></i>
</template>

<script>
import {useCommon} from "@/composables";
import {computed} from "vue";

export default {
name: "I",
setup() {
const {config, ...common} = useCommon();
const show = computed(() => config.showNonCanonical);
return {show, config, ...common};
return useCommon();
},
}
</script>

<style scoped>
.nonCanonical {
font-style: italic;
}
<style lang="scss" scoped>
@import "~@/common.scss";
</style>
35 changes: 35 additions & 0 deletions app/bibleview-js/src/components/MyBible/Li.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--
- Copyright (c) 2022-2022 Martin Denham, Tuomas Airaksinen and the AndBible contributors.
-
- This file is part of AndBible: Bible Study (http://github.com/AndBible/and-bible).
-
- AndBible is free software: you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software Foundation,
- either version 3 of the License, or (at your option) any later version.
-
- AndBible is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with AndBible.
- If not, see http://www.gnu.org/licenses/.
-->

<template>
<li><slot/></li>
</template>

<script>
import {useCommon} from "@/composables";

export default {
name: "Li",
setup() {
return useCommon();
},
}
</script>

<style lang="scss" scoped>
@import "~@/common.scss";
</style>
35 changes: 35 additions & 0 deletions app/bibleview-js/src/components/MyBible/Ol.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--
- Copyright (c) 2022-2022 Martin Denham, Tuomas Airaksinen and the AndBible contributors.
-
- This file is part of AndBible: Bible Study (http://github.com/AndBible/and-bible).
-
- AndBible is free software: you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software Foundation,
- either version 3 of the License, or (at your option) any later version.
-
- AndBible is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with AndBible.
- If not, see http://www.gnu.org/licenses/.
-->

<template>
<ol><slot/></ol>
</template>

<script>
import {useCommon} from "@/composables";

export default {
name: "Ol",
setup() {
return useCommon();
},
}
</script>

<style lang="scss" scoped>
@import "~@/common.scss";
</style>
35 changes: 35 additions & 0 deletions app/bibleview-js/src/components/MyBible/Strong.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--
- Copyright (c) 2022-2022 Martin Denham, Tuomas Airaksinen and the AndBible contributors.
-
- This file is part of AndBible: Bible Study (http://github.com/AndBible/and-bible).
-
- AndBible is free software: you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software Foundation,
- either version 3 of the License, or (at your option) any later version.
-
- AndBible is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- See the GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License along with AndBible.
- If not, see http://www.gnu.org/licenses/.
-->

<template>
<strong><slot/></strong>
</template>

<script>
import {useCommon} from "@/composables";

export default {
name: "Strong",
setup() {
return useCommon();
},
}
</script>

<style lang="scss" scoped>
@import "~@/common.scss";
</style>
7 changes: 6 additions & 1 deletion app/bibleview-js/src/components/documents/OsisSegment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ import NoOp from "@/components/OSIS/NoOp";
import H3 from "@/components/MyBible/H3";
import I from "@/components/MyBible/I";
import S from "@/components/MyBible/S";
import B from "@/components/MyBible/B.vue";
import Br from "@/components/MyBible/Br.vue";
import Li from "@/components/MyBible/Li.vue";
import Ol from "@/components/MyBible/Ol.vue";
import Strong from "@/components/MyBible/Strong.vue";

const teiComponents = {
Ref: Reference, Pron: Hi, Orth: Hi, EntryFree: Div,
Expand All @@ -64,7 +69,7 @@ const andBibleComponents = {
}

const myBibleComponents = {
S, M: NoOp, I, J:Q, N: Note, Pb, F: NoOp, H: Title, E: Hi, H3,
S, M: NoOp, I, J:Q, N: Note, Pb, F: NoOp, H: Title, E: Hi, H3, B, Br, Li, Ol, Strong
}

const osisComponents = {
Expand Down
12 changes: 9 additions & 3 deletions app/src/main/java/net/bible/android/BibleApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ import net.bible.android.view.util.locale.LocaleHelper
import net.bible.service.common.CommonUtils
import net.bible.service.device.ProgressNotificationManager
import net.bible.service.sword.SwordEnvironmentInitialisation
import net.bible.service.sword.myBibleBible
import net.bible.service.sword.myBibleCommentary
import net.bible.service.sword.myBibleDictionary
import net.bible.service.sword.mybible.myBibleBible
import net.bible.service.sword.mybible.myBibleCommentary
import net.bible.service.sword.mybible.myBibleDictionary
import net.bible.service.sword.mysword.mySwordBible
import net.bible.service.sword.mysword.mySwordCommentary
import net.bible.service.sword.mysword.mySwordDictionary

import org.crosswire.common.util.Language
import org.crosswire.common.util.PropertyMap
Expand Down Expand Up @@ -108,6 +111,9 @@ open class BibleApplication : Application() {
BookType.addSupportedBookType(myBibleBible)
BookType.addSupportedBookType(myBibleCommentary)
BookType.addSupportedBookType(myBibleDictionary)
BookType.addSupportedBookType(mySwordBible)
BookType.addSupportedBookType(mySwordCommentary)
BookType.addSupportedBookType(mySwordDictionary)

LocaleProviderManager.setLocaleProvider(MyLocaleProvider)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ import net.bible.service.db.DATABASE_NAME
import net.bible.service.db.DatabaseContainer
import net.bible.service.db.DatabaseContainer.db
import net.bible.service.download.isPseudoBook
import net.bible.service.sword.isMyBibleBook
import net.bible.service.sword.mybible.isMyBibleBook
import net.bible.service.sword.mysword.isMySwordBook
import org.crosswire.jsword.book.Book
import org.crosswire.jsword.book.BookCategory
import org.crosswire.jsword.book.Books
Expand Down Expand Up @@ -179,7 +180,7 @@ object BackupControl {
var result: List<Book>? = null
withContext(Dispatchers.Main) {
result = suspendCoroutine {
val books = Books.installed().books.filter { !it.isMyBibleBook && !it.isPseudoBook }.sortedBy { it.language }
val books = Books.installed().books.filter { !it.isMyBibleBook && !it.isMySwordBook && !it.isPseudoBook }.sortedBy { it.language }
val bookNames = books.map {
context.getString(R.string.something_with_parenthesis, it.name, it.language.code)
}.toTypedArray()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ import net.bible.service.common.CommonUtils.json
import net.bible.service.common.bookmarksMyNotesPlaylist
import net.bible.service.common.displayName
import net.bible.service.common.htmlToSpan
import net.bible.service.sword.intToBibleBook
import net.bible.service.sword.mybible.myBibleIntToBibleBook
import net.bible.service.sword.mysword.mySwordIntToBibleBook
import org.crosswire.jsword.book.Books
import org.crosswire.jsword.book.sword.SwordBook
import org.crosswire.jsword.passage.Verse
Expand Down Expand Up @@ -168,24 +169,48 @@ class BibleJavascriptInterface(

@JavascriptInterface
fun openExternalLink(link: String) {
if(link.startsWith("B:")) {
// MyBible links
val (book, rest) = link.split(" ", limit=2)
val bookInt = book.split(":")[1].toInt()
val bibleBook = intToBibleBook[bookInt]?: return
val lnk = "${bibleBook.osis} $rest"
val bibleLink = BibleView.BibleLink("content", target=lnk)
scope.launch(Dispatchers.Main) {
bibleView.linkControl.loadApplicationUrl(bibleLink)
when {
link.startsWith("B:") -> {
// MyBible links
val (book, rest) = link.split(" ", limit=2)
val bookInt = book.split(":")[1].toInt()
val bibleBook = myBibleIntToBibleBook[bookInt]?: return
val lnk = "${bibleBook.osis} $rest"
val bibleLink = BibleView.BibleLink("content", target=lnk)
scope.launch(Dispatchers.Main) {
bibleView.linkControl.loadApplicationUrl(bibleLink)
}
}
} else if(link.startsWith("S:")) {
val (prefix, rest) = link.split(":", limit=2)
val bibleLink = BibleView.BibleLink("strong", target=rest)
scope.launch(Dispatchers.Main) {
bibleView.linkControl.loadApplicationUrl(bibleLink)
link.startsWith("S:") -> {
// MyBible strongs
val (prefix, rest) = link.split(":", limit=2)
val bibleLink = BibleView.BibleLink("strong", target=rest)
scope.launch(Dispatchers.Main) {
bibleView.linkControl.loadApplicationUrl(bibleLink)
}
}
link.startsWith("#b") -> {
// MySword bible links
val rest = link.substring(2)
val (bookInt, chapInt, verInt) = rest.split(".").map { it.toInt() }
val bibleBook = mySwordIntToBibleBook[bookInt]?: return
val lnk = "${bibleBook.osis}.$chapInt.$verInt"
val bibleLink = BibleView.BibleLink("content", target=lnk)
scope.launch(Dispatchers.Main) {
bibleView.linkControl.loadApplicationUrl(bibleLink)
}
}
link.startsWith("#s") || link.startsWith("#d") -> {
// MySword strongs links
val rest = link.substring(2)
val bibleLink = BibleView.BibleLink("strong", target=rest)
scope.launch(Dispatchers.Main) {
bibleView.linkControl.loadApplicationUrl(bibleLink)
}
}
else -> {
mainBibleActivity.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(link)))
}
} else {
mainBibleActivity.startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(link)))
}
}

Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/net/bible/service/common/CommonUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ import net.bible.service.db.DatabaseContainer
import net.bible.service.device.speak.TextToSpeechNotificationManager
import net.bible.service.download.DownloadManager
import net.bible.service.sword.SwordContentFacade
import net.bible.service.sword.addManuallyInstalledMyBibleBooks
import net.bible.service.sword.mybible.addManuallyInstalledMyBibleBooks
import net.bible.service.sword.mysword.addManuallyInstalledMySwordBooks
import org.apache.commons.lang3.StringUtils
import org.crosswire.common.util.IOUtil
import org.crosswire.common.util.Version
Expand Down Expand Up @@ -897,6 +898,7 @@ object CommonUtils : CommonUtilsBase() {
ttsWidgetManager = SpeakWidgetManager()

addManuallyInstalledMyBibleBooks()
addManuallyInstalledMySwordBooks()

// IN practice we don't need to restore this data, because it is stored by JSword in book
// metadata (persisted by JSWORD to files) too.
Expand Down
Loading

0 comments on commit fec7dbc

Please sign in to comment.