Allow closing full screen dialogs with swipe down (#4237)

Mostly all that have a close button at top right, that may
be hard to reach or hit for some people: TOC, Bookmarks, History,
KeyValuePage (Book information, Statistics...), Book status...
Added full refresh on diagonal swipe where it was missing.
CoverMenu: removed onSwipe override, as it had become the same as
Menu a few months ago.
This commit is contained in:
poire-z
2018-09-21 15:48:40 +02:00
committed by GitHub
parent a037fc65aa
commit 47bcfc531e
7 changed files with 81 additions and 20 deletions

View File

@@ -5,6 +5,7 @@ local Device = require("device")
local Font = require("ui/font")
local FrameContainer = require("ui/widget/container/framecontainer")
local Geom = require("ui/geometry")
local GestureRange = require("ui/gesturerange")
local HorizontalGroup = require("ui/widget/horizontalgroup")
local HorizontalSpan = require("ui/widget/horizontalspan")
local InputContainer = require("ui/widget/container/inputcontainer")
@@ -61,6 +62,14 @@ function ReaderProgress:init()
seqtext = "any key", doc = "close dialog" }
}
end
if Device:isTouchDevice() then
self.ges_events.Swipe = {
GestureRange:new{
ges = "swipe",
range = function() return self.dimen end,
}
}
end
self[1] = FrameContainer:new{
width = self.width,
height = self.height,
@@ -488,6 +497,22 @@ function ReaderProgress:onAnyKeyPressed()
return self:onClose()
end
function ReaderProgress:onSwipe(arg, ges_ev)
if ges_ev.direction == "south" then
-- Allow easier closing with swipe up/down
self:onClose()
elseif ges_ev.direction == "east" or ges_ev.direction == "west" or ges_ev.direction == "north" then
-- no use for now
do end -- luacheck: ignore 541
else -- diagonal swipe
-- trigger full refresh
UIManager:setDirty(nil, "full")
-- a long diagonal swipe may also be used for taking a screenshot,
-- so let it propagate
return false
end
end
function ReaderProgress:onClose()
UIManager:close(self)
return true