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

Fix: conflict horizontal edge gesture with link swipe #5189

Merged
merged 2 commits into from Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions frontend/apps/reader/modules/readergesture.lua
Expand Up @@ -952,6 +952,15 @@ function ReaderGesture:setupGesture(ges, action)
overrides_vertical_edge = {
"paging_swipe",
"rolling_swipe",
"readermenu_swipe",
"readerconfigmenu_swipe",
}
overrides_horizontal_edge = {
"swipe_link",
"paging_swipe",
"rolling_swipe",
"readermenu_swipe",
"readerconfigmenu_swipe",
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it also overrides the ones that overrides_vertical_edge does?
And both overrides_vertical_edge and overrides_horizontal_edge might also need to override readerconfigmenu_swipe and readermenu_swipe (they may not overlap as DTAP_ZONE_MENU.x=1.8 in defaults.lua, but some people may increase that).

For info, some months ago (so it may no more be correct), I checked the various gestures overrides and possible conflicts in #4856 (comment).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fully agree :)

overrides_pan = {
"paging_swipe",
Expand Down
65 changes: 28 additions & 37 deletions frontend/apps/reader/modules/readerlink.lua
Expand Up @@ -6,8 +6,6 @@ local ButtonDialogTitle = require("ui/widget/buttondialogtitle")
local ConfirmBox = require("ui/widget/confirmbox")
local Device = require("device")
local Event = require("ui/event")
local Geom = require("ui/geometry")
local GestureRange = require("ui/gesturerange")
local InfoMessage = require("ui/widget/infomessage")
local InputContainer = require("ui/widget/container/inputcontainer")
local LinkBox = require("ui/widget/linkbox")
Expand All @@ -26,7 +24,34 @@ local ReaderLink = InputContainer:new{

function ReaderLink:init()
if Device:isTouchDevice() then
self:initGesListener()
self.ui:registerTouchZones({
{
id = "tap_link",
ges = "tap",
screen_zone = {
ratio_x = 0, ratio_y = 0,
ratio_w = 1, ratio_h = 1,
},
overrides = {
"tap_forward",
"tap_backward",
},
handler = function(ges) return self:onTap(_, ges) end,
},
{
id = "swipe_link",
ges = "swipe",
screen_zone = {
ratio_x = 0, ratio_y = 0,
ratio_w = 1, ratio_h = 1,
},
overrides = {
"paging_swipe",
"rolling_swipe"
},
handler = function(ges) return self:onSwipe(_, ges) end,
Copy link
Contributor

Choose a reason for hiding this comment

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

That new one might also need some override (paging_swipe, rolling_swipe...) I guess.

},
})
end
self.ui:registerPostInitCallback(function()
self.ui.menu:registerToMainMenu(self)
Expand All @@ -48,33 +73,6 @@ function ReaderLink:onReadSettings(config)
self.location_stack = {}
end

function ReaderLink:initGesListener()
if Device:isTouchDevice() then
self.ges_events = {
Tap = {
GestureRange:new{
ges = "tap",
range = Geom:new{
x = 0, y = 0,
w = Screen:getWidth(),
h = Screen:getHeight()
}
}
},
Swipe = {
GestureRange:new{
ges = "swipe",
range = Geom:new{
x = 0, y = 0,
w = Screen:getWidth(),
h = Screen:getHeight(),
}
}
},
}
end
end

local function isTapToFollowLinksOn()
return G_reader_settings:nilOrTrue("tap_to_follow_links")
end
Expand Down Expand Up @@ -375,13 +373,6 @@ function ReaderLink:showLinkBox(link, allow_footnote_popup)
end
end

function ReaderLink:onSetDimensions(dimen)
-- update listening according to new screen dimen
if Device:isTouchDevice() then
self:initGesListener()
end
end

function ReaderLink:onTap(_, ges)
if not isTapToFollowLinksOn() then return end
if self.ui.document.info.has_pages then
Expand Down