Commit Graph

919 Commits (master)

Author SHA1 Message Date
zwim 41e78b6ed3
userpatch: allow monkey-patching KOReader (#9104)
Supersede old android-only patch.lua.
2 years ago
Robert-Jan de Dreu 040dbfe1bd
Pocketbook: Keep wifi alive as long as wifi is enabled (#9208)
Schedule wifi keep-alive on wifi start but do not reschedule when
connection is lost. This will make sure this code is not run when
wifi is disabled again saving some battery and cpu cycles.
2 years ago
Martín Fernández b7a27a3db3
Fullscreen refactor (#9237)
Commonize fullscreen code across different devices.

Add fullscreen toggle on SDL desktop targets. 
Expose the toggle to the dispatcher and map it to F11.

Hide touchmenu when resizing.
2 years ago
NiLuJe 4f4b1e523a
Kobo: Handle the new Libra 2 hardware revision properly (#9234)
Includes a base bump for KoboUSBMS (https://github.com/koreader/koreader-base/pull/1493)

Fix #9218
2 years ago
NiLuJe dcb11c2542
Make luacheck >= 0.26 happy (#9174)
Re: https://github.com/koreader/koreader-base/pull/1487
2 years ago
Martín Fdez d644b1a851 android: update doShareText signature 2 years ago
NiLuJe e1ac3c4853
Minor Input:inhibitInput followup to #9065 (#9139)
* GestureDetector: Downgrade probeClockSource log messages to debug

We're seeing a bit more of 'em between autostandby and inhibitInput now,
and the whole thing was implemented long enough ago that it's no longer
critical to see this in random non-debug logs ;).

* Input: Reset gesture state in inhibitInput

Should prevent bogus gestures when re-enabling the handlers if we were
called in the middle of gesture detection.
2 years ago
NiLuJe ae5b2d68ca
AutoSuspend: Don't send LeaveStandby events from a zombie plugin instance (#9124)
Long story short: the LeaveStandby event is sent via `tickAfterNext`, so if we tear down the plugin right after calling it (in this case, that means that the very input event that wakes the device up from suspend is one that kills ReaderUI or FileManager), what's in UIManager's task queue isn't the actual function, but the anonymous nextTick wrapper constructed by `tickAfterNext` (c.f., 
https://github.com/koreader/koreader/issues/9112#issuecomment-1133999385).

Tweak `UIManager:tickAfterNext` to return a reference to said wrapper, so that we can store it and unschedule that one, too, in `AutoSuspend:onCloseWidget`.

Fix #9112 (many thanks to [@boredhominid](https://github.com/boredhominid) for his help in finding a repro for this ;)).
Re: #8638, as the extra debugging facilities (i.e., ebb81b9845) added during testing might help pinpoint the root issue for that one, too.

Also includes a minor simplification to `UIManager:_checkTasks`, and various other task queue related codepaths (e.g., `WakeupMgr`) ;).
2 years ago
yparitcher 8f316b1e8c
Merge `discardEvents` & `inhibitInput` (#9065)
Rename `discardEvents` to `inhibitInputUntil`
only discard Input events
2 years ago
Glen Sawyer cb95dcd4c9
Fix reMarkable crash bug v2022.05: event overwrite with new time module (#9121)
The change from timeval to time completely broke reMarkable.
frontend/device/remarkable/device.lua was using TimeVal:now() to manually overwrite event time values, as noted in the code comments.
Input:handleTouchEv is expecting those event time values to be timevals, not integer times.
So as soon as the user touches the screen, crash.
2 years ago
NiLuJe 118e063ae2
PocketBook: Don't break synthetic power input events on suspend
Regression since #9036
Fix #9095
2 years ago
NiLuJe fa76b9d615
Kindle: Fix retrieveNetworkInfo on the K4 (#9073)
Thanks to @hius07
(https://github.com/koreader/koreader/issues/7881#issuecomment-1028921755)
;).

Fix #7881
2 years ago
NiLuJe 2de2a8ab76
NetworkManager: Make sure we show an IM at the *start* of a Wi-Fi toggle action (#9064)
Ensures the worst-case scenario has minimal visual feedback.
2 years ago
zwim 9b9cfe29a4
[feat] Replace TimeVal (RIP) with time, fixed point time seconds (#8999) 2 years ago
yparitcher 54ead5fc88 Page turn animations
Kindle PW5 (MTK) with hardware support
Currently only in Crengine
2 years ago
NiLuJe 86c35ad066
A host of low power states related tweaks (#9036)
* Disable all non power management related input during suspend. (This prevents wonky touch events from being tripped when closing a sleep cover on an already-in-suspend device, among other things).
* Kobo: Use our WakeupMgr instance, not the class.
* WakupMgr: split `removeTask` in two: 
* `removeTask`, which *only* takes a queue index as input, and only removes a single task. Greatly simplifies the function (i.e., it's just a `table.remove`).
* `removeTasks`, which takes an epoch or a cb ref, and removes *every* task that matches.
* Both of these will also *always* re-schedule the next task (if any) on exit, since we can have multiple WakeupMgr tasks queued, but we can only have a single RTC wake alarm set ;).
* `wakeupAction` now takes a `proximity` argument, which it passes on to its `validateWakeupAlarmByProximity` call, allowing call sites to avoir having to duplicate that call themselves when they want to use a custom proximity window.
* `wakeupAction` now re-schedules the next task (if any) on exit.
* Simplify `Kobo:checkUnexpectedWakeup`, by removing the duplicate `WakerupMgr:validateWakeupAlarmByProximity` call, now that we can pass a proximity window to `WakeuoMgr:wakeupAction`.
* The various network activity timeouts are now halved when autostandby is enabled.
* Autostandby: get rid of the dummy deadline_guard task, as it's no longer necessary since #9009.
* UIManager: The previous change allows us to simplify `getNextTaskTimes` into a simpler `getNextTaskTime` variant, getting rid of a table & a loop.
* ReaderFooter & ReaderHeader: Make sure we only perform a single refresh when exiting standby.
* Kobo: Rewrite sysfs writes to use ANSI C via FFI instead of stdio via Lua, as it obscured some common error cases (e.g., EBUSY on /sys/power/state).
* Kobo: Simplify `suspend`, now that we have sane error handling in sysfs writes.
* Kobo.powerd: Change `isCharging` & `isAuxCharging` behavior to match the behavior of the NTX ioctl (i.e., Charging == Plugged-in). This has the added benefit of making the AutoSuspend checks behave sensibly in the "fully-charged but still plugged in" scenario (because being plugged in is enough to break PM on `!canPowerSaveWhileCharging` devices).
* AutoSuspend: Disable our `AllowStandby` handler when auto standby is disabled, so as to not interfere with other modules using `UIManager:allowStandby` (fix #9038).
* PowerD: Allow platforms to implement `isCharged`, indicating that the battery is full while still plugged in to a power source (battery icon becomes a power plug icon).
* Kobo.powerd: Implement `isCharged`, and kill charging LEDs once battery is full.
* Kindle.powerd: Implement `isCharged` on post-Wario devices. (`isCharging` is still true in that state, as it ought to).
2 years ago
slimpdev 7cac083db4
Kindle: Support warm light control on the Oasis 3 (#9054) 2 years ago
NiLuJe 5ac9463c09
AutoSuspend: Unbreak cohabitation between standby & suspend (#9009)
* Make sure AutoStandby cohabitates nicely with AutoSuspend (regression since #8985), specifically:
* Disable standby during suspend.
* Ensure that leaving standby restores the scheduled suspend properly, with the appropriate remaining amount of time based on the last user input.
* Handle devices with an auxiliary battery better when scheduling suspend (assume it's only charging when the aux battery is charging, not the ereader's).
* Tweak debug logging to be able to remote debug corner-cases more easily without requiring code changes.
* Fix erroneous behavior when awoken from standby by something that doesn't trigger an InputEvent Event (e.g., rtc alarm, gyro, or random bullshit).
2 years ago
NiLuJe bd17119d07
Kobo: Disable key repeat during suspend (#8987)
Might help avoiding evdev queue overflow on misbehaving covers (#8964).

At the very least shaves a fair bit of stupid from debug logs ;o).
2 years ago
NiLuJe 087b97457d
AutoSuspend: Handle standby scheduling in the same manner as suspend/shutdown (#8985)
Specifically, don't forcibly unschedule/schedule on every input event, instead, let the scheduled task figure out if the deadline came to pass or not ;).

c.f., https://github.com/koreader/koreader/pull/8970#issuecomment-1092775830

Besides getting rid of some overhead, this allows proper scheduling after a task that would have blocked for longer than the standby timeout.
2 years ago
zwim 0808560532
getElapsedTimeSinceBoot: Honor times in suspend, too (#8983) 2 years ago
NiLuJe 61cafab0e5
AutoSuspend: Avoid unbalanced prevent/allow Suspend calls (#8970)
This prevents crashing interactions with other prevent/allow callers when the feature is disabled.
2 years ago
zwim 7e2aa2a209
Kobo powerd: fix frequency in battery's getCapacity with enabled standby (#8958) 2 years ago
NiLuJe 815c078b89 Kobo: tone down the neocmd log chatter on unaffected devices 2 years ago
NiLuJe 2aa310a931
ScreenSaver: Minor refactor to avoid code duplication and weird rotation shenanigans (#8943)
* Handle said rotation shenanigans inside ScreenSaver & ScreenSaverWidget, which allows a more targeted approach; and prevents said rotation from affecting other widgets. (Also, gets rid of duplicated code).
* Handle the corner-case or exiting early from a "keep on screen for n sec" screensaver better, by unscheduling the extra refresh, since an early tap took care of that already.
2 years ago
zwim 158f4be724
Autosuspend: add autostandby (#8815)
Allows the device to go into standby (if available in `/sys/power/state`) to save power.
Adds an entry in the device menu to tune the timeout for standby.
(Shows total standby- and suspend-time in system statistics.)
2 years ago
Will c04fba943d
[reMarkable] Don't use KOReader suspend/screensaver/autosuspend when Oxide is running (#8900)
* Ignore hardware sleep button

When running KOReader with a launcher, having the power button trigger the Power event conflicts with the launcher's built-in screensaver (see https://github.com/koreader/koreader/issues/8891). This commit ignores the hardware power button in KOReader and lets the launcher handle sleep and wake normally.

* Disable autosuspend

If a launcher is active, there will be no way to un-suspend because the power button is ignored by KOReader and handled by the launcher.

* Ignore power button only if Oxide is running

Same with disabling auto suspend
2 years ago
NiLuJe 044341875f
Only toggle nightmode via the grayscale fb info flag on Kindle (#8931)
* Only toggle nightmode via the grayscale fb info flag on Kindle

Most NTX boards require elaborate trickery (see fbdepth) to actually
send a vput ioctl without the driver screwing with the rotation behind
your back.

This was causing spurious hardware rotations on exit on most Kobo
devices, something which might have gone mostly unnoticed, as current
Nickel versions will sanitize it on startup.
A simple repro was instead to start an USBMS session, as that exits
KOReader and restarts it without going through fbdepth again ;).
2 years ago
NiLuJe 23cd7e24bb
Minor Lua I/O cleanups (#8921)
Mostly making sure we always explicitly close io handles.
2 years ago
zwim 6a240b7d11
Kobo, Sage: better power cover detection (#8894) 2 years ago
NiLuJe 217a73f3c0
Initial Kindle PW5 support (#8856)
* Rejig frontlight warmth API to more closely match the existing API, and, hopefully, clarify some of its quirks, and reduce boilerplate and duplicate code in platform implementations.
* Tweak Kindle:setDateTime to prefer using the platform's custom script, as in interacts better with the stock UI. And make the fallbacks handle old busybox versions better.
* Add Kindle PW5 support ;).
* Add warmth support to the Kindle platform.
* Random TextBoxWidget cleanups: make sure we immediately free destroyed instances.
* FrontLightWidget: Refactor to make it slightly less obnoxious to grok and update; i.e., separate layout from update, and properly separate brightness from warmth handling. Move to simpler widgets instead of reinventing the wheel.
* TextBoxWidgets: Implement `setText` to match TextWidget's API, as some callers may be using the two interchangeably (i.e., Button).
* NaturalLightWidget: Make sure we pass a string to InputText
* InputText: Add debug guards to catch bad callers not passing strings ;).
2 years ago
Philip Chan 107156c0a8
[feat] Non-touch improvements (#8859)
FocusManager: fix round x use y layout
FocusManager: add tab and shift tab focus navigation support
FocusManager: handle Press key by default
FocusManager: make sure selected in instance level
FocusManager: add hold event support
FocusManager: Half move instead of edge move
FocusManager: add keymap override support
FocusManager: refocusWidget will delegate to parent FocusManager
Focusmanager: refocusWidget can execute on next tick
inputtext: can move out of focus on back
inputtext: fix cannot exit for non-touch device
inputtext: fix cannot input text with kindle dx physical keyboard
fontlightwidget: add non-touch support
datetimewidget: add non-touch support
datetimewidget: fix set date failed in kindle DX, fix datetimewidget month range to 1~23 by default
datetimewidget: make hour max value to 23
multiinputdialog: add non-touch support
checkbox: focusable and focus style
virtualkeyboard: no need to press two back to unfocus inputtext
virtualkeyboard: collect FocusManager event key names to let VirtualKeyboard disable them
openwithdialog: add non-touch support
inputdialog: can close via back button
enable all InputDialog and MultiInputDialog can be close by back
keyboardlayoutdialog: non-touch support
readertoc: non touch device can expand/collapse in toc
bookstatuswidget: non touch support
keyvaluepage: non-touch support
calendarview: non-touch support
2 years ago
Robert-Jan de Dreu 41e57fccd2
Fix Pocketbook crashes when filename is nil (#8823)
Function `SetSubtaskInfo` takes only chars as a valid book. Since
filename can be `nil` (not a char) the crash would happen. This
Change avoids the crash by using a char type nil value. See:

`int SetSubtaskInfo(int task, int subtask, const char *name, const char *book);`

Fixes #8053
Fixes #8392 too
Fixes #8743 last issue
2 years ago
Frans de Jonge f6acb98227
Add Pocketbook 740-3 (#8851)
Thanks to @uatel.

Fixes #8850.
2 years ago
Robert-Jan de Dreu e5e140d5fd
Fix invert for pocketbooks by disabling hardware invert (#8803)
With the inkview library inverting the screen seems possible but needs some 
discussion with the developers of Pocketbook. For now disable HWInvert so 
this feature is not broken while we figure out how to change the invert with inkview.
2 years ago
NiLuJe fb45576429
Kobo: Use the right input protocol on the Nia (#8794)
c.f., https://github.com/baskerville/plato/issues/220
2 years ago
NiLuJe 2d4e1584c7 Kobo: Drop deprecated comment
Inherited from the original Device abstraction implementation,
7 years ago, but it never made any sense on Kobo ;).
2 years ago
NiLuJe eca27fe497 Disable the WAIT_FOR ioctls on the Libra 2
Much like the Libra, it seems to be having issue with these...

Fix #8664
Re #8414
2 years ago
NiLuJe 0408816a54 ReaderFooter: Take the PowerCover into account in the battery level
widget

Since we only use a single icon, we have to take a few shortcuts:

* The icon itself is computed based on the average of both batteries.
* The actual value is the sum of both batteries.
* Much like everywhere else, charging means the *aux* battery charging
  (i.e., connected to a power source).

Re #8741, which does the same for ReaderHeader.
2 years ago
NiLuJe 5518a8109b PowerD: Ensure we actually pull battery capacity during early boot.
(i.e., when MONOTONIC returns something lower than 60).

Fix https://github.com/koreader/koreader/pull/8711#issuecomment-1021106079
2 years ago
Andrej Shadura f3ac95321b
PocketBook: make canAssociateFileExtensions always return true (#8729)
This change drops the #koreader signature check. 

This check prevents KOReader from modifying associations if something else has changed the file without putting a verbatim "#koreader" string back.

While this prevents KOReader from interfering with another application or the system trying to own the file, it also leads to hard to diagnose issues, when the user can inadvertently change associations without realising they’re doing so, and being unable to return back.
2 years ago
Robert-Jan de Dreu e8fa5bdedd
PocketBook: Check NET_CONNECTED to see if wifi is really connected (#8730)
I've emailed with PocketBook about the problem with Wifi on the newer models. They explained the wrong constant was being used:

> Dear Robert,
>
> Thank you for choosing Pocketbook.
​
> Wi-Fi Connection" enabled when no connection:
> https://github.com/koreader/koreader/issues/8617  
> The problem is in incorrect usage of constant. You should use flag NET_CONNECTED with bit AND operation as shown in example below.
>
> function NetworkMgr:isWifiOn()
>     local state = inkview.QueryNetwork()
>     return band(state, C.NET_CONNECTED) ~= 0
> end
>
> Inkpad3 Wifi Standby
> https://github.com/koreader/koreader/issues/4747 
> the same solution for this issue

Related issues:
https://github.com/koreader/koreader/issues/8617
https://github.com/koreader/koreader/issues/4747

Since I made the previous hack and their suggestion seems to work on the PB741 color. I've made this PR to remove my hack.

It might be wise to also test this fix on older models.
2 years ago
roshavagarga 4f707bb49d
PocketBook: add support for PB617 (Basic Lux 3) (#8740) 2 years ago
Robert-Jan de Dreu 943dc99645
PocketBook: handle rendering of interface and books directly with inkview (#8727)
Use ffi/framebuffer_pocketbook.lua, using Pocketbooks's own
inkview library for framebuffer interactions.
2 years ago
Martín Fernández 4423082949
Colordict: use generic send intent. (#8721)
Its custom intent was borked on last update and doesn't work anymore.

Fixes https://github.com/koreader/koreader/issues/8718
2 years ago
Martín Fernández d67d92bcab
android screen: decouple epd and color properties (#8717)
also included new devices: 

- added onyx nova 3
- fixed onyx note 5
2 years ago
poire-z 16e3b2f0ac Allow Backspace to work as back button 2 years ago
NiLuJe e39ee325f9 Cleverer UIManager <-> PowerD circular dependency handling
Thanks to @poire-z ;).
2 years ago
NiLuJe 2462c1c5c1 PowerD: Make sure we immediately display accurate battery capacity on
resume.

(MONOTONIC doesn't trick during suspend, so we could happily display the
pre-suspend capacity for a while).
2 years ago
NiLuJe 69718d6ee1 PowerD: Fix a stupid typo in getCapacity
Regression since #8672
2 years ago
NiLuJe 689ec2a839 PowerD: Prevent potential dependency loop in get*Capacity
Not currently happening in vanilla code, but, not entirely unlikely.
stateChanged already uses a similar guard.

Re https://github.com/koreader/koreader/pull/8672#discussion_r790126388
2 years ago
NiLuJe eb0c2bfc93 Kobo: Handle a few PowerCover quirks...
* The first few capacity reads after connecting to the cover may fail

* The PowerCover may trigger spurious move/add usb_plug uevent,
which translate into Charging events for us.
Instead of blindly lighting up the charging LED on those,
check if the device is actually charging, first.
2 years ago
NiLuJe 607f5db1dd Kobo: Accurately toggle the charging LED on startup
Kobo: Also refresh charging LED state on resume
2 years ago
NiLuJe dc98384177 PowerD: Add a framework to report the status of auxiliary batteries
Implement it on the Kobo Sage, for the PowerCover

TouchMenu: Display auxiliary battery status

Kobo: More accurately report the PowerCover's charging status

i.e., try to actually figure out if the auxiliary battery is charging
instead of just checking the reader's battery (because that one will
often swap between the charging and discharging state as it drains the
aux battery...).

PowerD: Use a cached timestamp when doing battery pull checks
2 years ago
yparitcher 0508014c1b SDL & Android: Do not set FM banner on resize
regression from #8648

FileManager.instance.banner was removed and replaced with TitleBar
2 years ago
Andrej Shadura 11cd34973b
Pocketbook: switch the Wi-Fi on before attempting to connect (#8546)
Fixes #4747.

Apparently, inkview.NetConnect() doesn’t enable the Wi-Fi on its own,
this results in a failure if the device has been put into the sleep or
standby mode, when the Wi-Fi hardware is powered down.

Signed-off-by: Andrej Shadura <andrew.shadura@collabora.co.uk>
2 years ago
Robert-Jan de Dreu e2a5fd5c36
[Pocketbook] wifi: fallback to new API when old API is out of bounds 2 years ago
zwim 6c9e222d33
Screensaver: allow limiting stretch of covers and images (#8570)
ImageWidget: adds stretch_limit_percentage parameter.
Add support for screensaver on the emulator, for easier testing.
2 years ago
zwim a001a13ab6
ReaderRolling: avoid ANR on Android when (re)rendering. (#8501)
Wrap document opening and re-renderings (which can block
the app for some time) with setIgnoreInput() to avoid ANR
on Android.
Any setting update that could possibly cause a re-rendering
should send the UpdatePos event, to ensure the re-rendering
happens in ReaderRolling:onUpdatePos() where precautions
are taken to avoid ANR.
2 years ago
Martín Fernández 3427c207b0
android: bump test activity (#8483)
Now users can test light drivers too. See https://github.com/koreader/android-luajit-launcher/pull/339#issuecomment-977822717
2 years ago
NiLuJe 1ff19f8ba7 Kobo: On sunxi, add a delay between the white flash and the sleep
screen.

Otherwise, on the Sage, weird flash glitches may happen, depending on
what was on screen...
(e.g., there's some weird update merging shenanigans going on
despite those updates being flagged NO_MERGE...).
3 years ago
zwim a7cfc65928
Fix crash when entering a digit on the SDL keyboard (#8388)
Fixes #8387.
3 years ago
NiLuJe e17b136d67
Initial support for the Kobo Libra 2 (#8367)
* Initial support for the Kobo Libra 2

* It's the same touch panel as the Elipsa & Sage.
* Plug in proper nightmode waveforms on mxcfb.

* Bump base

https://github.com/koreader/koreader-base/pull/1423
3 years ago
NiLuJe db21521968
Support frontlight warmth on the Sage (#8366)
Follow-up to #8361.
3 years ago
Mike Kozlowski 2cd4d09db4
Add initial support for Kobo Sage (Cadmus) (#8361) 3 years ago
ElimGarak1 863255c9f4
Add PocketBook InkPad Lite (PB970) (#8335)
Closes #8331.
3 years ago
zwim 0c7d174cd7
[frontlight, kobo, cervantes] Remove auto_warmth (#8154)
The feature is now provided by the "Auto warmth
and night mode" plugin (#8129).
3 years ago
NiLuJe 4a2f519600 Kobo: Use CLOEXEC in the Device module
We have a guarantee that it's supported on this platform.
3 years ago
NiLuJe 53b8ed48bf Kobo: Don't leak fds in isWifiOn
io.lines only closes the fd when the loop is exited sanely, not by a
control flow keyword (i.e., no break or return allowed).

Regression since #8169
3 years ago
NiLuJe 48da545e32 Kobo/Elipsa: More fine-grained control over the amount of online CPU
cores

* Only keep a single core online most of the time.
* Device: Add an enableCPUCores method to allow controlling the amount of
  online CPU cores.
* Move the initial core onlining setup to Kobo:init, instead of the startup script.
* Enable two CPU cores while hinting new (e.g., cache miss) pages in PDF land.
* Enable two CPU cores while processing book metadata.
* Drive-by fix to isolate the DocCache pressure check to KoptInterface
  and actually apply it when it matters most (e.g., k2pdfopt stuff).
3 years ago
zwim debf5dc550
Footer: add Warmth as footer item (#8060) 3 years ago
NiLuJe af8988ef5f
Minor script tweaks (#8169)
* Neater fbdepth usage on sunxi
* Make sure we only ever match *loaded* modules when we check lsmod
3 years ago
NiLuJe edfb29b406 Fix duplicate suspend scheduling in Device:onPowerEvent
We should always unschedule suspend before scheduling it again (i.e.,
use rescheduleSuspend ;)).

Fix #8097 (many thanks to @Mel-kior for the detailed repro!)
3 years ago
Galunid 611a5311b6
Fix warmth settings on some android devices (#8104) 3 years ago
Martín Fdez 6fb52528cd disable light settings on ChromeOS, android TV and e-ink devices without lights 3 years ago
Martín Fdez 8bf19a7327 flush settings before being killed 3 years ago
NiLuJe 1e9346aec6 Fix Wi-Fi toggle on the Elipsa
It turns out that the kernel needs a little push now that the dedicated
wifi power control module is gone ;).

Issue was only exposed if you booted KOReader while the Wi-Fi was down.
3 years ago
NiLuJe bc133e70d3
Input: Minor simplifications around pen/finger discrimination & the snow protocol (#8021)
* Decode EV_KEY:KEY_BATTERY
* Input: Only drop hovering *pen* events.
  There are currently too many broken 0-pressure *finger* events being
  reported on the Elipsa, making a dumb rejection highly annoying.
* Bump base
https://github.com/koreader/koreader-base/pull/1393
* Rely on actual events to detect loss of contact for the "snow"
protocol.
  Allows simplifying the whole thing.
* Use `ipairs` over `pairs` for pure arrays.
3 years ago
Martín Fernández 990b6768f4
disable battery level on desktop Linux (#8026)
This also include ChromeOS laptops (chromebooks) since the power sysfs attributes don't exist in linux containers.
3 years ago
NiLuJe 817e9e26e8
Minor input tweak after #7986 (#8004) 3 years ago
NiLuJe ae35e898fb
Kobo Elipsa support (#7986)
Includes a few minor cleanups along the way ;).
3 years ago
poire-z 16ab5aa194 SDL keyboard input: should go to top level widget only
Avoid the typed input to be added to all
InputText present on the stack: only the
top one should handle it.
3 years ago
hius07 884c664f63
Device status alarm: battery and memory (#7857)
Move former low battery alarm into a device status
alarm menu, and add high memory usage checks.
3 years ago
Martín Fernández ee92ca68e8
workaround for Onyx Poke2 nonsense (#7872)
Requires koreader/android-luajit-launcher#320

Also the luajit-launcher bump adds support for Likebook P78 and sanitizes clipboard text.
3 years ago
Martín Fernández 9f097da4f0
Bump android backend (#7813)
* Bumps the target Sdk to Android 11 (API30)
* Add a crash handler
3 years ago
Frans de Jonge 039947886f
Revert "Hyphenation: add custom hyphenation rules (#7746)" (#7785)
This reverts commit f25da5d0d5.
3 years ago
zwim f25da5d0d5
Hyphenation: add custom hyphenation rules (#7746)
The hyphenation of a word can be changed from its default
by long pressing for 3 seconds and selecting 'Hyphenate'.
These overrides are stored in a per-language file, i.e:
koreader/settings/user-German.hyph.
3 years ago
NiLuJe 1ded7c3907 PocketBook: Support the PB741
Re: https://github.com/koreader/koreader/issues/7747#issuecomment-846850605
3 years ago
NiLuJe 92afc63951 PocketBook: Deal with FW shenanigans on the PB627
Might break it on older FW, who knows.

Fix #7747
3 years ago
Martín Fernández b8d658b922
android: minor fixes (#7753)
* Save settings before installing a new APK & after resume. 
* Move Resume/Suspend events to Resume/Pause callbacks
3 years ago
Martín Fernández dc0d759148
don't log thirdparty app list if they're platform defaults (#7760) 3 years ago
zwim 6e2be98edc
Notifications: options to show none/some/more (#7718)
Notification: adds some functions so it can be used as
a notification manager.
Have various bits of code emitting events that may generate
notifications advertize themselves as the source for following
notifications.
Add a menu to allow selecting some subsets of sources
to show or hide.
3 years ago
poire-z 4b6b12b799 Remove unused "pan_delayed_interval" support 3 years ago
poire-z d0165f8bd1 Fix scrolling, add inertial scroll on non-eInk devices
Add a new reader module: ReaderScrolling, that exposes
some Scrolling options to the menu (which are to be used
by and implemented in ReaderPaging and ReaderRolling
themselves) and implement some inertial scrolling logic
used by both of them.
Default to "Classic scrolling" which is the expected
behaviour on phones and tablets.
The old CreDocument buggy behaviour is available as
"Turbo scrolling" for both Paging and Rolling documents.
Added a "On release scrolling" option that might be
useful on eInk to avoid dynamic pan/scrolling.

Try to avoid bad interactions between pan and swipe,
cancelling unwanted panning if we ended up doing a
swipe or multiswipe.
3 years ago
poire-z 0a3978f60b Reader: remove full refresh on vertical swipes
Small diagonal swipes is what can be used for
full refrehes. Tweak a bit how it is done.
3 years ago
Martín Fdez 23b7bfe0ce move android specific bits outside OTAManager 3 years ago
NiLuJe 4b265bcd7a Allow ingoring the B288 feature bans, for debugging purposes. 3 years ago
NiLuJe f413cd15e8 PB: Unconditionally disable HW rotation on B288 SoCs
Apparently, it's even more broken than usual on some devices/FW combos.

Fix #7663
3 years ago
NiLuJe 628aef2099 OTA: Unbreak exit code on Install
Regression since #7657
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
Martín Fernández 939fcf7f0e
android: avoid downloading the APK again if there's one download in progress + fix signature error (#7657) 3 years ago
NiLuJe 48c474e245 Device: Add some more logging in onPowerEvent
Could possibly help shed some light on potential SleepCover races...
re #7633
3 years ago
Frans de Jonge 310151fac9
Fix typo (#7655)
Follow-up to #7632.
3 years ago
Martín Fernández d303fdf694
android: Prompt for install updates when they're downloaded (#7632) 3 years ago
zwim 3d9ed32458
Android: Send Suspend/Resume Events on STOP/START (#7630)
* ReaderHeader: Refresh it *now* on Resume, instead of just re-scheduling an update if auto-refresh is enabled..
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
zwim e4c9409f97
[plugin] Add a caching mechanism for CoverImage (#7510) 3 years ago
Martín Fernández 53234fcdc1
add hasSystemFonts device property (#7535)
Add system + user paths to the ReMarkable (has normal linux paths)
3 years ago
NiLuJe 14cd6febbb Kindle Legacy: Cleanup key mappings
The K3 has a mapping similar to the K4, not to the DX & K2.

Fix #7561
3 years ago
gbyl 32802ee7f2
reMarkable: Remove refresh before poweroff (#7563)
This is now handled in a platform-agnostic manner (#7558).

Co-authored-by: gbyl <gbyl@users.noreply.github.com>
3 years ago
NiLuJe 1ac0ad2f1a Android: More input handling tweaks
* Android: Fix #7552 by simply ensuring we drain the input/cmd queue first, simply by scheduling the task to the next tick, instead of locally re-implementing part of the event loop ;). (Requires https://github.com/koreader/koreader-base/pull/1356 for extra safety).
* Android: Clear input state when the window loses focus. (Related to the above fix).

* Bump base:

https://github.com/koreader/koreader-base/pull/1356
https://github.com/koreader/koreader-base/pull/1357

* Bump android-luajit-launcher:

https://github.com/koreader/android-luajit-launcher/pull/293
https://github.com/koreader/android-luajit-launcher/pull/298
https://github.com/koreader/android-luajit-launcher/pull/299
3 years ago
NiLuJe 3274183466 Minor Input & TimeVal cleanups
* Input: Don't create a new TimeVal object for input frame timestamps, just promote our existing table by assigning it the `TimeVal` metatable.
* TimeVal: Export (const) `zero` & `huge` TimeVal objects, because they're common enough in our codebase. (NOTE: not actually const, that's a Lua 5.4 feature ;p).
* GestureDetector: Explain the behavior of the `last_tevs` & `first_tevs` tables, and why one needs a new object and not the other.
* Speaking of, simplify the copy method for `first_tevs`, because it doesn't need to create a new TimeVal object, we can just reference the original, it's unique and re-assigned for each frame.
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
Glen Sawyer b6b332e311
Fix for PR #7415 breaking reMarkable touch input (#7536)
The Wacom pen reports sane CLOCK_REALTIME timestamps, but the Touchscreen reports timestamps frozen at the boot time ts (in REALTIME) :s.

So, make everyone use synthetic CLOCK_MONOTONIC timestamps in order to make gesture detection behave.
3 years ago
zwim 10922561dd
Add update of the top and bottom status bars, on +/-Charging (#7379) 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
NiLuJe 8a923e3e77
Input: Followup tweaks to #7415 (#7478)
* Actually load librt properly on old Linux systems (fix #7472)
* Made sure SDL & Android honored timeouts properly in some edgy (or not so edgy, in SDL's case) cases (c.f., https://github.com/koreader/koreader-base/pull/1343).
* Try harder not to consume a timer callback when the timerfd backend is in use and `select` timed out *not* because of a timerfd expiring. This would take some particularly heinous timing to reproduce (e.g., a timerfd set, but a task deadline expiring *before* it). May or may not help with #7473.
* Decode `BTN_` KEY codes in verbose debug logs.
* Fix MultiTouch on the H2O (GestureDetector was hard-coding the two slots as 0 & 1, but the H2O kernel is a special snowflake that doesn't use slot 0, instead switching to slot 1 & 2).
3 years ago
NiLuJe 1f15184bbb
Kindle: Fix gyro events on Zelda (#7459)
* Kindle: Fix gyro event on Zelda

Like on Kobo, only honor the face-up events.
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 b325fa4a50
Initial KOA3 support (#7446)
* Move MXCFB capchecks to front

The fact that this was halfway in front/halfway in base was weird and
mistake-prone (c.f., the amount of times I forgot to update one bit or
the other).

* Initial KOA3 support

Assume it's essentially a KOA2. Meaning no warmth handling for now.

* Bump base

https://github.com/koreader/koreader-base/pull/1339
https://github.com/koreader/koreader-base/pull/1338
3 years ago
NiLuJe 861214ce2a
Kobo: Allow toggling the WAIT_FOR_UPDATE_COMPLETE hack (#7431)
* Allow toggling the MXCFB_WAIT_FOR_UPDATE_COMPLETE bypass

* Drive-by: enable the abort_on_crash menu on Pb & rM, since they support
it
3 years ago
NiLuJe 41182349bc
Re-implement the PB fb fixup insanity (#7404)
* Re-implement the PB fb fixup insanity

It's apparently still necessary on a number of devices.
Fix #7072

* Bump base

(Fix FBInk on the same devices, for another reason).
3 years ago
NiLuJe 0b3747927c
WakeupMgr: Minor usage tweak (#7400)
* Unify logging with AutoSuspend (e.g., keep ourselves to showing the delay in seconds, not the raw timestamp, as that's way harder to interpret, and the RTC module and/or logger will do that for us when the time comes).
* Speaking of, minor revamp of RTC related logging to make it more human-readable.
* On Kobo, if we hit the unexpected wakeup limit, re-engage AutoSuspend's *suspend* check, so that the device has a chance to poweroff instead of being kept awake.
3 years ago
Glen Sawyer 3f0654f530
Hold "Wi-Fi" menu to show network selection instead of auto-connecting (#7395)
* Hold "Wi-Fi connection" to show network connection options.
* Honor backend connections (e.g., if wpa_supplicant found a matching AP in its own config first).
* When user clicks "Wi-Fi connection" in menu, only prompt if state is ambiguous.
3 years ago
NiLuJe fba0b8eec7 Kobo: Refresh the system clock on resume.
Mimics Nickel's behavior, should fix #7092

Thanks to @gtalusan for the pointers ;).

Bump base

(https://github.com/koreader/koreader-base/pull/1322)
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
Glen Sawyer 15ef1a3a1b
reMarkable 2 clean wakeup from sleep (#7345) 3 years ago
Martín Fernández eb57c4e0da
Add a couple of modern android dicts (#7359)
https://play.google.com/store/apps/details?id=gaurav.lookuppro and its free version.

From https://www.mobileread.com/forums/showpost.php?p=4097548&postcount=8
3 years ago
NiLuJe 64611e6acb
Legacy Kindle: Actually handle (system) power events (#7336)
Otherwise, ScreenSaver handling doesn't work, duh'.
I have no idea how I managed to get that working the last time I tested
it :?.
Possibly I tested the final code on a K4 and not a K3?

Fix #7333
3 years ago
Rex Kerr 2510ff4847
Reversing commit 2348cd, changes to warmth values (#7296) 3 years ago
Rex Kerr 2348cdb066
Improved ramp-down of warm-light after max hour (#7272)
previously: warm light stays at 100% for 3 hours and then drops by 50% per hour
now: warm light stays at 100% for 4 hours and then drops by 15% per hour
3 years ago
Martín Fernández 4a89c93290
Remarkable1 wifi (#7216)
* add wifi support to Rm1
* remarkable: common suspend for all models
3 years ago
Glen Sawyer 34b177aa69
Wifi toggle for reMarkable 2 (#7122)
reMarkable 1 is no-op for the moment
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
NiLuJe 183e0a2e25
Bump android-luajit-launcher (#7137)
* Check available width when using a viewport

* Mention that available_width should always match width
3 years ago
poire-z 8f79c662cf Notification: closed by any event, but not consuming it
Make Notification have toast=true, and UIManager deal
specifically with such widget:
a "toast" widget gets closed by any event, and let
the event be handled by a lower widget.
This should allow us to not wait or tap to get rid
of a notification, and just go on with what we're
doing.
Also make them have a default timeout of 2s,
used with all existing ones.
3 years ago
yparitcher dc964f3941
reader.lua: rework file/directory argument handling. (#7053)
platform: do not pass a directory on the command line.
The home directory will be properly set by Device.home_dir.

It was sometimes crashing when opened with no args.

Fixes: #7049
3 years ago
NiLuJe 34b764dc06 Kindle Legacy: Probe for SO on the K3 & K4 3 years ago
NiLuJe 5ae5c99197
Legacy Kindle: Unbreak screensavers (#7112)
* The K2 & DXg cannot be SO, so, bypass the check there

* Handle native screensavers on FW 3.x & 4.x
3 years ago
NiLuJe 5756f1f43e
LuaJIT on Android fixes (#7094)
* Don't flag Android as should_restrict_JIT

And allow disabling the C blitter, to put the workaround to the test...

* Add a -d, --debug flag to the log function

Catches KOReader's debug, as well as (our) dlopen & luajit logging

* Bump android-luajit-launcher

https://github.com/koreader/android-luajit-launcher/pull/283
https://github.com/koreader/android-luajit-launcher/pull/282

* Bump base

(https://github.com/koreader/koreader-base/pull/1279)
3 years ago
John Beard 0e494169f2
Keyboard input in InputText (#7037)
For text input, use the SDL events, which contain the decoded
strings.

Still handle keypresses for non-text input.
3 years ago
Glen Sawyer 3bd3493014
Fix double-pressing reMarkable 2 power button twice to wake up (#7065) 3 years ago
Glen Sawyer 578f92e424
Time-adjust on all reMarkable events, not just EV_ABS (#7066) 3 years ago
gbyl d2379fc6e6
remarkable: poweroff.png ghosting fix (#7051) 3 years ago
NiLuJe f1f439d08b
More Android trickery (#7059)
* Modernize jit syntax

It's built-in, no need for a require anymore.

* Flag Android should_restrict_JIT again

It's mildly helpful at putting off the inevitable.
(very, very, very, very mildly).

* Bump android-luajit-launcher

https://github.com/koreader/android-luajit-launcher/pull/281
3 years ago
Frans de Jonge 53909db687
Close Lua state on all os.exit() calls (#7050)
Cf. <https://github.com/koreader/koreader/pull/7044>.
3 years ago
NiLuJe d845741b15
Android: Don't mark the platform as should_restrict_JIT (#7024)
* Android: Don't mark the platform as should_restrict_JIT

And see how much stuff breaks \o/

* Prevent Android users from disabling the C blitter, regardless of the
restrict flag

* Update android-luajit-launcher

https://github.com/koreader/android-luajit-launcher/pull/278
https://github.com/koreader/android-luajit-launcher/pull/275
3 years ago
NiLuJe 09c1f35191
rM: Unbreak PowerEvents (#7043)
Most of this is scheduled with delays for reasons, so this was a stupid
idea, my bad ;).

Fix #7033
3 years ago
NiLuJe 9cda84ef2f Prevent Busted from blowing up on cdata finalizers by properly closing
opened documents...
3 years ago
NiLuJe c0981a55d9 Make sure KindlePowerD's __gc metamethod will actually be called
* Via the newproxy hack.
3 years ago
Frans de Jonge db9b485e2d
[chore] Minor formatting fixes (#7009)
Cf. <https://github.com/koreader/koreader/pull/6992>.
3 years ago
ddvk 77ac32d4ac
remarkable2 support (#6992)
Fixes https://github.com/koreader/koreader/issues/6792
3 years ago
NiLuJe e0ac00f310
Make sure getting rid of a DPI override actually restores default behavior (#6984)
* Make switching *back* to the default DPI via auto actually work
properly.

eg., by actually setting DPI back to defaults, and clearing the override
flag.

* Bump base to pickup https://github.com/koreader/koreader-base/pull/1258
3 years ago
Martín Fernández c481c5aa04
move unpackArchive to Device, use native version on android (#6959) 3 years ago
NiLuJe 4b9627456e
Fix the frontlight gesture range scaling (#6946)
xref https://www.mobileread.com/forums/showthread.php?t=335341
3 years ago
Martín Fdez be2bcac28e switch between internal and external sdcard 3 years ago
NiLuJe 931f01ef26
Kobo: Warn on restart if the startup script is outdated (#6916)
* Warn on restart if the startup script has been updated, because a restart will not reload it.

* Also warn right after the update if it contained a startup script update...
3 years ago
zwim 52f66a89d2
CoverImage plugin: enable on Remarkable and PocketBook (#6906) 3 years ago
Martín Fernández 4a6f8769ae
android: fix dict overrides (#6887)
- User overrides marked as false were not checked
- Actions without app were skipped.
4 years ago
Martín Fernández d914476973
sdl: resize FM (#6882)
Required after #6309.

Uses the same logic as in android (I cannot locate the PR right now). Tested on a mac.
4 years ago
zwim 926e7dd402
coverimage plugin (#6813)
* Plugin for saving the cover image to file. Useful in some e-ink android devices.
4 years ago
yparitcher edec69ac8b
[CRe] Tweak nightmode and CRe call cache interaction (#6859)
Simplify 4caf8f28 (#6854), allowing us not to track
nightmode in two places.
4 years ago
NiLuJe 4caf8f281d
[CRe] Ensure toggling nightmode invalidates the drawCurrentView cache (#6854)
* Use a CRe set* method when toggling nightmode

This ensures it gets flagged as add_reset by the call cache, and that
CRe will actually re-render, as it's necessary if nightmode_images is
enabled (the default).

Fix #6845

* Prevent ReaderHighlight:onTap from running ReaderHighlight:clear when
it's unnecessary.

Avoiding a clearSelection call in CRe that could invalidate the cache
and cause unnecessary redraws.

* Don't store empty highlight arrays when all HLs on a page have
been deleted
4 years ago
Martín Fernández 91708e25d0
android-luajit-launcher refactor (#6821)
- Lcd devices won't use the SurfaceView, just the good old native content/window (except AndroidTv and ChromeOS)
- All android dialogs will be presented with Material Design on recent devices.
- Added an option to device settings to manage application battery optimization.
- Permissions that require the user to go to a settings page will be presented with a native android dialog.
- bump android-luajit-launcher

- Changes under the hood: koreader/android-luajit-launcher#257
4 years ago
poire-z 74c1813a82 GestureDetector: add Tap interval on keyboard setting
Follow up to b90f6db8: allow specifying an other
value for tap interval when the keyboard is shown
(a good value for tap interval on reader and UI
elements might be too long on the keyboard, and
prevent typing fast).
4 years ago
NiLuJe c810a19040
H2O: Fix initial tap detection (#6832)
* Fix initial tap on the H2O

There's no slot 0, so make sure the initialState doesn't get confused by input's init data that otherwise assumes the main slot is 0
4 years ago
Martín Fernández 99ad13b13c
android: handle onDestroy (#6811)
* handle onDestroy

we need it if killed by the system (ie: battery optimizations or OOM)
we need it to exit the lua VM when we call finish() from Kotlin

This prevents us for being trapped into a zombie state
4 years ago
ezdiy 5a86443eb1
Pocketbook: waveform presets (#6794)
On pocketbook, update modes are not as clear cut due to overall
chipset and kernel version mess. Inkview solves this by always
using the slowest (and safe) GC16 waveform. We now do that too
by default.

Slow updates suck though, so there's now a menu entry to configure
it for speed (with mild artifacts at best, kernel panic at worst).

This is a generic interface (any eink Screen can announce support).
The driver may interpret the slow/fast range however they want.
4 years ago
NiLuJe dda905271d
[Kobo, Mk. 7] Enable the power LED when charging (#6810) 4 years ago
NiLuJe 0406be3319
Random nano optimizations (#6801)
* Don't call Screen:afterPaint if nothing was actually painted

* Stupid micro-optimization (os.)time! (pun intended :D)
4 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
poire-z b90f6db876 GestureDetector: add Tap interval setting, to avoid bounces
Also fix info_text not displayed, and add more
descriptive ones.
4 years ago
ezdiy 893909146d
Pocketbook: use raw input I/O (#6791)
This allows for better energy efficiency (no more 50Hz tick poll),
as well as lower input lag / higher precision - touch events are
native linux ones.

In addition, auto off/suspend plugin is used in this mode, as we need
to trigger (timed) sleep / poweroff on our own, since the OS ones
will no longer work whenever koreader has focus.

This is for rooted devices only, and possibly somewhat FW
specific, so enabled only on PB740-2 where it's reasonably tested.
4 years ago
Martín Fdez 009e2b3b94 android: reinit FM after surface change 4 years ago
NiLuJe d2f533e5b7
A couple of hotfixes for 2020.10.1 (#6781)
* PB Crash Screen:
	* We don't actually support the "tap to restart now" behavior, it's a
	  plain sleep.

* Remove CBB toggling leftovers missed in #6696

Fix #6780
4 years ago
NiLuJe ac6b121c85
Disable HW inversion on rM (#6779)
Turns out it's being weird like on Mk. 7 Kobos with a crapload of PxP
processing flags.
Except without the "crapload of flags", part :D.
4 years ago
NiLuJe b932b97b20
A few reMarkable QoL fixes (#6772)
* Enable AutoSuspend plugin on rM

Fix #6769
Re: #6028

* Use the PowerEvent handler on rM

It makes much more sense than the fire & forget & hope for the best
approach copied from the Kindle platform, because we *are* controlling
suspend ourselves (mostly), unlike on Kindle ;).

Fix #6676

* Enable HW inversion on the rM

I mean, we kinda forgot to ever test that, but I don't really see why it
wouldn't work ;).
4 years ago
ezdiy 6b4188074e
Pocketbook: Fix silly rotation bug on PB1040 (#6735)
Ditto as PB740
4 years ago
ezdiy 592e54aa02
Pocketbook: Fix silly rotation bug on PB740 (#6734)
It detects B288, disables hwrot...
.... and there wasn't the isAlwaysPortrait enabled to serve as an alternative.
4 years ago
NiLuJe ec3ec8dc21
Show full ToC entry on hold (#6729)
Fix #6728
4 years ago
NiLuJe e169b34577
Fancier Wi-Fi status icons in ReaderFooter (#6725)
* In icons mode, just use two different icons to display Wi-Fi status

* Enable Wi-Fi status icon on Kobo & Cervantes, too

* Refresh footer on (dis)connect if the Wi-Fi status item is enabled
4 years ago
ezdiy 25d5e9322c
Pocketbook: Try to auto-detect HW feature caps more precisely (#6721)
The differences between Allwinner/MXC matter surprisingly little in practice, it's not even worth
it to bother the base mxc driver with it. Instead, frontend can make some informed choice by
probing for the hardware and tweaking requested device caps accordingly.

On Allwinner B288, we disable both hwrot (done in software in kernel and terribly, ie not worth it)
and hwinverse (no support whatsoever). On NXT we'll keep both on, as the kernel driver seems
to be using the hardware properly .
4 years ago
ezdiy ef8d2d0d6e
linuxfb: is_always_portrait must be passed to screen init() from all frontends. (#6712)
This is because fb driver should not be inspecting self.device for low level
caps anymore.

Fixes #6711
4 years ago
ezdiy 5345728cc4
Clean up C blitbuffer kludges. (#6696)
CBB now handles nightmode correctly (by deferring to Lua), so we no longer
need to do monkey dances about disabling it when hw invert is missing.

canUseCBB cap is resolved by generic device re-configuring blitbuffer
on the go, so as to avoid repeating the same thing in every device driver.

The dev setting can now flip cbb on the go, so one can gloat at the near
meaningless perf difference - 2Mp draw is 15ms Lua / 10ms C on 1GHz Cortex A7.
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
yparitcher 3e063498fc
FrontLight: fix footer update on FL on/off toggle (#6664)
move state change event to higher level function so it will be called after powerd.is_fl_on is updated.

makes _setIntensity redundant so get rid of it

obsoletes #6667
4 years ago
Martín Fernández 27fe0d7957
add eudic from gplay (#6682) 4 years ago
NiLuJe 23efabb913
[PB] Fix WAIT_FOR_UPDATE_COMPLETE ioctl (#6669)
* Fix WAIT_FOR_COMPLETE ioctl (fix #6000)

* Prevent a promotion to a flashing on fg/bg toggle

* Bump base for the matching PB updates

(https://github.com/koreader/koreader-base/pull/1188)
4 years ago
NiLuJe f1918cdfbb
[Kobo] Don't send a flood a FrontlightStateChanged events during the FL ramps (#6667)
* Only send a single FrontlightStateChanged event on toggle

Prevents the ReaderFooter refresh from going wonky
4 years ago
zwim 73b0c701ce
correct bug introduced with #6641 (#6665) 4 years ago
ezdiy 152ee087a8
Pocketbook: Fix frontlight handling. (#6663)
Account for InkView 5.x having different API for on/off states.
4 years ago
NiLuJe 99045b4311
Minor util & ffi/util cleanups (#6657) 4 years ago
Martín Fernández 8f61bc750b
AndroidPowerD: remove unneded syntactic sugar & JNI calls (#6641)
Each JNI call has a little overhead, so don't use them when it is not needed.
The syntactic sugar is not needed to use android module's functions.
4 years ago
ezdiy a110fe8686
Pocketbook: Add reboot option. (#6625)
Turns out there's an IPC command for it.
4 years ago
ezdiy 63e938f508
Pocketbook: Add file associations into "Open with" menu (#6624)
We used to put koreader alone in there, but apparently other
handlers can be left in as optional - see #6415
4 years ago
poire-z f15aa7103f
Allow following links and footnotes with keys (#6619)
Only with CreDocuments (as no way currently to highlight links
in PDFs).
Tab or Shift-Tab to select next or previous links.
Press to follow (or show footnote in popup, and in there Press
to follow), back to go back.
4 years ago
ezdiy 4857e97e30
Pocketbook: Launcher OS integration (#6620)
* Bring in restart koreader & shutdown device exit options
* Existing instance reused for opens via native book explorer
4 years ago
ezdiy c9a339ead0
Pocketbook: File handling OS integration (#6617)
* Show opened file in task manager
* Remember file to open on power-off
* Perform file associations
4 years ago
ezdiy 426f7b5ddc
Add API to set OS level file associations (#6615) 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
ezdiy 6d3d45a93b
Pocketbook frontend: Fix up missing require. (#6604)
This one slipped through tests somehow.
4 years ago
ezdiy 3c0e14703d
Poll mode pocketbook frontend. (#6559)
Out of the box, it behaves exactly as native pocketbook apps should, ie aggressive
standby, but no freezing at operations in progress.

Config UI will be done via koplugin that will also do adaptive standby. This is
because the API is now device independent (albeit PB is the only implemented user).
4 years ago
ezdiy fd31bcc5fd
Make UIManager track prevent/allowStandby state. (#6558)
Conversely, Trapper and plugins report standby interruptibility.
4 years ago
zwim 2c1d87a956 resolve ANR on hold and native light dialog 4 years ago
zwim 6fb2a0469b
update statusline after native light dialog (#6584) 4 years ago
zwim 24af0810d2
turn on frontlight switch on Tolino. (#6586) 4 years ago
Martín Fernández c7f77de72a
refactor thirdparty app integration (#6513)
* refactor thirdparty app integration
* Fix fora package name
4 years ago
Martín Fernández 189397e38c
android: fix frontlight dialog gesture (#6568) 4 years ago
zwim 66e8087c66
[android]: fix backlight toggle (#6520)
* check on startup if frontlight can be changed.
* Init fl_min if necessary not to use intensity==0
4 years ago
NiLuJe 6e3a3e8069
[Kobo] Support USBMS exports (#6552)
* \o/

* Make sure the (debug) event log doesn't end up in the fd table of our child processes...
Otherwise, it breaks USBMS.

* Close suspicious fds in the Wi-Fi scripts
To prevent any and all issues w/ USBMS down the road...

* Minor USBMS UI tweaks

* Always ask for confirmation to start on USBMS session on plug

* Bump base

https://github.com/koreader/koreader-base/pull/1161
https://github.com/koreader/koreader-base/pull/1162
https://github.com/koreader/koreader-base/pull/1163
https://github.com/koreader/koreader-base/pull/1165
https://github.com/koreader/koreader-base/pull/1167
4 years ago
Martín Fdez 09e5143d2f pocketbook: fix for devices without natural light :p 4 years ago
roshavagarga 61e9d0b40a
Specify that PocketBook 515 has no frontlight (#6549)
It doesn't have one, and having it in there might lead to issues.
4 years ago
NiLuJe b5d3305876
A few e-Ink flash rate QoL tweaks (#6528)
* Add an option to *always* flash on chapter boundaries

* Optionally, in flash on chapter boundaries mode, also flash on the *second* page of a chapter.

(There's often a large river at the top of the page on a chapter's first page)

* In CRe, request a flashing update when there is significant image content on the page.

* Register all refresh rate related options in Dispatcher, making them available in Gestures & Profiles.
4 years ago
NiLuJe 1b904f0f0d
Revamp manual rotation events (#6530)
Restore a Swap event like before #6309
Implement an Invert one
And keep the fairly useless +90° CW one, but under an accurate name.

Fix #6524
4 years ago
roshavagarga 87fac74ea2
Fixes and changes to PocketBook definitions (#6533)
**Changes:**
- [x] Added new CIS-unique device definition for PocketBook 606 - [News article](https://pocketbook.ru/news/novyy-pocketbook-606/)
- [x] Added new CIS-unique codename for PocketBook Aqua (640) - [Russian manual](http://support.pocketbook-int.com/fw/640/ru/4.4.1853/manual/User_Guide_PocketBook_640_RU.pdf) (last page)
- [x] Added new CIS-unique codename for PocketBook Ultra (650) - [Russian manual](http://support.pocketbook-int.com/fw/650/ru/5.14.789/manual/User_Guide_PocketBook_650_RU.pdf) (last page)
4 years ago
Martín Fernández b9ffb2e0d0
pocketbook: warmth lights support (#6531)
* also enables natural light controls for the emulator
4 years ago
Teteros 01ed79fb92
Update PB633 device definition (#6529) 4 years ago
roshavagarga a9aa63d94c
Update PocketBook device definitions (#6525) 4 years ago
zwim b3f64dc73b
gesture: messages and sensitivity changes for small (warmth) scales; devicelistener dedup (#6468)
* deduplicate code on warmth/brightness swipes

if device has a small scale (e.g. warmth is going from 0..10)
* adjust warmth message
* use a smaller gesture sensitivity
4 years ago
Martín Fernández d935ca6937
sdl: keep track of window position and size (#6495) 4 years ago
roshavagarga ec87d36e57
PocketBook: Add new device definitions (#6481) 4 years ago
Martín Fdez 9037a1f4f2 bump luajit-launcher and remove frontlightwidget leftovers 4 years ago
Martín Fdez bdbebb9e08 standalone osx application bundle 4 years ago
zwim a6763465b4
[Android]: Native light dialog (#6426)
* Adds support for Tolino Epos 2 warmth light
4 years ago
Galunid a9d0990f84
Add Set Frontlight/Set Frontlight Warmth to dispatcher (#6440)
Add Set Frontlight/Set Frontlight warmth events to dispatcher. This allows users to set day/night profiles with different fl/warmth values as requested in #6444
4 years ago
NiLuJe 2ad976387d
More #6424 cleanups (#6442)
* Simplify logic, and more detailed debug logging
* Kill Nickel's FIFO on startup
Avoids udev/udhcpc scripts hanging when trying to open() it.
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
Martín Fernández ca21d1401a SDL: use platform as model for desktop computers, report battery if available 4 years ago
Martín Fernández 94c0d7854f remove filechooser 4 years ago
Martín Fdez fca7f9e7d5 desktop/emulator 4 years ago
yparitcher 1db2b7d875
better logic for #6386 (#6388) 4 years ago
yparitcher 6671d984ed
SetNightMode event & Night Mode refresh rate (#6386)
If the user has not set a separate refresh rate for night mode
the default one will be used, as was the previous behavior

Closes: #5019
Closes: #6094
4 years ago
NiLuJe a8da762955
Initial handling of the upcoming Kobo Nia (#6380)
Obviously untested ;p
4 years ago
yparitcher bda44a99ef
Dispatcher: use sections (#6364)
use `device` `filemanager` `rolling` and `paging` sections to organize the
dispatcher menu and allow the user to know when the action will apply

add events from ReaderGesture

allow profiles in FM
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
Martín Fernández 1adea4a497 Add macOS target
Co-authored-by: Jason Benwell <jbenwell@hotmail.com>
4 years ago
Martín Fdez a376a52c3a easier user font paths with Device.home_dir 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
Martín Fdez 8324154177 keep newlines outside translations 4 years ago
Martín Fdez 7094519e1b android: support for native surface rotation 4 years ago
yparitcher f7d538b108
Landscape FM / Refactor rotation (#6309)
* landscape FM / Refactor rotation

refactor and simplify the orientation handling code. the user generally cares about the rotation (what direction the device is facing) and not about if koreader is displaying in portrait or landscape mode

* bump base

update luasocket, libjpeg-turbo, curl
add logging to evernote-sdk-lua
update framebuffer for proper rotation
4 years ago
Martín Fernández 32207523b0
emulator: add fake network manager (#6314) 4 years ago
roshavagarga 46bf88c573
Add PocketBook 614W (Basic 3) definition (#6312)
Cf. <#6311>.
4 years ago
zwim 43693c9fe9
Add the possibility run shell scripts from filemanager on android (#6288) 4 years ago
NiLuJe ff1e50c5c0
Don't rotate BookStatus & ReadingProgress in screensavers. (#6286)
They're full-screen, and they work fine in Landscape.

re: #5724

* Fix multiline indents in the Kindle c/p ;p
4 years ago
Martín Fernández 83cde64bcc
unified calibre plugin (#6177)
joins calibre metadata search and calibre wireless connections into a single plugin

search metadata changes:

- search directly into calibre metadata files.
- search can be performed on more than one library (configurable from a menu)
- device scans now find all calibre libraries under a given root
- search options can be configured from a menu. (case sensitive, find by title, author and path)
- removed legacy global variables.
- *option* to search from the reader
- *option* to generate a cache of books for faster searches.

calibre wireless connection changes:

- keep track of books in a library (includes prunning books from calibre metadata if the file was deleted locally)
- remove files on device from calibre
- support password protected connections
- FM integration: if we're in the inbox dir it will be updated each time a book is added or deleted.
- disconnect when requested by calibre, available on newer calibre versions (+4.17)
- remove unused opcodes.
- better report of client name, version and device id
- free disk space checks for all calibre versions
- bump supported extensions to match what KOReader can handle. Users can override this with their own list of extensions (or from calibre, by configuring the wireless device).
4 years ago
Martín Fernández 2e731dd4dd
[chore] Device abstraction (#6280)
* generic Device:info() function which returns the model

* add Device:canSuspend() and make it true in all devices that have suspend routines and the emulator

* also enable fake poweroff/reboot on the emulator

* add Device.home_dir

* add Device:hasExitOptions() and update menus & comments
4 years ago
Martín Fernández 765b35a7bf
android: add a toggle to ignore back button events (#6269)
Requires koreader/android-luajit-launcher#233
Requires koreader/koreader-base#1117

It is a workaround for #6263 but can be useful on some devices with erratic back key behaviour too (yep, Onyx)
4 years ago
Martín Fdez 835f9f62c6 fix ANRs in Kosync plugin login/register 4 years ago