2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00
Commit Graph

9017 Commits

Author SHA1 Message Date
roygbyte
e995cf1355
Fix typo in ListView doc (#8444) 2021-11-15 09:02:00 +01:00
Aleksa Sarai
7e611ac50c
keyboard: japanese: always put digits as the south gesture for latin (#8443)
This is to match GBoard's layout for the latin keyboard mode.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-11-14 14:10:25 +01:00
Dylan Garrett
26ec5bafe3
[plugin] Display OPDS download titles if available (#8441)
I've found that some OPDS catalogs have multiple downloads of the same filetype, but optimized or formatted in different ways. The Title of the download is much more descriptive in this case, so I thought it would be better to display the title if available.

The OPDS catalog at https://standardebooks.org/opds is a good example. Note how entries in https://standardebooks.org/opds/new-releases have three different epub downloads, titled "Recommended compatible epub", "Advanced epub", and "Kobo Kepub epub".
2021-11-14 07:52:53 +01:00
Aleksa Sarai
5709b4c2f1
kopt: correctly handle CJK character detection for space insertion (#8438)
Previously getTextFromBoxes would just pass the first and last three
bytes of the current and previous words when trying to detect CJK
characters (which shouldn't have spaces inserted).

However, this handling was not correct because CJK characters can be
longer than 3 bytes, and internally BaseUtil.utf8charcode doesn't ensure
that it was only given a single utf8 character (it blindly does the bit
operations on whatever length code you give it).

As a result, before this patch selections in PDF documents would have
lots of spaces stripped because getTextFromBoxes would think that almost
all characters were CJK characters.

Fixes: 6f1b70e5eb ("util.utf8: improve CJK character detection")
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-11-11 16:09:05 +01:00
zwim
15778ac939
[plugin] Autowarmth: Fix sanity check for longitude (#8434)
This PR will fix https://www.mobileread.com/forums/showthread.php?t=342905
2021-11-10 18:43:01 +01:00
zwim
89064487b7
ReaderDictionary: Colons in menus (#8431) 2021-11-09 20:15:52 +01:00
zwim
eb4e958303
[Coverimage, plugin] Colons in menus; unlock sizespinner (#8430) 2021-11-09 20:09:05 +01:00
zwim
c6e415d646
[Status bar] Consistent menu entries; Add "centered dot" as separator (#8424)
* Consistent menu entries; Add "centered dot" as separator

* Menu entry: Colon
2021-11-09 19:08:41 +01:00
zwim
abcd989ec4
[Status bar] Add custom text to footer (#8419)
Allows to add any text to the status bar. Can be a placeholder (empty space) for better positioning of the indicators.
2021-11-09 19:04:44 +02:00
hius07
3dabbd5d73
Typeset menu: adds "Reset document settings to default" (#8412) 2021-11-07 19:29:53 +01:00
hius07
e6d2c1cae6
ReaderGoto: adds Go to % (#8395) 2021-11-07 19:26:07 +01:00
Aleksa Sarai
cdae66a661 keyboard: japanese: switch to 12-key flick layout
This layout is far more commonly used on mobile devices, and allows for
much easier typing. The keyboard primarily functions through gestures in
the four cardinal directions to select which vowel kana to select. In
addition, users can cycle through each kana row by tapping the key
within a 2-second window (this is the equivalent to T9 input for
Japanese phone keyboards).

This also resolves the long-standing issue that the old keyboard did not
correctly handle dakuten (there was a standalone dakuten key which added
a stray dakuten mark, and the umlat mode which added dakuten to all of
the keys it could) and could not input handakuten characters at all.

In order to allow adding dakuten and cycling through the various
modifiers for the previous kana, we need to wrap the input-box (similar
to korean) but luckily we don't need any state machine magic since we
just need to modify the last character in the character buffer. However
because the tap timeout for T9-like-cycling needs to be reset after any
non-tap key we need to add some basic wrappers around a few other
input-box methods.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-11-07 19:23:56 +01:00
Aleksa Sarai
fb0e5fca94 menu: keyboard_layout: add ability for layout-specific settings
A layout might want to make some specific feature configurable, so
create an addToMainMenu-like system for allowing layouts to add their
own configuration sub-menu to the keyboard configuration menu.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-11-07 19:23:56 +01:00
Aleksa Sarai
cb702fb062 inputtext: add access methods for internal character list
This allows for InputText wrappers (namely the Japanese keyboard which
needs to be able to apply modifiers to the character before the cursor)
to nicely access the character list.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-11-07 19:23:56 +01:00
Aleksa Sarai
ac907df634 util: add reversible table method wrapping helper
In some cases, it's useful to be able to wrap a function and either
replace its contents entirely or have some callback be run before
calling the underlying function.

The most obvious users for this feature are the Japanese and Korean
keyboards (both of which need to wrap the inputbox methods with either
their own versions or have basic callbacks be run before the method is
executed).

This is loosely based on how busted/luassert spies work.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-11-07 19:23:56 +01:00
poire-z
1278e19e4a
bump crengine: CSS fixes and optimisations (#8427)
Includes:
- lString32Collection::erase(): fix bounds checking
- ldomDocumentFragmentWriter: fix OnTagBody called twice
- CSS: optimize E.class rule check
- CSS: optimize E#id rule check
- EPUB: forward class attribute from the html element
2021-11-07 18:29:04 +01:00
Aleksa Sarai
3fd931bb2f
readerhighlight: ignore cases where no text is selected (#8399)
It's possible for the user to have selected nothing, and trying to
operate on the nil highlight can cause confusion or crashes. This
restores the behaviour before commit 7a0e3d5e68 ("readerhighlight:
remove selected_word and use selected_text everywhere"), which missed
this case.

In addition, add some debug guards to ReaderHighlight methods which
cannot handle selected_text being nil (or at least, shouldn't be called
with selected_text being nil).

Fixes: 7a0e3d5e68 ("readerhighlight: remove selected_word and use selected_text everywhere")
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-11-06 08:11:06 +01:00
Aleksa Sarai
7baeebc2d4
dictionaries: switch to far more up-to-date JM(ne)dict (#8413)
The previous version of JMdict comes from 2009 and doesn't appear to
work at all when trying to do basic lookups (likely due to some kind of
encoding problem). In addition, the license information and sourcing was
not really in line with the requirements specified by the JMdict
license. This version is far more up-to-date and also includes synonym-based
deinflection (though because KOReader has a Japanese plugin now, this is
technically not necessary).

Since there didn't exist a nicely-maintained place to download these
dictionaries (because StarDict is not widely used for Japanese
dictionaries), I've set up a personal GitHub repository where I've
hosted them. Note that we're intentionally not pinning the commit hash
because GitHub only recommends we use gh-pages for CDN purposes, and one
of the requirements of the JMdict license is that you need to be able to
update to later versions.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-11-04 10:17:06 +01:00
Frans de Jonge
aa3fa5abfa
[fix, plugin] Gestures migration: check if setting exists instead of assuming it does (#8409)
Fixes <https://github.com/koreader/koreader/issues/8406>.
2021-11-03 19:44:24 +01:00
Martín Fernández
1bba05ff41
Bump android-luajit-launcher (#8404)
Fix #8355
2021-11-03 08:39:40 +01:00
NiLuJe
d9fc34cbba
Bump base to unbreak lj_wpaclient (#8403)
https://github.com/koreader/koreader-base/pull/1425

Fix #8401
2021-11-02 17:37:27 +01:00
NiLuJe
4d261d29a4 ProgressWidget: Better contrast in thin mode
Re #8400

Also, use the proper colors when switching between thick & thin.
2021-11-01 23:38:22 +01:00
NiLuJe
bc5da5276d NetworkManager: Always prefer system APs as intended.
If we had a local prefered AP with a higher RSSI,
we attempted to associate with it over wpa_supplicant
being already attempting to associate with its own preferred AP.
That... failed horribly.

Also adapt to the new lj-wpaclient API, fixing a few other edge-cases,
and making the whole thing slightly faster because we no longer
uselessly sleep.
And more reliable because we now actually wait for replies to our
requests.

Bump base

https://github.com/koreader/koreader-base/pull/1424
2021-11-01 23:38:22 +01:00
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...).
2021-11-01 23:38:22 +01:00
NiLuJe
98b53b0390 Kobo: More readable crash screen on sunxi (Sage, especially).
Switch to flashing GC16, because the screen is so fast that using GL16
simply leaves us with an unreadable mess of ghosting.

I'm halfway considering rewriting this in Lua so that I can do a proper
batched update...
2021-11-01 23:38:22 +01:00
NiLuJe
f94101178f ReaderFooter: Add a compact prefix for frontlight_warmth
Fix #8398

Also, tweak the actual codepoints being used so that they somewhat look
like their icon brothers. May or may not actually be compact :D.
2021-11-01 23:38:22 +01:00
zwim
23a1ef2db2
[Autowarmth plugin] Optimisations; Documentation (#8397)
* Documentation; Improved accuracy
* Documentation update
* Remove todo tag for circleCI
* Cleanup
2021-11-01 18:59:15 +01:00
zwim
7887c9b1cf
Fix crash in readerhighlight (#8396) 2021-10-31 17:36:00 +01:00
hius07
bfddf710d6
InputDialog: fix "number" input (#8383) 2021-10-29 14:03:57 +03:00
zwim
a7cfc65928
Fix crash when entering a digit on the SDL keyboard (#8388)
Fixes #8387.
2021-10-29 12:59:03 +02:00
zwim
6aa0d802ec
[autowarmth, plugin] Bug if all scheduler entries are deleted (#8386) 2021-10-28 22:13:41 +02:00
Frans de Jonge
0aab7d7378
[fix] gettext: unescape \\ for ID matching (#8357)
Fixes <https://github.com/koreader/koreader/issues/8356>.
2021-10-28 17:48:23 +02:00
NiLuJe
3483238546
Fix reflow calls for DjVu documents (#8379)
The second argument is a ddjvu_render_mode_t
Try to actually honor the user settings instead of enforcing COLOR
while we're there.

Fix #8376
Regression since #8250
2021-10-26 21:13:57 +02:00
zwim
54605d8313
[Autowarmth, plugin] Corner case for warmth setting; warmth on resume for KA1 (#8373) 2021-10-26 09:54:21 +02:00
Aleksa Sarai
de7c1e20c5 languagesupport: check that ui.languagesupport is non-nil
Now that FileManager registers its UI modules in the same way as Reader,
this shouldn't be necessary but this protects us against some other app
creating a ReaderDictionary instance without having ui.languagesupport
registered properly.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-10-26 07:41:17 +02:00
Aleksa Sarai
cdbedcbcce filemanager: align UI plugin registration with reader
With the addition of the language support module, ReaderDictionary
tries to use modules registered with the UI instance, but the
FileManager doesn't provide key-based registration of its UI modules.

In order to allow the same code to be used by both FileManager and
Reader seamlessly, copy the :registerPlugin() method from Reader and use
it with FileManager. This will ensure any other hidden assumptions about
UI module registration are handled properly.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-10-26 07:41:17 +02:00
hius07
f301ca59b7
Bookmarks: icon by type, combined view, filter, bulk remove (#8347)
- Add an icon to distinguish between page bookmarks, plain
  highlights, and highlights with an added note
- Bookmark details: show both highlighted text and added note
- Bookmark list: allow filtering by type and/or by keyword
- New bookmark selection mode, to allow multiple removals
- New option: show separator line
2021-10-25 20:21:24 +02:00
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
2021-10-24 20:26:04 +02:00
Aleksa Sarai
501a6204f8
luacheckrc: allow busted's "match" global for spec/ (#8369)
This was fixed in luacheck 0.24.0 but our CI still uses an older version
at the moment.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-10-24 15:31:22 +02:00
Aleksa Sarai
d0d2d0d1d6
*: luacheck fixes (#8368)
These weren't caught during the Japanese support plugin review.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-10-24 10:58:14 +02:00
NiLuJe
db21521968
Support frontlight warmth on the Sage (#8366)
Follow-up to #8361.
2021-10-23 20:56:35 +02:00
Frans de Jonge
59710ec67a
[chore] Fix todo and fixme tags (#8365)
Slightly overlooked in #8312.
2021-10-23 16:29:00 +02:00
Frans de Jonge
db45881183
[chore] Spaces for indendation, not tabs (#8364)
Overlooked in #8312.
2021-10-23 16:11:47 +02:00
Aleksa Sarai
56899eab8e spec: add tests for LanguageSupport
This primarily consists of some spies added to ensure that the
LanguageSupport plugin is actually being called at the right time.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-10-23 15:49:54 +02:00
Aleksa Sarai
3d4e54c7e6 plugins: add Japanese Support plugin
This plugin provides support for Japanese deinflection during lookup as
well as making long-hold word selection actually select whole words
properly. With this plugin, word lookups in Japanese text in KOReader
become much easier, and no longer requires users to use special
dictionaries that have synonym-based deinflection rules defined (which
were always fairly annoying to use).

The basic idea and deinflection data for this plugin come from
Yomichan (which is also a GPL-3.0+ project), but everything was
implemented specifically for KOReader.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-10-23 15:49:54 +02:00
Aleksa Sarai
7c5243667b reader: implement language-support plugin system
This creates a new plugin system which hooks into a handful of reader
operations in order to allow plugins to add language-specific support
where the default reader falls short. The two hooks added are:

 * During hold-without-pan taps, language plugins can modify the
   selection in order to better match what users expect koreader to
   highlight when selecting a single word.

   The vast majority of CJK language words are more than one character,
   but KOReader treats all CJK characters as a single word by default,
   so adding this hook means that readers no longer need to manually
   select the whole word every time they need to look something.

 * During dictionary lookup, language plugins can propose alternative
   candidate words to look up if the selected word could not be found in
   the dictionary.

   This is pretty necessary for Japanese and Korean, both of which are
   highly agglutinative languages and the fuzzy searching system of
   StarDict is simply not usable because often the inflection of the
   word is so much longer than the dictionary form that sdcv decides to
   chop off the actual word and search for the inflection (which yields
   useless results).

This system is of particular interest for readers of CJK languages
(without this, looking up words using KOReader was fairly painful) but
this system is designed to be minimal and language-agnostic enough that
other languages could make use of it by creating their own plugins if
the default "whole word" highlight and fuzzy-search system doesn't match
their needs.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-10-23 15:49:54 +02:00
Aleksa Sarai
da70fe9de1 common_settings: migrate document menu to menu_order ordering
This is necessary in order to allow the language support module to be
added to the menu outside of the common_settings menu table definition.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-10-23 15:49:54 +02:00
Aleksa Sarai
dca65a793e readerdictionary: separate out raw sdcv handling from startSdcv
In order to make startSdcv usable for plugins that might need to do
dictionary lookups in order to work, it is necessary to split out the
core of startSdcv into another method which returns the raw data from
sdcv.

In addition, in order to make it possible to amortise the cost of each
lookup (which could be fairly expensive) make it possible to pass
multiple words to rawSdcv at the same time. Sdcv supports passing
multiple words as arguments (which it then looks up in order and returns
a separate JSON array per line for each word) so we just need to tweak
the return style accordingly.

All of the deduplication and dummy results handling remains in startSdcv
because plugins might strongly depend on whether sdcv returned actual
results.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-10-23 15:49:54 +02:00
Aleksa Sarai
7a0e3d5e68 readerhighlight: remove selected_word and use selected_text everywhere
There were two ways of specifing selected text for a highlight depending
on whether it was a "single word" or text selected using hold-and-pan.
In addition to being a bit more complicated than is necessary, with the
addition of the language support plugin system (where the "single word"
selected might be expanded), it makes more sense to simply use the same
logic and table structure for both cases.

The dictionary lookup special case (hold-without-pan triggering a
dictionary lookup by default) still works as before.

In addition, this patch fixes a minor inefficiency during dictionary
quick lookup -- before this patch, the highlight would be re-selected
because the quick lookup window is run concurrently and tries to fetch
ReaderHighlight.selected_text but this is set to nil immediately after
triggering the lookup. This is unnecessary because :clear() will be
called anyway when the quick pop-up closes, and so clearing this can be
left until then.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-10-23 15:49:54 +02:00
Aleksa Sarai
3ffb4c1692 kopt: add fallbacks for cases where kctx is not in cache
There were a handful of cases where if there was no cached kctx there
was no fallback and several KoptInterface methods would return nil,
causing issues in various parts of KOReader (this happened with the
migration to selected_text everywhere but it's unclear how that change
caused this regression).

In any case, from a correctness perspective it makes sense to have the
corresponding fallback paths to create a new kctx if we couldn't find a
cached one.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2021-10-23 15:49:54 +02:00