Commit Graph

46 Commits (master)

Author SHA1 Message Date
hius07 b8090c641c
Minimize DocSettings:open() calls (#11437) 3 months ago
hius07 aabd6d7a26
File browser, Collection: improve group actions (#11178)
Maintain correct records in History and Favorites when moving/deleting folders or group of files.
Optimize Collection module to minimize storage requests.
5 months ago
hius07 4044c81a5a
History: update on deleting a folder (#11090) 6 months ago
hius07 c92d94af4d
writeToFile: centralize (#11012) 6 months ago
hius07 6ccf19b99f
History: update on renaming/moving a folder (#10999) 6 months ago
hius07 517731dbbb
Finished books: freeze history timestamp and statistics (#10968) 7 months ago
hius07 4a775b03f1
History: update short date/time correctly (#10601)
Further to #10594, fix updating the mandatory.
10 months ago
hius07 45428dda49
History: shorten date/time field (#10594) 10 months ago
hius07 91fc8a0061
readhistory: fix clear missing (#10257) 1 year ago
hius07 df9c2bcb7f
History: fix book info buttons disable (#10244) 1 year ago
hius07 fe7b10f18d
Datastorage: do not create unnecessary folders (#10162) 1 year ago
hius07 5c9ba53353
History: update last book access time (#10156) 1 year ago
hius07 d1081fa982
Docsettings: add centralized sdr storage (#10074)
Added an option to choose a new location to save document settings, highlights and bookmarks 
(koreader/docsettings folder).
1 year ago
hius07 20ac8004d6
ReadHistory: further minor refactoring (#9991) 1 year ago
zwim 192a243b4d Add datetime.lua
Move date and time related functions from util.lua
(and the statistics plugin) to a new datetime.lua.
1 year ago
hius07 4d4b04359c
ReadHistory: refactoring with binary search (#9603)
Get rid of indexing and sorting, reduce flushing.
2 years ago
NiLuJe fadee1f5dc
Clarify our OOP semantics across the codebase (#9586)
Basically:

* Use `extend` for class definitions
* Use `new` for object instantiations

That includes some minor code cleanups along the way:

* Updated `Widget`'s docs to make the semantics clearer.
* Removed `should_restrict_JIT` (it's been dead code since https://github.com/koreader/android-luajit-launcher/pull/283)
* Minor refactoring of LuaSettings/LuaData/LuaDefaults/DocSettings to behave (mostly, they are instantiated via `open` instead of `new`) like everything else and handle inheritance properly (i.e., DocSettings is now a proper LuaSettings subclass).
* Default to `WidgetContainer` instead of `InputContainer` for stuff that doesn't actually setup key/gesture events.
* Ditto for explicit `*Listener` only classes, make sure they're based on `EventListener` instead of something uselessly fancier.
* Unless absolutely necessary, do not store references in class objects, ever; only values. Instead, always store references in instances, to avoid both sneaky inheritance issues, and sneaky GC pinning of stale references.
  * ReaderUI: Fix one such issue with its `active_widgets` array, with critical implications, as it essentially pinned *all* of ReaderUI's modules, including their reference to the `Document` instance (i.e., that was a big-ass leak).
* Terminal: Make sure the shell is killed on plugin teardown.
* InputText: Fix Home/End/Del physical keys to behave sensibly.
* InputContainer/WidgetContainer: If necessary, compute self.dimen at paintTo time (previously, only InputContainers did, which might have had something to do with random widgets unconcerned about input using it as a baseclass instead of WidgetContainer...).
* OverlapGroup: Compute self.dimen at *init* time, because for some reason it needs to do that, but do it directly in OverlapGroup instead of going through a weird WidgetContainer method that it was the sole user of.
* ReaderCropping: Under no circumstances should a Document instance member (here, self.bbox) risk being `nil`ed!
* Kobo: Minor code cleanups.
2 years ago
yparitcher c9bfb74d2a Book Shortcuts: allow recursively searching folders 2 years ago
hius07 8026370d5c
ReadHistory: force reload history after files changes (#8813) 2 years ago
hius07 a024a42289
readhistory: fix file move/rename (#8575)
Reload updated history after file move/rename.
2 years ago
yparitcher 8207bdc3e3
BookShortcuts plugin: folder support (#8449)
Allow setting a folder as a book shortcut, with 2 options:
- open file browser: opens the FM in that folder
- last book: opens the most recently read book (via
  ReadHistory) in that folder
2 years ago
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
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 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
poire-z d63d282806 History: avoid opening non-existent files
Mostly just so we don't get the History closed when
erroneously tapping on a deleted file.
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 32bf53cfdf
ReaderFooter: Don't duplicate a 12h clock time format option (#6973)
* ReaderFooter:
	* Honor the global twelve_hour_clock setting, instead of
	  duplicating a local one.
	  (Re #6969)

* os.date is a thin wrapper around strftime, so we might be able to get
away with some not-quite-standard extensions...

These are *definitely* supported on Linux, but are *NOT* the glibc
extension (that'd be e.g., %-I), so, hopefully, they're somewhat
portable...

They are also supported on BSD/macOS.
They are *not* supported by the MS UCRT. That means MinGW-w64, too.
This *appears* to be supported on current Bionic (it might even support
said glibc format altering extensions).

* And of course, Windows is terrible, so, make this terribly ugly to not
break it there...

* Turns out BSD also supports the dash trim format extension, so, leave
the trimming to the libc, and handle the special-casing in a way that
doesn't create stupid locals.

* Random unrelated cleanup ^^.

(https://gitter.im/koreader/koreader?at=5fd24be492aa1c4ef5d11f31)

* Update the testsuite

(Because the default used to be 24h clock).

Changed the default to 24h clock ;p.

* Explain why we don't try to fix it in Lua
3 years ago
NiLuJe 99045b4311
Minor util & ffi/util cleanups (#6657) 4 years ago
poire-z cfa45f8d88 History: show last read date instead of file size
In classic and list display modes.
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
poire-z 17c686628c History: fix possible issues when saving and loading
Internal self.hist being an array, iterating it with 'pairs'
could have some strange effects. Best to use 'ipairs'.
4 years ago
poire-z 46221985a6
Delegate "lastfile" management to ReadHistory (#6128)
Simplify (and avoid edge cases) in other code by having
ReadHistory manage the "lastfile" setting on add, remove,
rename...
Fixed a few other cases of things not updated.
4 years ago
poire-z 04d9a557aa Use fsync() for more robust setting files saving
Bump base for util.fsyncOpenedFile() and util.fsyncDirectory().

Use these to force flush to storage device when
saving luasetting, docsetting, and history.lua.
Also dont rotate them to .old until they are at least
60 seconds old.
Also make auto_save_paging_count count right.

Also bump crengine: open (as text) small or empty files
4 years ago
Frans de Jonge a2dcfe9aec
[doc] Tag @todo, @fixme and @warning (#5244)
This commit standardizes the various todos around the code a bit in a manner recognized by LDoc.

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

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

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

* and some random beautification
5 years ago
poire-z 9afe3da6c2 History: show files sizes, as File browser does 5 years ago
alethiophile 4c8ef61477 Fix sort-by-last-read when partition is mounted noatime (#3990) 6 years ago
Robert a66d657195 Update History and Last open document when move (cut and paste) file (#3607) 6 years ago
poire-z 4d18ac1100 Some History fixes and enhancements (#3247)
Made the onHold buttons table similar to the one of File browser.
Added "Purge .sdr" and "Delete" to these buttons.
Moved the purgeSettings and removeFileFromHistoryIfWanted
logic into filemanagerutil functions.
Stay on the same page when manipulating history (previously, we were
always put back on first page).
Really keep deleted files in history (unless setting says otherwise).
Show deleted files in grey or dimmed in classic History and all
CoverBrowser display modes.
7 years ago
Hzj_jie d6845d94b1 ReadHistory: support reload (#3003)
Allows ReadHistory to reload according to the modification timestamp of history.lua.
7 years ago
Frans de Jonge da3ff5e336 History: add 'autoremove_deleted_items_from_history' setting 7 years ago
Frans de Jonge 827e77afbe FileManagerHistory: fix loop error 7 years ago
Frans de Jonge 2c80ff7d7b FileManagerHistory: remove harmful deletion code and turn it into a feature
Fixes the problem introduced in 51327911f2 and turns it into a feature that should fix #2477
7 years ago
Zijie He ced671bc69 Add readhistory_spec / docsettings_spec 8 years ago
Hzj_jie 7493fc89f6 Add removed item name in "Remove this item from history" and fix wrong items deleted issue. (#2164)
* Add removed item name in "Remove this item from history".

* Fix #2162, wrong history items deleted.
8 years ago
Hzj_jie 51327911f2 Won't track missing files in history, and always keep latest timestamp 8 years ago
Zijie He 667e8834ad Migrate history folder, FileManagerHistory uses own history.lua file and ReadHistory component 8 years ago