Commit Graph

1103 Commits (ce624be8b83e880b1a81106a143e1440eeda4aab)

Author SHA1 Message Date
poire-z a628714f51 [RTL UI] Bidi wrapping tweaks
- Alias everything to Bidi.nowrap() when in LTR UI, as using
  LTR isolates seems uneeded when already LTR.
- Better wrapping of RTL filename by using auto direction and
  LTR-isolating only the suffix so it's always on a side.
- menu.lua: handle bidi_wrap_func outside getMenuText(), which
  may be used in other contexts.
- Add BD.filepath() and BD.dirpath()
4 years ago
poire-z d89317e820 bump crengine, fribidi, xtext
- bump crengine: (Upstream) DocX: fix paragraphs with single hyperlink
- bump fribidi to 1.0.8 (for nested isolates fix)
- xtext.makeLine(): return no_allowed_break_met=true when that
  happens, so we know the line breaks inside a word.

TextBoxWidget: add forgotten property (when use_xtext=true) when no
line break opportunity was found: has_split_inside_word=true.
(Only used by CoverBrowser Mosaic mode to make nicer text covers
by reducing font size when that happens.)
4 years ago
poire-z a838a6eb1d TextBoxWidget: fix crash when empty last line and alignment center/right (#5691) 4 years ago
poire-z ea67b9be77 TextBoxWidget: fix crash on hold after end of text (#5689) 4 years ago
Robert e26ad2b287 [UX] Adds DoubleSpinWidget (#5679)
Replaces HyphenationLimits widget by making it more generic.
4 years ago
poire-z 55f3575a10
UI font rendering: use available bold fonts for bold (#5675)
A few fixes and enhancement related to bold text:
- When using bold=true with a regular font, use its bold
  variant if one exists (can be prevented by manually
  adding a setting: "use_bold_font_for_bold" = false).
- When using a bold font without bold=true, promote bold
  to true, so fallback fonts are drawn bold too.
- Whether using a bold font, or using bold=true, ensure
  fallback fonts are drawn bold, with their available bold
  variant if one exists, or with synthetized bold.
- When using a bold variant of a fallback font, keep using
  the regular variant as another fallback (as bold fonts
  may contain less glyphs than their regular counterpart).
- Allow providing bold=Font.FORCE_SYNTHETIZED_BOLD to
  get synth bold even when a bold font exists (might be
  interesting to get text in bold the same width as the
  same text non-bold).
- Use the font realname in the key when caching glyphs,
  instead of our aliases (cfont, infont...) to avoid
  duplication and wasting memory.
4 years ago
poire-z 7952fa2c09 [RTL UI] update widgets and apps for UI mirroring
Small tweaks all around to handle UI mirroring:
- swap existing symbols like arrows, or use alternative ones
- rotate some images, like chevrons and dogear icons
- flip some left and right swipe handling
- flip some geometry arithmetic like tap on left or right
  side of page or dict window
- use new ProgressWidget:getPercentageFromPosition() instead
  of geometry arithmetic
- BD.wrap() some concatenated string bits, like in reader
  and menu footers
- flip inverse_reading_order when UI is mirrored

More specific tweaks:
- ReaderGesture: reset some specific gestures when UI direction
  has changed (tap on top/bottom left/right corners, for
  bookmarks and FileManager "Plus menu").
- ReaderRolling: show markers on the correct side of page,
  in single or dual page mode.
- KoptOptions: swap left and right icons in Alignment toggle
- CheckMark: proper rendering in all 4 mirroring/rtl combinations.
- VirtualKeyboard: forbid any mirroring
- Move util.getMenuText into Menu.lua
4 years ago
poire-z 36ce82d8c2 [RTL UI] update low-level widgets to handle mirroring
These updated low-level widgets will handle 90%
of the needed UI mirroring.
4 years ago
poire-z d6d49a64a7 [RTL UI] use auto or LTR text direction in some specific cases
Allow TextBoxWidget new text direction/lang parameters to be
set on upper widgets, and propagate them all the way to it
(ScrollTextWidget, InputText, InputDialog, TextViewer).

Use specific non-default ones in some specific cases:
- Force LTR text direction when showing HTML and CSS, and
  configuration files (in some plugins).
- Use Wikipedia server language and text direction when
  showing an article.
- Use auto with Dictionary results, as we don't know the
  dictionary language, and they may contain mixed content.
- Force LTR when showing some paths (still needs more of them)

TextEditor plugin: add 2 new options "Auto paragraph direction"
and "Force paragraph direction LTR".

Footnotes popup: grab HTML direction, and forward it
to MuPDF for proper display.
4 years ago
poire-z 3c280f6e5f KeyValuePage: proper padding between key and value
Use some HorizontalSpan for padding between key and value,
instead of prepending a space to the value text (which
won't work as expected if value text is RTL, as it would
be put on the right side of screen).
4 years ago
poire-z ef08f50336 DictQuickLookup: properly truncate title text 4 years ago
poire-z e9032a2b2a TextBoxWidget: slightly better cursor positionning in RTL text 5 years ago
poire-z 588c35967f TextBoxWidget: minor optimisations
It's best to do all free'ing via :free(), and not :onCloseWidget(),
as :free() is more logically called in cascade when upper widgets
are closed.
5 years ago
Mihai Vasiliu 2541440bb8 [UX] Add Romanian keyboard layout (#5660)
This adds a new separate Romanian keyboard layout, with popup support.

- Functional buttons are translated.
- Pages 5&6 contain 3 groups of characters (I tried my best to group them logically):
  - On the left: traditional Romanian cyrillic pre-1850s
  - On the middle latinised forms from 1850s onwards
  - On the right modern diacritics from 1900s to today
- Pages 7&8 add only large double quotes and section/paragraph mark.
- Popups are only avalable for most common diacritics. Swipe up for circumflex, swipe down for breve.

I can really call this the most complete though-the-ages Romanian keyboard. :)
5 years ago
poire-z a1247160a1 TextWidget: minor optimisations
Also fix possible crash with NumberPickerWidget.
5 years ago
Robert b0738960df Dictionary: add menu item to set font size (#5647) 5 years ago
poire-z 397211644d Keyboard: properly handle keyboard layout height change
The japanese keyboard being taller than the others, when
switching to/from it from/to another layout:
- re-init InputDialog for proper sizing and positionning
- refresh the whole screen, to remove any trace of
  a previous taller keyboard

Also add calls to :free() here and there to free keyboard
keys' TextWidgets' XText C objects without waiting for GC.
5 years ago
poire-z 13fa6d962c Korean keyboard: unwrap InputText on layout change
The korean keyboard wraps InputText and overrides some
of its methods to process input in some specific way.
When switching to another keyboard layout, the original
methods need to be restored.
5 years ago
NiLuJe 4778d3db3b
[RFC] Switch remaining keyboard icons to glyphs (#5639)
* Switch the last few remaining icons to true glyphs
(Del/Backspace & Enter).
Also, allow a glyph to be rendered in (fake) bold, and use it for Enter.
* Update fonts
Pickup the tweaked nerdfonts for the backspace symbol
5 years ago
Robert 03fda96041 [fix] Empty directory path and crash on TextWidget (#5606) 5 years ago
Frans de Jonge 7775233688
[fix] Prevent xtext crash by not freeing TextWidget prematurely (#5616)
Fixes <https://github.com/koreader/koreader/issues/5614>.
5 years ago
Frans de Jonge 15fe0fef07
[chore] Extract Cyrillic/Russian keyboard (#5610)
Follow-up to #5583.

* Add separate Cyrillic/Russian keyboard

* And remove that from English

* Update French keyboard (is easy)

* Remove yahzhert, that was just a double of QWERTY

* Update Spanish keyboard

* Reduce Japanese to 4 layers and add globe

* Reduce Korean to 4 layers

* Reduce Greek to 8 layers
5 years ago
Frans de Jonge 67b57834da
[lang] Minor touchups (#5611) 5 years ago
yparitcher 5e8d1227ef [feat, UX] Pick keyboard layout from keyboard (#5583)
* Tap goes to next activated keyboard.
* Hold opens a selection popup.
5 years ago
poire-z 89c0bd0886 ConfigDialog: allow larger toggle title text
Avoid a few truncated text, as some fit when allowed
to bite a bit on the (large) left padding.
5 years ago
poire-z dc8696bd34 TextBoxWidget: add new properties, use them in Menu
- height_adjust: if true, reduce height to a multiple of
  line_height (for nicer centering)
- height_overflow_show_ellipsis: if height overflow, append
  ellipsis to last shown line
(Implemented in both use_xtext and legacy code path.)

Use them in Menu.lua to clean up/shorten the code used for multiline
menu items by delegating the work to TextBoxWidget, or using
TextWidget when we end up needing only a single line.
5 years ago
poire-z e699a1ee22 TextBoxWidget: use xtext for text shaping
Alternative code to size, split lines and draw text with
the help of the xtext Lua C module.
Enabled by default (can be disabled via an added menu
item in "Developer options").

New properties can be specified by calling widgets, only
used when xtext is used:
- lang: use specified language instead of the UI language
- para_direction_rtl: true/false to override the default
  direction for the UI language
- auto_para_direction: detect direction of each paragraph
  in text
- alignment_strict: prevent the inversion of the specified
  alignment= that is done when a paragraph direction is
  set or detected as RTL.

Also: fix possible memory leak (present even when not using xtext)
by calling :free() in onCloseWidget() like it's done in ImageWidget.
5 years ago
poire-z 22e3e34c45 TextWidget: use xtext for text shaping
Alternative code to size and draw text with the help
of the xtext Lua C module.
Enabled by default (can be disabled via an added menu
item in "Developer options").

New properties can be specified by calling widgets, only
used when xtext is used:
- lang: use specified language instead of the UI language
- para_direction_rtl: true/false to override the default
  direction for the UI language
- auto_para_direction: detect direction of each paragraph
  in text
5 years ago
poire-z 272d8857a2 TextBoxWidget: fix two minor bugs 5 years ago
NiLuJe b21b4c8776
Update nerdfonts symbol codepoints for the updated version with no PUA (#5595)
* Update nerdfonts symbol codepoints for the updated version with no PUA conflicts

Should no longer stomp on Arabic & CJK PUA stuff.
5 years ago
Frans de Jonge 2855fdfdac
[feat] Support callback function in VirtualKeyPopup (#5588)
Required for <https://github.com/koreader/koreader/pull/5583>.
5 years ago
Frans de Jonge 425c808c18
[UX] Switch ButtonTable to COLOR_GRAY (#5585)
Same as the menu.

See <https://github.com/koreader/koreader/pull/5584>.
5 years ago
Robert 98555908c8 [fix] Enable rewind button in sort widget (#5579)
See: #5578
Close: #5578
5 years ago
Robert 2ae91ac6f6 [fix] Prevent crash on local calibre OPDS server (#5572)
Close: #5476 
- Prevent segmentation fault when we enter incorrect address of calibre opds server (eg http://192.168.1.1:8080/ instead of proper http://192.168.1.1:8080/opds
- prevent unnecessary infos in Gutenberg OPDS
5 years ago
poire-z 0885e9947d Keyboard: avoid additional key stroke on hold release (#5573) 5 years ago
Robert 371e3336a5 [feat] Favorites: organize book into collections (#5527)
View, add, remove, sort, open book to/from collections.
For now, only one collection named Favorites.
5 years ago
poire-z eb8795e4e0
ButtonTable: taller buttons for easier tap (#5554) 5 years ago
Robert 7b6a3f3cb2 [fix] Handle max_width in time widget (#5540)
Set max_width like in #5503
5 years ago
NiLuJe 8d281647ae
Unify battery meters look'n feel (#5537)
* Unify battery meters look'n feel

Switch to proper (vertical) battery icons (one per 10% steps).

Fix #5535

* Bump fonts (https://github.com/koreader/koreader-fonts/pull/7)

Because we need the new symbols from nerdfonts ;).
5 years ago
yparitcher aa165cefe9 [UX] Set global settings independent of local setting (#5522) 5 years ago
yparitcher 6c68df42ec [feat] Open unsupported documents as text (#5497) 5 years ago
Robert c7ecd08d9d Menu: new algorithm for multi-lines items (#5496)
(used by bookmarks list and classic file browser)
When text is too long or line too tall:
first: we try to decrease the number of lines (eg from 3 to 2 and from 2 to 1 line)
second: when 1 line is too tall, we try to decrease font size (-1)
And at the end we try to add or remove chars to better fit text.
5 years ago
poire-z f05e62c1fb
TextWidget: small refactoring, better handle max_width (#5503)
Lots of code was doing some renderText calls to get the size
of some text string, and truncate it to some width if needed,
with or without an added ellipsis, before instantiating
a TextWidget with that tweaked text string.

This PR fixes/adds some properties and methods to TextWidget
so all that can be done by it. It makes the calling code
simpler, as they don't need to use RenderText directly.
(Additionally, when we go at using Harfbuzz for text rendering,
we'll just have to update or replace textwidget.lua without
the need to update any higher level code.)

Also:
- RenderText: removed the space added by truncateTextByWidth
  after the ellipsis, as it doesn't feel needed, and break
  right alignment of the ellipsis with other texts.
- KeyValuePage: fix some subtle size and alignment issues.
- NumberPickerWidget: fix font size (provided font size was
  not used)
5 years ago
Nick ef22e85469 UI Changes (#5508)
* Changed File Browser text

KOReader looks nicer than KOReader File Browser,

* Remove the "page x of x" if only one page

Removes it from the bottom of the file browser

* Remove the "page x of x" if only one page

Removes it from the top menu, if there is only one page, why show page 1 of 1

* Renamed ~ to Home

Since the file browser can be considered "Home"

* Added 12 hour time option

Also tweaked the charging icon,  looks nicer than +, tweaked seperator between time and battery, - instead of @
5 years ago
Nick daacb84114 [UX] Add timeout to Wi-Fi connected message (#5514)
Resolves #5501
5 years ago
Frans de Jonge 761f332d47
[doc] Update InputDialog example (#5510)
Make it work out of the box, add some cross-references, and update a few minor things.

In response to @dontcrash.

Cf. <https://gitter.im/koreader/koreader?at=5dac431978e4974ace8c4213>.
5 years ago
NiLuJe f2f2aa6e4d
Minor state handling tweaks when the footer is disabled/invisible (#5494)
* Don't break `doc_pages` updates when it's completely disabled. (c.f., the commit's comment, doing it on every page turn seems a bit overkill, but I get that it's probably done that way because it was easier ;)).
* Detect the empty footerTextGenerator properly in `_updateFooterText` (it's `""`, not `nil`).
* Abort `_updateFooterText` early when the footer is invisible (and has been for a while/ever, i.e., when not requesting a repaint, like a mode switch would).
* Never send `SetBottomPageMargin` events twice.
* Minor tweaks to touchmenu & configdialog to avoid useless repaints (don't redraw the reader/fm unless we absolutely need to).
* Make sure we show the progress bar alone instead of nothing when disabling the last enabled mode in the menu.
5 years ago
Robert 5209493ba8 [UX] Option to show progress bar at the bottom of the screen (#5442) 5 years ago
Max CW a7ff9ba0dc ImageViewer: start with image fullscreen with no buttons shown (#5446)
Tap any part of screen to toggle bottom buttons visibility.
Swipe south to quickly close it (as long as image is scaled
to fit, and there's no need for panning).
5 years ago
Robert 7badb67e3d Fix crash on book status change (#5453) 5 years ago
Robert 056a4f9129 Fix: Crash toggleswitch when args are empty (#5438)
Fix: #5434
5 years ago
Frans de Jonge f7861bc1eb
[feat] Add haptic feedback (#5380)
References <https://github.com/koreader/koreader/issues/5374>.
5 years ago
Robert a934d2d52e [UX] Add fine tune for zoom(dpi) and font size (#5432)
Close: #5312
5 years ago
Frans de Jonge d0f95ec669
[UX] Use ProgressWidget in frontlight (#5373)
This makes it behave like a pretty decent slider.

Cf. <https://github.com/koreader/koreader/issues/5314>.
5 years ago
Robert 3de3ea04ff [UX] Better align buttonprogress in configdialog (#5427)
Similar to #5420
5 years ago
Robert 67abf9a26a Better align toggleswitch in configdialog (#5420) 5 years ago
Robert 02218cb9e2 [UX] Add fine tune in contrast (#5413) 5 years ago
yparitcher 31b9f78384 [UX] Add Hebrew keyboard (#5414) 5 years ago
Robert 28e2e664b1 fix: Truncate text in spinwidget (#5393) 5 years ago
Robert a7c358b080 [UX] Sort footer elements (#5389)
Close: #5329 

- new option for footer - `Sort items`
- new widget `SortWidget`
5 years ago
Robert b7d464ae4b Set screenshot output folder (#5382)
Close: #4230
5 years ago
Robert 54568d4dcd [UX] Add fine tune in line spacing (#5375)
See https://github.com/koreader/koreader/issues/5312#issuecomment-528506421

Progress widget has a new extra button ⋮ that triggers SpinWidget.
5 years ago
Robert 9163a85b3c Messages in numberpicker widget (#5353)
See: #5342
5 years ago
Frans de Jonge 17e437dbd0
[UX] Allow keyboard layout selection (#5318)
Fixes <https://github.com/koreader/koreader/issues/3998>.

This isn't quite what I want but I've been letting this slip for
too long due to fancier keyboard interaction concepts.
5 years ago
Robert ae50569055 Frontlight - Add checkbox use system settings (#5307)
See: https://github.com/koreader/koreader/issues/5205#issuecomment-526935357

Devices with `hasLightLevelFallback = true` (for now Android) has extra checkbutton `Use system settings`. Default unchecked.
5 years ago
NiLuJe d66cf7ab61 [fix] Allow setting a fine-tuned font size as default (#5306)
And a couple bugfix this unearthed:

* Always set the default as the *current* value, no matter what (by chance, this was not an issue for margins).
* Don't crash on the hold gesture in the -/+ buttons for the horizontal margins (regression since #5303).
5 years ago
Frans de Jonge 4cdc3ab99b
[feat, plugin] Add AutoTurn (#5295)
Fixes <https://github.com/koreader/koreader/issues/3019>.
5 years ago
Robert b038fa3046 [UX] Add fine tune buttons to horizontal margins (#5303)
Similar to top and bottom margins I add fine tune buttons to L/R margins.
5 years ago
Frans de Jonge 0b62fc56ee
[doc] Add NumberPickerWidget developer docs (#5298) 5 years ago
Frans de Jonge 37bab4fe89
[fix] Pass plain link to link:onGotoLink (#5286)
Internal links carry more baggage than external ones.

See <https://github.com/koreader/koreader/pull/5282#issuecomment-526813719>.
5 years ago
Frans de Jonge f1f6eebce0
[feat] Add MuPDF EPUB/FB2 dynamic font size (#5282)
Closes #4368.
5 years ago
Frans de Jonge be87fb27a0
[chore] Convert a couple more todos (#5267)
Cf. <https://github.com/koreader/koreader/pull/5244>.

Also update check.
5 years ago
Frans de Jonge 2c555830f9
[feat, i18n] Implement ngettext (#5257)
Fixes <https://github.com/koreader/koreader/issues/5249>.

See https://www.gnu.org/software/gettext/manual/html_node/Plural-forms.html and https://www.gnu.org/software/gettext/manual/html_node/Translating-plural-forms.html for more information.

Usage:
```lua
local T = ffiUtil.template
local _ = require("gettext")
local N_ = _.ngettext

local items_string = T(N_("1 item", "%1 items", num_items), num_items)
```
5 years ago
Frans de Jonge 6ed58346a1
[i18n] Add translator notes (#5250)
Thanks to <https://github.com/koreader/koreader/pull/5237> we can now  extract the knowledge currently embedded in Transifex and put it directly in our source. This positively affects <https://github.com/koreader/koreader/issues/3754>.

Translation instructions and knowledge that comes out of localization-related questions should be preserved in the source, because Transifex is too ephemeral. For example, the links from <https://github.com/koreader/koreader/pull/2290> are no longer accessible. Even when they are, it's quite useful to have this information around while dealing with the code as well, and I also hope it'll be informative to contributors who seldom visit Transifex.

This commit also makes a few minor changes to obviate the need for comments where possible.
5 years ago
Frans de Jonge a2dcfe9aec
[doc] Tag @todo, @fixme and @warning (#5244)
This commit standardizes the various todos around the code a bit in a manner recognized by LDoc.

Besides drawing more attention by being displayed in the developer docs, they're also extractable with LDoc on the command line:

```sh
ldoc --tags todo,fixme *.lua
```

However, whether that particular usage offers any advantage over other search tools is questionable at best.

* and some random beautification
5 years ago
Robert dc6d4085ea Fix: Unable to hold top right corner in FileManager (#5248)
Close: #5247
5 years ago
Frans de Jonge da988c15de
[CI] Switch to custom xgettext build to extract multiline strings (#5242)
Because let's face it, it just looks much better this way.

Docker image update in https://github.com/koreader/virdevenv/pull/43

Discussion in https://github.com/koreader/koreader/pull/5238#issuecomment-523675211 and https://github.com/koreader/koreader/pull/4524
5 years ago
Edoardo Putti 0906b69c06 [fix] Handle OPDS catalog responses accordingly (#5241)
- handle moved permanently HTTP 301
- handle authentication required HTTP 401
- handle authentication errors HTTP 403
- handle catalog not found HTTP 404
5 years ago
Frans de Jonge e2ceace302
[fix, CI] Push to Transifex from master, fix multiline strings for xgettext (#5238)
Related to https://github.com/koreader/koreader/pull/5237
5 years ago
Robert c57beada27 [chore] Remove Polish keyboard (#5223) 5 years ago
NiLuJe 9e4a7797c9
Honor the alpha channel in our icon for the About popup (#5208)
It ends up with a black background otherwise.
(Old regression that dates back to my alpha shenanigans a few months
ago)
5 years ago
Robert 5245bc88ff [UX] Add horizontal edge gestures (#5179) 5 years ago
poire-z a82d7832b9 Dict lookups: have them always interruptible
They should be now interruptible when fuzzy search is disabled
and on Android.
5 years ago
Robert a10fc83a4a Fix: hold bottom left corner doesn't work properly (#5177) 5 years ago
Robert 1743c0ca23 [UX] Extend the touch zone for up button in touch menu (#5175)
See: #5155
Close: #5155
5 years ago
Robert a38ba01b6e [chore] SpinWidget default_text instead of defaults_text (#5153) 5 years ago
Robert b71d0a19b8 [UX] Set font size for menu items (#5146)
Ref: #4757
This PR add option to changing the font size of items in menu widget (filemanger in classic mode, TOC) in single line mode.
Close: #4757
5 years ago
Robert 1f6af80817 [feat] Make gesture intervals configurable (#5138)
Discussion: #4842
Close: #4842
5 years ago
Robert 39bf5a4677 [feat] File manager - add option to view unsupported files (#5129)
New option to show all files (also not supported by KOReader) in file manager. Default this option is disabled.
5 years ago
poire-z 0f3f2b660b TOC: baseline align chapter name and page number 5 years ago
NiLuJe 2e7a910178
Some BookStatus QoL tweaks (#5100)
* Make the cover thumbnail respect the cover's AR in the widget
* Add a "Mark as read/unread" button in the FM's longpress menu.
* Make sure the cover_info cache is wiped if necessary (sidecar purge/BookInfo cache clear).
5 years ago
poire-z 03bbba249a
MovableContainer: avoid refresh glitches on close (#5094)
The contained widget may not have integer position/dimen
(which should probably be fixed in those that don't ensure
that), and our maths could eventually make them even more
shifted by fractional parts.
In the end, when closing the widget, the refresh code may
miss painting/cleaning 1px and leave a border of the widget
on the screen.
5 years ago
NiLuJe 4ccb1f3dd5
Allow disabling automagic image inversion in Nightmode in CRe (#5095)
* Allow disabling automagic image inversion in NightMode

Fix #4986
5 years ago
Frans de Jonge fca51757af
[fix] OPDS crash with fewer than 4 servers (#5092)
Regression introduced in <https://github.com/koreader/koreader/pull/4249>.

Fixes <https://github.com/koreader/koreader/issues/5091>.
5 years ago
limerainne 53b6e3d018 [i18n] Add Korean keyboard (2-beolsik) (#5053) 5 years ago
limerainne 98b681bb4f [fix] InputText: fix ignoring first char when carat not in front of hint (#5052) 5 years ago
poire-z 34e6f41e05
cre: fix 2 footnotes issues, bump crengine (#5031)
- Popup footnotes: workaround strange behaviour of MuPDF
  which is adding some unwanted margin above elements
  with an "id=" attribute.
- In-page footnotes: also remove any left and right margin,
  to keep footnotes aligned with the main text.
  Also add 2 classnames (witnessed in quite a few recent
  french books) to the list of classic classnames.
- Also bump crengine: CSS: fix parsing of multi classnames
  and attributes selectors
5 years ago
Frans de Jonge 8815cbe07a
[fix, chore] Abstract filename logic in util.getSafeFilename() (#5026)
Fixes https://github.com/koreader/koreader/issues/5025

The OPDS browser was doing some fancier stuff in a way that should be abstracted away in util (because it applies anywhere files will be saved):

eace8d25c1/frontend/ui/widget/opdsbrowser.lua (L482-L491)
5 years ago
Frans de Jonge 2968f558eb
[fix, UX] Ignore first hold release when keyboard opened with hold (#5011)
Fixes #4902.
5 years ago
poire-z 7c53fcd922 CRe margins: hide bottom menu on change (#5000)
So we can immediately see how's the bottom margin.
5 years ago
NiLuJe 888d3591b2
Give more control over CRe margins (#4945)
Without having to resort to weird custom defaults.

* Split the current margins setting in three:
  * Horizontal margins (because you generally want those two to be balanced).
  * Top margin & Bottom margin (because you may want to tweak those separately to deal with quirky status bar/final line shenanigans).

* Also, add a "Reclaim bar height from bottom margin" toggle to the status bar menu, to optionally make sure the status bar won't eat into the bottom margin.

* Includes a free fix to diacritics popup refresh handling in the keyboard ;).
5 years ago
NiLuJe 9134594119
Allow toggling CRe's new dithering & scaling (#4922)
Smooth scaling toggle is per document, in the gear tab.
Dithering is in the Dev top menu ;).
5 years ago
NiLuJe f63ca005c6 [fix] Update AutoWarmth state on resume (#4901)
Regression since #4871
Fix #4895

* Hide the "Configure" button in the FL/NL widget on devices where it
won't do anything

(i.e., those w/ a NL mixer).
5 years ago
Frans de Jonge 021f1d9107
[fix] VirtualKeyboard: always fall back to en (like it used to) (#4900)
Fixes #4899.
5 years ago
Frans de Jonge 4ba826ca3c
[fix] VirtualKeyPopup close refresh (#4897)
See https://github.com/koreader/koreader/pull/4891#issuecomment-481866246
5 years ago
Frans de Jonge 3f59dee721
[UX] VirtualKeyPopup: variable size (#4892)
This makes the code a lot more complex, but it looks much better.
5 years ago
Frans de Jonge fd50dc34a6
[UX] VirtualKeyPopup: close on hold release (#4891)
As suggested by @poire-z.
5 years ago
Frans de Jonge 80953b5c4c
[UX] Keyboard: add @ and A diacritics (#4889)
Also rename std to en_keyboard.
5 years ago
Frans de Jonge 69e3830bc1
[UX] VirtualKeyPopup: respond to hold & pan release (#4887)
As suggested by @poire-z in https://github.com/koreader/koreader/pull/4886#discussion_r273569802

This is actually much better than before.

It subtly changes the behavior of every key this way, but I don't think that's a bad thing.
5 years ago
Frans de Jonge 23f903274a
[UX] Keyboard character selection popup (#4886) 5 years ago
Frans de Jonge 2760b98582
[UX] Add keyboard swipes (#4884)
Only the `e` and `E` are added in this initial commit.
5 years ago
NiLuJe 4005bf69aa
Slightly less crappy Nightmode (#4871)
Companion PR to https://github.com/koreader/koreader-base/pull/884
* Basically flags devices known to be stable when using PxP inversion.
* Plus, random fix for #4870 ;).
* A few FrontLight tweaks & cleanups on Kobo:
  * Moved the Kobo-specific startup status insanity to Kobo-specific init
  * Made turnOff/turnOn frontlight do a smooth ramp down/up
  * On Kobo, use turnOff/turnOn for suspend/resume, to get that smooth toggle
  * On Kobo, for NaturalLight w/ a mixer, only set warmth for setWarmth, and only set Brightness for setBrightness, otherwise, it tried to set both with not in-sync values, which made the FL widget jittery.
5 years ago
Frans de Jonge 8466af2c5b
[UX] Gesture manager: corner gestures (#4878)
Adds configuration to the top corners as well as the additional gestures hold and two-finger tap.

Deprecates `DTAP_ZONE_FLIPPING` and `DTAP_ZONE_BOOKMARK`.

Fixes #4877.
5 years ago
Frans de Jonge 22db71c075
[fix] OPDS last-modified check (#4874)
Fixes #4873. Unfortunately this will introduce a slight delay but I don't see any other quick & reasonable solution.
5 years ago
poire-z 5c38bcb8b7 [UX] Links menu and handling tweaks (#4867)
- Removed "Swipe to follow first link on page" menu item and
  handling code, as it feels not really as practical as
  "Swipe to follow nearest link".
- Removed recently added "External link action", as we can
  just always present a popup with the url and the available
  actions.
- Generic handling of these actions in onGoToExternalLink(),
  so they are proposed on the Wikipedia lookup popup too.
- Allow external link on PDF documents (previously, only
  internal links were handled).
- Have "Ignore external links on tap" available on all
  document types.
- Added "Ignore external links on swipe" (default to true,
  the current behaviour).
- Added multiswipe gesture "Follow nearest internal link"
  (the existing "Follow nearest link" now follows the
  nearest external or internal link)
- ButtonDialogTitle: added an option to look a bit more
  alike ConfirmBoxes.
- Footnote popups: fix link unhighlight when tap on external link.
5 years ago
Frans de Jonge 0a314e3ab8
[fix] widget/scrollhtmlwidget: default_font_size same as infofont and Screen:scaleBySize() (#4864)
Otherwise it's:

1. Too small on virtually all devices due to a lack of scaling.
2. Unusably small by default.

It's currently scaled by the callers (dictquicklookup & footnotewidget) based on other properties, but you shouldn't have to change it from the default just to get something usable. ;-)
5 years ago
poire-z 8f019b8183 Night mode: keep some images non-inverted
Have the code pre-invert some images when in night mode,
so they get inverted back to normal by night mode.
This will allow images to be displayed normally in
the following contexts:
- images in credocument pages
- long-press on images in credocument viewed in ImageViewer
- cover thumbnails in File browser and History
- full size covers when viewed in ImageViewer
- images in Wikipedia lookup results
5 years ago
poire-z e2b4099228 Footnote popups: fix link unhighlight when closing with keys 5 years ago
NiLuJe b72a2000b1
A few minor fixes after #4847 (#4850)
* Add a toggle to disable the C blitter in the Dev menu (depends on https://github.com/koreader/koreader-base/pull/882) (never shown if the JIT is disabled, grayed out if the C blitter is not installed)
* Fix a few sizeUtf8Text call sites that were doing a nil check in order to account for the new return type.
* Tweak statusbar handling to avoid spurious sizeUtf8Text warnings when it's hidden, and unify its behavior between being hidden via toggle, and hidden on book open (at least when all-at-once is not enabled).
* c.f., https://github.com/koreader/koreader-base/pull/882 (Android, PB, RGB32 & Legacy Kindle regression fixes).
5 years ago
NiLuJe 7210fb478d
Faster blitting @ BB8/BBRGB32 when no processing is needed (#4847)
* Pickup the eponymous blitting performance tweaks from koreader/koreader-base#878
* Cleanup BitOpts usage (require & cache)
* Unify oddness checks (MOD -> AND)
* Enforce the native Portrait orientation on Kobo (except @ 16bpp, i.e., KSM w/ 8bpp swap disabled), to allow for faster blitting when unrotted.
* Switch CRe BB to 32BPP on color screens
* Minor cleanups
5 years ago
poire-z b7b4cdd2a7 ConfigDialog: fix possible crash (#4838)
When one has set a default for toggles thad don't have 'values' in
their definitions (possibly only Orientation).
5 years ago
NiLuJe 003de939b0 [fix] Properly account for MuPDF feeding us premultiplied alpha (#4807)
* Properly account for MuPDF feeding us premultiplied alpha

* Bump base to pickup necessary backend changes

Also includes a bunch of CMake refactoring
(https://github.com/koreader/koreader-base/pull/865
https://github.com/koreader/koreader-base/pull/867
https://github.com/koreader/koreader-base/pull/868)
5 years ago
poire-z b16aa79636
ConfigDialog ButtonProgress: black border on default item (#4805)
Make the default (user set, or KOReader's default) item
among the button progress squares shown with a black border.
5 years ago
poire-z c060595580
ConfigDialog: fix ButtonProgressWidget and some refreshes (#4793)
This internal ButtonProgressWidget widget was behaving
differently from all others (OptionTextItem, OptionIconItem
and ToggleSwitch) by duplicating some code from
ConfigDialog:onConfigChoose() instead of calling it directly.

While making it similar to others, I noticed that onConfigChoose()
did a full repaint, which was necessary for some settings to
be applied (ie: Contrast).
On CreDocument, this full repaint may cause some double drawing
on config changes (ie: Margins, drawing once after margin changes,
and then re-positionning to previous xpointer).
So, make the need for full repaint a condition on KoptOptions.
5 years ago
poire-z 9560bc2061
ConfigDialog: fix some gray mismatch in prev commit (#4797)
Remove gray underline on text items (font size items).
Adjust gray color of ButtonProgressWidget to match the
one of ToggleSwitch (just need to invert it, as it's
used to select button, which cause this color to be
inverted).
5 years ago
NiLuJe 2011cf1ad1 Various blitting related cleanups (#4789)
* Fix the "Enable debug logging" checkbox so that it properly disables "Enable verbose debug logging" when it gets disabled
* Avoid asking ImageWidget for alpha-blending when it's not useful
* Make ImageWidget's alpha-blending code-path double-check that alpha-blending actually is needed, and avoid it if possible
* In the same vein, only do alpha-blending in textboxwidget when absolutely necessary
* Prefer color constants over the gray() method, ensuring that they're part of the eInk palette

Depends on https://github.com/koreader/koreader-base/pull/853

Fix #4774
5 years ago
NiLuJe 930286d3f5 Slightly prettier virtual keyboard (#4776)
Add a thin border around keys (square)
5 years ago
Frans de Jonge 2536cc2645
[fix] widget/menu: Don't propagate ShowGotoDialog to other widgets (#4761)
Fixes #4760.
5 years ago
Qingping Hou 634fed5487 use device instead of canvascontext in UI modules 5 years ago
Qingping Hou 1605409c60 rename runtimectl to document/canvascontext 5 years ago
Qingping Hou adb5d5a52c use screen for UI color control 5 years ago
Qingping Hou d749591984 decouple device from pdfdocument, font & bgr checking 5 years ago
Qingping Hou 02eca23649 decouple device from document modules 5 years ago
poire-z 779909343c [UX] ButtonProgressWidget: thin grey buttons instead of black (#4700)
May help with ghosting when closing bottom dialog,
and fit better with the other grey toggles.
5 years ago
Frans de Jonge 1d1dc74290 [UX] creoptions: add more margin values
Fixes #4684.
5 years ago
Frans de Jonge 1475acdae7
[UX] Gesture manager: add action - go to (#4690)
Cf. <https://github.com/koreader/koreader/issues/4687>.
5 years ago
Galunid 015fb4d34e Allows adjusting highlight start and end (#4582)
Adds arrow buttons under Delete|Edit.
Tap to move by word, hold to move by char.
5 years ago
NiLuJe abc6d17a25
A few minor fixes after #4541 (#4561)
* Enforce dithering in PicDocument
* Ensure we'll get a flashing update on ScreenSaver exit
5 years ago
NiLuJe 8189945be9
A few graphics fixes after #4541 (#4554)
* Various FocusManager related tweaks to limit its usage to devices with a DPad, and prevent initial button highlights in Dialogs on devices where it makes no sense (i.e., those without a DPad. And even on DPad devices, I'm not even sure how we'd go about making one of those pop up anyway, because no Touch ;)!).
* One mysterious fix to text-only Buttons so that the flash_ui highlight always works, and always honors `FrameContainer`'s pill shape. (Before that, an unhighlight on a text button with a callback that didn't repaint anything [say, the find first/find last buttons in the Reader's search bar when you're already on the first/last match] would do a square black highlight, and a white pill-shaped unhighlight (leaving the black corners visible)).
The workaround makes *absolutely* no sense to me (as `self[1] -> self.frame`, AFAICT), but it works, and ensures all highlights/unhighlights are pill-shaped, so at least we're not doing maths for rounded corners for nothing ;).
5 years ago
NiLuJe 812e595608
Enable HW dithering in a few key places (#4541)
* Enable HW dithering on supported devices (Clara HD, Forma; Oasis 2, PW4)
  * FileManager and co. (where appropriate, i.e., when covers are shown)
  * Book Status
  * Reader, where appropriate:
    * CRe: on pages whith image content (for over 7.5% of the screen area, should hopefully leave stuff like bullet points or small scene breaks alone).
    * Other engines: on user-request (in the gear tab of the bottom menu), via the new "Dithering" knob (will only appear on supported devices).
  * ScreenSaver
  * ImageViewer
* Minimize repaints when flash_ui is enabled (by, almost everywhere, only repainting the flashing element, and not the toplevel window which hosts it).
  (The first pass of this involved fixing a few Button instances whose show_parent was wrong, in particular, chevrons in the FM & TopMenu).
* Hunted down a few redundant repaints (unneeded setDirty("all") calls),
  either by switching the widget to nil when only a refresh was needed, and not a repaint,
  or by passing the appropritate widget to setDirty.
  (Note to self: Enable *verbose* debugging to catch broken setDirty calls via its post guard).
  There were also a few instances of 'em right behind a widget close.
* Don't repaint the underlying widget when initially showing TopMenu & ConfigDialog.
  We unfortunately do need to do it when switching tabs, because of their variable heights.
* On Kobo, disabled the extra and completely useless full refresh before suspend/reboot/poweroff, as well as on resume. No more double refreshes!
* Fix another debug guard in Kobo sysfs_light
* Switch ImageWidget & ImageViewer mostly to "ui" updates, which will be better suited to image content pretty much everywhere, REAGL or not.

PS: (Almost 💯 commits! :D)
5 years ago
poire-z 335a513826 [chore] cleanup multi-lines translatable strings
Revert 9971eb85 and make multi-lines strings more readable.
(Multiline translatable strings extraction has been fixed
in koreader-misc tralua_xgettext.py.)
5 years ago
Sergey Avseyev 744316ea6f opds: add two more public servers (#4515) 5 years ago
Sergey Avseyev 3337e45381 opds: fix parsing OPDS from textos.info (#4514) 5 years ago
NiLuJe 81b255cb85 Better-than-nothing key repeat handling.
Mainly aimed at the Forma.
Still fairly terrible, as these things goes ;p.
5 years ago
poire-z 4d67dd59ca Rationalize Links> menu items
- Remove duplicated "Show footnote popup". Have the same setting
  applied for Tap or 'Swipe to follow nearest link'.
- Make some menu items enabled or disabled depending on if they would
  have some effect with the current state of other menu items, as
  some kind of visual self-documentation of these dependancies.
- Add menu item to set the footnote popup font size, relative to
  the book font size.
- SpinWidget: allow for showing some informative text
5 years ago
poire-z df28b90419 TouchMenu: show checkboxes in grey for disabled menu items 5 years ago
poire-z 77ec8e32e9 ConfigDialog: tweak widths computation
Small fixes to widths computation for a more balanced layout.
Decreased min width of names (on the left) from 33% to 25%, to
allow more room for toggles on the right.
(May make things a little bit too stretched out with english,
but should help with other languages that use longer words to
name things than english.)

Also ignore disabled option names in the names width calculation
(noticable on the PDF right most config menu, where toggles were
uneededly too small)
5 years ago
poire-z f533acb7f9 InfoMessage: avoid overflowing screen height with long messages
When no height= provided, and the InfoMessage would overflow
screen height when some long message is provided, decrease the
font size until the widget fit.
5 years ago
NiLuJe f6743a45db
Proper Forma support (#4414)
* Enforce a known rotation on startup, to make sure we handle touch input coordinates properly.
* Proper FrontLight warmth support (thanks to @cairnsh & @pazos in #4291)!
* Fix the PageTurn buttons mapping to match Nickel's defaults
* Properly remap PageTurn buttons depending on the current rotation.
* Actually enable the Mk.7 screen refresh codepath on *all* Mk.7 devices (I'd messed up the device check...).
* Full accelerometer handling (includes a touch of refactoring regarding orientation handling in general).
* Fix insidiously broken USBMS behavior in Nickel after we exit on FW >4.8.

Fix #4291
Fix #3002
5 years ago
endofline 295cc55e03 [fix] ODPS: socket.http redirect, where the target is a different host (#4420)
Split https/http code-path (as socket.http can adjust the Authorization/Host headers automatically)
Warn the user when the protocol differs from http/https
5 years ago
poire-z ed8f87f9f4 Fix diagonal refresh not working in TOC and History
By delegating diagonal swipe handling to GestureManager only
when the Menu or FileChooser instance is the FileManager one.
6 years ago
Sergey Avseyev 063071fcdf [UX] Set timeout for wifi result info message (#4371)
When Wifi is connected, the message "Connected." stays on the screen
waiting for the user feedback. The change sets reasonable timeout
for info message to disappear
6 years ago
poire-z 872c908a02 [UX] ConfigDialog: larger tap area around font and icons (#4351)
The font size items (Aa Aa ... Aa) and the align & column
items (for PDF) had a non-tapable spacing between them,
which could make hitting an item difficult.
This replaces this spacing by padding on each side of the item,
so a tap in between will always catch one item, for easier
selection.
6 years ago
poire-z f8199dd493
Fix a few edge cases crashes and issues (#4334)
- ReaderConfig does not need to call again self:initGesListener() on
  screen rotation/resize, as it uses the TouchZone infrastructure
  that deals itself with rotation. So, it was adding new gestures
  that were overriding tap on footer and preventing it from working.
- ReaderFooter: fix refresh area (which was too small when toggling
  from hidden to visible)
- ReaderToc: fix crash when showing TOC in scroll mode after rotation
- Menu: fix crash when no onReturn defined (could happen when tap on
  bottom left corner when showing an empty TOC)
6 years ago
poire-z 5d6807620f Fix footnote size after screen rotation (#4316) 6 years ago
Martín Fernández 1e69fae7bc [feat] Add support for BQ/Fnac devices (#4294)
Adds support for devices found in https://blog.bq.com/es/bq-ereaders-developers-program/. Tested on BQ Cervantes 4 (last BQ device from 2017).

It adds a new touch input event handler (discussed in #4275) which should work on other single touch devices (ie: Kobo Touch, Mini, Glo, Aura HD) but wasn't tested.

Includes base bump with: [feat] Add BQ/Fnac device support (https://github.com/koreader/koreader-base/pull/745)
6 years ago
Yann Muller 3fa2dad0b7 Fix for Internet Archive URL. 6 years ago
Yann Muller 030a02dfc4 Escape &, < and > when removing CDATA. 6 years ago
Yann Muller 9c251185eb Filter out CDATA. 6 years ago
Yann Muller 64d00b2969 [UX] Display the author in OPDS catalogs. (#4278) 6 years ago
poire-z 1b3d974bec Footnotes: fix current link being unhighlight in some cases
When a link is covered by the footnote widget, we highlight it
again when closing the footnote, and schedule an unhighlight
0.5s later.
When we tap on another footnote link, this was happening too
but the unhighlight unhighlighted all, including the new
footnote link.
This disable the former when the latter happens.
6 years ago
Qingping Hou a72f8b6338 decouple UI from core document code 6 years ago
poire-z f9086a2ba9
EPUB links: show footnotes in popup, larger tap area (#4261)
Adds new options to the Links> submenu, for now only
available and used with CRE documents.
- Allow larger tap area around links
- Ignore external links
- Show footnotes in popup
- Show more links as footnotes

(This last item is mostly for testing and loosening the
footnote detection algorithm, and see how it would behave
with glossary-like links and inter glossary terms links.)

Fix distance computation from gesture position to link by
using segments.
Code for detecting if a link is a footnote is in cre.cpp, and
tweakable a bit with flags in ReaderLink:showAsFoonotePopup().

Footnotes HTML content is displayed by a new FootnoteWidget,
which uses MuPDF for its rendering.
From it, swipe south or tap outside to close, swipe to the left
to follow the original link and jump to the footnote location
in the book.

Also fix tap on highlights after the recent change to use segments
for displaying: use segments also when checking taps.
6 years ago
poire-z 0e2a3b6263 Selection menu: allow viewing HTML 6 years ago
Robert 6cf0a6473f OPDS - change url for Internet Archive (#4249) 6 years ago
Robert a29f0fb190 Add support for tiff and gif format in screensaver (#4250) 6 years ago
Robert 9fda983001 Add OPDS authentication (#4248) 6 years ago
Robert dc5a479b66 Gesture manager (initial) (#4240)
Manager supports separate gestures for the file manager and the reader. Gestures from the manager have a higher priority than built-in gestures.

Settings available in Gear -> Device -> Gesture manager
6 years ago
Martín Fernández a6df153d2c add spanish keyboard with Ñ character (#4244) 6 years ago
poire-z 47bcfc531e
Allow closing full screen dialogs with swipe down (#4237)
Mostly all that have a close button at top right, that may
be hard to reach or hit for some people: TOC, Bookmarks, History,
KeyValuePage (Book information, Statistics...), Book status...
Added full refresh on diagonal swipe where it was missing.
CoverMenu: removed onSwipe override, as it had become the same as
Menu a few months ago.
6 years ago
NiLuJe f2abdd4dfe Fix touchmenu unhilight optimization (#4236)
* Don't optimize away a touchmenu unhighlight when we need it

Fix #4234
(Regression after #4189, which, incidentally, gave us a neat way to
handle the issue, which was theoretically present well before that ;)).

* Bump base

Pickup latest changes, just because we can ;).
(OpenSSH bump)
6 years ago
Robert ad45eb28de Change icon in About window (#4233) 6 years ago
Robert afc8427d96 [UX] Add password field to FTP (Cloud storage) (#4232) 6 years ago
Robert eed3a4b5a2 Fix setting contrast on non-touch devices (#4219) 6 years ago
Robert a706fde2d7 Cleanup downloadmgr titles (#4222) 6 years ago
poire-z 850be52177
Keep some menus open when Tap or Hold (#4189)
TouchMenu: added options to menu items with the following defaults:
    keep_menu_open = false
    hold_keep_menu_open = true
So, default for Tap callback is to close menu, and for Hold callback
to keep menu open.
In both cases, provide the TouchMenu instance as the 1st argument to
the callback functions (instead of a refresh_menu_func I added in #3941)
so the callback can do more things, like closing, refreshing,
changing menu items text and re-ordering...

ReaderZooming: show symbol for default (like it was done for
ReaderFont, ReaderHyphenation...)
TextEditor plugin: update the previously opened files list in real
time, so the menu can be kept open and used as the TextEditor main
interface.
SSH plugin: keep menu open and update the Start/Stop state in real time
ReadTimer plugin: tried to do what feels right (but I don't use it)

Also remove forgotten cp in the move/paste file code
6 years ago
poire-z e1ba5ccffe Various minor fixes (#4172)
- css tweaks: use correct CSS "hyphens:" instead of "hyphenate:"
- screenshoter: more logical order of lines (no change in what it does)
- textviewer: make diagonal swipe really trigger a full refresh
- textwidget: more adequate text length to help with centering
- toggleswitch: fix sizing & centering with correct calculations
  (this reduces a bit the size of switches, and may cause a new
  truncation in some translations)
6 years ago
Robert 225b5d417d Adds ReaderDeviceStatus: low battery alarm (#4144) 6 years ago
Robert 55dab14c71 Change title and button text in OPDS (#4155) 6 years ago
Robert 7e6802737e Sorting: adds Sort by name - mixed files and folders (#4140)
Also moves the 2 Sort by percent in a sub-menu
6 years ago
poire-z adceda15b7
TextEditor: allow scrolling by lines with Pan (#4145)
Feature of ScrollTextWidget, only used for now by TextEditor.
Pan is like Swipe, but wait a bit at end of gesture to release:
the line on which Pan was started will be moved to where Pan is
released.

May conflict with MovableContainer (so not enabled for DictQuickLookup,
where it could have been nice - but it would work only with text
dictionaries, not with HTML ones, as ScrollHtmlWidget can't really
do that).
6 years ago
alethiophile 637abfdf84 Various changes to sorting (#4067)
Don't consider sidecar file when sorting by access time.
Rename 'sort by title' to 'sort by filename':
This is in accordance with the actual function of the code, which
uses filename rather than title as specified in file metadata.
6 years ago
poire-z 6e35e683dd
Text editor plugin, InputDialog enhancements (#4135)
This plugin mostly sets up a "Text editor>" submenu, that allows
browsing files, creating a new file, and managing a history of
previously opened file for easier re-opening.
It restore previous scroll and cursor positions on re-opening.
Additional "Check lua" syntax button is added when editing
a .lua file, and prevent saving if errors.
The text editing is mainly provided by the enhanced InputDialog.

InputDialog: added a few more options, the main one being
'save_callback', which will add a Save and Close buttons
and manage saving/discarding/exiting.
If "fullscreen" and "add_nav_bar", will add a show/hide keyboard
button to it.
Moved the preset buttons setup code in their own InputDialog
methods for clarity of the main init code.
Buttons are now enabled/disabled depending on context for feedback
(eg: Save is disabled as long as text has not been modified).

Added util.checkLuaSyntax(lua_string), might be useful elsewhere.
6 years ago
poire-z 1d18b01cf7
PathChooser: clearer usage and behaviour (#4133)
Explicit new options: select_directory, select_file, show_files.
With select_directory, show an entry to select current directory
(so, removed undocumented hack "hold on .. to select current
directory").
6 years ago
poire-z 9971eb8533 Fix untranslatable strings (#4132)
Some problem somewhere with [[...]] strings starting with a
leading newline. Should probably be allowed, but for now
fix the few such cases to allow them being translated.
6 years ago
poire-z 620542b055
Text input related fixes & enhancements (#4124)
InputText: checks whether provided content can be given
back unaltered, which may not be the case after it is
splitted to UTF8 chars if the text is binary content.
Prevent editing text if that is the case.
Adds InputText and InputDialog :isEditable() and :isEdited()
methods.
Also accounts for the scrollbar width when measuring text
to prevent it from being displayed when not needed.
Also ensure a minimal size of the scrollbar thumb so it is
rendered when huge text with many lines is displayed.

Virtual keyboard: Hold on Backspace: delete from cursor
to start of line instead of clearing all text content.
6 years ago
Robert 19b1c919d6 FileChooser, PathChooser: show current path in header (#4125) 6 years ago
Robert 00a71a84ad Screenshoter: propose to set as screensaver image (#4113) 6 years ago
NiLuJe fea0d8dbaf
Another set of fixes (#4083)
* Make findcalibre actually useful

By setting SEARCH_LIBRARY_PATH when a Calibre tree is found, so that
book paths can properly be constructed.

Users should still very much set it themselves, but at least everything
works as intended when not, instead of mysteriously half-breaking later.

Drop the SetDefaults bits, it appeared to have been added to fix no-ops
detected by Luacheck, and it's actually non-functional, because
SetDefaults doesn't handle saving variables it did not itself assign.
So this was just causing the "Do you want to save new defaults" popup to
show up on exit, but it couldn't actually do anything useful (like, say,
save the new SEARCH_LIBRARY_PATH value).

fix #4082

* Better comments about the state of NaturalLight on the Clara, and how this might translate to the H2O²r2.

re #4015

* Make ScrolltextWidget refresh as "partial" only on actual Scroll events

Moving the cursor should stay "ui", or things gets annoying really fast
;).

re #4084

* Bump base to pickup ZMQ fixes (fix #4086)
6 years ago
poire-z 0d66ea7555
Text input fixes and enhancements (#4084)
InputText, ScrollTextWidget, TextBoxWidget:
- proper line scrolling when moving cursor or inserting/deleting text
  to behave like most text editors do
- fix cursor navigation, optimize refreshes when moving only the cursor,
  don't recreate the textwidget when moving cursor up/down
- optimize refresh areas, stick to "ui" to avoid a "partial" black
  flash every 6 appended or deleted chars

InputText:
- fix issue when toggling Show password multiple times
- new option: InputText.cursor_at_end (default: true)
- if no InputText.height provided, measure the text widget height
  that we would start with, and use a ScrollTextWidget with that
  fixed height, so widget does not overflow container if we extend
  the text and increase the number of lines
- as we are using "ui" refreshes while text editing, allows refreshing
  the InputText with a diagonal swipe on it (actually, refresh the
  whole screen, which allows refreshing the keyboard too if needed)

ScrollTextWidget:
- properly align scrollbar with its TextBoxWidget

TextBoxWidget:
- some cleanup (added new properties to avoid many method calls), added
  proxy methods for upper widgets to get them
- reordered/renamed/refactored the *CharPos* methods for easier reading
  (sorry for the diff that won't help reviewing, but that was needed)

InputDialog:
- new options:
   allow_newline = false, -- allow entering new lines
   cursor_at_end = true, -- starts with cursor at end of text, ready to append
   fullscreen = false, -- adjust to full screen minus keyboard
   condensed = false, -- true will prevent adding air and balance between elements
   add_scroll_buttons = false, -- add scroll Up/Down buttons to first row of buttons
   add_nav_bar = false, -- append a row of page navigation buttons
- find the most adequate text height, when none provided or fullscreen, to
  not overflow screen (and not be stuck with Cancel/Save buttons hidden)
- had to disable the use of a MovableContainer (many issues like becoming
  transparent when a PathChooser comes in front, Hold to paste from
  clipboard, moving the InputDialog under the keyboard and getting stuck...)

GestureRange: fix possible crash (when event processed after widget
destruction ?)

LoginDialog: fix some ui stack increase and possible crash when switching
focus many times.
6 years ago
poire-z 7666644362
Bookmarks, CoverBrowser: scale dogear icon (#4081)
The Dogear icon is 20x20 pixels and was never scaled where used. Now:
- The bookmark icon (top right of screen) is scaled to 1/32th of the screen
width (previously, it was 1/30th on a 600px wide emulator, 1/53th on a GloHD).
On CreDocument, furthermore decrease its size if needed depending on the
selected margins so it never overwrite the text.
- CoverBrowser list view: scale it to the available room under
the "N % of P page" text, so it does not cover "page".
- CoverBrowser mosaic view: scale it to 1/16th of the cover rectangle, which
should prevent if from overwritting the text thanks to a max text width of
7/8 of the cover rectangle.

Also for CoverBrowser: don't index metadata for unsupported document
(which could happen when browsing files with PathChooser) and show
full filename for such documents.
Also: ImageWidget: small fix in case we use both scale_factor and
scale_for_dpi.
6 years ago
NiLuJe 464672108e
Misc. minor fixes (#4080)
* Unbreak dropbear after #4077
* Move the Kindle SO check to init
* Various virtual keyboard fixes to eradicate the remaining refresh conflicts (i.e., tearing artifacts), no matter the user's settings. (re #4069, re #3130).
6 years ago
Robert 5caabfb174 OpenWithDialog widget: improved display (#4078)
- add refresh after tap Cancel button,
- radiobutton and checkbutton with the same font size,
- truncates text outside window,
- better control font face and size in OpenWithDialog
  and RadioButtonTable widgets
6 years ago
poire-z 665cb37308
VirtualKeyboard: scale icons to fit font height (#4069)
The 4 keys that use images could be too big or too small
depending on screen size and DPI. They are now scaled in
all cases to fit font height.
6 years ago
Robert 6220d05a34 Fix focus/unfocus in MultiInputDialog (#4060)
Also fix size of window DCREREADER_CONFIG_FONT_SIZE
in Advanced settings
6 years ago
NiLuJe 75df3fcea3
Dismiss Wi-Fi scan popup after connection (#4055)
* Add a config switch to automatically dismiss the WiFi scan popup on connect
6 years ago
Robert 1510e5d7ed Buttons: properly truncate text when too long (#4057) 6 years ago
poire-z 9e4db559ab
TouchMenu: properly truncate item text when too long (#4052) 6 years ago
Robert d29a65b96e cre: add Word Gap setting to bottom config panel (#4026)
Maps to crengine's Space Condensing feature (named Word Gap
as a similar feature is named for PDF)
6 years ago
poire-z 6e8cb23d33
bump crengine: fix drawing position of bottom and right borders (#4013)
Also let tap propagate when a Notification is displayed.
6 years ago
NiLuJe 5871132c25
UI Behavior tweaks (#3983)
* Switch all initial highlights to "fast" update

i.e., everything that does an invert
Plus a few other things that refresh small UI elements onTap
Re #3130

* Tweak refreshtype for a number of widgets:
  * Fix iconbutton dimen
  * Make touchmenu flash on close & initial menu popup. Full-screen on close.
  * Use flashing updates when opening/closing dictionary popup. Full-screen on close.
  * Switch FileManager to partial.
    It's mostly text, and we want flash promotion there.
  * Make configdialog & menu flash on exit
  * Make FLWidget flash on close
  * virtualkeyboard: flash on layout change & popup.
  * Potentially not that great workaround to ensure we actually see the
highlights in the FM's chevrons
  * Flash when closing BookStatus Widget
  * Optimize away a quirk of the dual "fast" update in touchmenu

* Promote updates to flashing slightly more agressively.

* Document what each refreshtype actually does.

With a few guidelines on their optimal usecases.

* Switch remaining scheduleIn(0.0) to nextTick()

* Tighter scheduling timers

Shaving a hundred ms off UI callbacks...

* Cache FFI C Library namespace

* Ask MuPDF to convert pixmaps to BGR on Kobo

Fix #3949

* Mention koxtoolchain in the README

re #3972

* Kindle: Handle *all* fonts via EXT_FONT_DIR instead of bind mounts insanity

* Make black flashes in UI elements user-configurable

(All or nothing).

* Jot down some random KOA2 sysfs path
6 years ago
Robert 895372f781 Show current and default values in config dialog (pdf) (#3973) 6 years ago
poire-z 9b6b91b743
TouchMenu: added hook to show help text on long-press (#3980)
When Hold and there is no hold callback attached to a menu item, a help_text
attribute, when present, is shown in an InfoMessage.
6 years ago
Robert b7f67ea8a8 template -> T (#3966) 6 years ago
Robert 136a72f316 [UX] Notification are displayed too short (#3962)
Changed from 1 second to 2.

I also fixed the problem with blocking the UI when displaying the message. Now notification box is closed after taping anywhere (like InfoMessage).
6 years ago
Robert da65db191b Show current and default values in config dialog (epub) (#3952)
when long-press on the title strings on the left of the buttons
6 years ago
Robert fbd549bcfd
End of document action (#3943)
* End of document action

* Rev1

* Rev2

* Rev3

* File browser
6 years ago
poire-z a9905c5129
Font menu: add symbols for default and fallback fonts (#3941)
Also allows for updating the fallback font and see results
in real-time on the underlying document.
Bump crengine for: fix updating fallback font

Also adds a menu item to generate a html document showing some
sample text rendered with each available font (only if the user has
a file koreader/settings/fonts-test-sample.html with some HTML
snippet of his choice).
6 years ago
poire-z 0fc7a5ed6d
ProgressWidget: add some bound checks (#3916)
Avoid drawing the fill bar our of the progress bar.
Avoid zero divided by zero that return 'nan' (Not a Number),
that does not bother lua code, but will crash libblitbuffer.so
when it gets nan as a coordinate.
6 years ago
poire-z 4bb3999cbc RenderImage: factorize all image rendering and scaling code
New module RenderImage (alongside existing RenderText) to provides
image rendering and scaling facilities.
Uses MuPDF, but tries first giflib on GIF.
Allows for getting all the frames from an animated GIF.
6 years ago
poire-z 782a57121c ImageViewer: allow viewing a list of images
Mostly useful for browsing the frames of animated GIFs
(but generic enough for other uses).
6 years ago
poire-z d601eabc4a TextBoxWidget: optimize memory usage (#3904)
By reducing the number of data structures, and avoiding nested tables,
which seemed to impose a lot of work on the garbage collector.
6 years ago
poire-z 7f6aebe399
cre hyphenation: allow for setting min left/right fragment length (#3890)
When hyphenating a word, the existing algorithms enforced a minimal
length of 2 for each word fragments on left or right side.
This adds a widget to allow changing these minimal sizes (from 1 to 10).
6 years ago
Frode Austvik 2dc508537c [fix] Update charpos in InputText after moving the cursor up/down. (#3874) 6 years ago
David Engster 7a28c7d7aa [fix, UX] frontlightwidget: More space for text and centering
Otherwise clock display will have a line break for low DPI (see issue
6 years ago
David Engster 33c8c36f7a [fix, UX] frontlightwidget: Reduce text for automatic warmth
Reduce text size because for larger fonts this would not fit into
widget's size (issue #3825).
6 years ago
David Engster cb0fadb80b [fix, UX] naturallightwidget: Reduce text size in button
'Save settings' was too large a string for larger fonts, so replace
with just 'Save' (issue #3825).
6 years ago
David Engster 9b67323326 [UX] naturallightwidget: Use unicode minus for button 6 years ago
poire-z 2473ebce01
Wikipedia link: check if previously saved as EPUB (#3837)
Also makes MultiConfirmBox movable, like ConfirmBox is.
6 years ago
poire-z eb613ace3e [chore] CoverBrowser: avoid page info code duplication (#3835)
Also allows full refresh with small diagonal swipe
of Menu instances (TOC, bookmarks)
6 years ago
poire-z 6a997cf609 [UX] FileManager menu: split Settings tab into 2 tabs (#3836) 6 years ago
Frans de Jonge 489bfb4c77
[fix, i18n] ui/widget/frontlightwidget: translators don't need to worry about number of spaces (#3823)
Transifex warns about some issues but this is not one of them.

The proper solution would be `padding_right`. But although it's supported on FrameContainer it's not passed on through TextBoxWidget.
6 years ago
David Engster daa1f466ff [feat, UX] frontlighwidget: Support for automatic warmth
If the device supports it, add a checkbox for enabling automatic
warmth, and a widget for setting the hour at which warmth should be
maximal ("bedtime").

The hour can be changed through +/- buttons; holding them will change
with 30min steps. As soon as automatic warmth is enabled, the 'warmth'
cannot be changed manually anymore, so we make its widget grey, but
the current value is still displayed correctly. Changing the hour
changes warmth accordingly.
6 years ago
onde2rock f893b01f04 [fix, UX] CoverBrowser: reset cursor (#3817)
Also don't show the underline before the first key move.
6 years ago
onde2rock 74a06d98a2 [chore] Code cleanup : deprecate the 'Enter' event, replaced with 'Press' (#3815)
'Escape' now do 'Back' on SDL
'Enter' now do 'Press' on SDL
6 years ago
onde2rock e502bf04d3 [feat, UX] Support the virtualKeyboard on non touch-device (#3796)
* [VirtualKeyboard] Add support for keynaviguation

Also rename the variable "layout" to "keyboard_layout" because conflict
with the layout from the focusmanager

* Make the goto dialog compatible with key naviguation

My solution is to change the order of the widget. The last one will the
virtualkeybard so it catch all the keybinding, and below it, make the
dialog "is_always_active = true" so it can receive touch event.

* Correctly show the virtual keyboard on dpad devices

* change the order to call the virtualKeyboard so it end up on top

* Handle the multi input dialog

* Support reopening the virtualKeyboard by the Press key

* add check focusmanager

* Fix https://github.com/koreader/koreader/issues/3797

* MultiInputDialog : Now work on non touch-device

* Set the virtualkeyboard to be a modal widget

* Fix the layout in multiinputwidget

* Fix for the various combination of
hasKeys,hasDpad,isTouchDevice

* [Focusmanager] Better handling of malformed layout
6 years ago
Frode Austvik f36d93a8f7 [Fix] Make ScrollTextWidget:moveCursor return the new charpos. (#3808) 6 years ago
onde2rock dfd87447da [UX] Make the reader bottom menu compatible with key navigation (#3785)
* [toggleswitch] Add support for key navigation to this widget

Add the onFocus an onUnfocus event handler
add a new function that just circle the switch if not touch event is
detected

* Add key navigation to the readermenu

The shortcut is still Alt-gr on sdl, to be defined on Kindle

* Remove the old method of handling the Press key.

Now the event is handled by the main widget who implement focusmanager
and then dispatched to the currently focused item.
Modify the fine font tuning only for non touch-devices

See : https://github.com/koreader/koreader/pull/3785#issuecomment-375306466
6 years ago
Frans de Jonge 65a63d244b
[UX] SDL2: set window title (#3784)
This initial implementation only sets the title for FileManager and ReaderUI.

Fixes #3713.
6 years ago
onde2rock 1b91470899 [FocusManager] More intuitive key navigation + spec (#3774)
FocusManager now finds the closest widget on the right or left on inner horizontal border.

See : https://github.com/koreader/koreader/pull/3765#issuecomment-373944897
6 years ago
Frans de Jonge d0f1dee618 [UX, fix] ui/widget/menu: add onScreenResize action 6 years ago
onde2rock 5fcb804d47 Allow opening hold menu on non touch devices (#3765)
Emulate the hold touch behavior on non touch device by clicking the right key
ButtonTable: do not add vertical separator to the layout because the focus
manager can't traverse them. Add check to make disabled button non-clickable.
6 years ago
poire-z 5e47a83e6a
UIManager: avoid painting widgets covered by a full screen widget (#3770)
Navigating the TOC, viewing a full screen image, browsing
reading stats... would call paintTo() on ReaderUI (so, asking
the engine to render the page) or FileManager (so, rendering cover
images) even though their content is hidden.
Widgets registering to UIManager have to explicitely states
they cover the full screen (UIManager can't know, parts of their
dimen may be transparent, e.g. if it is a CenterContainer).
6 years ago
poire-z b46628c08c
new option: Save Wikipedia EPUB in current book directory (#3762)
Also uses PathChooser (instead of InputDialog) in 'Set Wikipedia
Save as EPUB directory'. When setting not yet set, propose to
create and use ~/Wikipedia/ .
6 years ago
onde2rock e8aab49ee9 Kindle4NT improvements (#3745)
* [device][kindle4] add fake event to kindle4

* modify focusmanager to allow for more complex layout

The focusmanager now naviguate the layout by avoiding nil value
instead of relying on table lenght. It should be completely backward
compatible

* add Dpad naviguation to the touchmenu

* fix crash because virtualkeyboard on non touch device

the kindle4NT has no keyboard nor touch, the fix open the virtual
keyboard so koreader dont crash but it's not useable

* Enable device with keys to use the touchmenu

* Don't get stuck in reader progress statistics plugin

* [underlinecontainer] Fix and remove unused function

References #1898.
6 years ago
David Engster 51b6e1625e ui/widget/frontlightwidget: Add 'Configure' button
For devices with natural light (KA1, H2O2), add new button 'Configure'
at the bottom which will open the naturallightwidget, which will be
placed at the top. The frontlightwidget will be moved to the bottom,
and both have permanent focus. This way, you can change the parameters
and immediately test them by changing the frontlight level and
warmth. On the KA1, both widgets will easily fit, but on smaller
devices it may be that they overlap.

Since the frontlightwidget will keep focus, we disable the 'Configure'
button when the naturallightwidget opens. We also remove its 'Close'
button and disable 'onTapCloseFL', so that the frontlightwidget cannot
be closed while the naturallightwidget is displayed.
6 years ago
David Engster 4fe80a0817 ui/widget/naturallightwidget: New widget to configure gain/offset
This widget is used to configure the natural light on KA1/H2O2. It
allows the user to set the gain/offset values for white/red/green, as
well as the exponent used in the formula.

Numbers can be changed via screen keyboard or through the plus/minus
buttons next to the numbers (holding the buttons will in/decrase with
smaller steps). Changes are applied immediately, but will only be set
permanently if 'OK' is pressed. If 'Cancel' is pressed, the new values
are discarded and the old ones restored. Also, pressing 'OK' will save
these values in the koreader settings file (there's no support for
changing these values in Nickel, so there's nothing to sync to its
config file). The 'Restore Default' button will install the original
defaults that were derived from Nickel's behavior.

This widget is meant to be called from the frontlight widget and is
placed at the top, so that the frontlight widget can still be used to
test the current values (see next commit).
6 years ago
poire-z c93bbec40d
cre: more constrast settings (#3737)
Use ButtonProgress like it was done for kopt.
6 years ago
poire-z 48da3dc750
Fix some issues with movable dict window (reworked) (#3726)
Clearer rework of this fix (a few commits ago): more explicite,
no need for the additional callback.
6 years ago
Frans de Jonge e15a1ab1b3
[fix, spec] InputText:addChars() unicode handling (#3729)
Also rename from `addChar` to `addChars` for clarity.

Fixes #3703.
6 years ago
poire-z e7f705bf10 Fix some issues with movable dict window (#3722)
Some Hold and move (hold on title and move away from it) would not work.
Pan (=swipe with hold at end) while selecting text would move the
window (it now does nothing: proper text selection still needs Hold
on word at start).
Also increase hold duration from 2s to 3s (for switching lookup
between dict/wikipedia) to be consistent with the 3s duration in
readerhighlight.
6 years ago
poire-z a8e71706b1 coverbrowser list view: show book status (#3708)
Replace reading percentage with 'Finished' or 'Abandoned'
when book status is no more 'Reading' (can be changed back
via Book Status widget).
6 years ago
Frans de Jonge ca6a486806
[UX] InputText: Paste on hold (#3682)
See https://github.com/koreader/koreader/issues/3441
6 years ago
David Engster 78284e13d9 frontlightwidget: Add widgets for changing 'warmth' if available
If the device supports natural light (currently only KA1), extend the
frontlight widget to also allow for changing the 'warmth' value. We
more or less duplicate the widget for 'brightness', with the exception
that we drop the 'toggle' button, which does not make much sense for
the frontlight's warmth. Also, we add captions 'Brightness' and
'Warmth' for clarity.
6 years ago
David Engster 95951953f2 frontlightwidget: Make 'powerd' an object member
Small refactoring to make it easier to access 'powerd' object.
6 years ago
Frans de Jonge dc0dc7e962
[feat, UX] Add new OpenWithDialog based on RadioButton and RadioButtonTable (#3678)
Fixes #3659
6 years ago
Robert 39738955f3 File manager: added 'Go to letter' (#3664)
When Hold on page number, allows for inputing letters to go to file
starting with them (and not only numbers to go to page number).
6 years ago
Robert 04b49a7c80 [fix, UX] timewidget and datewidget in landscape mode (#3666) 6 years ago
poire-z c0c243c41a Menu: don't underline items on touch devices (#3663)
First item would be underlined if the device is both Touch and Keys
capable (emulator, android, pocketboot...), which is not really
pretty. Delay that till Keys for focusing are really used.
6 years ago
Robert 9c373f138f Menu: speed up rendering of long texts (#3657)
Slowness mostly noticable in Bookmarks with long highlights
6 years ago