Commit Graph

63 Commits (90c38e2d0d162a7dd10af0ff9f169cb9dce96d06)

Author SHA1 Message Date
NiLuJe 90c38e2d0d ReadHistory: nil guard a Document instance access
We're now more careful about this, so, I suppose weird timings may mean
we might be trying to access a nil here.

Fix #7706

Guard a few other similar constructs
3 years ago
gbyl 508a294016
ScreenSaver: Allow toggling the reboot/poweroff overlay message (#7566)
Co-authored-by: gbyl <gbyl@users.noreply.github.com>
3 years ago
NiLuJe 22b9396696
Centralize one time migration code after updates (#7531)
There have been a couple of these this month, and keeping stuff that should only ever run once piling up in their respective module was getting ugly, especially when it's usually simple stuff (settings, files).

So, move everything to a dedicated module, run by reader.lua on startup, and that will actually only do things once, when necessary.
3 years ago
NiLuJe cbfcb2373d
ScreenSaver: Get rid of automagic settings (#7496)
By which I mean, explicitly initialize default settings, making everything seven hundred billion percent less weird.

Also, split the background option between image and (solo) message, because the defaults for those are different, and trying to twist the one into the other was leading to pure madness.
3 years ago
NiLuJe dfc9d16a19
ScreenSaver: Fix default settings (#7479)
* ScreenSavers: Fix default settings

Awesome typo ;D.
3 years ago
hius07 17129915f9
Standardize directory/folder to folder (#7410)
Follow-up to https://github.com/koreader/koreader/pull/7328
3 years ago
NiLuJe 601d2fc3d2
Screensaver: Unbreak screensaver_stretch_images (#7403)
* Screensaver: Unbreak screensaver_stretch_images

We don't have real ternary operators in Lua, if the second argument evaluates to false, it doesn't work.
Invert the test to avoid this pitfall.
(c.f., http://lua-users.org/wiki/TernaryOperator).

Fix #7402, regression since #7371

* Free a few similar constructs (incidentally, some of 'em also tweaked in #7371 ^^).
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 681c00ecac Screensaver: Use the current ReaderUI instance if available.
Instead of always opening the document & docsettings twice...
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
Frans de Jonge 1bd4636a03
Standardize directory/folder to folder (#7328)
Closes <https://github.com/koreader/koreader/issues/7157>.
3 years ago
NiLuJe 467264f59f
ScreenSaver: Don't expand special tokens with an empty string (#7314) 3 years ago
NiLuJe 47568ae9b4
ScreenSaver: Unbreak "disable" mode (#7124)
* Unbreak "disable" mode

Regression since f67296942f
3 years ago
NiLuJe f67296942f ScreenSaver:
* Don't try to expand a screensaver message without any special tokens
  * Don't needlessly nil the background when show_message is true
    Honor the actual nil background setting, now that we've got one.
    Also, only clear covers_fullscreen with no background *and* no widget.
  * Support special tokens outside of ReaderUI. Because the undocumented
    "Oops, I'll use the fallback otherwise" was extremely not
    user-friendly.
3 years ago
sladflob 9e9f3b419d
[feat] Allow message to be overlaid on other screensavers (#6238) 4 years ago
Rena Kunisaki fd05842686
Add "message at top of screen" screensaver (#5739)
Adds a screensaver mode which is just a line of text at the top of the screen. Purpose is to be minimally obstructive while still displaying something to indicate the device is asleep.
4 years ago
poire-z 0599c440cc [RTL UI] Bidi-wrap filenames, paths, urls, metadata
bidi.lua:
- Revert "Alias everything to Bidi.nowrap() when in LTR UI,
  as using LTR isolates seems uneeded when already LTR" (part
  of a628714f) which was a wrong assumption: we need proper
  wrappers for all things paths. Enhance some of these wrappers.
- Fix GetText RTL wrapping which was losing empty lines and
  trailing \n.

- Wrap all paths, directories, filenames in the code with
  these wrappers.
- Wrap all book metadata (title, authors...) with BD.auto(),
  as it helps fixing some edge cases (like open/close quotation
  marks which are not considered as bracket types by FriBiDi).
  (Needed some minor logic changes in CoverBrowser.)

- Tweak hyphenation menu text
- Update forgotten SortWidget for UI mirroring
- KoptConfig: update "justification" index for RTL re-ordering,
  following the recent addition of the page_gap_height option.
4 years ago
poire-z f410315f83 Screensaver: avoid crash when no lastfile 4 years ago
poire-z f05e62c1fb
TextWidget: small refactoring, better handle max_width (#5503)
Lots of code was doing some renderText calls to get the size
of some text string, and truncate it to some width if needed,
with or without an added ellipsis, before instantiating
a TextWidget with that tweaked text string.

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

Also:
- RenderText: removed the space added by truncateTextByWidth
  after the ellipsis, as it doesn't feel needed, and break
  right alignment of the ellipsis with other texts.
- KeyValuePage: fix some subtle size and alignment issues.
- NumberPickerWidget: fix font size (provided font size was
  not used)
5 years ago
poire-z 7caa21a3fb [chore] Remove uneeded doc_settings:close() (#5504)
When just reading settings, no need to close and
write the file to disk.
5 years ago
Robert e315d8690d [chore] Remove unnecessary indent on new line (#5391) 5 years ago
Frans de Jonge 5bc9700c24
[feat] Allow setting any document cover as screensaver (#5369)
Cf. suggestion by @KenMaltby in <https://github.com/koreader/koreader/issues/3033#issuecomment-526657352>.
5 years ago
sladflob 4717d6f70a Update screensaver.lua (#5123)
Change to use Math.round()
5 years ago
sladflob 912e617377 [feat] Add percentage read (and other book information) to sleep message (#5121)
Add checking for escape sequences for current/total page, percentage read, and document title.
5 years ago
poire-z 6239d89022
Screensaver: fix crash when "Choose screensaver image" (#4799)
Just switched to use the friendly PathChooser instead of
FileChooser (which is more like a superclass and shouldn't
be used directly).
5 years ago
NiLuJe 2011cf1ad1 Various blitting related cleanups (#4789)
* Fix the "Enable debug logging" checkbox so that it properly disables "Enable verbose debug logging" when it gets disabled
* Avoid asking ImageWidget for alpha-blending when it's not useful
* Make ImageWidget's alpha-blending code-path double-check that alpha-blending actually is needed, and avoid it if possible
* In the same vein, only do alpha-blending in textboxwidget when absolutely necessary
* Prefer color constants over the gray() method, ensuring that they're part of the eInk palette

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

Fix #4774
5 years ago
NiLuJe 5495c5d108 [fix] Fix partial refresh when coming out of ScreenSaver in landscape (#4622)
When we rotate to show a screensaver, restore original rotation *before* closing the ScreenSaver window.

And ensure closing the ScreenSaver *always* triggers a full update, no
matter the settings.

Fix #4621
5 years ago
NiLuJe 812e595608
Enable HW dithering in a few key places (#4541)
* Enable HW dithering on supported devices (Clara HD, Forma; Oasis 2, PW4)
  * FileManager and co. (where appropriate, i.e., when covers are shown)
  * Book Status
  * Reader, where appropriate:
    * CRe: on pages whith image content (for over 7.5% of the screen area, should hopefully leave stuff like bullet points or small scene breaks alone).
    * Other engines: on user-request (in the gear tab of the bottom menu), via the new "Dithering" knob (will only appear on supported devices).
  * ScreenSaver
  * ImageViewer
* Minimize repaints when flash_ui is enabled (by, almost everywhere, only repainting the flashing element, and not the toplevel window which hosts it).
  (The first pass of this involved fixing a few Button instances whose show_parent was wrong, in particular, chevrons in the FM & TopMenu).
* Hunted down a few redundant repaints (unneeded setDirty("all") calls),
  either by switching the widget to nil when only a refresh was needed, and not a repaint,
  or by passing the appropritate widget to setDirty.
  (Note to self: Enable *verbose* debugging to catch broken setDirty calls via its post guard).
  There were also a few instances of 'em right behind a widget close.
* Don't repaint the underlying widget when initially showing TopMenu & ConfigDialog.
  We unfortunately do need to do it when switching tabs, because of their variable heights.
* On Kobo, disabled the extra and completely useless full refresh before suspend/reboot/poweroff, as well as on resume. No more double refreshes!
* Fix another debug guard in Kobo sysfs_light
* Switch ImageWidget & ImageViewer mostly to "ui" updates, which will be better suited to image content pretty much everywhere, REAGL or not.

PS: (Almost 💯 commits! :D)
5 years ago
poire-z 85ac59ae00 CreDocument: fix document loading interferences (#4349)
When a main document is opened for displaying, some other
document openings (for getting metadata or cover image)
could affect the main document.
Split some code from CreDocument:init() into another new
method CreDocument:setupDefaultView(), that will only be
called by ReaderUI when opening the main document (and not
by these other openings like Book inforation, View cover...)

Also speed up some of these other openings (Search, Screensaver)
by using doc:loadDocument(false) to load only metadata and
avoid parsing the HTML.

Details in https://github.com/koreader/koreader/issues/4346#issuecomment-440036496
6 years ago
Robert a29f0fb190 Add support for tiff and gif format in screensaver (#4250) 6 years ago
Robert a706fde2d7 Cleanup downloadmgr titles (#4222) 6 years ago
Robert c17864999e [fix] Show hidden dirs and files in Choose screensaver image (#4121)
Fixes #4117.
6 years ago
Robert 00cfc469f1 Allow selecting a single image as screensaver (#4095) 6 years ago
NiLuJe 18db509325 Assorted bag of fixes (#4014)
* Link to the WiKi, it's a bit more explainy ;).

* More WiFi trickery for some HW revs

* Fix Rev2 detection under KSM

That's to future-proof it, the other end of this hasn't made it into
current KSM build yet.

* Resync nickel.sh w/ current rcS

We don't have CPU, but we have PLATFORM, which is based on CPU, so,
that'll do :).

* Go back to using rmmod instead of modprobe -r

Functionally identical on current FW, will potentially avoid getting
outsmarted by modprobe if Kobo ever deigns shipping an actually usable
Linux system one day...

* Don't crash if screensavers directory doesn't exist

c.f., https://www.mobileread.com/forums/showpost.php?p=3706979&postcount=2919
6 years ago
onde2rock e502bf04d3 [feat, UX] Support the virtualKeyboard on non touch-device (#3796)
* [VirtualKeyboard] Add support for keynaviguation

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

* Make the goto dialog compatible with key naviguation

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

* Correctly show the virtual keyboard on dpad devices

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

* Handle the multi input dialog

* Support reopening the virtualKeyboard by the Press key

* add check focusmanager

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

* MultiInputDialog : Now work on non touch-device

* Set the virtualkeyboard to be a modal widget

* Fix the layout in multiinputwidget

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

* [Focusmanager] Better handling of malformed layout
6 years ago
poire-z 5e47a83e6a
UIManager: avoid painting widgets covered by a full screen widget (#3770)
Navigating the TOC, viewing a full screen image, browsing
reading stats... would call paintTo() on ReaderUI (so, asking
the engine to render the page) or FileManager (so, rendering cover
images) even though their content is hidden.
Widgets registering to UIManager have to explicitely states
they cover the full screen (UIManager can't know, parts of their
dimen may be transparent, e.g. if it is a CenterContainer).
6 years ago
poire-z 35df1749b2
Screensaver: a few tweaks and fixes (#3619)
When no manually added specific 'poweroff' or 'reboot' screensaver
settings, use the suspend/sleep settings set via menu with an added
overlay message in top right corner.
Generalized some settings: "White background behind message and images"
and "Stretch covers and images to fit screen", and move "Exclude this
book's cover from screensaver" up a level (and remove this menu item
added by ReaderMenu when closing document).
Don't use memory cache with rendered screensaver images.

ImageWidget: fix wrong behaviour (stretch) when 'file', 'width',
'height' and 'scale_factor' provided: now, keep aspect ratio.
ImageWidget: increase file image mem cache (mostly used for icons)
from 2 to 5MB to be ready for devices with very high DPI.
6 years ago
poire-z 98abcafa1b Screensaver: change default & show messages on reboot and poweroff (#3572)
Use "message" as the default for screensaver (instead of "disable") (https://github.com/koreader/koreader/pull/3535#issuecomment-353337143)

On Kobo 
Fix: display message on poweroff or reboot (https://github.com/koreader/koreader/pull/3535#issuecomment-352355865)
Allows for overwritting these default messages with the classic screensaver settings, by just prepending "poweroff_" or "reboot_" to them. (https://github.com/koreader/koreader/pull/3535#issuecomment-352498497)

So one can manually add to its settings.reader.lua:
```
"poweroff_screensaver_type" = "random_image" or "message", "cover", "bookstatus", "readingprogress", "disable",
"poweroff_screensaver_dir" = "path to same as screensaver_dir or alternate dir for poweroff image(s)",
"poweroff_screensaver_message" = "message to use instead of Powered off",
```
```
"reboot_screensaver_type" = "random_image" or "message", "cover", "bookstatus", "readingprogress", "disable",
"reboot_screensaver_dir" = "path to same as screensaver_dir or alternate dir for reboot image(s)",
"reboot_screensaver_message" = "message to use instead of Rebooting...",
```
6 years ago
Robert efa0d06df9 Add new options to screensaver (#3535)
* Prevent open screensaver more than one in the same time

* Add option to enable/disable background in message screensaver

* fallback to random images if this book cover is excluded feature + fix Disabled (leave screen/page as it is)

* Autostretch disable by default, more fallback options, leave screen as it is
6 years ago
Frans de Jonge cfaa119c35 [fix, UX] Allow modal widget on top of modal widget (#3170)
Fixes #2653.
7 years ago
Robert 59873ae293 Screensaver option on Kindle devices (#2734)
* Screensaver on Kindle devices
7 years ago
poire-z 7166efd777 ImageViewer: added zoom & pan via gestures
ImageWidget: removed 'autostretch' setting (replaced by scale_factor=0)
and renamed 'autoscale' setting to 'scale_for_dpi'.
7 years ago
poire-z 0577fde59e Better tracking, management and freeing of BlitBuffers
This should fix the most obvious memory leaks (noticable when
using images as screensaver).
ImageWidget: added a few more options needed by ImageViewer,
and removed 'overflow' option as logic was wrong.
7 years ago
Qingping Hou f95ad00b9e feat: add logger module & rewrite kobo suspend script in lua 7 years ago
Bastien Dejean b959c4de1c Allow local overrides of use_lastfile_as_screensaver 8 years ago
Bastien Dejean 64bc5cd63c Make the powered off state customizable
This changes the behavior of the powered off transition phase for the
Kobo devices: instead of displaying a confirmation dialog, a screensaver
is used after a 2 seconds press delay.

Users can specify separate directories/files/messages for the powered
off and sleeping states through the `path` and `message` attributes of
the `{poweroff,suspend}_screensaver` settings.

Fixes #2327 and closes #2306.
8 years ago
Bastien Dejean fe738ef101 Don't try to return an element from an empty set 8 years ago
Qingping Hou ec6da5318c screensaver(fix): add back menu toggle to support screensaver folder 8 years ago
Qingping Hou e9b9bbadcc fix: luacheck 8 years ago
Hzj_jie 0fb5d5f6fc Fix a naming, which breaks coding style 8 years ago