Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reader: rationalize "Back" key/action handling #6840

Merged
merged 4 commits into from
Nov 3, 2020

Conversation

poire-z
Copy link
Contributor

@poire-z poire-z commented Oct 31, 2020

Have ReaderBack be the sole handler of onBack.
Add 4 mutually exclusive options for the Back key, to avoid ReaderLink and ReaderBack location stacks from interfering (ReaderBack's stack being always a superset of ReaderLink's stack).
So, remove "Enable back history", which is replaced by Back option "Go to previous read page".
Fix a few possible crashes and inconsistencies (when zoom, scroll or reflow have changed) with ReaderPaging and ReaderView when restoring previous context (page/view).

image image

Some details about the issues in #6619 (comment) and follow up.

It can still be a bit of a mess (mostly, one back out of two not changing anything) in ReaderPaging, when switching some zoom/scroll/reflow settings. I tried and failed fixing more stuff in ReaderPaging/ReaderView, so I ended up being the less intrusive in them - at the expense of catching many events, some possibly uneeded/duplicating. But well...

The default for this new option is now the Back to exit action. No need to have "Go to previous read page" (old "Enable back history") be the default as most devices don't have a back key, and I think not many users might use the back action (which was quite confusing with its inconsitencies).
I don't know if we need to have an other default for devices with hasKeys and not isTouch.


This change is Reviewable

Have ReaderBack be the sole handle of onBack.
Add 4 mutually exclusive options for the Back key,
to avoid ReaderLink and ReaderBack location stacks
from interfering (ReaderBack's stack being always a
superset of ReaderLink's stack).
So, remove "Enable back history", which is replaced
by Back option "Go to previous read page".
Fix a few possible crashes and inconsistencies (when
zoom, scroll or reflow have changed) with ReaderPaging
and ReaderView when restoring previous page/view.
@poire-z poire-z requested a review from Frenzie October 31, 2020 14:35
@poire-z poire-z added this to the 2020.11 milestone Oct 31, 2020
@NiLuJe
Copy link
Member

NiLuJe commented Oct 31, 2020

I don't know if we need to have an other default for devices with hasKeys and not isTouch.

There may be a case to be made for "previous location" there, but no strong feelings about that (and no real first-hand experience either, as I've never actually used KOReader on a K4 ;)).

elseif #location_stack > 1 then
local saved_location = table.remove(location_stack)
-- Hook to events that do/may change page/view (more than one of these events
-- might be send on a single page turn/scroll, _addPreviousLocationToStack()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-- might be send on a single page turn/scroll, _addPreviousLocationToStack()
-- may be sent on a single page turn/scroll, _addPreviousLocationToStack()

else
logger.dbg("[ReaderBack] no location history, closing")
elseif back_in_reader == "previous_location" then
-- ReaderLink maintain its own location_stack of less frequent jumps
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
-- ReaderLink maintain its own location_stack of less frequent jumps
-- ReaderLink maintains its own location_stack of less frequent jumps

-- (links or TOC entries followed, skim document...)
if back_to_exit == "disable" then
-- Let ReaderLink always show its notification if empty
self.ui.link:onGoBackLink(true) -- show_notification_if_empty=true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh, good idea of the Python-like named argument comment, makes those kind of tricks much more readable ;).

-- of either the previous page or the current one).
UIManager:nextTick(self._addPreviousLocationToStackCallback)
end
self.back_resist = nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super-fond of the variable name, but I don't really have any better idea either ;D.

Copy link
Member

@NiLuJe NiLuJe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At a quick glance, LGTM ;).

@poire-z
Copy link
Contributor Author

poire-z commented Oct 31, 2020

There may be a case to be made for "previous location" there

I agree, so done. And having "previous location" as the default restores the ReaderLink "Back" handling I added for following links with keys (and when one has not followed any link or jumped around, it fallbacks to "Back to exit (prompt|always|disable)" - which should be fine.

@poire-z
Copy link
Contributor Author

poire-z commented Nov 3, 2020

Latest commit according to #6798 (review)

@poire-z poire-z merged commit 8403154 into koreader:master Nov 3, 2020
@poire-z poire-z deleted the back_in_reader_rework branch November 3, 2020 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants