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

Better e-ink support #3354

Merged
merged 59 commits into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
14d506a
Add monochrome (e-ink) mode and disable colors
tuomas2 Dec 25, 2024
4df8f1b
Disable colors in ButtonGrid if monochrome mode
tuomas2 Dec 25, 2024
44a0cfa
Try to fix epub crash
tuomas2 Dec 25, 2024
1058270
Do not dim background in e-ink mode when using drawer
tuomas2 Dec 25, 2024
4c42bc5
Disable some animations with e-ink
tuomas2 Dec 25, 2024
dce7529
Set toolbar to black when e-ink
tuomas2 Dec 25, 2024
a3f759a
Remove page up/down scrolling animation
tuomas2 Dec 26, 2024
94b9e07
Remove highlight animation with e-ink
tuomas2 Dec 26, 2024
fece69d
Do not animate loading indicator with e-ink
tuomas2 Dec 26, 2024
1c90e8c
Add prev/next page buttons and helper lines if top margin is enabled
tuomas2 Dec 26, 2024
85c1437
Show topmargin for non-bibles too if e-ink mode enabled
tuomas2 Dec 26, 2024
b4e89ce
Make next/prev page buttons a bit larger
tuomas2 Dec 26, 2024
e00d051
Use paddings instead of margins for left&right margins, making center…
tuomas2 Dec 26, 2024
6d5b7a0
Disable animations if in e-ink mode
tuomas2 Dec 26, 2024
54ba3b1
Improve next / prev page buttons
tuomas2 Dec 26, 2024
dcfe7c6
Fix night mode
tuomas2 Dec 26, 2024
36eadeb
Split to two modes: disable animations and monochrome mode
tuomas2 Dec 27, 2024
0c6e26b
Add to bottom-most window touch block area to prevent reacting to and…
tuomas2 Dec 27, 2024
2d2ee7a
Adjust SpeakTransportWidget for monochrome mode
tuomas2 Dec 27, 2024
20b2f57
Disable some animations for e-ink
tuomas2 Dec 27, 2024
35ec93b
Remove borders from next/prev buttons
tuomas2 Dec 28, 2024
3b2ce28
Remove bottom-margin line and make so that last line is displayed fir…
tuomas2 Dec 28, 2024
54f7a53
Remove box-shadow from e-ink displays
tuomas2 Dec 28, 2024
5619645
Adjust some colors to monochrome
tuomas2 Dec 28, 2024
1608222
Revert "Adjust some colors to monochrome"
tuomas2 Dec 28, 2024
eb236d5
Add force sync button to toolbar if there is space
tuomas2 Dec 28, 2024
bdc515c
Add font size multiplier setting
tuomas2 Dec 28, 2024
09fb646
Add icons for new settings
tuomas2 Dec 28, 2024
bc27f3e
Change summary for font size multiplication setting
tuomas2 Dec 28, 2024
ba93548
Revert topMargin change: show only with bibles
tuomas2 Dec 30, 2024
c56ab2c
Make margins act as next / back button
tuomas2 Dec 31, 2024
8349b38
Remove colors from bookmarks in monochrome mode
tuomas2 Dec 31, 2024
80a6250
Make pagedown animation faster
tuomas2 Dec 31, 2024
8a1df0f
Remove blocking modal backdrop color in monochrome
tuomas2 Dec 31, 2024
831adb1
Wait 2 seconds until starting sync after returning from sleep
tuomas2 Dec 31, 2024
eecc1ba
Remove force sync button
tuomas2 Dec 31, 2024
5ffe860
Clean up fontawesome.ts
tuomas2 Dec 31, 2024
364daf1
Do not scroll up / down when modal is open
tuomas2 Dec 31, 2024
dfa6bab
Change night mode monochrome highlight color
tuomas2 Dec 31, 2024
ac3324e
Adjust some colors
tuomas2 Dec 31, 2024
db04ad3
Fix modal closing by tapping borders
tuomas2 Dec 31, 2024
514c0ad
Clean up code
tuomas2 Dec 31, 2024
2ed94ad
Code review fixes
tuomas2 Dec 31, 2024
7b4de38
Fix lint
tuomas2 Dec 31, 2024
aaae011
Fix js tests
tuomas2 Dec 31, 2024
b0215c6
Adjust colors a bit more
tuomas2 Dec 31, 2024
153b6ca
Adjust modal colors for e-ink
tuomas2 Jan 1, 2025
93f81eb
Change highlight color back to darker, now it is not visible any more
tuomas2 Jan 1, 2025
ab4c2e9
Adjust highlight color also a bit darker
tuomas2 Jan 1, 2025
808e988
Aggressively seek the position even if it can't be found in the curre…
tuomas2 Jan 1, 2025
acf1833
Remove some more colors for monochrome mode
tuomas2 Jan 1, 2025
fcb42d3
Fix link opening in wrong document if force-doc=true
tuomas2 Jan 1, 2025
d7163cc
Fix reference highlighting with monochrome
tuomas2 Jan 1, 2025
668195e
Wait a little longer for WIFI
tuomas2 Jan 1, 2025
d816a83
Syncronize automatically when network state is restored
tuomas2 Jan 1, 2025
14e5e61
Add proper loading indicator for monochrome
tuomas2 Jan 1, 2025
0cb27d0
Remove force sync code (not used, not needed)
tuomas2 Jan 1, 2025
f6c573e
Fix verse-notifier (when reading direction is changed)
tuomas2 Jan 1, 2025
1422e90
Revert "Syncronize automatically when network state is restored"
tuomas2 Jan 1, 2025
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
14 changes: 14 additions & 0 deletions app/bibleview-js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app/bibleview-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"dependencies": {
"@fortawesome/fontawesome-svg-core": "~6.5.2",
"@fortawesome/free-solid-svg-icons": "~6.5.2",
"@fortawesome/free-regular-svg-icons": "~6.5.2",
"@fortawesome/vue-fontawesome": "~3.0.6",
"@vue/runtime-core": "~3.4.23",
"color": "~4.2.3",
Expand Down
7 changes: 4 additions & 3 deletions app/bibleview-js/src/__tests__/bookmarks.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe("verseHighlight tests", () => {

const highlightColorFn = (v) => Color(v.color);

const css = verseHighlighting({highlightLabels, highlightLabelCount, underlineLabels, underlineLabelCount, highlightColorFn});
const css = verseHighlighting({highlightLabels, highlightLabelCount, underlineLabels, underlineLabelCount, highlightColorFn, appSettings: {nightMode: false}});
expect(css).toBe(result);
}

Expand Down Expand Up @@ -79,7 +79,7 @@ describe("useBookmark tests", () => {
let gb, b;
let startOrd, startOff, endOrd, endOff;
beforeEach(() => {
const {config} = useConfig();
const {config, appSettings} = useConfig();
gb = useGlobalBookmarks(config, {value: "bible"});
const fragmentReady = ref(true);
b = useBookmarks(
Expand All @@ -91,7 +91,8 @@ describe("useBookmark tests", () => {
true,
fragmentReady,
{adjustedColor: () => null},
config
config,
appSettings,
);
gb.updateBookmarkLabels([{
id: 1,
Expand Down
20 changes: 18 additions & 2 deletions app/bibleview-js/src/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@

$button-border-radius: 8px;
$button-padding: 6px;
$button-grey: #8e8e8e;
$button-grey: var(--modal-grey);

.button {
font-size: 90%;
Expand All @@ -111,6 +111,9 @@ $button-grey: #8e8e8e;
background-color: #616161;
color: #bdbdbd;
}
.night.monochrome & {
color: white;
}
}
&.warning {
background: rgba(255, 0, 0, 0.5);
Expand Down Expand Up @@ -160,18 +163,31 @@ $button-grey: #8e8e8e;
justify-content: flex-start;
}

$modal-header-background-color: rgba(172,172,172,1);
:root {
--modal-grey: rgb(172,172,172);
.monochrome {
--modal-grey: rgb(76, 76, 76);
}
}

$modal-header-background-color: var(--modal-grey);
$night-modal-header-background-color: rgba(69,69,69,1);

$modal-content-background-color: #fefefe;
$modal-content-background-color-night: rgb(33, 33, 33);

.highlight-transition {
transition: background-color 0.5s ease;
.noAnimation & {
transition: none;
}
}

.isHighlighted {
background-color: rgba(0, 0, 0, 0.1);
.monochrome & {
background-color: rgba(0, 0, 0, 0.2);
}
.night & {
background-color: rgba(255, 255, 255, 0.3);
}
Expand Down
6 changes: 6 additions & 0 deletions app/bibleview-js/src/components/AmbiguousActionButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ setupKeyboardListener((e: KeyboardEvent) => {
// padding-inline-end: 14px; // Causes non-alignment of the icons in the verse action dialog.
.horizontal & {
color: $button-grey;
.monochrome.night & {
color: white;
}
margin: 0 auto 0 auto;
padding-bottom: 5px;
$size: 20px;
Expand All @@ -188,6 +191,9 @@ setupKeyboardListener((e: KeyboardEvent) => {

.title {
margin: 0 auto 0 auto;
.monochrome.night & {
color: white;
}
}

padding-bottom: 0.5em;
Expand Down
122 changes: 100 additions & 22 deletions app/bibleview-js/src/components/BibleView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
-->

<template>
<div @click="ambiguousSelection?.handle" :class="{night: appSettings.nightMode}" :style="topStyle" :dir="direction">
<div
@click="ambiguousSelection?.handle"
:class="{night: appSettings.nightMode, noAnimation: appSettings.disableAnimations, monochrome: appSettings.monochromeMode}"
:style="topStyle"
:dir="direction"
>
<div class="background" :style="backgroundStyle"/>
<div :style="`height:${calculatedConfig.topOffset}px`"/>
<div :style="modalStyle" id="modals"/>
Expand All @@ -35,13 +40,25 @@
<div class="bottom-right-corner"/>
</div>
<div id="top"/>
<div class="loading" v-if="isLoading"><div class="lds-ring"><div></div><div></div><div></div><div></div></div></div>
<div id="content" ref="topElement" :style="contentStyle">
<div style="position: absolute; top: -5000px;" v-if="documents.length === 0">Invisible element to make fonts load
properly
<div class="loading" v-if="isLoading">
<div v-if="appSettings.disableAnimations" class="loading-icon">
<FontAwesomeIcon size="2x" icon="fa-regular fa-clock"/>
</div>
<div v-else class="lds-ring"><div/><div/><div/><div/></div>
</div>
<div id="content" ref="topElement" :style="contentStyle">
<div style="position: absolute; top: -5000px;" v-if="documents.length === 0">Invisible element to make fonts load properly</div>
<DocumentBroker v-for="document in documents" :key="document.id" :document="document"/>
</div>
<template v-if="!modalOpen">
<div class="prev-page-button" @click.stop="scrollUpDown(true)" :style="{width: `${calculatedConfig.marginLeft}px`}"/>
<div class="next-page-button" @click.stop="scrollUpDown()" :style="{width: `${calculatedConfig.marginRight}px`}" />
</template>
<div
v-if="appSettings.isBottomWindow"
@touchmove.stop.prevent
class="bottom-touch-block"
/>
<div id="bottom"/>
</div>
</template>
Expand Down Expand Up @@ -78,14 +95,15 @@ import {useKeyboard} from "@/composables/keyboard";
import {useVerseNotifier} from "@/composables/verse-notifier";
import {useAddonFonts} from "@/composables/addon-fonts";
import {useFontAwesome} from "@/composables/fontawesome";
import {useConfig} from "@/composables/config";
import {black, useConfig, white} from "@/composables/config";
import {useOrdinalHighlight} from "@/composables/ordinal-highlight";
import {useModal} from "@/composables/modal";
import {useCustomCss} from "@/composables/custom-css";
import {useCustomFeatures} from "@/composables/features";
import {useSharing} from "@/composables/sharing";
import {AnyDocument, BibleViewDocumentType} from "@/types/documents";
import AmbiguousSelection from "@/components/modals/AmbiguousSelection.vue";
import {FontAwesomeIcon} from "@fortawesome/vue-fontawesome";

console.log("BibleView setup");
useAddonFonts();
Expand Down Expand Up @@ -135,7 +153,7 @@ function getFootNoteCount() {

provide(footnoteCountKey, {getFootNoteCount});

const {closeModals} = modal;
const {closeModals, modalOpen} = modal;

const mounted = ref(false);

Expand Down Expand Up @@ -229,7 +247,9 @@ provide(androidKey, android);
const ambiguousSelection = ref<InstanceType<typeof AmbiguousSelection> | null>(null);

const backgroundStyle = computed(() => {
const colorInt = appSettings.nightMode ? config.colors.nightBackground : config.colors.dayBackground;
const nightColor = appSettings.monochromeMode ? black : config.colors.nightBackground;
const dayColor = appSettings.monochromeMode? white : config.colors.dayBackground;
const colorInt = appSettings.nightMode ? nightColor : dayColor;
if (colorInt === null) return "";
const backgroundColor = Color(colorInt).hsl().string();
return `
Expand All @@ -238,7 +258,9 @@ const backgroundStyle = computed(() => {
});

const contentStyle = computed(() => {
const textColor = Color(appSettings.nightMode ? config.colors.nightTextColor : config.colors.dayTextColor);
const nightColor = appSettings.monochromeMode? white: config.colors.nightTextColor;
const dayColor = appSettings.monochromeMode ? black: config.colors.dayTextColor;
const textColor = Color(appSettings.nightMode ? nightColor : dayColor);

let style = `
max-width: ${config.marginSize.maxWidth}mm;
Expand All @@ -250,13 +272,13 @@ 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 += `
margin-left: ${config.marginSize.marginLeft}mm;
margin-right: ${config.marginSize.marginRight}mm;
padding-left: ${config.marginSize.marginLeft}mm;
padding-right: ${config.marginSize.marginRight}mm;
`;
}
return style;
Expand All @@ -266,17 +288,29 @@ 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};`
});

const topStyle = computed(() => {
const backgroundColor = Color(appSettings.nightMode ? config.colors.nightBackground : config.colors.dayBackground);
const nightTextColor = appSettings.monochromeMode? white: config.colors.nightTextColor;
const dayTextColor = appSettings.monochromeMode ? black: config.colors.dayTextColor;

const nightBackgroundColor = appSettings.monochromeMode ? black : config.colors.nightBackground;
const dayBackgroundColor = appSettings.monochromeMode? white : config.colors.dayBackground;

const backgroundColor = Color(appSettings.nightMode ? nightBackgroundColor : dayBackgroundColor);
const noiseOpacity = appSettings.nightMode ? config.colors.nightNoise : config.colors.dayNoise;
const textColor = Color(appSettings.nightMode ? config.colors.nightTextColor : config.colors.dayTextColor);
const verseNumberColor = appSettings.nightMode ?
textColor.fade(0.2).hsl().string() :
textColor.fade(0.5).hsl().string();
const textColor = Color(appSettings.nightMode ? nightTextColor : dayTextColor);
let verseNumberColor: string;
if (appSettings.monochromeMode) {
verseNumberColor = textColor.hsl().string();
} else {
verseNumberColor = appSettings.nightMode ?
textColor.fade(0.2).hsl().string() :
textColor.fade(0.5).hsl().string();
}

return `
--bottom-offset: ${appSettings.bottomOffset}px;
--top-offset: ${appSettings.topOffset}px;
Expand All @@ -302,15 +336,19 @@ setupEventBusListener("adjust_loading_count", (a: number) => {
const isLoading = computed(() => documents.length === 0 || loadingCount.value > 0);

function scrollUpDown(up = false) {
const amount = window.innerHeight / 2;
doScrolling(window.pageYOffset + (up ? -amount : amount), 500)
const amount =
window.innerHeight
- calculatedConfig.value.topOffset
- 1.5*lineHeight.value; // 1.5 times because last line might be otherwise displayed partially
doScrolling(window.scrollY + (up ? -amount : amount), 200)
}

setupEventBusListener("scroll_down", () => scrollUpDown());
setupEventBusListener("scroll_up", () => scrollUpDown(true));

useSharing({topElement, android});
const direction = computed(() => appSettings.rightToLeft ? "rtl" : "ltr");

</script>
<style lang="scss">
@import "~@/common.scss";
Expand All @@ -324,6 +362,14 @@ $ring-thickness: calc(#{$ring-size} / 12);
top: calc(50% - #{$ring-size} / 2);
}

.loading-icon {
border-radius: 50%;
background: white;
.night & {
background: black;
}
}

$ring-color: $button-grey;

.lds-ring {
Expand Down Expand Up @@ -452,11 +498,19 @@ $borderDistance: 0;
left: 0;
right: 0;

.night & {
.night & {
background-color: rgba(255, 255, 255, 0.15);
}

background-color: rgba(0, 0, 0, 0.15);

.noAnimation & {
background-color: unset;
border-bottom: 1px dashed rgba(0, 0, 0, 0.5);
}
.night.noAnimation & {
border-bottom: 1px dashed rgba(255, 255, 255, 0.5);
}
}

a {
Expand Down Expand Up @@ -521,4 +575,28 @@ a {
width: 5em;
height: 1em;
}

.next-page-button {
position: fixed;
right: 0;
bottom: 0;
top: 0;
width: 0;
}

.prev-page-button {
@extend .next-page-button;
left: 0;
right: unset;
}

.bottom-touch-block {
position: fixed;
bottom: 0;
height: 1cm;
width: 100%;
background: transparent;
z-index: 10;
}

</style>
Loading
Loading