Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to hide verse text when sharing/copying a verse #2178

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class ShareWidget(context: Context, attributeSet: AttributeSet?, val selection:
toggleVersenumbers.isChecked = CommonUtils.settings.getBoolean("share_verse_numbers", true)
advertise.isChecked = CommonUtils.settings.getBoolean("share_show_add", true)
toggleShowReference.isChecked = CommonUtils.settings.getBoolean("share_show_reference", true)
toggleShowVerseText.isChecked = CommonUtils.settings.getBoolean("share_show_verse_text", true)
toggleAbbreviateReference.isChecked = CommonUtils.settings.getBoolean("share_abbreviate_reference", true)
toggleShowVersion.isChecked = CommonUtils.settings.getBoolean("share_show_version", true)
toggleShowReferenceAtFront.isChecked =
Expand All @@ -72,9 +73,11 @@ class ShareWidget(context: Context, attributeSet: AttributeSet?, val selection:
toggleVersenumbers.setOnClickListener { updateWidgetState() }
advertise.setOnClickListener { updateWidgetState() }
toggleShowReference.setOnClickListener { updateWidgetState() }
toggleShowVerseText.setOnClickListener { updateWidgetState() }
toggleAbbreviateReference.setOnClickListener { updateWidgetState() }
toggleShowVersion.setOnClickListener { updateWidgetState() }
toggleShowReferenceAtFront.setOnClickListener { updateWidgetState() }
toggleShowReference.setOnClickListener { updateWidgetState() }
toggleNotes.setOnClickListener { updateWidgetState() }
toggleShowSelectionOnly.setOnClickListener { updateWidgetState() }
toggleShowEllipsis.setOnClickListener { updateWidgetState() }
Expand Down Expand Up @@ -107,6 +110,7 @@ class ShareWidget(context: Context, attributeSet: AttributeSet?, val selection:
setBoolean("share_verse_numbers", bindings.toggleVersenumbers.isChecked)
setBoolean("share_show_add", bindings.advertise.isChecked)
setBoolean("share_show_reference", bindings.toggleShowReference.isChecked)
setBoolean("share_show_verse_text", bindings.toggleShowVerseText.isChecked)
setBoolean("share_abbreviate_reference", bindings.toggleAbbreviateReference.isChecked)
setBoolean("share_show_version", bindings.toggleShowVersion.isChecked)
setBoolean("show_notes", bindings.toggleNotes.isChecked)
Expand All @@ -120,7 +124,12 @@ class ShareWidget(context: Context, attributeSet: AttributeSet?, val selection:
bindings.toggleAbbreviateReference.isEnabled = bindings.toggleShowReference.isChecked
bindings.toggleShowVersion.isEnabled = bindings.toggleShowReference.isChecked
bindings.toggleShowReferenceAtFront.isEnabled = bindings.toggleShowReference.isChecked
bindings.toggleShowEllipsis.isEnabled = bindings.toggleShowSelectionOnly.isChecked

bindings.toggleShowQuotes.isEnabled = bindings.toggleShowVerseText.isChecked
bindings.toggleVersenumbers.isEnabled = bindings.toggleShowVerseText.isChecked
bindings.toggleShowSelectionOnly.isEnabled = bindings.toggleShowVerseText.isChecked
bindings.toggleShowEllipsis.isEnabled = bindings.toggleShowVerseText.isChecked && bindings.toggleShowSelectionOnly.isChecked

}

/**
Expand All @@ -139,7 +148,8 @@ class ShareWidget(context: Context, attributeSet: AttributeSet?, val selection:
showReferenceAtFront = bindings.toggleShowReferenceAtFront.isChecked,
showSelectionOnly = bindings.toggleShowSelectionOnly.isChecked,
showEllipsis = bindings.toggleShowEllipsis.isChecked,
showQuotes = bindings.toggleShowQuotes.isChecked
showQuotes = bindings.toggleShowQuotes.isChecked,
showVerseText = bindings.toggleShowVerseText.isChecked
)
val isRtl = TextUtils.getLayoutDirectionFromLocale(Locale(selection.book.language.code)) == LayoutDirection.RTL

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ object SwordContentFacade {
showVersion: Boolean = true,
showSelectionOnly: Boolean = true,
showEllipsis: Boolean = true,
showQuotes: Boolean = true
showQuotes: Boolean = true,
showVerseText: Boolean = true
): String {

class VerseAndText(val verse: Verse, val text: String)
Expand Down Expand Up @@ -259,6 +260,7 @@ object SwordContentFacade {


val verseText = when {
!showVerseText -> {""}
verseTexts.size == 1 -> {
val end = startVerse.slice(endOffset until startVerse.length)
val text = startVerse.slice(startOffset until min(endOffset, startVerse.length))
Expand Down
12 changes: 11 additions & 1 deletion app/src/main/res/layout/share_verses.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,36 +62,46 @@
android:layout_marginLeft="10dp"
android:padding="7dip"
android:text="@string/show_reference_at_front" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/toggleShowVerseText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="7dip"
android:text="@string/show_verse_text" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/toggleVersenumbers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:padding="7dip"
android:text="@string/show_versenumbers" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/toggleShowQuotes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="7dip"
android:layout_marginLeft="10dp"
android:text="@string/show_quotes" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/toggleFullVerses"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="7dip"
android:layout_marginLeft="10dp"
android:text="@string/show_full_verses"
android:visibility="gone" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/toggleShowSelectionOnly"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:padding="7dip"
android:text="@string/show_selection_only"/>
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/toggleShowEllipsis"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginLeft="27dp"
android:padding="7dip"
android:text="@string/show_ellipsis" />
<androidx.appcompat.widget.SwitchCompat
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,7 @@
<string name="verse_share_advertise">Shared using %s.</string>
<string name="show_reference">Show reference</string>
<string name="show_reference_at_front">Show at front of verse</string>
<string name="show_verse_text">Show verse text</string>
<string name="abbreviate_reference">Abbreviate reference</string>
<string name="version_name">Version name</string>
<string name="show_version_name">Include version name</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ class TestShare {
showNotes: Boolean = true,
showVersion: Boolean = true,
showEllipsis: Boolean = true,
showQuotes: Boolean = true
showQuotes: Boolean = true,
showVerseText: Boolean = true
) {

val book = Books.installed().getBook(initials) as SwordBook
Expand Down Expand Up @@ -201,6 +202,7 @@ class TestShare {
showNotes = showNotes,
showVersion = showVersion,
showEllipsis = showEllipsis,
showVerseText = showVerseText
)

assertThat(text, equalTo(compareText))
Expand Down Expand Up @@ -378,4 +380,24 @@ class TestShare {
showEllipsis = false,
showNotes = false
)

@Test
fun testShare13() =
testShare(
initials = "KJV",
verseRangeStr = "Ps.43.1",
offsetRange = 0..100,
showWholeVerse = false,
compareText = "Psalms 43:1 ",
advertiseApp = false,
showReference = true,
abbreviateReference = false,
showVersion = false,
showReferenceAtFront = true,
showVerseNumbers = false,
showQuotes = false,
showEllipsis = false,
showNotes = false,
showVerseText = false
)
}
23 changes: 3 additions & 20 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
#
# Copyright (c) 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/.
#

#Thu Sep 24 18:46:34 EEST 2020
#Sat Jan 21 14:20:25 MMT 2023
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
zipStoreBase=GRADLE_USER_HOME