Commit Graph

372 Commits (863255c9f426bdd6845f3f3eced4f270f1baecee)

Author SHA1 Message Date
yparitcher 8c29b71e45
Tests: emptydir switch from data/dict to history (#8296)
So this test doesn't fail when one has dictionaries locally
(history folder is deprecated and should be empty).
3 years ago
NiLuJe acbf4b7a8c
Document: Round dimensions properly in getPageDimensions (#8170)
* Geom:transformByScale:
  * Apply the right scaling factor to the y axis
  * Round in a more sensible fashion (àla fz_round_rect, since we pretty much exclusively use it in a similar fashion).
* Bump base (https://github.com/koreader/koreader-base/pull/1407)
3 years ago
Martín Fernández 903646debe
[plugin] Exporter plugin without evernote (#7983) 3 years ago
Brian Hughes ba65dc155b
Adds time left for chapter and document to the screensaver message options (#7897) 3 years ago
Frans de Jonge 27fa19c9c4
[chore, spec] Version: test 8-character hash just in case (#7809)
Cf. https://github.com/koreader/koreader/issues/7805#issuecomment-855337115.
3 years ago
NiLuJe a7f23efa65
Double tap: Update default tap zones (#7711)
Make 'em match backward & forward.
Now that we have working overrides and the gesture manager, trying to fit them in a weird superset of the top corner tapzones in a vain attempt to avoid bad interactions doesn't make much sense anymore, and just makes the Gesture Manager UI confusing.

Also make sure the corner zones override the L/R ones for double taps, like it's the case with other gestures.

Fix #7710
3 years ago
NiLuJe 2986094cc9 ReaderFooter test: Untangle settings handling
Do a proper reset to defaults before each test without actually poking
at the defaults table itself.
3 years ago
NiLuJe d56a944b79 Tests: Handle FM/ReaderUI instances slightly more sanely
* Tear down FM instances properly
* Don't manhandle ReaderUI too much, and document when the tests do
  actively broken shit, like bypassing safeties to open two // ReaderUI
  instances.
3 years ago
NiLuJe 6dc1c1efca Unbreak ReaderFooter test
Tests: Update the ffi.metatype wrapper

(Better idea: move to busted master).
3 years ago
NiLuJe bb65a69193
Geom: nil guard a few rect methods (#7664)
We've managed to trip a few of those on dimen fields post-init but
pre-paintTo in a few weird coner-cases, a point at which dimen is often
nil.

ConfigDialog: Deal with that very thing in update()

Fix #7656
3 years ago
NiLuJe 21b067792d Cache: Rewrite based on lua-lru
Ought to be faster than our naive array-based approach.
Especially for the glyph cache, which has a solid amount of elements,
and is mostly cache hits.
(There are few things worse for performance in Lua than
table.remove @ !tail and table.insert @ !tail, which this was full of :/).

DocCache: New module that's now an actual Cache instance instead of a
weird hack. Replaces "Cache" (the instance) as used across Document &
co.
Only Cache instance with on-disk persistence.

ImageCache: Update to new Cache.

GlyphCache: Update to new Cache.
Also, actually free glyph bbs on eviction.
3 years ago
NiLuJe e7acec1526 ReaderUI: Saner FM/RD lifecycle
* Ensure that going from one to the other tears down the former and
    its plugins before instantiating the latter and its plugins.

UIManager: Unify Event sending & broadcasting
  * Make the two behave the same way (walk the widget stack from top to
    bottom), and properly handle the window stack shrinking shrinking
    *and* growing.
    Previously, broadcasting happened bottom-to-top and didn't really
    handle the list shrinking/growing, while sending only handled the list
    shrinking by a single element, and hopefully that element being the one
    the event was just sent to.

These two items combined allowed us to optimize suboptimal
refresh behavior with Menu and other Menu classes when
opening/closing a document.
e.g., the "opening document" Notification is now properly regional,
and the "open last doc" option no longer flashes like a crazy person
anymore.

Plugins: Allow optimizing Menu refresh with custom menus, too.

Requires moving Menu's close_callback *after* onMenuSelect, which, eh,
probably makes sense, and is probably harmless in the grand scheme of
things.
3 years ago
NiLuJe 7ed97c8714 Tests: Make the timeouts more lenient during OPDS tests
Helps prevent spurious failures when stuff is slow.
3 years ago
NiLuJe c9ba30a870 Unbreak FileManager test after #7582 3 years ago
NiLuJe e0a67bb656
OTA: Handle tar checkpointing visual feedback w/ an FBInk daemon (#7588)
Instead of forking it on every checkpoint.

Won't change much in the grand scheme of things, but FIFOs are fun.
3 years ago
NiLuJe 47c59e0e5a
Persist: Add the new native LuaJIT serializer to the list of supported codecs (#7543)
And swap the Calibre metadata cache to it.
3 years ago
NiLuJe f2e90f505b
Input: Minor cleanups (#7542)
* TimeVal: Log the results of the COARSE probes in debug logs
* GestureDetector: Print details of failed clock probes in debug logs
* GestureDetector: Skip the BOOTTIME probe when CLOCK_BOOTTIME is unsupported.
* Input: Decode ABS_DISTANCE events in debug logs
* Get rid of duplicated <linux/input.h> constants, use the FFI module everywhere (re #7536)
* Kobo: Get rid of the `touch_alyssum_protocol` quirk. Replace it by setting `main_finger_slot` to `1`, like on the H2O.
3 years ago
NiLuJe 03e9fac156
Input: Process input events in batches (#7483)
Requires https://github.com/koreader/koreader-base/pull/1344 & https://github.com/koreader/koreader-base/pull/1346 (fix #7485)

Assorted input fixes:

* Actually handle errors in the "there's a callback timer" input polling loop.
* Don't break timerfd when the clock probe was inconclusive.

Not directly related, but noticed because of duplicate onInputEvent handlers:

* HookContainer: Fix deregistration to actually deregister properly. "Regression" extant since its inception in #2933 (!).
* Made sure the three plugins (basically the trio of AutoThingies ;p) that were using HookContainer actually unschedule their task on teardown.
3 years ago
Steady Quad 8fb6ae715b
Update tests in opds_spec for Gutenberg http → https (#7489)
See #7439
3 years ago
NiLuJe 6d53f83286
The great Input/GestureDetector/TimeVal spring cleanup (a.k.a., a saner main loop) (#7415)
* ReaderDictionary: Port delay computations to TimeVal
* ReaderHighlight: Port delay computations to TimeVal
* ReaderView: Port delay computations to TimeVal
* Android: Reset gesture detection state on APP_CMD_TERM_WINDOW.
  This prevents potentially being stuck in bogus gesture states when switching apps.
* GestureDetector:
  * Port delay computations to TimeVal
  * Fixed delay computations to handle time warps (large and negative deltas).
  * Simplified timed callback handling to invalidate timers much earlier, preventing accumulating useless timers that no longer have any chance of ever detecting a gesture.
  * Fixed state clearing to handle the actual effective slots, instead of hard-coding slot 0 & slot 1.
  * Simplified timed callback handling in general, and added support for a timerfd backend for better performance and accuracy.
  * The improved timed callback handling allows us to detect and honor (as much as possible) the three possible clock sources usable by Linux evdev events.
    The only case where synthetic timestamps are used (and that only to handle timed callbacks) is limited to non-timerfd platforms where input events use
    a clock source that is *NOT* MONOTONIC.
    AFAICT, that's pretty much... PocketBook, and that's it?
* Input:
  * Use the <linux/input.h> FFI module instead of re-declaring every constant
  * Fixed (verbose) debug logging of input events to actually translate said constants properly.
  * Completely reset gesture detection state on suspend. This should prevent bogus gesture detection on resume.
  * Refactored the waitEvent loop to make it easier to comprehend (hopefully) and much more efficient.
    Of specific note, it no longer does a crazy select spam every 100µs, instead computing and relying on sane timeouts,
    as afforded by switching the UI event/input loop to the MONOTONIC time base, and the refactored timed callbacks in GestureDetector.
* reMarkable: Stopped enforcing synthetic timestamps on input events, as it should no longer be necessary.
* TimeVal:
  * Refactored and simplified, especially as far as metamethods are concerned (based on <bsd/sys/time.h>).
  * Added a host of new methods to query the various POSIX clock sources, and made :now default to MONOTONIC.
  * Removed the debug guard in __sub, as time going backwards can be a perfectly normal occurrence.
  * New methods:
    * Clock sources: :realtime, :monotonic, :monotonic_coarse, :realtime_coarse, :boottime
    * Utility: :tonumber, :tousecs, :tomsecs, :fromnumber, :isPositive, :isZero
* UIManager:
  * Ported event loop & scheduling to TimeVal, and switched to the MONOTONIC time base.
    This ensures reliable and consistent scheduling, as time is ensured never to go backwards.
  * Added a :getTime() method, that returns a cached TimeVal:now(), updated at the top of every UI frame.
    It's used throughout the codebase to cadge a syscall in circumstances where we are guaranteed that a syscall would return a mostly identical value,
    because very few time has passed.
    The only code left that does live syscalls does it because it's actually necessary for accuracy,
    and the only code left that does that in a REALTIME time base is code that *actually* deals with calendar time (e.g., Statistics).
* DictQuickLookup: Port delay computations to TimeVal
* FootNoteWidget: Port delay computations to TimeVal
* HTMLBoxWidget: Port delay computations to TimeVal
* Notification: Port delay computations to TimeVal
* TextBoxWidget: Port delay computations to TimeVal
* AutoSuspend: Port to TimeVal
* AutoTurn:
  * Fix it so that settings are actually honored.
  * Port to TimeVal
* BackgroundRunner: Port to TimeVal
* Calibre: Port benchmarking code to TimeVal
* BookInfoManager: Removed unnecessary yield in the metadata extraction subprocess now that subprocesses get scheduled properly.

* All in all, these changes reduced the CPU cost of a single tap by a factor of ten (!), and got rid of an insane amount of weird poll/wakeup cycles that must have been hell on CPU schedulers and batteries..
3 years ago
NiLuJe 0674e6060a
Screensaver: Fix a fallback snafu (#7397)
* Screensaver: Don't assume a missing show_message setting means that type
setting is, too.
3 years ago
NiLuJe 48b0f2242c
OPDSBrowser: Unbreak test (#7393) 3 years ago
NiLuJe bf6c0cdd6c
LuaSettings: Add a method to initialize a setting properly (#7371)
* LuaSettings/DocSettings: Updated readSetting API to allow proper initialization to default.
Use it to initialize tables, e.g., fixing corner-cases in readerFooter that could prevent settings from being saved.
(Fixes an issue reported on Gitter).
* LuaSettings/DocSettings: Add simpler API than the the flip* ones to toggle boolean settings.
* Update LuaSettings/DocSettigns usage throughout the codebase to use the dedicated boolean methods wher appropriate, and clean up some of the more mind-bending uses.
* FileChooser: Implement an extended default exclusion list (fix #2360)
* ScreenSaver: Refactor to avoid the pile of kludges this was threatening to become. Code should be easier to follow and use, and fallbacks now behave as expected (fix #4418).
3 years ago
Alex Vanderpot ac26ccdc58
OPDS: Parse Open Search Definition for feeds that support it (#7380) 3 years ago
NiLuJe b75ea3da03
ReaderFooter: Fix some interactions between margins and text width (#7391) 3 years ago
NiLuJe 75356f2837
flash_ui: Workaround potential EPDC races (#7332)
* flash_ui: Yield to the kernel between the HL and the UNHL/CB to let the EPDC do its thing in peace.
* UIManager: Handle nils in task scheduling arguments.
* SkimTo: Use the same, thicker chapter nav icons as ReaderSearch (fix #7326).
* SkimTo: The bookmark toggle button doesn't require a vsync flag.
3 years ago
Martín Fernández 5c9e649804
move opds to plugin (#7237) 3 years ago
poire-z a192a335f1 Footer: tweak auto refresh code
Make it similar to how it's been done recently for CRe
alt status bar, avoiding scheduling when not needed.
3 years ago
poire-z 49e2d91afb Don't toggle the footer when toggling the top status bar 3 years ago
Frans de Jonge 5c9dc850e8
Address assorted Weblate comments (#7154)
* Fix typo in dropbox

Reported by @lescheck

* Rephrase text justification explanation more elegantly

* CoverBrowser: fix up some plurals

* Statistics: remove random use of template function

* Use ngettext for minute/minutes and second/seconds

* Change KB/MB/GB to kB/MB/GB SI units
3 years ago
NiLuJe dffe86dfe9
Cleanup eye-gouging madness around io.read calls (#7149)
* Don't reinvent the wheel when reading a one-line int or string from sysfs

* Simplify a whole other bunch of read calls
3 years ago
Martín Fdez b8f0dc3752 add table persistence module 3 years ago
NiLuJe 048b0b2d83 Unbreak testsuite after #7047 3 years ago
poire-z 24424e505e Update UI layout code to use new SVG icons
- Add IconWidget, use it for icons instead of ImageWidget.
  Specify icons by name only, look for them (with either
  .svg or .png suffixes) in multiple directories (including
  koreader/settings/icons/ to allow customizing them).
  Don't crash when icon name not found, shown a black
  background warning icon instead.
- Don't trust the icons' native sizes: replace
  scale_for_dpi=true with width/height=DGENERIC_ICON_SIZE,
  so all icons get the same (tunable) size - except in
  a few specific use cases.
- Top and bottom menu bars: normalize, and have icons
  properly centered in them, extend vertical line
  separators up to the edges.
- TOC: adjust expand/collapse icons size to items size
3 years ago
NiLuJe 9cda84ef2f Prevent Busted from blowing up on cdata finalizers by properly closing
opened documents...
3 years ago
NiLuJe 83e148bc9e
Tests: Make a few things more deterministic (#6991)
This way we still get the passed/expected actual values in Busted's
output

Which helps not make this any more maddening than it already is to
update...
3 years ago
NiLuJe 493eab92c9
[RFC] Make default UI tapzones more generous (#6918)
* Top menu & bottom menu tapzones are now full-width, thanks to the now sane override system.
* A separate, extra tapzone was also created for each of them to provide a taller, but narrower tapzone extension (one that doesn't clash with the prev/next tapzones).
* The footer tapzone was made much taller.
3 years ago
poire-z 633d43b322 Devices: get rid of touch_probe_ev_epoch_time
On devices where the event time is the uptime (time since
boot), we don't need to trash it and use TimeVal:now()
and lose precision. We can still use these times for
relative delays and durations computations, which is
mostly all we use them for.
We just need a real clock time in GestureDetector for
two timers (long-press and double tap), where we do
the event time type detection on the first event, on
all devices.
4 years ago
NiLuJe dfe3502b91
ReaderStatistics: Data collection improvements (#6778)
* Update the data collection format & handler to make it much less tortuous
* Update the pagecount & resync the stats on document layout changes
* Update the database schema to allow doing most queries against a SQL view that rescales the collected data to be accurate regardless of document layout (thanks to @marek-g for the SQL magic ;)).
* Add a "reset stats for current book" entry in the list of reset options, one that won't horribly break stats in said book ;).
* Fixed a couple of resource (SQL connection) leaks (in ReaderStatistics:getCurrentBookStats & ReaderStatistics:getCurrentBookStats).
* Flush stats to the DB on periodical metadata saves.
* Minor cosmetic tweaks to the code
4 years ago
NiLuJe ec3ec8dc21
Show full ToC entry on hold (#6729)
Fix #6728
4 years ago
NiLuJe 1ac5846eff
Revamp ToC ticks handling (#6716)
Replace the level `0` `getTocTicks` heuristic with a simple sorted, deduped flat listing of *every* ToC node (via `getTocTicksFlattened`).
4 years ago
ezdiy d59a3e217e
Pocketbook: Implement HW screen rotation, bring in PB specific kludges from linuxfb (#6684)
* Uses bunch of new plumbing in base to configure screen rotations in hardware (koreader normally does this via blit buffer rotations, except for android).

* Some PB specific kludges that used to pollute core/framebuffer_linux are brought into PBs frontend driver.
4 years ago
poire-z 962fd02c98
Tame BackgroundRunner: stop running when no more job (#6605)
A BackgroundRunner plugin instance will stop running
(rescheduling a check every 2 seconds) when there is no
(or no more) job to run.
Clients of this service now have to emit an event after
adding a job into PluginShare.backgroundJobs, so an
already loaded but stopped BackgroundRunner can notice
it and start running again.
4 years ago
NiLuJe 9abd92044a
Make sure "Clear history of deleted files" actually persists. (#6557)
* Make sure "Clear history of deleted files" actually persists.

The current code was only clearing the live table, it was forgotten after a restart.
4 years ago
NiLuJe 37a01100b7
Various Wi-Fi QoL improvements (#6424)
* Revamped most actions that require an internet connection to a new/fixed backend that allows forwarding the initial action and running it automatically once connected. (i.e., it'll allow you to set "Action when Wi-Fi is off" to "turn_on", and whatch stuff connect and do what you wanted automatically without having to re-click anywhere instead of showing you a Wi-Fi prompt and then not doing anything without any other feedback).
* Speaking of, fixed the "turn_on" beforeWifi action to, well, actually work. It's no longer marked as experimental.
* Consistently use "Wi-Fi" everywhere.
* On Kobo/Cervantes/Sony, implemented a "Kill Wi-Fi connection when inactive" system that will automatically disconnect from Wi-Fi after sustained *network* inactivity (i.e., you can keep reading, it'll eventually turn off on its own). This should be smart and flexible enough not to murder Wi-Fi while you need it, while still not keeping it uselessly on and murdering your battery.
(i.e., enable that + turn Wi-Fi on when off and enjoy never having to bother about Wi-Fi ever again).
* Made sending `NetworkConnected` / `NetworkDisconnected` events consistent (they were only being sent... sometimes, which made relying on 'em somewhat problematic).
* restoreWifiAsync is now only run when really needed (i.e., we no longer stomp on an existing working connection just for the hell of it).
* We no longer attempt to kill a bogus non-existent Wi-Fi connection when going to suspend, we only do it when it's actually needed.
* Every method of enabling Wi-Fi will now properly tear down Wi-Fi on failure, instead of leaving it in an undefined state.
* Fixed an issue in the fancy crash screen on Kobo/reMarkable that could sometime lead to the log excerpt being missing.
* Worked-around a number of sneaky issues related to low-level Wi-Fi/DHCP/DNS handling on Kobo (see the lengthy comments [below](https://github.com/koreader/koreader/pull/6424#issuecomment-663881059) for details). Fix #6421 
Incidentally, this should also fix the inconsistencies experienced re: Wi-Fi behavior in Nickel when toggling between KOReader and Nickel (use NM/KFMon, and run a current FW for best results).
* For developers, this involves various cleanups around NetworkMgr and NetworkListener. Documentation is in-line, above the concerned functions.
4 years ago
Frans de Jonge 7c1a716d57
Fake battery status in readerfooter_spec to succeed on devices with batteries (#6417)
Cf. <https://github.com/koreader/koreader/pull/6370#issuecomment-662382487>.
4 years ago
Frans de Jonge 8e66494ec2
[fix] Use orderedPairs in touch menu item table (#6404)
Cf. <https://github.com/koreader/koreader/pull/6403> and <https://github.com/koreader/koreader/pull/6371>.
4 years ago
NiLuJe 4e5def4282
Tame a few tests that relied on `pairs` being somewhat deterministic (#6371)
* Mangle stupid defaults test so that it compares tables, and not a non-deterministic string representation of one.

It's still extremely dumb and annoying to update. (i.e., feel free to kill it with fire in a subsequent PR, I think everybody would cheer).

* Rewrite DepGraph to be deterministic

i.e., fully array based, no more hashes, which means no more pairs randomly re-ordering stuff.

Insertion order is now preserved.

Pretty sure a couple of bugs have been fixed and/or added along the way
;p.

* Resync frontend/apps/filemanager/lib/md.lua w/ upstream

And use orderedPairs in the attribute parsing code, just to make that stupid test happy.
4 years ago
yparitcher 70f89c4df1
ReaderGesture: cleanup (#6292)
convert all gesture actions to use events for better modularity
add network event handlers and device event handlers
4 years ago
NiLuJe 509ee7bb86
Allow locking the gyro to the current screen mode (#6347)
* Allow locking the gyro to the current screen mode (i.e., orientation).
* Tweak the "sticky rota" option to work both ways
* More rotation constant usage instead of magic numbers
4 years ago