[UX] Move double tap to gesture manager (#6322)

Also replaces the default with +10/-10 pages instead of prev/next chapter.

Closes <https://github.com/koreader/koreader/issues/2721>.
reviewable/pr6327/r1
Frans de Jonge 4 years ago committed by GitHub
parent 5795e6d63c
commit 86db43a052
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -191,6 +191,12 @@ function ReaderGesture:init()
one_finger_swipe_top_edge_left = "ignore",
one_finger_swipe_bottom_edge_right = "ignore",
one_finger_swipe_bottom_edge_left = "ignore",
double_tap_left_side = self.ges_mode == "gesture_reader" and "page_jmp_back_10",
double_tap_right_side = self.ges_mode == "gesture_reader" and "page_jmp_fwd_10",
double_tap_top_left_corner = "ignore",
double_tap_top_right_corner = "ignore",
double_tap_bottom_left_corner = "ignore",
double_tap_bottom_right_corner = "ignore",
two_finger_tap_top_left_corner = "ignore",
two_finger_tap_top_right_corner = "ignore",
two_finger_tap_bottom_left_corner = "ignore",
@ -243,6 +249,8 @@ function ReaderGesture:init()
local mirrored_if_rtl = {
tap_top_left_corner = "tap_top_right_corner",
tap_right_bottom_corner = "tap_left_bottom_corner",
double_tap_left_side = "double_tap_right_side",
double_tap_right_side = "double_tap_left_side",
}
local is_rtl = BD.mirroredUILayout()
if is_rtl then
@ -352,6 +360,39 @@ function ReaderGesture:addToMainMenu(menu_items)
},
},
}
local double_tap_submenu = {
text = _("Double tap"),
enabled_func = function()
return self.ges_mode == "gesture_reader" and self.ui.disable_double_tap ~= true
end,
sub_item_table = {
{
text_func = function() return actionTextFunc("double_tap_left_side", _("Left side")) end,
sub_item_table = self:buildMenu("double_tap_left_side", self.default_gesture["double_tap_left_side"]),
},
{
text_func = function() return actionTextFunc("double_tap_right_side", _("Right side")) end,
sub_item_table = self:buildMenu("double_tap_right_side", self.default_gesture["double_tap_right_side"]),
},
{
text_func = function() return actionTextFunc("double_tap_top_left_corner", _("Top left")) end,
sub_item_table = self:buildMenu("double_tap_top_left_corner", self.default_gesture["double_tap_top_left_corner"]),
},
{
text_func = function() return actionTextFunc("double_tap_top_right_corner", _("Top right")) end,
sub_item_table = self:buildMenu("double_tap_top_right_corner", self.default_gesture["double_tap_top_right_corner"]),
},
{
text_func = function() return actionTextFunc("double_tap_bottom_left_corner", _("Bottom left")) end,
sub_item_table = self:buildMenu("double_tap_bottom_left_corner", self.default_gesture["double_tap_bottom_left_corner"]),
},
{
text_func = function() return actionTextFunc("double_tap_right_bottom_corner", _("Bottom right")) end,
sub_item_table = self:buildMenu("double_tap_bottom_right_corner", self.default_gesture["double_tap_bottom_right_corner"]),
separator = true,
},
}
}
menu_items.gesture_manager = {
text = _("Gesture manager"),
sub_item_table = {
@ -477,6 +518,7 @@ function ReaderGesture:addToMainMenu(menu_items)
},
},
},
double_tap_submenu,
},
}
menu_items.gesture_intervals = {
@ -1005,6 +1047,18 @@ function ReaderGesture:setupGesture(ges, action)
ratio_w = DTAP_ZONE_BOTTOM_RIGHT.w,
ratio_h = DTAP_ZONE_BOTTOM_RIGHT.h,
}
local zone_left = {
ratio_x = DDOUBLE_TAP_ZONE_PREV_CHAPTER.x,
ratio_y = DDOUBLE_TAP_ZONE_PREV_CHAPTER.y,
ratio_w = DDOUBLE_TAP_ZONE_PREV_CHAPTER.w,
ratio_h = DDOUBLE_TAP_ZONE_PREV_CHAPTER.h,
}
local zone_right = {
ratio_x = DDOUBLE_TAP_ZONE_NEXT_CHAPTER.x,
ratio_y = DDOUBLE_TAP_ZONE_NEXT_CHAPTER.y,
ratio_w = DDOUBLE_TAP_ZONE_NEXT_CHAPTER.w,
ratio_h = DDOUBLE_TAP_ZONE_NEXT_CHAPTER.h,
}
local overrides_tap_corner
local overrides_hold_corner
@ -1080,6 +1134,24 @@ function ReaderGesture:setupGesture(ges, action)
ges_type = "tap"
zone = zone_bottom_left_corner
overrides = overrides_tap_corner
elseif ges == "double_tap_left_side" then
ges_type = "double_tap"
zone = zone_left
elseif ges == "double_tap_right_side" then
ges_type = "double_tap"
zone = zone_right
elseif ges == "double_tap_top_left_corner" then
ges_type = "double_tap"
zone = zone_top_left_corner
elseif ges == "double_tap_top_right_corner" then
ges_type = "double_tap"
zone = zone_top_right_corner
elseif ges == "double_tap_bottom_right_corner" then
ges_type = "double_tap"
zone = zone_bottom_right_corner
elseif ges == "double_tap_bottom_left_corner" then
ges_type = "double_tap"
zone = zone_bottom_left_corner
elseif ges == "hold_top_left_corner" then
ges_type = "hold"
zone = zone_top_left_corner

@ -8,7 +8,6 @@ local MultiConfirmBox = require("ui/widget/multiconfirmbox")
local UIManager = require("ui/uimanager")
local logger = require("logger")
local _ = require("gettext")
local Input = Device.input
local Screen = Device.screen
@ -355,14 +354,12 @@ function ReaderPaging:enterFlippingMode()
logger.dbg("store zoom mode", self.orig_zoom_mode)
self.view.document.configurable.text_wrap = 0
self.view.page_scroll = self.flipping_scroll_mode
Input.disable_double_tap = false
self.ui:handleEvent(Event:new("EnterFlippingMode", self.flipping_zoom_mode))
end
function ReaderPaging:exitFlippingMode()
self.view.document.configurable.text_wrap = self.orig_reflow_mode
self.view.page_scroll = self.orig_scroll_mode
Input.disable_double_tap = true
self.flipping_zoom_mode = self.view.zoom_mode
self.flipping_scroll_mode = self.view.page_scroll
logger.dbg("restore zoom mode", self.orig_zoom_mode)

@ -322,15 +322,6 @@ function ReaderRolling:setupTouchZones()
ratio_w = DTAP_ZONE_BACKWARD.w, ratio_h = DTAP_ZONE_BACKWARD.h,
}
local forward_double_tap_zone = {
ratio_x = DDOUBLE_TAP_ZONE_NEXT_CHAPTER.x, ratio_y = DDOUBLE_TAP_ZONE_NEXT_CHAPTER.y,
ratio_w = DDOUBLE_TAP_ZONE_NEXT_CHAPTER.w, ratio_h = DDOUBLE_TAP_ZONE_NEXT_CHAPTER.h,
}
local backward_double_tap_zone = {
ratio_x = DDOUBLE_TAP_ZONE_PREV_CHAPTER.x, ratio_y = DDOUBLE_TAP_ZONE_PREV_CHAPTER.y,
ratio_w = DDOUBLE_TAP_ZONE_PREV_CHAPTER.w, ratio_h = DDOUBLE_TAP_ZONE_PREV_CHAPTER.h,
}
local do_mirror = BD.mirroredUILayout()
if self.inverse_reading_order then
do_mirror = not do_mirror
@ -338,11 +329,6 @@ function ReaderRolling:setupTouchZones()
if do_mirror then
forward_zone.ratio_x = 1 - forward_zone.ratio_x - forward_zone.ratio_w
backward_zone.ratio_x = 1 - backward_zone.ratio_x - backward_zone.ratio_w
forward_double_tap_zone.ratio_x =
1 - forward_double_tap_zone.ratio_x - forward_double_tap_zone.ratio_w
backward_double_tap_zone.ratio_x =
1 - backward_double_tap_zone.ratio_x - backward_double_tap_zone.ratio_w
end
self.ui:registerTouchZones({
@ -358,18 +344,6 @@ function ReaderRolling:setupTouchZones()
screen_zone = backward_zone,
handler = function() return self:onGotoViewRel(-1) end,
},
{
id = "double_tap_forward",
ges = "double_tap",
screen_zone = forward_double_tap_zone,
handler = function() return self:onGotoNextChapter() end
},
{
id = "double_tap_backward",
ges = "double_tap",
screen_zone = backward_double_tap_zone,
handler = function() return self:onGotoPrevChapter() end
},
{
id = "rolling_swipe",
ges = "swipe",

@ -78,40 +78,6 @@ function ReaderZooming:init()
},
}
end
if Device:isTouchDevice() then
self.ges_events = {
Spread = {
GestureRange:new{
ges = "spread",
range = Geom:new{
x = 0, y = 0,
w = Screen:getWidth(),
h = Screen:getHeight(),
}
}
},
Pinch = {
GestureRange:new{
ges = "pinch",
range = Geom:new{
x = 0, y = 0,
w = Screen:getWidth(),
h = Screen:getHeight(),
}
}
},
ToggleFreeZoom = {
GestureRange:new{
ges = "double_tap",
range = Geom:new{
x = 0, y = 0,
w = Screen:getWidth(),
h = Screen:getHeight(),
}
}
},
}
end
self.ui.menu:registerToMainMenu(self)
end
@ -222,6 +188,41 @@ function ReaderZooming:onReZoom(font_size)
end
function ReaderZooming:onEnterFlippingMode(zoom_mode)
if Device:isTouchDevice() then
self.ges_events = {
Spread = {
GestureRange:new{
ges = "spread",
range = Geom:new{
x = 0, y = 0,
w = Screen:getWidth(),
h = Screen:getHeight(),
}
}
},
Pinch = {
GestureRange:new{
ges = "pinch",
range = Geom:new{
x = 0, y = 0,
w = Screen:getWidth(),
h = Screen:getHeight(),
}
}
},
ToggleFreeZoom = {
GestureRange:new{
ges = "double_tap",
range = Geom:new{
x = 0, y = 0,
w = Screen:getWidth(),
h = Screen:getHeight(),
}
}
},
}
end
self.orig_zoom_mode = self.zoom_mode
if zoom_mode == "free" then
self.ui:handleEvent(Event:new("SetZoomMode", "page"))
@ -231,6 +232,9 @@ function ReaderZooming:onEnterFlippingMode(zoom_mode)
end
function ReaderZooming:onExitFlippingMode(zoom_mode)
if Device:isTouchDevice() then
self.ges_events = {}
end
self.orig_zoom_mode = nil
self.ui:handleEvent(Event:new("SetZoomMode", zoom_mode))
end

@ -326,8 +326,8 @@ function ReaderUI:init()
view = self.view,
ui = self
})
self.disable_double_tap = G_reader_settings:readSetting("disable_double_tap") ~= false
end
self.disable_double_tap = G_reader_settings:readSetting("disable_double_tap") ~= false
-- back location stack
self:registerModule("back", ReaderBack:new{
ui = self,

Loading…
Cancel
Save