Skip to content

Commit

Permalink
Add font size multiplier setting
Browse files Browse the repository at this point in the history
  • Loading branch information
tuomas2 committed Dec 28, 2024
1 parent eb236d5 commit bdc515c
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 4 deletions.
6 changes: 3 additions & 3 deletions app/bibleview-js/src/components/BibleView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ const contentStyle = computed(() => {
line-height: ${config.lineSpacing / 10}em;
text-align: ${config.justifyText ? "justify" : "start"};
font-family: ${config.fontFamily};
font-size: ${config.fontSize}px;
--font-size: ${config.fontSize}px;
font-size: ${config.fontSize*appSettings.fontSizeMultiplier}px;
--font-size: ${config.fontSize*appSettings.fontSizeMultiplier}px;
`;
if (config.marginSize.marginLeft || config.marginSize.marginRight) {
style += `
Expand All @@ -282,7 +282,7 @@ const modalStyle = computed(() => {
return `
--bottom-offset: ${appSettings.bottomOffset}px;
--top-offset: ${appSettings.topOffset}px;
--font-size:${config.fontSize}px;
--font-size:${config.fontSize*appSettings.fontSizeMultiplier}px;
--font-family:${config.fontFamily};`
});

Expand Down
2 changes: 2 additions & 0 deletions app/bibleview-js/src/composables/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export type AppSettings = {
genericModalButtons: GenericModalButtonId[],
monochromeMode: boolean,
disableAnimations: boolean,
fontSizeMultiplier: number,
}

export type CalculatedConfig = Ref<{
Expand Down Expand Up @@ -190,6 +191,7 @@ export function useConfig(documentType: Ref<BibleViewDocumentType>) {
genericModalButtons: ["BOOKMARK", "BOOKMARK_NOTES", "SPEAK"],
monochromeMode: false,
disableAnimations: false,
fontSizeMultiplier: 1.0,
});

function calcMmInPx() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,7 @@ class BibleView(val mainBibleActivity: MainBibleActivity,
genericModalButtons: $genericModalButtons,
monochromeMode: $monochromeMode,
disableAnimations: $disableAnimations,
fontSizeMultiplier: ${CommonUtils.settings.fontSizeMultiplierFloat},
},
initial: $initial,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import androidx.preference.Preference
import androidx.preference.PreferenceCategory
import androidx.preference.PreferenceDataStore
import androidx.preference.PreferenceFragmentCompat
import androidx.preference.SeekBarPreference
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
Expand Down Expand Up @@ -149,6 +150,9 @@ class SettingsActivity: ActivityBase() {
"google_drive_sync",
"bible_bookmark_modal_buttons",
"gen_bookmark_modal_buttons",
"monochrome_mode",
"disable_animations",
"font_size_multiplier"
)
for(key in keys) {
editor.removeString(key)
Expand Down Expand Up @@ -219,6 +223,12 @@ class SettingsFragment : PreferenceFragmentCompat() {
val showGreekMorph = setupDictionary(greekMorph, FeatureType.GREEK_PARSE)
val dictCategory = preferenceScreen.findPreference<PreferenceCategory>("dictionaries_category") as PreferenceCategory
dictCategory.isVisible = showGreek || showHebrew || showGreekMorph
val fontSizeMultiplier = preferenceScreen.findPreference<SeekBarPreference>("font_size_multiplier") as SeekBarPreference
fontSizeMultiplier.summary = getString(R.string.pref_font_size_multiplier_summary, CommonUtils.settings.fontSizeMultiplier.toString())
fontSizeMultiplier.setOnPreferenceChangeListener { pref, newValue ->
fontSizeMultiplier.summary = getString(R.string.pref_font_size_multiplier_summary, (newValue as Int).toString())
true
}

preferenceScreen.findPreference<ListPreference>("toolbar_button_actions")?.apply {
if (value.isNullOrBlank())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import net.bible.android.activity.databinding.TextSizeWidgetBinding
import net.bible.android.activity.databinding.ValueSliderWidgetBinding
import net.bible.android.database.WorkspaceEntities
import net.bible.service.common.AndBibleAddons
import net.bible.service.common.CommonUtils
import net.bible.service.common.ProvidedFont
import java.util.*

Expand Down Expand Up @@ -128,7 +129,7 @@ class FontSizeWidget(context: Context, attributeSet: AttributeSet?): LinearLayou
fun updateValue() = bindings.apply {
val availableFonts = availableFonts
val fontSize = value
dialogMessage.textSize = fontSize.toFloat()
dialogMessage.textSize = fontSize.toFloat()* CommonUtils.settings.fontSizeMultiplierFloat
fontSizeValue.text = context.getString(R.string.font_size_pt, fontSize)
val fontDefinition = availableFonts.find { it.realFontFamily == fontFamily }?:return@apply
dialogMessage.typeface = getTypeFace(fontDefinition)
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/net/bible/service/common/CommonUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ object CommonUtils : CommonUtilsBase() {

val monochromeMode: Boolean get() = getBoolean("monochrome_mode", false)
val disableAnimations: Boolean get() = getBoolean("disable_animations", false)
val fontSizeMultiplier: Int get() = getInt("font_size_multiplier", 100)
val fontSizeMultiplierFloat: Float get() = getInt("font_size_multiplier", 100) / 100F
}

private var _settings: AndBibleSettings? = null
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1235,4 +1235,6 @@
<string name="dont_show">
Don\'t show this message again
</string>
<string name="pref_font_size_multiplier_title">Font size multiplier</string>
<string name="pref_font_size_multiplier_summary">Multiply font sizes by this number. Current value: %s%%</string>
</resources>
8 changes: 8 additions & 0 deletions app/src/main/res/xml/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@
android:summary="@string/prefs_disable_animations_summary"
android:defaultValue="false"
android:icon="@drawable/ic_color_settings_24dp"
/>
<SeekBarPreference android:key="font_size_multiplier"
android:title="@string/pref_font_size_multiplier_title"
android:summary=""
android:defaultValue="100"
android:min="10"
android:max="500"
android:icon="@drawable/ic_color_settings_24dp"
/>
<Preference android:key="open_links"
android:title="@string/open_bible_links_title"
Expand Down

0 comments on commit bdc515c

Please sign in to comment.