2019-02-17 20:38:02 +00:00
|
|
|
local ConfirmBox = require("ui/widget/confirmbox")
|
|
|
|
local DataStorage = require("datastorage")
|
2018-09-29 21:15:57 +00:00
|
|
|
local Device = require("device")
|
|
|
|
local Event = require("ui/event")
|
2019-02-22 19:59:32 +00:00
|
|
|
local Geom = require("ui/geometry")
|
|
|
|
local GestureRange = require("ui/gesturerange")
|
2019-02-24 11:29:49 +00:00
|
|
|
local InfoMessage = require("ui/widget/infomessage")
|
2018-09-29 21:15:57 +00:00
|
|
|
local InputContainer = require("ui/widget/container/inputcontainer")
|
2019-02-22 19:59:32 +00:00
|
|
|
local InputDialog = require("ui/widget/inputdialog")
|
|
|
|
local LuaData = require("luadata")
|
2019-09-04 18:52:24 +00:00
|
|
|
local Notification = require("ui/widget/notification")
|
2018-09-29 21:15:57 +00:00
|
|
|
local Screen = require("device").screen
|
|
|
|
local UIManager = require("ui/uimanager")
|
|
|
|
local T = require("ffi/util").template
|
|
|
|
local _ = require("gettext")
|
2019-02-22 19:59:32 +00:00
|
|
|
local logger = require("logger")
|
2018-09-29 21:15:57 +00:00
|
|
|
|
2019-02-24 14:12:01 +00:00
|
|
|
local ReaderGesture = InputContainer:new{}
|
2018-09-29 21:15:57 +00:00
|
|
|
|
2019-02-24 16:07:42 +00:00
|
|
|
local action_strings = {
|
|
|
|
nothing = _("Nothing"),
|
2019-08-14 14:54:53 +00:00
|
|
|
ignore = _("Pass through"),
|
2019-02-24 16:07:42 +00:00
|
|
|
|
|
|
|
page_jmp_back_10 = _("Back 10 pages"),
|
|
|
|
page_jmp_back_1 = _("Previous page"),
|
|
|
|
page_jmp_fwd_10 = _("Forward 10 pages"),
|
|
|
|
page_jmp_fwd_1 = _("Next page"),
|
2019-03-01 13:54:38 +00:00
|
|
|
prev_chapter = _("Previous chapter"),
|
|
|
|
next_chapter = _("Next chapter"),
|
2019-03-01 11:59:39 +00:00
|
|
|
go_to = _("Go to"),
|
2019-02-24 16:07:42 +00:00
|
|
|
skim = _("Skim"),
|
2019-02-28 21:38:24 +00:00
|
|
|
back = _("Back"),
|
2019-02-24 16:07:42 +00:00
|
|
|
previous_location = _("Back to previous location"),
|
2019-02-24 20:40:27 +00:00
|
|
|
latest_bookmark = _("Go to latest bookmark"),
|
2019-03-02 20:23:40 +00:00
|
|
|
follow_nearest_link = _("Follow nearest link"),
|
2019-04-02 16:27:35 +00:00
|
|
|
follow_nearest_internal_link = _("Follow nearest internal link"),
|
2019-03-02 21:55:09 +00:00
|
|
|
clear_location_history = _("Clear location history"),
|
2019-02-24 16:07:42 +00:00
|
|
|
|
|
|
|
toc = _("Table of contents"),
|
|
|
|
bookmarks = _("Bookmarks"),
|
|
|
|
reading_progress = _("Reading progress"),
|
2019-08-03 08:40:20 +00:00
|
|
|
book_statistics = _("Book statistics"),
|
2019-03-06 17:50:32 +00:00
|
|
|
book_status = _("Book status"),
|
2019-03-14 13:05:20 +00:00
|
|
|
book_info = _("Book information"),
|
|
|
|
book_description = _("Book description"),
|
|
|
|
book_cover = _("Book cover"),
|
2019-02-24 16:07:42 +00:00
|
|
|
|
|
|
|
history = _("History"),
|
|
|
|
open_previous_document = _("Open previous document"),
|
2019-02-28 19:50:43 +00:00
|
|
|
filemanager = _("File browser"),
|
2019-02-24 16:07:42 +00:00
|
|
|
|
2019-03-02 12:29:10 +00:00
|
|
|
dictionary_lookup = _("Dictionary lookup"),
|
|
|
|
wikipedia_lookup = _("Wikipedia lookup"),
|
2019-03-02 20:36:30 +00:00
|
|
|
fulltext_search = _("Fulltext search"),
|
2019-03-03 11:43:09 +00:00
|
|
|
file_search = _("File search"),
|
2019-03-02 12:29:10 +00:00
|
|
|
|
2019-02-24 16:07:42 +00:00
|
|
|
full_refresh = _("Full screen refresh"),
|
|
|
|
night_mode = _("Night mode"),
|
|
|
|
suspend = _("Suspend"),
|
2019-03-04 17:46:58 +00:00
|
|
|
exit = _("Exit KOReader"),
|
|
|
|
restart = _("Restart KOReader"),
|
2019-08-15 12:49:15 +00:00
|
|
|
reboot = _("Reboot the device"),
|
|
|
|
poweroff = _("Power off"),
|
2019-02-26 17:58:26 +00:00
|
|
|
show_menu = _("Show menu"),
|
|
|
|
show_config_menu = _("Show bottom menu"),
|
2019-02-26 08:27:28 +00:00
|
|
|
show_frontlight_dialog = _("Show frontlight dialog"),
|
2019-02-24 16:07:42 +00:00
|
|
|
toggle_frontlight = _("Toggle frontlight"),
|
2019-08-01 17:08:09 +00:00
|
|
|
increase_frontlight = _("Increase frontlight brightness"),
|
|
|
|
decrease_frontlight = _("Decrease frontlight brightness"),
|
|
|
|
increase_frontlight_warmth = _("Increase frontlight warmth"),
|
|
|
|
decrease_frontlight_warmth = _("Decrease frontlight warmth"),
|
2019-02-24 16:07:42 +00:00
|
|
|
toggle_gsensor = _("Toggle accelerometer"),
|
|
|
|
toggle_rotation = _("Toggle rotation"),
|
2019-03-05 20:34:58 +00:00
|
|
|
|
|
|
|
wifi_on = _("Enable wifi"),
|
|
|
|
wifi_off = _("Disable wifi"),
|
|
|
|
toggle_wifi = _("Toggle wifi"),
|
|
|
|
|
2019-04-07 17:00:15 +00:00
|
|
|
toggle_bookmark = _("Toggle bookmark"),
|
|
|
|
toggle_page_flipping = _("Toggle page flipping"),
|
2019-03-01 09:38:29 +00:00
|
|
|
toggle_reflow = _("Toggle reflow"),
|
2019-02-24 16:07:42 +00:00
|
|
|
|
|
|
|
zoom_contentwidth = _("Zoom to fit content width"),
|
|
|
|
zoom_contentheight = _("Zoom to fit content height"),
|
|
|
|
zoom_pagewidth = _("Zoom to fit page width"),
|
|
|
|
zoom_pageheight = _("Zoom to fit page height"),
|
|
|
|
zoom_column = _("Zoom to fit column"),
|
|
|
|
zoom_content = _("Zoom to fit content"),
|
|
|
|
zoom_page = _("Zoom to fit page"),
|
|
|
|
|
2019-08-07 18:18:36 +00:00
|
|
|
increase_font = _("Increase font size"),
|
|
|
|
decrease_font = _("Decrease font size"),
|
|
|
|
|
2019-02-24 16:07:42 +00:00
|
|
|
folder_up = _("Folder up"),
|
2019-04-07 17:00:15 +00:00
|
|
|
show_plus_menu = _("Show plus menu"),
|
2019-03-04 21:45:55 +00:00
|
|
|
folder_shortcuts = _("Folder shortcuts"),
|
2019-03-16 10:24:11 +00:00
|
|
|
cycle_highlight_action = _("Cycle highlight action"),
|
2019-04-18 10:12:38 +00:00
|
|
|
cycle_highlight_style = _("Cycle highlight style"),
|
2019-03-05 12:40:07 +00:00
|
|
|
wallabag_download = _("Wallabag retrieval"),
|
2019-02-24 16:07:42 +00:00
|
|
|
}
|
|
|
|
|
2019-02-22 19:59:32 +00:00
|
|
|
local custom_multiswipes_path = DataStorage:getSettingsDir().."/multiswipes.lua"
|
|
|
|
local custom_multiswipes = LuaData:open(custom_multiswipes_path, { name = "MultiSwipes" })
|
|
|
|
local custom_multiswipes_table = custom_multiswipes:readSetting("multiswipes")
|
|
|
|
|
2019-02-24 11:29:49 +00:00
|
|
|
local default_multiswipes = {
|
|
|
|
"west east",
|
|
|
|
"east west",
|
|
|
|
"north south",
|
|
|
|
"south north",
|
2019-03-04 17:46:58 +00:00
|
|
|
true, -- separator
|
2019-02-24 11:29:49 +00:00
|
|
|
"north west",
|
|
|
|
"north east",
|
|
|
|
"south west",
|
|
|
|
"south east",
|
|
|
|
"east north",
|
|
|
|
"west north",
|
|
|
|
"east south",
|
|
|
|
"west south",
|
2019-03-04 17:46:58 +00:00
|
|
|
true, -- separator
|
2019-03-01 15:37:45 +00:00
|
|
|
"north south north",
|
|
|
|
"south north south",
|
2019-02-25 13:43:05 +00:00
|
|
|
"west east west",
|
2019-03-04 17:46:58 +00:00
|
|
|
"east west east",
|
|
|
|
true, -- separator
|
|
|
|
"south west north",
|
|
|
|
"north east south",
|
|
|
|
"north west south",
|
|
|
|
"west south east",
|
|
|
|
"west north east",
|
|
|
|
"east south west",
|
2019-02-25 13:43:05 +00:00
|
|
|
"east north west",
|
|
|
|
"south east north",
|
2019-03-04 17:46:58 +00:00
|
|
|
true, -- separator
|
2019-02-25 13:43:05 +00:00
|
|
|
"east north west east",
|
|
|
|
"south east north south",
|
2019-03-04 17:46:58 +00:00
|
|
|
true, -- separator
|
2019-02-24 11:29:49 +00:00
|
|
|
"east south west north",
|
2019-03-04 17:46:58 +00:00
|
|
|
"west south east north",
|
|
|
|
"south east north west",
|
|
|
|
"south west north east",
|
|
|
|
true, -- separator
|
2019-03-02 20:23:40 +00:00
|
|
|
"southeast northeast",
|
2019-03-04 17:46:58 +00:00
|
|
|
"northeast southeast",
|
|
|
|
-- "southwest northwest", -- visually ambiguous
|
|
|
|
-- "northwest southwest", -- visually ambiguous
|
2019-03-05 20:34:58 +00:00
|
|
|
"northwest southwest northwest",
|
|
|
|
"southeast southwest northwest",
|
|
|
|
"southeast northeast northwest",
|
2019-02-24 11:29:49 +00:00
|
|
|
}
|
|
|
|
local multiswipes = {}
|
2019-08-22 15:11:47 +00:00
|
|
|
local multiswipes_info_text = _([[
|
|
|
|
Multiswipes allow you to perform complex gestures built up out of multiple swipe directions, never losing touch with the screen.
|
2019-03-02 13:38:40 +00:00
|
|
|
|
|
|
|
These advanced gestures consist of either straight swipes or diagonal swipes. To ensure accuracy, they can't be mixed.]])
|
2019-02-17 20:38:02 +00:00
|
|
|
|
2018-09-29 21:15:57 +00:00
|
|
|
function ReaderGesture:init()
|
|
|
|
if not Device:isTouchDevice() then return end
|
2019-02-24 14:12:01 +00:00
|
|
|
self.multiswipes_enabled = G_reader_settings:readSetting("multiswipes_enabled")
|
2018-09-29 21:15:57 +00:00
|
|
|
self.is_docless = self.ui == nil or self.ui.document == nil
|
|
|
|
self.ges_mode = self.is_docless and "gesture_fm" or "gesture_reader"
|
2019-02-25 15:07:04 +00:00
|
|
|
self.default_gesture = {
|
2019-04-07 17:00:15 +00:00
|
|
|
tap_top_left_corner = self.ges_mode == "gesture_reader" and "toggle_page_flipping" or "ignore",
|
|
|
|
tap_top_right_corner = self.ges_mode == "gesture_reader" and "toggle_bookmark" or "show_plus_menu",
|
|
|
|
tap_right_bottom_corner = "ignore",
|
|
|
|
tap_left_bottom_corner = Device:hasFrontlight() and "toggle_frontlight" or "ignore",
|
|
|
|
hold_top_left_corner = "ignore",
|
|
|
|
hold_top_right_corner = "ignore",
|
|
|
|
hold_bottom_left_corner = "ignore",
|
|
|
|
hold_bottom_right_corner = "ignore",
|
2019-08-01 17:08:09 +00:00
|
|
|
one_finger_swipe_left_edge_down = Device:hasFrontlight() and "decrease_frontlight" or "ignore",
|
|
|
|
one_finger_swipe_left_edge_up = Device:hasFrontlight() and "increase_frontlight" or "ignore",
|
|
|
|
one_finger_swipe_right_edge_down = Device:hasNaturalLight() and "decrease_frontlight_warmth" or "ignore",
|
|
|
|
one_finger_swipe_right_edge_up = Device:hasNaturalLight() and "increase_frontlight_warmth" or "ignore",
|
2019-08-04 17:59:20 +00:00
|
|
|
one_finger_swipe_top_edge_right = "ignore",
|
|
|
|
one_finger_swipe_top_edge_left = "ignore",
|
|
|
|
one_finger_swipe_bottom_edge_right = "ignore",
|
|
|
|
one_finger_swipe_bottom_edge_left = "ignore",
|
2019-04-07 17:00:15 +00:00
|
|
|
two_finger_tap_top_left_corner = "ignore",
|
|
|
|
two_finger_tap_top_right_corner = "ignore",
|
|
|
|
two_finger_tap_bottom_left_corner = "ignore",
|
|
|
|
two_finger_tap_bottom_right_corner = "ignore",
|
2019-02-25 15:07:04 +00:00
|
|
|
short_diagonal_swipe = "full_refresh",
|
|
|
|
multiswipe = "nothing", -- otherwise registerGesture() won't pick up on multiswipes
|
2019-03-01 15:42:26 +00:00
|
|
|
multiswipe_west_east = self.ges_mode == "gesture_reader" and "previous_location" or "nothing",
|
|
|
|
multiswipe_east_west = self.ges_mode == "gesture_reader" and "latest_bookmark" or "nothing",
|
|
|
|
multiswipe_north_east = self.ges_mode == "gesture_reader" and "toc" or "nothing",
|
2019-03-04 21:45:55 +00:00
|
|
|
multiswipe_north_west = self.ges_mode == "gesture_reader" and "bookmarks" or "folder_shortcuts",
|
|
|
|
multiswipe_north_south = self.ges_mode == "gesture_reader" and "nothing" or "folder_up",
|
2019-02-25 15:07:04 +00:00
|
|
|
multiswipe_east_north = "history",
|
2019-03-06 17:50:32 +00:00
|
|
|
multiswipe_west_north = self.ges_mode == "gesture_reader" and "book_status" or "nothing",
|
2019-03-01 11:59:39 +00:00
|
|
|
multiswipe_east_south = "go_to",
|
2019-03-01 15:42:26 +00:00
|
|
|
multiswipe_south_north = self.ges_mode == "gesture_reader" and "skim" or "nothing",
|
|
|
|
multiswipe_south_east = self.ges_mode == "gesture_reader" and "toggle_reflow" or "nothing",
|
2019-02-26 08:27:28 +00:00
|
|
|
multiswipe_south_west = "show_frontlight_dialog",
|
2019-02-28 21:38:24 +00:00
|
|
|
multiswipe_west_south = "back",
|
2019-03-01 15:42:26 +00:00
|
|
|
multiswipe_north_south_north = self.ges_mode == "gesture_reader" and "prev_chapter" or "nothing",
|
|
|
|
multiswipe_south_north_south = self.ges_mode == "gesture_reader" and "next_chapter" or "nothing",
|
2019-02-25 15:07:04 +00:00
|
|
|
multiswipe_west_east_west = "open_previous_document",
|
2019-03-01 15:42:26 +00:00
|
|
|
multiswipe_east_north_west = self.ges_mode == "gesture_reader" and "zoom_contentwidth" or "nothing",
|
|
|
|
multiswipe_south_east_north = self.ges_mode == "gesture_reader" and "zoom_contentheight" or "nothing",
|
|
|
|
multiswipe_east_north_west_east = self.ges_mode == "gesture_reader" and "zoom_pagewidth" or "nothing",
|
|
|
|
multiswipe_south_east_north_south = self.ges_mode == "gesture_reader" and "zoom_pageheight" or "nothing",
|
2019-02-25 15:07:04 +00:00
|
|
|
multiswipe_east_south_west_north = "full_refresh",
|
2019-03-02 20:23:40 +00:00
|
|
|
multiswipe_southeast_northeast = self.ges_mode == "gesture_reader" and "follow_nearest_link" or "nothing",
|
2019-03-05 20:34:58 +00:00
|
|
|
multiswipe_northwest_southwest_northwest = Device:hasWifiToggle() and "toggle_wifi" or "nothing",
|
|
|
|
multiswipe_southeast_southwest_northwest = Device:hasWifiToggle() and "wifi_off" or "nothing",
|
|
|
|
multiswipe_southeast_northeast_northwest = Device:hasWifiToggle() and "wifi_on" or "nothing",
|
2019-03-19 19:18:38 +00:00
|
|
|
|
2019-04-07 17:00:15 +00:00
|
|
|
two_finger_swipe_east = self.ges_mode == "gesture_reader" and "toc" or "ignore",
|
2019-03-29 10:28:24 +00:00
|
|
|
two_finger_swipe_west = self.ges_mode == "gesture_reader" and "bookmarks" or "folder_shortcuts",
|
2019-08-06 17:54:09 +00:00
|
|
|
two_finger_swipe_south = Device:hasFrontlight() and "decrease_frontlight" or "ignore",
|
|
|
|
two_finger_swipe_north = Device:hasFrontlight() and "increase_frontlight" or "ignore",
|
2019-04-07 17:00:15 +00:00
|
|
|
two_finger_swipe_northeast = "ignore",
|
|
|
|
two_finger_swipe_northwest = "ignore",
|
|
|
|
two_finger_swipe_southeast = "ignore",
|
|
|
|
two_finger_swipe_southwest = "ignore",
|
2019-08-07 18:18:36 +00:00
|
|
|
spread_gesture = self.ges_mode == "gesture_reader" and "increase_font" or "ignore",
|
|
|
|
pinch_gesture = self.ges_mode == "gesture_reader" and "decrease_font" or "ignore",
|
2019-02-25 15:07:04 +00:00
|
|
|
}
|
2018-09-29 21:15:57 +00:00
|
|
|
local gm = G_reader_settings:readSetting(self.ges_mode)
|
|
|
|
if gm == nil then G_reader_settings:saveSetting(self.ges_mode, {}) end
|
|
|
|
self.ui.menu:registerToMainMenu(self)
|
|
|
|
self:initGesture()
|
|
|
|
end
|
|
|
|
|
|
|
|
function ReaderGesture:initGesture()
|
|
|
|
local gesture_manager = G_reader_settings:readSetting(self.ges_mode)
|
2019-02-25 15:07:04 +00:00
|
|
|
for gesture, action in pairs(self.default_gesture) do
|
2018-09-29 21:15:57 +00:00
|
|
|
if not gesture_manager[gesture] then
|
|
|
|
gesture_manager[gesture] = action
|
|
|
|
end
|
|
|
|
end
|
|
|
|
for gesture, action in pairs(gesture_manager) do
|
|
|
|
self:setupGesture(gesture, action)
|
|
|
|
end
|
|
|
|
G_reader_settings:saveSetting(self.ges_mode, gesture_manager)
|
|
|
|
end
|
|
|
|
|
2019-02-24 11:29:49 +00:00
|
|
|
function ReaderGesture:genMultiswipeSubmenu()
|
|
|
|
return {
|
|
|
|
text = _("Multiswipe"),
|
|
|
|
sub_item_table = self:buildMultiswipeMenu(),
|
|
|
|
enabled_func = function() return self.multiswipes_enabled end,
|
|
|
|
separator = true,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-09-29 21:15:57 +00:00
|
|
|
function ReaderGesture:addToMainMenu(menu_items)
|
2019-04-07 17:00:15 +00:00
|
|
|
local gesture_manager = G_reader_settings:readSetting(self.ges_mode)
|
|
|
|
|
|
|
|
local actionTextFunc = function(gesture, gesture_name)
|
|
|
|
local action_name = gesture_manager[gesture] ~= "nothing" and action_strings[gesture_manager[gesture]] or _("Available")
|
|
|
|
return T(_("%1 (%2)"), gesture_name, action_name)
|
|
|
|
end
|
2019-08-18 17:36:11 +00:00
|
|
|
local corner_tap_submenu = {
|
|
|
|
text = _("Tap corner"),
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
2019-09-01 12:56:41 +00:00
|
|
|
text_func = function() return actionTextFunc("tap_top_left_corner", _("Top left")) end,
|
2019-08-18 17:36:11 +00:00
|
|
|
enabled_func = function() return self.ges_mode == "gesture_reader" end,
|
|
|
|
sub_item_table = self:buildMenu("tap_top_left_corner", self.default_gesture["tap_top_left_corner"]),
|
|
|
|
},
|
|
|
|
{
|
2019-09-01 12:56:41 +00:00
|
|
|
text_func = function() return actionTextFunc("tap_top_right_corner", _("Top right")) end,
|
2019-08-18 17:36:11 +00:00
|
|
|
sub_item_table = self:buildMenu("tap_top_right_corner", self.default_gesture["tap_top_right_corner"]),
|
|
|
|
},
|
|
|
|
{
|
2019-09-01 12:56:41 +00:00
|
|
|
text_func = function() return actionTextFunc("tap_left_bottom_corner", _("Bottom left")) end,
|
2019-08-18 17:36:11 +00:00
|
|
|
sub_item_table = self:buildMenu("tap_left_bottom_corner", self.default_gesture["tap_left_bottom_corner"]),
|
|
|
|
},
|
|
|
|
{
|
2019-09-01 12:56:41 +00:00
|
|
|
text_func = function() return actionTextFunc("tap_right_bottom_corner", _("Bottom right")) end,
|
2019-08-18 17:36:11 +00:00
|
|
|
sub_item_table = self:buildMenu("tap_right_bottom_corner", self.default_gesture["tap_right_bottom_corner"]),
|
|
|
|
separator = true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2019-04-07 17:00:15 +00:00
|
|
|
local corner_hold_submenu = {
|
|
|
|
text = _("Hold corner"),
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
|
|
|
text_func = function() return actionTextFunc("hold_top_left_corner", _("Top left")) end,
|
|
|
|
enabled_func = function() return self.ges_mode == "gesture_reader" end,
|
|
|
|
sub_item_table = self:buildMenu("hold_top_left_corner", self.default_gesture["hold_top_left_corner"]),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text_func = function() return actionTextFunc("hold_top_right_corner", _("Top right")) end,
|
|
|
|
sub_item_table = self:buildMenu("hold_top_right_corner", self.default_gesture["hold_top_right_corner"]),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text_func = function() return actionTextFunc("hold_bottom_left_corner", _("Bottom left")) end,
|
|
|
|
sub_item_table = self:buildMenu("hold_bottom_left_corner", self.default_gesture["hold_bottom_left_corner"]),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text_func = function() return actionTextFunc("hold_bottom_right_corner", _("Bottom right")) end,
|
|
|
|
sub_item_table = self:buildMenu("hold_bottom_right_corner", self.default_gesture["hold_bottom_right_corner"]),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2019-02-28 19:42:00 +00:00
|
|
|
menu_items.gesture_manager = {
|
2018-09-29 21:15:57 +00:00
|
|
|
text = _("Gesture manager"),
|
|
|
|
sub_item_table = {
|
2019-02-17 20:38:02 +00:00
|
|
|
{
|
|
|
|
text = _("Enable multiswipes"),
|
|
|
|
checked_func = function() return self.multiswipes_enabled end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("multiswipes_enabled", not self.multiswipes_enabled)
|
|
|
|
self.multiswipes_enabled = G_reader_settings:isTrue("multiswipes_enabled")
|
|
|
|
end,
|
|
|
|
help_text = multiswipes_info_text,
|
|
|
|
},
|
2019-02-22 19:59:32 +00:00
|
|
|
{
|
|
|
|
text = _("Multiswipe recorder"),
|
|
|
|
enabled_func = function() return self.multiswipes_enabled end,
|
2019-03-04 17:46:58 +00:00
|
|
|
keep_menu_open = true,
|
2019-02-24 11:29:49 +00:00
|
|
|
callback = function(touchmenu_instance)
|
2019-02-22 19:59:32 +00:00
|
|
|
local multiswipe_recorder
|
|
|
|
multiswipe_recorder = InputDialog:new{
|
|
|
|
title = _("Multiswipe recorder"),
|
|
|
|
input_hint = _("Make a multiswipe gesture"),
|
|
|
|
buttons = {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
text = _("Cancel"),
|
|
|
|
callback = function()
|
|
|
|
UIManager:close(multiswipe_recorder)
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Save"),
|
|
|
|
is_enter_default = true,
|
|
|
|
callback = function()
|
|
|
|
local recorded_multiswipe = multiswipe_recorder._raw_multiswipe
|
|
|
|
if not recorded_multiswipe then return end
|
|
|
|
logger.dbg("Multiswipe recorder detected:", recorded_multiswipe)
|
2019-02-24 11:29:49 +00:00
|
|
|
|
|
|
|
for k, multiswipe in pairs(multiswipes) do
|
|
|
|
if recorded_multiswipe == multiswipe then
|
|
|
|
UIManager:show(InfoMessage:new{
|
|
|
|
text = _("Recorded multiswipe already exists."),
|
|
|
|
show_icon = false,
|
|
|
|
timeout = 5,
|
|
|
|
})
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-02-22 19:59:32 +00:00
|
|
|
custom_multiswipes:addTableItem("multiswipes", recorded_multiswipe)
|
2019-08-23 17:53:53 +00:00
|
|
|
--- @todo Implement some nicer method in TouchMenu than this ugly hack for updating the menu.
|
2019-02-24 11:29:49 +00:00
|
|
|
touchmenu_instance.item_table[3] = self:genMultiswipeSubmenu()
|
2019-03-04 17:46:58 +00:00
|
|
|
touchmenu_instance:updateItems()
|
2019-02-22 19:59:32 +00:00
|
|
|
UIManager:close(multiswipe_recorder)
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
multiswipe_recorder.ges_events.Multiswipe = {
|
|
|
|
GestureRange:new{
|
|
|
|
ges = "multiswipe",
|
|
|
|
range = Geom:new{
|
|
|
|
x = 0, y = 0,
|
|
|
|
w = Screen:getWidth(),
|
|
|
|
h = Screen:getHeight(),
|
|
|
|
},
|
|
|
|
doc = "Multiswipe in gesture creator"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function multiswipe_recorder:onMultiswipe(arg, ges)
|
|
|
|
multiswipe_recorder._raw_multiswipe = ges.multiswipe_directions
|
|
|
|
multiswipe_recorder:setInputText(ReaderGesture:friendlyMultiswipeName(multiswipe_recorder._raw_multiswipe))
|
|
|
|
end
|
|
|
|
|
|
|
|
UIManager:show(multiswipe_recorder)
|
|
|
|
end,
|
|
|
|
help_text = _("The number of possible multiswipe gestures is theoretically infinite. With the multiswipe recorder you can easily record your own."),
|
|
|
|
},
|
2019-02-24 11:29:49 +00:00
|
|
|
-- NB If this changes from position 3, also update the position of this menu in multigesture recorder callback
|
|
|
|
self:genMultiswipeSubmenu(),
|
2019-08-18 17:36:11 +00:00
|
|
|
corner_tap_submenu,
|
2019-04-07 17:00:15 +00:00
|
|
|
corner_hold_submenu,
|
2018-09-29 21:15:57 +00:00
|
|
|
{
|
|
|
|
text = _("Short diagonal swipe"),
|
2019-02-25 15:07:04 +00:00
|
|
|
sub_item_table = self:buildMenu("short_diagonal_swipe", self.default_gesture["short_diagonal_swipe"]),
|
2018-09-29 21:15:57 +00:00
|
|
|
},
|
2019-08-01 17:08:09 +00:00
|
|
|
{
|
|
|
|
text = _("One-finger swipe"),
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
|
|
|
text_func = function() return actionTextFunc("one_finger_swipe_left_edge_down", _("Left edge down")) end,
|
|
|
|
sub_item_table = self:buildMenu("one_finger_swipe_left_edge_down", self.default_gesture["one_finger_swipe_left_edge_down"]),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text_func = function() return actionTextFunc("one_finger_swipe_left_edge_up", _("Left edge up")) end,
|
|
|
|
sub_item_table = self:buildMenu("one_finger_swipe_left_edge_up", self.default_gesture["one_finger_swipe_left_edge_up"]),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text_func = function() return actionTextFunc("one_finger_swipe_right_edge_down", _("Right edge down")) end,
|
|
|
|
sub_item_table = self:buildMenu("one_finger_swipe_right_edge_down", self.default_gesture["one_finger_swipe_right_edge_down"]),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text_func = function() return actionTextFunc("one_finger_swipe_right_edge_up", _("Right edge up")) end,
|
|
|
|
sub_item_table = self:buildMenu("one_finger_swipe_right_edge_up", self.default_gesture["one_finger_swipe_right_edge_up"]),
|
|
|
|
},
|
2019-08-04 17:59:20 +00:00
|
|
|
{
|
|
|
|
text_func = function() return actionTextFunc("one_finger_swipe_top_edge_right", _("Top edge right")) end,
|
|
|
|
sub_item_table = self:buildMenu("one_finger_swipe_top_edge_right", self.default_gesture["one_finger_swipe_top_edge_right"]),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text_func = function() return actionTextFunc("one_finger_swipe_top_edge_left", _("Top edge left")) end,
|
|
|
|
sub_item_table = self:buildMenu("one_finger_swipe_top_edge_left", self.default_gesture["one_finger_swipe_top_edge_left"]),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text_func = function() return actionTextFunc("one_finger_swipe_bottom_edge_right", _("Bottom edge right")) end,
|
|
|
|
sub_item_table = self:buildMenu("one_finger_swipe_bottom_edge_right", self.default_gesture["one_finger_swipe_bottom_edge_right"]),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text_func = function() return actionTextFunc("one_finger_swipe_bottom_edge_left", _("Bottom edge left")) end,
|
|
|
|
sub_item_table = self:buildMenu("one_finger_swipe_bottom_edge_left", self.default_gesture["one_finger_swipe_bottom_edge_left"]),
|
|
|
|
},
|
2019-08-01 17:08:09 +00:00
|
|
|
},
|
|
|
|
},
|
2018-09-29 21:15:57 +00:00
|
|
|
},
|
|
|
|
}
|
2019-07-24 12:31:20 +00:00
|
|
|
menu_items.gesture_intervals = {
|
|
|
|
text = _("Gesture intervals"),
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
|
|
|
text = _("Double tap interval"),
|
|
|
|
callback = function()
|
|
|
|
local SpinWidget = require("ui/widget/spinwidget")
|
|
|
|
local GestureDetector = require("device/gesturedetector")
|
|
|
|
local items = SpinWidget:new{
|
2019-08-22 15:11:47 +00:00
|
|
|
text = T(_([[
|
|
|
|
Set double tap interval in milliseconds.
|
2019-07-24 12:31:20 +00:00
|
|
|
The interval value can range from 100 (0.1 seconds) to 2000 (2 seconds).
|
|
|
|
Default value: %1]]), GestureDetector.DOUBLE_TAP_INTERVAL/1000),
|
|
|
|
width = Screen:getWidth() * 0.6,
|
|
|
|
value = GestureDetector:getInterval("ges_double_tap_interval")/1000,
|
|
|
|
value_min = 100,
|
|
|
|
value_max = 2000,
|
|
|
|
value_step = 100,
|
|
|
|
value_hold_step = 500,
|
|
|
|
ok_text = _("Set interval"),
|
|
|
|
title_text = _("Double tap interval"),
|
|
|
|
default_value = GestureDetector.DOUBLE_TAP_INTERVAL/1000,
|
|
|
|
callback = function(spin)
|
|
|
|
G_reader_settings:saveSetting("ges_double_tap_interval", spin.value*1000)
|
|
|
|
GestureDetector:setNewInterval("ges_double_tap_interval", spin.value*1000)
|
|
|
|
end
|
|
|
|
}
|
|
|
|
UIManager:show(items)
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Two finger tap duration"),
|
|
|
|
callback = function()
|
|
|
|
local SpinWidget = require("ui/widget/spinwidget")
|
|
|
|
local GestureDetector = require("device/gesturedetector")
|
|
|
|
local items = SpinWidget:new{
|
2019-08-22 15:11:47 +00:00
|
|
|
text = T(_([[
|
|
|
|
Set two finger tap duration in milliseconds.
|
2019-07-24 12:31:20 +00:00
|
|
|
The duration value can range from 100 (0.1 seconds) to 2000 (2 seconds).
|
|
|
|
Default value: %1]]), GestureDetector.TWO_FINGER_TAP_DURATION/1000),
|
|
|
|
width = Screen:getWidth() * 0.6,
|
|
|
|
value = GestureDetector:getInterval("ges_two_finger_tap_duration")/1000,
|
|
|
|
value_min = 100,
|
|
|
|
value_max = 2000,
|
|
|
|
value_step = 100,
|
|
|
|
value_hold_step = 500,
|
|
|
|
ok_text = _("Set duration"),
|
|
|
|
title_text = _("Two finger tap duration"),
|
|
|
|
default_value = GestureDetector.TWO_FINGER_TAP_DURATION/1000,
|
|
|
|
callback = function(spin)
|
|
|
|
G_reader_settings:saveSetting("ges_two_finger_tap_duration", spin.value*1000)
|
|
|
|
GestureDetector:setNewInterval("ges_two_finger_tap_duration", spin.value*1000)
|
|
|
|
end
|
|
|
|
}
|
|
|
|
UIManager:show(items)
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Hold interval"),
|
|
|
|
callback = function()
|
|
|
|
local SpinWidget = require("ui/widget/spinwidget")
|
|
|
|
local GestureDetector = require("device/gesturedetector")
|
|
|
|
local items = SpinWidget:new{
|
2019-08-22 15:11:47 +00:00
|
|
|
text = T(_([[
|
|
|
|
Set hold interval in milliseconds.
|
2019-07-24 12:31:20 +00:00
|
|
|
The interval value can range from 100 (0.1 seconds) to 2000 (2 seconds).
|
|
|
|
Default value: %1]]), GestureDetector.HOLD_INTERVAL/1000),
|
|
|
|
width = Screen:getWidth() * 0.6,
|
|
|
|
value = GestureDetector:getInterval("ges_hold_interval")/1000,
|
|
|
|
value_min = 100,
|
|
|
|
value_max = 2000,
|
|
|
|
value_step = 100,
|
|
|
|
value_hold_step = 500,
|
|
|
|
ok_text = _("Set interval"),
|
|
|
|
title_text = _("Hold interval"),
|
|
|
|
default_value = GestureDetector.HOLD_INTERVAL/1000,
|
|
|
|
callback = function(spin)
|
|
|
|
G_reader_settings:saveSetting("ges_hold_interval", spin.value*1000)
|
|
|
|
GestureDetector:setNewInterval("ges_hold_interval", spin.value*1000)
|
|
|
|
end
|
|
|
|
}
|
|
|
|
UIManager:show(items)
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Pan delay interval"),
|
|
|
|
callback = function()
|
|
|
|
local SpinWidget = require("ui/widget/spinwidget")
|
|
|
|
local GestureDetector = require("device/gesturedetector")
|
|
|
|
local items = SpinWidget:new{
|
2019-08-22 15:11:47 +00:00
|
|
|
text = T(_([[
|
|
|
|
Set pan delay interval in milliseconds.
|
2019-07-24 12:31:20 +00:00
|
|
|
The interval value can range from 100 (0.1 seconds) to 2000 (2 seconds).
|
|
|
|
Default value: %1]]), GestureDetector.PAN_DELAYED_INTERVAL/1000),
|
|
|
|
width = Screen:getWidth() * 0.6,
|
|
|
|
value = GestureDetector:getInterval("ges_pan_delayed_interval")/1000,
|
|
|
|
value_min = 100,
|
|
|
|
value_max = 2000,
|
|
|
|
value_step = 100,
|
|
|
|
value_hold_step = 500,
|
|
|
|
ok_text = _("Set interval"),
|
|
|
|
title_text = _("Pan delay interval"),
|
|
|
|
default_value = GestureDetector.PAN_DELAYED_INTERVAL/1000,
|
|
|
|
callback = function(spin)
|
|
|
|
G_reader_settings:saveSetting("ges_pan_delayed_interval", spin.value*1000)
|
|
|
|
GestureDetector:setNewInterval("ges_pan_delayed_interval", spin.value*1000)
|
|
|
|
end
|
|
|
|
}
|
|
|
|
UIManager:show(items)
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Swipe interval"),
|
|
|
|
callback = function()
|
|
|
|
local SpinWidget = require("ui/widget/spinwidget")
|
|
|
|
local GestureDetector = require("device/gesturedetector")
|
|
|
|
local items = SpinWidget:new{
|
2019-08-22 15:11:47 +00:00
|
|
|
text = T(_([[
|
|
|
|
Set swipe interval in milliseconds.
|
2019-07-24 12:31:20 +00:00
|
|
|
The interval value can range from 100 (0.1 seconds) to 2000 (2 seconds).
|
|
|
|
Default value: %1]]), GestureDetector.SWIPE_INTERVAL/1000),
|
|
|
|
width = Screen:getWidth() * 0.6,
|
|
|
|
value = GestureDetector:getInterval("ges_swipe_interval")/1000,
|
|
|
|
value_min = 100,
|
|
|
|
value_max = 2000,
|
|
|
|
value_step = 100,
|
|
|
|
value_hold_step = 500,
|
|
|
|
ok_text = _("Set interval"),
|
|
|
|
title_text = _("Swipe interval"),
|
|
|
|
default_value = GestureDetector.SWIPE_INTERVAL/1000,
|
|
|
|
callback = function(spin)
|
|
|
|
G_reader_settings:saveSetting("ges_swipe_interval", spin.value*1000)
|
|
|
|
GestureDetector:setNewInterval("ges_swipe_interval", spin.value*1000)
|
|
|
|
end
|
|
|
|
}
|
|
|
|
UIManager:show(items)
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2019-03-30 12:06:15 +00:00
|
|
|
|
|
|
|
local twoFingerSwipeTextFunc = function(gesture, friendly_name)
|
|
|
|
local action_name = gesture_manager[gesture] ~= "nothing" and action_strings[gesture_manager[gesture]] or _("Available")
|
|
|
|
return T(_("%1 (%2)"), friendly_name, action_name)
|
|
|
|
end
|
|
|
|
|
2019-03-19 19:18:38 +00:00
|
|
|
if Device:hasMultitouch() then
|
2019-04-07 17:00:15 +00:00
|
|
|
local corner_two_finger_tap_submenu = {
|
|
|
|
text = _("Two-finger tap corner"),
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
|
|
|
text_func = function() return actionTextFunc("two_finger_tap_top_left_corner", _("Top left")) end,
|
|
|
|
sub_item_table = self:buildMenu("two_finger_tap_top_left_corner", self.default_gesture["two_finger_tap_top_left_corner"]),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text_func = function() return actionTextFunc("two_finger_tap_top_right_corner", _("Top right")) end,
|
|
|
|
sub_item_table = self:buildMenu("two_finger_tap_top_right_corner", self.default_gesture["two_finger_tap_top_right_corner"]),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text_func = function() return actionTextFunc("two_finger_tap_bottom_left_corner", _("Bottom left")) end,
|
|
|
|
sub_item_table = self:buildMenu("two_finger_tap_bottom_left_corner", self.default_gesture["two_finger_tap_bottom_left_corner"]),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text_func = function() return actionTextFunc("two_finger_tap_bottom_right_corner", _("Bottom right")) end,
|
|
|
|
sub_item_table = self:buildMenu("two_finger_tap_bottom_right_corner", self.default_gesture["two_finger_tap_bottom_right_corner"]),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
table.insert(menu_items.gesture_manager.sub_item_table, corner_two_finger_tap_submenu)
|
2019-03-19 19:18:38 +00:00
|
|
|
table.insert(menu_items.gesture_manager.sub_item_table, {
|
2019-04-07 17:00:15 +00:00
|
|
|
text = _("Two-finger swipe"),
|
2019-03-19 19:18:38 +00:00
|
|
|
sub_item_table = {
|
|
|
|
{
|
2019-09-06 13:49:41 +00:00
|
|
|
text_func = function() return twoFingerSwipeTextFunc("two_finger_swipe_east", "⇒") end,
|
2019-03-29 10:28:24 +00:00
|
|
|
sub_item_table = self:buildMenu("two_finger_swipe_east", self.default_gesture["two_finger_swipe_east"]),
|
|
|
|
},
|
|
|
|
{
|
2019-09-06 13:49:41 +00:00
|
|
|
text_func = function() return twoFingerSwipeTextFunc("two_finger_swipe_west", "⇐") end,
|
2019-03-19 19:18:38 +00:00
|
|
|
sub_item_table = self:buildMenu("two_finger_swipe_west", self.default_gesture["two_finger_swipe_west"]),
|
|
|
|
},
|
2019-08-06 17:54:09 +00:00
|
|
|
{
|
2019-09-06 13:49:41 +00:00
|
|
|
text_func = function() return twoFingerSwipeTextFunc("two_finger_swipe_south", "⇓") end,
|
2019-08-06 17:54:09 +00:00
|
|
|
sub_item_table = self:buildMenu("two_finger_swipe_south", self.default_gesture["two_finger_swipe_south"]),
|
|
|
|
},
|
|
|
|
{
|
2019-09-06 13:49:41 +00:00
|
|
|
text_func = function() return twoFingerSwipeTextFunc("two_finger_swipe_north", "⇑") end,
|
2019-08-06 17:54:09 +00:00
|
|
|
sub_item_table = self:buildMenu("two_finger_swipe_north", self.default_gesture["two_finger_swipe_north"]),
|
|
|
|
},
|
2019-03-19 19:18:38 +00:00
|
|
|
{
|
2019-09-06 13:49:41 +00:00
|
|
|
text_func = function() return twoFingerSwipeTextFunc("two_finger_swipe_northeast", "⇗") end,
|
2019-03-29 10:28:24 +00:00
|
|
|
sub_item_table = self:buildMenu("two_finger_swipe_northeast", self.default_gesture["two_finger_swipe_northeast"]),
|
|
|
|
},
|
|
|
|
{
|
2019-09-06 13:49:41 +00:00
|
|
|
text_func = function() return twoFingerSwipeTextFunc("two_finger_swipe_northwest", "⇖") end,
|
2019-03-29 10:28:24 +00:00
|
|
|
sub_item_table = self:buildMenu("two_finger_swipe_northwest", self.default_gesture["two_finger_swipe_northwest"]),
|
|
|
|
},
|
|
|
|
{
|
2019-09-06 13:49:41 +00:00
|
|
|
text_func = function() return twoFingerSwipeTextFunc("two_finger_swipe_southeast", "⇘") end,
|
2019-03-29 10:28:24 +00:00
|
|
|
sub_item_table = self:buildMenu("two_finger_swipe_southeast", self.default_gesture["two_finger_swipe_southeast"]),
|
|
|
|
},
|
|
|
|
{
|
2019-09-06 13:49:41 +00:00
|
|
|
text_func = function() return twoFingerSwipeTextFunc("two_finger_swipe_southwest", "⇙") end,
|
2019-03-29 10:28:24 +00:00
|
|
|
sub_item_table = self:buildMenu("two_finger_swipe_southwest", self.default_gesture["two_finger_swipe_southwest"]),
|
2019-03-19 19:18:38 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
2019-08-07 18:18:36 +00:00
|
|
|
table.insert(menu_items.gesture_manager.sub_item_table, {
|
|
|
|
text = _("Spread and pinch"),
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
|
|
|
text_func = function() return actionTextFunc("spread_gesture", _("Spread")) end,
|
|
|
|
sub_item_table = self:buildMenu("spread_gesture", self.default_gesture["spread_gesture"]),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text_func = function() return actionTextFunc("pinch_gesture", _("Pinch")) end,
|
|
|
|
sub_item_table = self:buildMenu("pinch_gesture", self.default_gesture["pinch_gesture"]),
|
|
|
|
},
|
|
|
|
}
|
|
|
|
})
|
2019-03-19 19:18:38 +00:00
|
|
|
end
|
2018-09-29 21:15:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function ReaderGesture:buildMenu(ges, default)
|
|
|
|
local gesture_manager = G_reader_settings:readSetting(self.ges_mode)
|
|
|
|
local menu = {
|
2019-02-24 16:07:42 +00:00
|
|
|
{"nothing", true },
|
2019-04-07 17:00:15 +00:00
|
|
|
{"ignore", true, true },
|
2019-02-24 16:07:42 +00:00
|
|
|
{"page_jmp_back_10", not self.is_docless},
|
|
|
|
{"page_jmp_back_1", not self.is_docless},
|
|
|
|
{"page_jmp_fwd_10", not self.is_docless},
|
|
|
|
{"page_jmp_fwd_1", not self.is_docless},
|
2019-03-01 13:54:38 +00:00
|
|
|
{"prev_chapter", not self.is_docless},
|
|
|
|
{"next_chapter", not self.is_docless},
|
2019-03-01 11:59:39 +00:00
|
|
|
{"go_to", true},
|
2019-02-24 16:07:42 +00:00
|
|
|
{"skim", not self.is_docless},
|
2019-02-28 21:38:24 +00:00
|
|
|
{"back", true},
|
2019-02-24 20:40:27 +00:00
|
|
|
{"previous_location", not self.is_docless},
|
2019-03-02 20:23:40 +00:00
|
|
|
{"latest_bookmark", not self.is_docless},
|
2019-03-02 21:55:09 +00:00
|
|
|
{"follow_nearest_link", not self.is_docless},
|
2019-04-02 16:27:35 +00:00
|
|
|
{"follow_nearest_internal_link", not self.is_docless},
|
2019-03-02 21:55:09 +00:00
|
|
|
{"clear_location_history", not self.is_docless, true},
|
2019-02-24 14:12:01 +00:00
|
|
|
|
2019-03-04 21:45:55 +00:00
|
|
|
{"folder_up", self.is_docless},
|
2019-04-07 17:00:15 +00:00
|
|
|
{"show_plus_menu", self.is_docless},
|
2019-03-08 20:02:25 +00:00
|
|
|
{"folder_shortcuts", true, true},
|
2019-02-24 14:12:01 +00:00
|
|
|
|
2019-02-24 16:07:42 +00:00
|
|
|
{ "toc", not self.is_docless},
|
|
|
|
{"bookmarks", not self.is_docless},
|
2019-03-06 17:50:32 +00:00
|
|
|
{"reading_progress", ReaderGesture.getReaderProgress ~= nil},
|
2019-08-03 08:40:20 +00:00
|
|
|
{"book_statistics", not self.is_docless},
|
|
|
|
|
2019-03-14 13:05:20 +00:00
|
|
|
{"book_status", not self.is_docless},
|
2019-03-12 08:17:27 +00:00
|
|
|
{"book_info", not self.is_docless},
|
2019-03-14 13:05:20 +00:00
|
|
|
{"book_description", not self.is_docless},
|
|
|
|
{"book_cover", not self.is_docless, true},
|
2019-02-24 14:12:01 +00:00
|
|
|
|
2019-02-24 16:07:42 +00:00
|
|
|
{"history", true},
|
|
|
|
{"open_previous_document", true, true},
|
2019-02-28 19:50:43 +00:00
|
|
|
{"filemanager", not self.is_docless, true},
|
2019-02-24 14:12:01 +00:00
|
|
|
|
2019-03-02 12:29:10 +00:00
|
|
|
{"dictionary_lookup", true},
|
|
|
|
{"wikipedia_lookup", true, true},
|
2019-03-03 11:43:09 +00:00
|
|
|
{"fulltext_search", not self.is_docless},
|
|
|
|
{"file_search", true, true},
|
2019-03-02 12:29:10 +00:00
|
|
|
|
2019-02-24 16:07:42 +00:00
|
|
|
{"full_refresh", true},
|
|
|
|
{"night_mode", true},
|
|
|
|
{"suspend", true},
|
2019-03-04 17:46:58 +00:00
|
|
|
{"exit", true},
|
2019-08-15 12:49:15 +00:00
|
|
|
{"restart", Device:canRestart()},
|
|
|
|
{"reboot", Device:canReboot()},
|
|
|
|
{"poweroff", Device:canPowerOff()},
|
2019-03-04 17:46:58 +00:00
|
|
|
|
2019-02-26 17:58:26 +00:00
|
|
|
{"show_menu", true},
|
2019-03-05 20:34:58 +00:00
|
|
|
{"show_config_menu", not self.is_docless, true},
|
2019-02-26 08:27:28 +00:00
|
|
|
{"show_frontlight_dialog", Device:hasFrontlight()},
|
2019-08-01 17:08:09 +00:00
|
|
|
{"toggle_frontlight", Device:hasFrontlight()},
|
|
|
|
{"increase_frontlight", Device:hasFrontlight()},
|
|
|
|
{"decrease_frontlight", Device:hasFrontlight(), true},
|
|
|
|
{"increase_frontlight_warmth", Device:hasNaturalLight()},
|
|
|
|
{"decrease_frontlight_warmth", Device:hasNaturalLight(), true},
|
|
|
|
|
2019-02-24 16:07:42 +00:00
|
|
|
{"toggle_gsensor", Device:canToggleGSensor()},
|
|
|
|
{"toggle_rotation", not self.is_docless, true},
|
2019-02-24 14:12:01 +00:00
|
|
|
|
2019-03-05 20:34:58 +00:00
|
|
|
{"wifi_on", Device:hasWifiToggle()},
|
|
|
|
{"wifi_off", Device:hasWifiToggle()},
|
|
|
|
{"toggle_wifi", Device:hasWifiToggle(), true},
|
|
|
|
|
2019-08-07 18:18:36 +00:00
|
|
|
{"increase_font", not self.is_docless},
|
|
|
|
{"decrease_font", not self.is_docless, true},
|
|
|
|
|
2019-04-07 17:00:15 +00:00
|
|
|
{"toggle_bookmark", not self.is_docless, true},
|
|
|
|
{"toggle_page_flipping", not self.is_docless, true},
|
2019-03-05 20:34:58 +00:00
|
|
|
{"toggle_reflow", not self.is_docless, true},
|
2019-02-24 16:07:42 +00:00
|
|
|
{"zoom_contentwidth", not self.is_docless},
|
|
|
|
{"zoom_contentheight", not self.is_docless},
|
|
|
|
{"zoom_pagewidth", not self.is_docless},
|
|
|
|
{"zoom_pageheight", not self.is_docless},
|
|
|
|
{"zoom_column", not self.is_docless},
|
|
|
|
{"zoom_content", not self.is_docless},
|
2019-03-05 12:40:07 +00:00
|
|
|
{"zoom_page", not self.is_docless, true},
|
2019-03-16 10:24:11 +00:00
|
|
|
{"cycle_highlight_action", not self.is_docless},
|
2019-04-18 10:12:38 +00:00
|
|
|
{"cycle_highlight_style", not self.is_docless},
|
2019-03-06 17:50:32 +00:00
|
|
|
{"wallabag_download", self.ui.wallabag ~= nil},
|
2018-09-29 21:15:57 +00:00
|
|
|
}
|
|
|
|
local return_menu = {}
|
|
|
|
-- add default action to the top of the submenu
|
|
|
|
for __, entry in pairs(menu) do
|
2019-02-24 16:36:15 +00:00
|
|
|
if entry[1] == default then
|
2019-02-24 16:07:42 +00:00
|
|
|
local menu_entry_default = T(_("%1 (default)"), action_strings[entry[1]])
|
|
|
|
table.insert(return_menu, self:createSubMenu(menu_entry_default, entry[1], ges, true))
|
2019-02-20 08:34:44 +00:00
|
|
|
|
|
|
|
if not gesture_manager[ges] then
|
|
|
|
gesture_manager[ges] = default
|
|
|
|
G_reader_settings:saveSetting(self.ges_mode, gesture_manager)
|
|
|
|
end
|
2018-09-29 21:15:57 +00:00
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
-- another elements
|
|
|
|
for _, entry in pairs(menu) do
|
2019-02-24 16:07:42 +00:00
|
|
|
if not entry[2] and gesture_manager[ges] == entry[1] then
|
2018-09-29 21:15:57 +00:00
|
|
|
gesture_manager[ges] = "nothing"
|
|
|
|
G_reader_settings:saveSetting(self.ges_mode, gesture_manager)
|
|
|
|
end
|
2019-02-24 16:07:42 +00:00
|
|
|
if entry[1] ~= default and entry[2] then
|
|
|
|
local sep = entry[1] == "nothing" or entry[3] == true
|
|
|
|
table.insert(return_menu, self:createSubMenu(action_strings[entry[1]], entry[1], ges, sep))
|
2018-09-29 21:15:57 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
return return_menu
|
|
|
|
end
|
|
|
|
|
2019-02-24 11:29:49 +00:00
|
|
|
function ReaderGesture:buildMultiswipeMenu()
|
2019-02-24 16:07:42 +00:00
|
|
|
local gesture_manager = G_reader_settings:readSetting(self.ges_mode)
|
2019-02-24 11:29:49 +00:00
|
|
|
local menu = {}
|
|
|
|
multiswipes = {}
|
2019-02-22 19:59:32 +00:00
|
|
|
|
2019-03-04 17:46:58 +00:00
|
|
|
-- Build a list of gestures in settings, so we can show those
|
|
|
|
-- that don't appear anymore in default or custom lists, and
|
|
|
|
-- allow removing them (as they will still work)
|
|
|
|
local settings_gestures = {}
|
|
|
|
for k, v in pairs(gesture_manager) do
|
|
|
|
if k:sub(1, 11) == "multiswipe_" then
|
|
|
|
k = k:sub(12):gsub("_", " ")
|
|
|
|
settings_gestures[k] = v
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-02-24 11:29:49 +00:00
|
|
|
for k, v in pairs(default_multiswipes) do
|
2019-02-22 20:31:22 +00:00
|
|
|
table.insert(multiswipes, v)
|
2019-03-04 17:46:58 +00:00
|
|
|
settings_gestures[v] = nil -- remove from settings list
|
2019-02-22 20:31:22 +00:00
|
|
|
end
|
2019-02-17 20:38:02 +00:00
|
|
|
|
2019-03-04 17:46:58 +00:00
|
|
|
if custom_multiswipes_table and #custom_multiswipes_table > 0 then
|
|
|
|
table.insert(multiswipes, true) -- add separator
|
2019-02-24 11:29:49 +00:00
|
|
|
for k, v in pairs(custom_multiswipes_table) do
|
|
|
|
table.insert(multiswipes, v)
|
2019-03-04 17:46:58 +00:00
|
|
|
settings_gestures[v] = nil -- remove from settings list
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if next(settings_gestures) then -- there are old gestures in settings
|
|
|
|
table.insert(multiswipes, true) -- add separator
|
|
|
|
for k, v in pairs(settings_gestures) do
|
|
|
|
table.insert(multiswipes, k)
|
2019-02-24 11:29:49 +00:00
|
|
|
end
|
|
|
|
end
|
2019-02-17 20:38:02 +00:00
|
|
|
|
|
|
|
for i=1, #multiswipes do
|
2019-03-04 17:46:58 +00:00
|
|
|
local separator = false
|
|
|
|
if i < #multiswipes and multiswipes[i+1] == true then
|
|
|
|
separator = true
|
|
|
|
end
|
|
|
|
if type(multiswipes[i]) == "string" then -- skip separators (true)
|
|
|
|
local multiswipe = multiswipes[i]
|
|
|
|
local friendly_multiswipe_name = self:friendlyMultiswipeName(multiswipe)
|
|
|
|
-- friendly_multiswipe_name = friendly_multiswipe_name .. os.time() -- for debugging menu updates
|
|
|
|
local safe_multiswipe_name = "multiswipe_"..self:safeMultiswipeName(multiswipe)
|
|
|
|
local default_action = self.default_gesture[safe_multiswipe_name] and self.default_gesture[safe_multiswipe_name] or "nothing"
|
|
|
|
table.insert(menu, {
|
|
|
|
text_func = function()
|
|
|
|
local action_name = gesture_manager[safe_multiswipe_name] ~= "nothing" and action_strings[gesture_manager[safe_multiswipe_name]] or _("Available")
|
|
|
|
return T(_("%1 (%2)"), friendly_multiswipe_name, action_name)
|
|
|
|
end,
|
|
|
|
sub_item_table = self:buildMenu(safe_multiswipe_name, default_action),
|
|
|
|
hold_callback = function(touchmenu_instance)
|
|
|
|
if i > #default_multiswipes + 1 then -- +1 for added separator (true)
|
|
|
|
UIManager:show(ConfirmBox:new{
|
|
|
|
text = T(_("Remove custom multiswipe %1?"), friendly_multiswipe_name),
|
|
|
|
ok_text = _("Remove"),
|
|
|
|
ok_callback = function()
|
|
|
|
-- Remove associated action from settings
|
|
|
|
gesture_manager[safe_multiswipe_name] = nil
|
|
|
|
-- multiswipes are a combined table, first defaults, then custom
|
|
|
|
-- so the right index is minus #defalt_multiswipes minus 1 added separator
|
|
|
|
custom_multiswipes:removeTableItem("multiswipes", i-#default_multiswipes-1)
|
|
|
|
-- touchmenu_instance.item_table = self:buildMultiswipeMenu()
|
|
|
|
-- We need to update touchmenu_instance.item_table in-place for the upper
|
|
|
|
-- menu to have it updated too
|
|
|
|
local item_table = touchmenu_instance.item_table
|
|
|
|
while #item_table > 0 do
|
|
|
|
table.remove(item_table, #item_table)
|
|
|
|
end
|
|
|
|
for __, v in ipairs(self:buildMultiswipeMenu()) do
|
|
|
|
table.insert(item_table, v)
|
|
|
|
end
|
|
|
|
touchmenu_instance:updateItems()
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
separator = separator,
|
|
|
|
})
|
|
|
|
end
|
2019-02-17 20:38:02 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return menu
|
|
|
|
end
|
|
|
|
|
2018-09-29 21:15:57 +00:00
|
|
|
function ReaderGesture:createSubMenu(text, action, ges, separator)
|
|
|
|
local gesture_manager = G_reader_settings:readSetting(self.ges_mode)
|
|
|
|
return {
|
|
|
|
text = text,
|
|
|
|
checked_func = function()
|
|
|
|
return gesture_manager[ges] == action
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
gesture_manager[ges] = action
|
|
|
|
G_reader_settings:saveSetting(self.ges_mode, gesture_manager)
|
|
|
|
self:setupGesture(ges, action)
|
|
|
|
end,
|
|
|
|
separator = separator or false,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2019-02-17 20:38:02 +00:00
|
|
|
local multiswipe_to_arrow = {
|
2019-03-02 13:38:40 +00:00
|
|
|
east = "➡",
|
|
|
|
west = "⬅",
|
|
|
|
north = "⬆",
|
|
|
|
south = "⬇",
|
2019-03-05 21:56:59 +00:00
|
|
|
northeast = "⬈",
|
|
|
|
northwest = "⬉",
|
2019-03-02 13:38:40 +00:00
|
|
|
southeast = "⬊",
|
|
|
|
southwest = "⬋",
|
2019-02-17 20:38:02 +00:00
|
|
|
}
|
|
|
|
function ReaderGesture:friendlyMultiswipeName(multiswipe)
|
2019-03-02 13:38:40 +00:00
|
|
|
return multiswipe:gsub("%S+", multiswipe_to_arrow)
|
2019-02-17 20:38:02 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function ReaderGesture:safeMultiswipeName(multiswipe)
|
|
|
|
return multiswipe:gsub(" ", "_")
|
|
|
|
end
|
|
|
|
|
2018-09-29 21:15:57 +00:00
|
|
|
function ReaderGesture:setupGesture(ges, action)
|
|
|
|
local ges_type
|
|
|
|
local zone
|
|
|
|
local overrides
|
|
|
|
local direction, distance
|
2019-03-19 19:18:38 +00:00
|
|
|
|
|
|
|
local zone_fullscreen = {
|
2019-08-05 19:24:58 +00:00
|
|
|
ratio_x = 0, ratio_y = 0,
|
2019-03-19 19:18:38 +00:00
|
|
|
ratio_w = 1, ratio_h = 1,
|
|
|
|
}
|
|
|
|
|
2019-08-01 17:08:09 +00:00
|
|
|
local zone_left_edge = {
|
2019-08-05 19:24:58 +00:00
|
|
|
ratio_x = 0, ratio_y = 0,
|
|
|
|
ratio_w = 1/8, ratio_h = 1,
|
2019-08-01 17:08:09 +00:00
|
|
|
}
|
|
|
|
local zone_right_edge = {
|
2019-08-05 19:24:58 +00:00
|
|
|
ratio_x = 7/8, ratio_y = 0,
|
|
|
|
ratio_w = 1/8, ratio_h = 1,
|
2019-08-01 17:08:09 +00:00
|
|
|
}
|
2019-08-04 17:59:20 +00:00
|
|
|
local zone_top_edge = {
|
2019-08-05 19:24:58 +00:00
|
|
|
ratio_x = 0, ratio_y = 0,
|
|
|
|
ratio_w = 1, ratio_h = 1/8,
|
2019-08-04 17:59:20 +00:00
|
|
|
}
|
|
|
|
local zone_bottom_edge = {
|
2019-08-05 19:24:58 +00:00
|
|
|
ratio_x = 0, ratio_y = 7/8,
|
|
|
|
ratio_w = 1, ratio_h = 1/8,
|
2019-08-04 17:59:20 +00:00
|
|
|
}
|
2019-08-01 17:08:09 +00:00
|
|
|
|
2019-04-07 17:00:15 +00:00
|
|
|
-- legacy global variable DTAP_ZONE_FLIPPING may still be defined in default.persistent.lua
|
|
|
|
local dtap_zone_top_left = DTAP_ZONE_FLIPPING and DTAP_ZONE_FLIPPING or DTAP_ZONE_TOP_LEFT
|
|
|
|
local zone_top_left_corner = {
|
|
|
|
ratio_x = dtap_zone_top_left.x,
|
|
|
|
ratio_y = dtap_zone_top_left.y,
|
|
|
|
ratio_w = dtap_zone_top_left.w,
|
|
|
|
ratio_h = dtap_zone_top_left.h,
|
|
|
|
}
|
|
|
|
-- legacy global variable DTAP_ZONE_BOOKMARK may still be defined in default.persistent.lua
|
|
|
|
local dtap_zone_top_right = DTAP_ZONE_BOOKMARK and DTAP_ZONE_BOOKMARK or DTAP_ZONE_TOP_RIGHT
|
|
|
|
local zone_top_right_corner = {
|
|
|
|
ratio_x = dtap_zone_top_right.x,
|
|
|
|
ratio_y = dtap_zone_top_right.y,
|
|
|
|
ratio_w = dtap_zone_top_right.w,
|
|
|
|
ratio_h = dtap_zone_top_right.h,
|
|
|
|
}
|
|
|
|
local zone_bottom_left_corner = {
|
|
|
|
ratio_x = DTAP_ZONE_BOTTOM_LEFT.x,
|
|
|
|
ratio_y = DTAP_ZONE_BOTTOM_LEFT.y,
|
|
|
|
ratio_w = DTAP_ZONE_BOTTOM_LEFT.w,
|
|
|
|
ratio_h = DTAP_ZONE_BOTTOM_LEFT.h,
|
|
|
|
}
|
|
|
|
local zone_bottom_right_corner = {
|
|
|
|
ratio_x = DTAP_ZONE_BOTTOM_RIGHT.x,
|
|
|
|
ratio_y = DTAP_ZONE_BOTTOM_RIGHT.y,
|
|
|
|
ratio_w = DTAP_ZONE_BOTTOM_RIGHT.w,
|
|
|
|
ratio_h = DTAP_ZONE_BOTTOM_RIGHT.h,
|
|
|
|
}
|
|
|
|
|
|
|
|
local overrides_tap_corner
|
|
|
|
local overrides_hold_corner
|
2019-08-04 17:59:20 +00:00
|
|
|
local overrides_vertical_edge, overrides_horizontal_edge
|
2019-08-01 17:08:09 +00:00
|
|
|
local overrides_pan, overrides_pan_release
|
|
|
|
local overrides_swipe_pan, overrides_swipe_pan_release
|
2019-04-07 17:00:15 +00:00
|
|
|
if self.is_docless then
|
|
|
|
overrides_tap_corner = {
|
|
|
|
"filemanager_tap",
|
|
|
|
}
|
2019-08-04 17:59:20 +00:00
|
|
|
overrides_horizontal_edge = {
|
|
|
|
"filemanager_swipe",
|
|
|
|
}
|
2019-04-07 17:00:15 +00:00
|
|
|
else
|
|
|
|
overrides_tap_corner = {
|
|
|
|
"tap_backward",
|
|
|
|
"tap_forward",
|
|
|
|
"readermenu_tap",
|
|
|
|
"readerconfigmenu_tap",
|
|
|
|
"readerfooter_tap",
|
|
|
|
}
|
|
|
|
overrides_hold_corner = {
|
|
|
|
"readerfooter_hold",
|
|
|
|
}
|
2019-08-01 17:08:09 +00:00
|
|
|
overrides_vertical_edge = {
|
|
|
|
"paging_swipe",
|
|
|
|
"rolling_swipe",
|
2019-08-08 13:19:09 +00:00
|
|
|
"readermenu_swipe",
|
|
|
|
"readerconfigmenu_swipe",
|
|
|
|
}
|
|
|
|
overrides_horizontal_edge = {
|
|
|
|
"swipe_link",
|
|
|
|
"paging_swipe",
|
|
|
|
"rolling_swipe",
|
|
|
|
"readermenu_swipe",
|
|
|
|
"readerconfigmenu_swipe",
|
2019-08-01 17:08:09 +00:00
|
|
|
}
|
|
|
|
overrides_pan = {
|
|
|
|
"paging_swipe",
|
|
|
|
"rolling_swipe",
|
|
|
|
}
|
|
|
|
overrides_pan_release = {
|
|
|
|
"paging_pan_release",
|
|
|
|
}
|
2019-04-07 17:00:15 +00:00
|
|
|
end
|
|
|
|
|
2019-02-17 20:38:02 +00:00
|
|
|
if ges == "multiswipe" then
|
|
|
|
ges_type = "multiswipe"
|
2019-03-19 19:18:38 +00:00
|
|
|
zone = zone_fullscreen
|
2019-02-17 20:38:02 +00:00
|
|
|
direction = {
|
|
|
|
northeast = true, northwest = true,
|
|
|
|
southeast = true, southwest = true,
|
|
|
|
east = true, west = true,
|
|
|
|
north = true, south = true,
|
|
|
|
}
|
2019-04-07 17:00:15 +00:00
|
|
|
elseif ges == "tap_top_left_corner" then
|
|
|
|
ges_type = "tap"
|
|
|
|
zone = zone_top_left_corner
|
|
|
|
overrides = overrides_tap_corner
|
|
|
|
elseif ges == "tap_top_right_corner" then
|
|
|
|
ges_type = "tap"
|
|
|
|
zone = zone_top_right_corner
|
|
|
|
overrides = overrides_tap_corner
|
2019-02-17 20:38:02 +00:00
|
|
|
elseif ges == "tap_right_bottom_corner" then
|
2018-09-29 21:15:57 +00:00
|
|
|
ges_type = "tap"
|
2019-04-07 17:00:15 +00:00
|
|
|
zone = zone_bottom_right_corner
|
|
|
|
overrides = overrides_tap_corner
|
2018-09-29 21:15:57 +00:00
|
|
|
elseif ges == "tap_left_bottom_corner" then
|
|
|
|
ges_type = "tap"
|
2019-04-07 17:00:15 +00:00
|
|
|
zone = zone_bottom_left_corner
|
|
|
|
overrides = overrides_tap_corner
|
|
|
|
elseif ges == "hold_top_left_corner" then
|
|
|
|
ges_type = "hold"
|
|
|
|
zone = zone_top_left_corner
|
|
|
|
overrides = overrides_hold_corner
|
|
|
|
elseif ges == "hold_top_right_corner" then
|
|
|
|
ges_type = "hold"
|
|
|
|
zone = zone_top_right_corner
|
|
|
|
overrides = overrides_hold_corner
|
|
|
|
elseif ges == "hold_bottom_right_corner" then
|
|
|
|
ges_type = "hold"
|
|
|
|
zone = zone_bottom_right_corner
|
|
|
|
overrides = overrides_hold_corner
|
|
|
|
elseif ges == "hold_bottom_left_corner" then
|
|
|
|
ges_type = "hold"
|
|
|
|
zone = zone_bottom_left_corner
|
|
|
|
overrides = overrides_hold_corner
|
2019-08-01 17:08:09 +00:00
|
|
|
elseif ges == "one_finger_swipe_left_edge_down" then
|
|
|
|
ges_type = "swipe"
|
|
|
|
zone = zone_left_edge
|
|
|
|
direction = {south = true}
|
|
|
|
overrides = overrides_vertical_edge
|
|
|
|
overrides_swipe_pan = overrides_pan
|
|
|
|
overrides_swipe_pan_release = overrides_pan_release
|
|
|
|
elseif ges == "one_finger_swipe_left_edge_up" then
|
|
|
|
ges_type = "swipe"
|
|
|
|
zone = zone_left_edge
|
|
|
|
direction = {north = true}
|
|
|
|
overrides = overrides_vertical_edge
|
|
|
|
overrides_swipe_pan = overrides_pan
|
|
|
|
overrides_swipe_pan_release = overrides_pan_release
|
|
|
|
elseif ges == "one_finger_swipe_right_edge_down" then
|
|
|
|
ges_type = "swipe"
|
|
|
|
zone = zone_right_edge
|
|
|
|
direction = {south = true}
|
|
|
|
overrides = overrides_vertical_edge
|
|
|
|
overrides_swipe_pan = overrides_pan
|
|
|
|
overrides_swipe_pan_release = overrides_pan_release
|
|
|
|
elseif ges == "one_finger_swipe_right_edge_up" then
|
|
|
|
ges_type = "swipe"
|
|
|
|
zone = zone_right_edge
|
|
|
|
direction = {north = true}
|
|
|
|
overrides = overrides_vertical_edge
|
|
|
|
overrides_swipe_pan = overrides_pan
|
|
|
|
overrides_swipe_pan_release = overrides_pan_release
|
2019-08-04 17:59:20 +00:00
|
|
|
elseif ges == "one_finger_swipe_top_edge_right" then
|
|
|
|
ges_type = "swipe"
|
|
|
|
zone = zone_top_edge
|
|
|
|
direction = {east = true}
|
|
|
|
overrides = overrides_horizontal_edge
|
|
|
|
overrides_swipe_pan = overrides_pan
|
|
|
|
overrides_swipe_pan_release = overrides_pan_release
|
|
|
|
elseif ges == "one_finger_swipe_top_edge_left" then
|
|
|
|
ges_type = "swipe"
|
|
|
|
zone = zone_top_edge
|
|
|
|
direction = {west = true}
|
|
|
|
overrides = overrides_horizontal_edge
|
|
|
|
overrides_swipe_pan = overrides_pan
|
|
|
|
overrides_swipe_pan_release = overrides_pan_release
|
|
|
|
elseif ges == "one_finger_swipe_bottom_edge_right" then
|
|
|
|
ges_type = "swipe"
|
|
|
|
zone = zone_bottom_edge
|
|
|
|
direction = {east = true}
|
|
|
|
overrides = overrides_horizontal_edge
|
|
|
|
overrides_swipe_pan = overrides_pan
|
|
|
|
overrides_swipe_pan_release = overrides_pan_release
|
|
|
|
elseif ges == "one_finger_swipe_bottom_edge_left" then
|
|
|
|
ges_type = "swipe"
|
|
|
|
zone = zone_bottom_edge
|
|
|
|
direction = {west = true}
|
|
|
|
overrides = overrides_horizontal_edge
|
|
|
|
overrides_swipe_pan = overrides_pan
|
|
|
|
overrides_swipe_pan_release = overrides_pan_release
|
2019-04-07 17:00:15 +00:00
|
|
|
elseif ges == "two_finger_tap_top_left_corner" then
|
|
|
|
ges_type = "two_finger_tap"
|
|
|
|
zone = zone_top_left_corner
|
|
|
|
elseif ges == "two_finger_tap_top_right_corner" then
|
|
|
|
ges_type = "two_finger_tap"
|
|
|
|
zone = zone_top_right_corner
|
|
|
|
elseif ges == "two_finger_tap_bottom_right_corner" then
|
|
|
|
ges_type = "two_finger_tap"
|
|
|
|
zone = zone_bottom_right_corner
|
|
|
|
elseif ges == "two_finger_tap_bottom_left_corner" then
|
|
|
|
ges_type = "two_finger_tap"
|
|
|
|
zone = zone_bottom_left_corner
|
2019-03-19 19:18:38 +00:00
|
|
|
elseif ges == "two_finger_swipe_west" then
|
|
|
|
ges_type = "two_finger_swipe"
|
|
|
|
zone = zone_fullscreen
|
|
|
|
direction = {west = true}
|
|
|
|
elseif ges == "two_finger_swipe_east" then
|
|
|
|
ges_type = "two_finger_swipe"
|
|
|
|
zone = zone_fullscreen
|
|
|
|
direction = {east = true}
|
2019-08-06 17:54:09 +00:00
|
|
|
elseif ges == "two_finger_swipe_south" then
|
|
|
|
ges_type = "two_finger_swipe"
|
|
|
|
zone = zone_fullscreen
|
|
|
|
direction = {south = true}
|
|
|
|
elseif ges == "two_finger_swipe_north" then
|
|
|
|
ges_type = "two_finger_swipe"
|
|
|
|
zone = zone_fullscreen
|
|
|
|
direction = {north = true}
|
2019-03-29 10:28:24 +00:00
|
|
|
elseif ges == "two_finger_swipe_northwest" then
|
|
|
|
ges_type = "two_finger_swipe"
|
|
|
|
zone = zone_fullscreen
|
|
|
|
direction = {northwest = true}
|
|
|
|
elseif ges == "two_finger_swipe_northeast" then
|
|
|
|
ges_type = "two_finger_swipe"
|
|
|
|
zone = zone_fullscreen
|
|
|
|
direction = {northeast = true}
|
|
|
|
elseif ges == "two_finger_swipe_southwest" then
|
|
|
|
ges_type = "two_finger_swipe"
|
|
|
|
zone = zone_fullscreen
|
|
|
|
direction = {southwest = true}
|
|
|
|
elseif ges == "two_finger_swipe_southeast" then
|
|
|
|
ges_type = "two_finger_swipe"
|
|
|
|
zone = zone_fullscreen
|
|
|
|
direction = {southeast = true}
|
2018-09-29 21:15:57 +00:00
|
|
|
elseif ges == "short_diagonal_swipe" then
|
|
|
|
ges_type = "swipe"
|
|
|
|
zone = {
|
|
|
|
ratio_x = 0.0, ratio_y = 0,
|
|
|
|
ratio_w = 1, ratio_h = 1,
|
|
|
|
}
|
|
|
|
direction = {northeast = true, northwest = true, southeast = true, southwest = true}
|
|
|
|
distance = "short"
|
|
|
|
if self.is_docless then
|
2019-03-30 20:05:44 +00:00
|
|
|
overrides = {
|
|
|
|
"filemanager_tap",
|
2019-08-04 17:59:20 +00:00
|
|
|
"filemanager_swipe"
|
2019-03-30 20:05:44 +00:00
|
|
|
}
|
2018-09-29 21:15:57 +00:00
|
|
|
else
|
2019-03-30 20:05:44 +00:00
|
|
|
overrides = {
|
|
|
|
"rolling_swipe",
|
|
|
|
"paging_swipe",
|
|
|
|
}
|
2018-09-29 21:15:57 +00:00
|
|
|
end
|
2019-08-07 18:18:36 +00:00
|
|
|
elseif ges == "spread_gesture" then
|
|
|
|
ges_type = "spread"
|
|
|
|
zone = zone_fullscreen
|
|
|
|
elseif ges == "pinch_gesture" then
|
|
|
|
ges_type = "pinch"
|
|
|
|
zone = zone_fullscreen
|
2018-09-29 21:15:57 +00:00
|
|
|
else return
|
|
|
|
end
|
|
|
|
self:registerGesture(ges, action, ges_type, zone, overrides, direction, distance)
|
2019-08-01 17:08:09 +00:00
|
|
|
-- make dummy zone to disable panning and panning_release when gesture is swipe
|
|
|
|
if ges_type == "swipe" and ges ~= "short_diagonal_swipe" then
|
|
|
|
local pan_gesture = ges.."_pan"
|
|
|
|
local pan_release_gesture = ges.."_pan_release"
|
|
|
|
self:registerGesture(pan_gesture, "", "pan", zone, overrides_swipe_pan, direction, distance)
|
|
|
|
self:registerGesture(pan_release_gesture, "", "pan_release", zone, overrides_swipe_pan_release, direction, distance)
|
|
|
|
end
|
2018-09-29 21:15:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function ReaderGesture:registerGesture(ges, action, ges_type, zone, overrides, direction, distance)
|
|
|
|
self.ui:registerTouchZones({
|
|
|
|
{
|
|
|
|
id = ges,
|
|
|
|
ges = ges_type,
|
|
|
|
screen_zone = zone,
|
|
|
|
handler = function(gest)
|
|
|
|
if distance == "short" and gest.distance > Screen:scaleBySize(300) then return end
|
|
|
|
if direction and not direction[gest.direction] then return end
|
2019-02-17 20:38:02 +00:00
|
|
|
|
|
|
|
if ges == "multiswipe" then
|
|
|
|
if self.multiswipes_enabled == nil then
|
|
|
|
UIManager:show(ConfirmBox:new{
|
|
|
|
text = _("You have just performed a multiswipe gesture for the first time.") .."\n\n".. multiswipes_info_text,
|
|
|
|
ok_text = _("Enable"),
|
|
|
|
ok_callback = function()
|
|
|
|
G_reader_settings:saveSetting("multiswipes_enabled", true)
|
|
|
|
self.multiswipes_enabled = true
|
|
|
|
end,
|
|
|
|
cancel_text = _("Disable"),
|
|
|
|
cancel_callback = function()
|
|
|
|
G_reader_settings:saveSetting("multiswipes_enabled", false)
|
|
|
|
self.multiswipes_enabled = false
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
else
|
2019-03-02 20:23:40 +00:00
|
|
|
return self:multiswipeAction(gest.multiswipe_directions, gest)
|
2019-02-17 20:38:02 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-03-02 20:23:40 +00:00
|
|
|
return self:gestureAction(action, gest)
|
2018-09-29 21:15:57 +00:00
|
|
|
end,
|
|
|
|
overrides = overrides,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2019-09-04 18:52:24 +00:00
|
|
|
local function lightFrontlight()
|
|
|
|
return Device:hasLightLevelFallback() and G_reader_settings:nilOrTrue("light_fallback")
|
|
|
|
end
|
|
|
|
|
2019-03-02 20:23:40 +00:00
|
|
|
function ReaderGesture:gestureAction(action, ges)
|
2019-04-07 17:00:15 +00:00
|
|
|
if action == "ignore" then
|
|
|
|
return
|
|
|
|
elseif action == "reading_progress" and ReaderGesture.getReaderProgress then
|
2018-09-29 21:15:57 +00:00
|
|
|
UIManager:show(ReaderGesture.getReaderProgress())
|
2019-08-03 08:40:20 +00:00
|
|
|
elseif action == "book_statistics" and ReaderGesture.getBookStats then
|
|
|
|
UIManager:show(ReaderGesture.getBookStats())
|
2018-09-29 21:15:57 +00:00
|
|
|
elseif action == "toc" then
|
|
|
|
self.ui:handleEvent(Event:new("ShowToc"))
|
|
|
|
elseif action == "night_mode" then
|
2019-04-08 21:05:08 +00:00
|
|
|
local night_mode = G_reader_settings:isTrue("night_mode")
|
2018-09-29 21:15:57 +00:00
|
|
|
Screen:toggleNightMode()
|
2018-10-01 18:24:10 +00:00
|
|
|
UIManager:setDirty("all", "full")
|
2018-09-29 21:15:57 +00:00
|
|
|
G_reader_settings:saveSetting("night_mode", not night_mode)
|
|
|
|
elseif action == "full_refresh" then
|
2018-10-01 11:00:12 +00:00
|
|
|
if self.view then
|
|
|
|
-- update footer (time & battery)
|
|
|
|
self.view.footer:updateFooter()
|
|
|
|
end
|
2018-10-05 18:20:00 +00:00
|
|
|
UIManager:setDirty("all", "full")
|
2018-09-29 21:15:57 +00:00
|
|
|
elseif action == "bookmarks" then
|
|
|
|
self.ui:handleEvent(Event:new("ShowBookmark"))
|
2019-02-16 18:15:51 +00:00
|
|
|
elseif action == "history" then
|
|
|
|
self.ui:handleEvent(Event:new("ShowHist"))
|
2019-03-12 08:17:27 +00:00
|
|
|
elseif action == "book_info" then
|
|
|
|
self.ui:handleEvent(Event:new("ShowBookInfo"))
|
2019-03-14 13:05:20 +00:00
|
|
|
elseif action == "book_description" then
|
2019-03-15 14:29:25 +00:00
|
|
|
self.ui:handleEvent(Event:new("ShowBookDescription"))
|
2019-03-14 13:05:20 +00:00
|
|
|
elseif action == "book_cover" then
|
2019-03-15 14:29:25 +00:00
|
|
|
self.ui:handleEvent(Event:new("ShowBookCover"))
|
2019-03-06 17:50:32 +00:00
|
|
|
elseif action == "book_status" then
|
|
|
|
self.ui:handleEvent(Event:new("ShowBookStatus"))
|
2019-02-09 15:28:22 +00:00
|
|
|
elseif action == "page_jmp_fwd_10" then
|
2018-09-29 21:15:57 +00:00
|
|
|
self:pageUpdate(10)
|
2019-02-09 15:28:22 +00:00
|
|
|
elseif action == "page_jmp_fwd_1" then
|
2019-03-01 15:05:03 +00:00
|
|
|
self.ui:handleEvent(Event:new("GotoViewRel", 1))
|
2019-02-09 15:28:22 +00:00
|
|
|
elseif action == "page_jmp_back_10" then
|
2018-09-29 21:15:57 +00:00
|
|
|
self:pageUpdate(-10)
|
2019-02-09 15:28:22 +00:00
|
|
|
elseif action == "page_jmp_back_1" then
|
2019-03-01 15:05:03 +00:00
|
|
|
self.ui:handleEvent(Event:new("GotoViewRel", -1))
|
2019-03-01 13:54:38 +00:00
|
|
|
elseif action == "next_chapter" then
|
|
|
|
self.ui:handleEvent(Event:new("GotoNextChapter"))
|
|
|
|
elseif action == "prev_chapter" then
|
|
|
|
self.ui:handleEvent(Event:new("GotoPrevChapter"))
|
2019-03-01 11:59:39 +00:00
|
|
|
elseif action == "go_to" then
|
|
|
|
self.ui:handleEvent(Event:new("ShowGotoDialog"))
|
2019-02-24 14:12:01 +00:00
|
|
|
elseif action == "skim" then
|
|
|
|
self.ui:handleEvent(Event:new("ShowSkimtoDialog"))
|
2019-02-28 21:38:24 +00:00
|
|
|
elseif action == "back" then
|
|
|
|
self.ui:handleEvent(Event:new("Back"))
|
2019-02-16 17:20:30 +00:00
|
|
|
elseif action == "previous_location" then
|
2019-03-02 21:55:09 +00:00
|
|
|
self.ui:handleEvent(Event:new("GoBackLink", true)) -- show_notification_if_empty
|
2019-02-24 20:40:27 +00:00
|
|
|
elseif action == "latest_bookmark" then
|
2019-03-02 21:55:09 +00:00
|
|
|
self.ui:handleEvent(Event:new("GoToLatestBookmark"))
|
2019-03-02 20:23:40 +00:00
|
|
|
elseif action == "follow_nearest_link" then
|
|
|
|
self.ui:handleEvent(Event:new("GoToPageLink", ges, false, G_reader_settings:isTrue("footnote_link_in_popup")))
|
2019-04-02 16:27:35 +00:00
|
|
|
elseif action == "follow_nearest_internal_link" then
|
|
|
|
self.ui:handleEvent(Event:new("GoToPageLink", ges, true, G_reader_settings:isTrue("footnote_link_in_popup")))
|
2019-03-02 21:55:09 +00:00
|
|
|
elseif action == "clear_location_history" then
|
|
|
|
self.ui:handleEvent(Event:new("ClearLocationStack", true)) -- show_notification
|
2019-02-28 18:07:33 +00:00
|
|
|
elseif action == "filemanager" then
|
|
|
|
self.ui:onClose()
|
|
|
|
self.ui:showFileManager()
|
2019-03-03 11:43:09 +00:00
|
|
|
elseif action == "file_search" then
|
|
|
|
if self.ges_mode == "gesture_fm" then
|
|
|
|
self.ui:handleEvent(Event:new("ShowFileSearch", self.ui.file_chooser.path))
|
|
|
|
else
|
|
|
|
local last_dir = self.ui:getLastDirFile()
|
|
|
|
self.ui:handleEvent(Event:new("ShowFileSearch", last_dir))
|
|
|
|
end
|
2019-01-08 01:59:47 +00:00
|
|
|
elseif action == "folder_up" then
|
2018-09-29 21:15:57 +00:00
|
|
|
self.ui.file_chooser:changeToPath(string.format("%s/..", self.ui.file_chooser.path))
|
2019-04-07 17:00:15 +00:00
|
|
|
elseif action == "show_plus_menu" then
|
|
|
|
self.ui:handleEvent(Event:new("ShowPlusMenu"))
|
2019-03-04 21:45:55 +00:00
|
|
|
elseif action == "folder_shortcuts" then
|
|
|
|
self.ui:handleEvent(Event:new("ShowFolderShortcutsDialog"))
|
2019-02-22 15:29:19 +00:00
|
|
|
elseif action == "open_previous_document" then
|
|
|
|
-- FileManager
|
|
|
|
if self.ui.menu.openLastDoc and G_reader_settings:readSetting("lastfile") ~= nil then
|
|
|
|
self.ui.menu:openLastDoc()
|
|
|
|
-- ReaderUI
|
|
|
|
elseif self.ui.switchDocument and self.ui.menu then
|
|
|
|
self.ui:switchDocument(self.ui.menu:getPreviousFile())
|
|
|
|
end
|
2019-03-02 12:29:10 +00:00
|
|
|
elseif action == "dictionary_lookup" then
|
|
|
|
self.ui:handleEvent(Event:new("ShowDictionaryLookup"))
|
|
|
|
elseif action == "wikipedia_lookup" then
|
|
|
|
self.ui:handleEvent(Event:new("ShowWikipediaLookup"))
|
2019-03-02 20:36:30 +00:00
|
|
|
elseif action == "fulltext_search" then
|
|
|
|
self.ui:handleEvent(Event:new("ShowFulltextSearchInput"))
|
2019-02-26 17:58:26 +00:00
|
|
|
elseif action == "show_menu" then
|
|
|
|
if self.ges_mode == "gesture_fm" then
|
|
|
|
self.ui:handleEvent(Event:new("ShowMenu"))
|
|
|
|
else
|
|
|
|
self.ui:handleEvent(Event:new("ShowReaderMenu"))
|
|
|
|
end
|
|
|
|
elseif action == "show_config_menu" then
|
|
|
|
self.ui:handleEvent(Event:new("ShowConfigMenu"))
|
2019-02-26 08:27:28 +00:00
|
|
|
elseif action == "show_frontlight_dialog" then
|
|
|
|
if self.ges_mode == "gesture_fm" then
|
|
|
|
local ReaderFrontLight = require("apps/reader/modules/readerfrontlight")
|
|
|
|
ReaderFrontLight:onShowFlDialog()
|
|
|
|
else
|
|
|
|
self.ui:handleEvent(Event:new("ShowFlDialog"))
|
|
|
|
end
|
2019-08-01 17:08:09 +00:00
|
|
|
elseif action == "increase_frontlight" then
|
2019-09-04 18:52:24 +00:00
|
|
|
-- when using frontlight system settings
|
|
|
|
if lightFrontlight() then
|
|
|
|
UIManager:show(Notification:new{
|
|
|
|
text = _("Frontlight controlled by system settings."),
|
|
|
|
timeout = 2.5,
|
|
|
|
})
|
|
|
|
return true
|
|
|
|
end
|
2019-08-01 17:08:09 +00:00
|
|
|
if self.ges_mode == "gesture_fm" then
|
|
|
|
local ReaderFrontLight = require("apps/reader/modules/readerfrontlight")
|
|
|
|
ReaderFrontLight:onChangeFlIntensity(ges, 1)
|
|
|
|
else
|
|
|
|
self.ui:handleEvent(Event:new("ChangeFlIntensity", ges, 1))
|
|
|
|
end
|
|
|
|
elseif action == "decrease_frontlight" then
|
2019-09-04 18:52:24 +00:00
|
|
|
-- when using frontlight system settings
|
|
|
|
if lightFrontlight() then
|
|
|
|
UIManager:show(Notification:new{
|
|
|
|
text = _("Frontlight controlled by system settings."),
|
|
|
|
timeout = 2.5,
|
|
|
|
})
|
|
|
|
return true
|
|
|
|
end
|
2019-08-01 17:08:09 +00:00
|
|
|
if self.ges_mode == "gesture_fm" then
|
|
|
|
local ReaderFrontLight = require("apps/reader/modules/readerfrontlight")
|
|
|
|
ReaderFrontLight:onChangeFlIntensity(ges, -1)
|
|
|
|
else
|
|
|
|
self.ui:handleEvent(Event:new("ChangeFlIntensity", ges, -1))
|
|
|
|
end
|
|
|
|
elseif action == "increase_frontlight_warmth" then
|
|
|
|
if self.ges_mode == "gesture_fm" then
|
|
|
|
local ReaderFrontLight = require("apps/reader/modules/readerfrontlight")
|
|
|
|
ReaderFrontLight:onChangeFlWarmth(ges, 1)
|
|
|
|
else
|
|
|
|
self.ui:handleEvent(Event:new("ChangeFlWarmth", ges, 1))
|
|
|
|
end
|
|
|
|
elseif action == "decrease_frontlight_warmth" then
|
|
|
|
if self.ges_mode == "gesture_fm" then
|
|
|
|
local ReaderFrontLight = require("apps/reader/modules/readerfrontlight")
|
|
|
|
ReaderFrontLight:onChangeFlWarmth(ges, -1)
|
|
|
|
else
|
|
|
|
self.ui:handleEvent(Event:new("ChangeFlWarmth", ges, -1))
|
|
|
|
end
|
2019-04-07 17:00:15 +00:00
|
|
|
elseif action == "toggle_bookmark" then
|
|
|
|
self.ui:handleEvent(Event:new("ToggleBookmark"))
|
2019-01-08 01:59:47 +00:00
|
|
|
elseif action == "toggle_frontlight" then
|
2019-09-04 18:52:24 +00:00
|
|
|
-- when using frontlight system settings
|
|
|
|
if lightFrontlight() then
|
|
|
|
UIManager:show(Notification:new{
|
|
|
|
text = _("Frontlight controlled by system settings."),
|
|
|
|
timeout = 2.5,
|
|
|
|
})
|
|
|
|
return true
|
|
|
|
end
|
2018-09-29 21:15:57 +00:00
|
|
|
Device:getPowerDevice():toggleFrontlight()
|
|
|
|
self:onShowFLOnOff()
|
2019-01-08 01:59:47 +00:00
|
|
|
elseif action == "toggle_gsensor" then
|
|
|
|
G_reader_settings:flipNilOrFalse("input_ignore_gsensor")
|
2019-07-01 15:12:24 +00:00
|
|
|
Device:toggleGSensor(not G_reader_settings:isTrue("input_ignore_gsensor"))
|
2019-01-08 01:59:47 +00:00
|
|
|
self:onGSensorToggle()
|
2019-04-07 17:00:15 +00:00
|
|
|
elseif action == "toggle_page_flipping" then
|
|
|
|
if not self.ui.document.info.has_pages then
|
|
|
|
-- ReaderRolling has no support (yet) for onTogglePageFlipping,
|
|
|
|
-- so don't make that top left tap area unusable (and allow
|
|
|
|
-- taping on links there)
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
self.ui:handleEvent(Event:new("TogglePageFlipping"))
|
2019-03-01 09:38:29 +00:00
|
|
|
elseif action == "toggle_reflow" then
|
|
|
|
if not self.document.info.has_pages then return end
|
|
|
|
if self.document.configurable.text_wrap == 1 then
|
|
|
|
self.document.configurable.text_wrap = 0
|
|
|
|
else
|
|
|
|
self.document.configurable.text_wrap = 1
|
|
|
|
end
|
|
|
|
self.ui:handleEvent(Event:new("RedrawCurrentPage"))
|
|
|
|
self.ui:handleEvent(Event:new("RestoreZoomMode"))
|
|
|
|
self.ui:handleEvent(Event:new("InitScrollPageStates"))
|
2019-02-16 18:25:17 +00:00
|
|
|
elseif action == "toggle_rotation" then
|
2019-03-05 17:33:50 +00:00
|
|
|
local event_name = self.document.info.has_pages and "SwapScreenMode" or "ChangeScreenMode"
|
|
|
|
local arg = Screen:getScreenMode() == "portrait" and "landscape" or "portrait"
|
|
|
|
self.ui:handleEvent(Event:new(event_name, arg))
|
2019-03-05 20:34:58 +00:00
|
|
|
elseif action == "toggle_wifi" then
|
|
|
|
local NetworkMgr = require("ui/network/manager")
|
|
|
|
|
|
|
|
if not NetworkMgr:isOnline() then
|
2019-03-14 09:37:25 +00:00
|
|
|
UIManager:show(InfoMessage:new{
|
|
|
|
text = _("Enabling wifi…"),
|
|
|
|
timeout = 1,
|
|
|
|
})
|
|
|
|
|
2019-03-05 20:34:58 +00:00
|
|
|
-- NB Normal widgets should use NetworkMgr:promptWifiOn()
|
|
|
|
-- This is specifically the toggle wifi action, so consent is implied.
|
|
|
|
NetworkMgr:turnOnWifi()
|
|
|
|
else
|
|
|
|
NetworkMgr:turnOffWifi()
|
|
|
|
|
|
|
|
UIManager:show(InfoMessage:new{
|
|
|
|
text = _("Wifi disabled."),
|
|
|
|
timeout = 1,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
elseif action == "wifi_off" then
|
|
|
|
local NetworkMgr = require("ui/network/manager")
|
|
|
|
-- can't hurt
|
|
|
|
NetworkMgr:turnOffWifi()
|
|
|
|
|
|
|
|
UIManager:show(InfoMessage:new{
|
|
|
|
text = _("Wifi disabled."),
|
|
|
|
timeout = 1,
|
|
|
|
})
|
|
|
|
elseif action == "wifi_on" then
|
|
|
|
local NetworkMgr = require("ui/network/manager")
|
|
|
|
|
|
|
|
if not NetworkMgr:isOnline() then
|
2019-03-14 09:37:25 +00:00
|
|
|
UIManager:show(InfoMessage:new{
|
|
|
|
text = _("Enabling wifi…"),
|
|
|
|
timeout = 1,
|
|
|
|
})
|
|
|
|
|
2019-03-05 20:34:58 +00:00
|
|
|
-- NB Normal widgets should use NetworkMgr:promptWifiOn()
|
|
|
|
-- This is specifically the toggle wifi action, so consent is implied.
|
|
|
|
NetworkMgr:turnOnWifi()
|
|
|
|
else
|
|
|
|
local info_text
|
|
|
|
local current_network = NetworkMgr:getCurrentNetwork()
|
|
|
|
-- this method is only available for some implementations
|
2019-09-06 20:51:45 +00:00
|
|
|
if current_network and current_network.ssid then
|
|
|
|
info_text = T(_("Already connected to network %1."), current_network.ssid)
|
2019-03-05 20:34:58 +00:00
|
|
|
else
|
|
|
|
info_text = _("Already connected.")
|
|
|
|
end
|
|
|
|
UIManager:show(InfoMessage:new{
|
|
|
|
text = info_text,
|
|
|
|
timeout = 1,
|
|
|
|
})
|
|
|
|
end
|
2019-08-07 18:18:36 +00:00
|
|
|
elseif action == "increase_font" then
|
|
|
|
self.ui:handleEvent(Event:new("AdjustFontSize", ges, 1))
|
|
|
|
elseif action == "decrease_font" then
|
|
|
|
self.ui:handleEvent(Event:new("AdjustFontSize", ges, -1))
|
2019-02-16 18:08:28 +00:00
|
|
|
elseif action == "suspend" then
|
|
|
|
UIManager:suspend()
|
2019-03-04 17:46:58 +00:00
|
|
|
elseif action == "exit" then
|
|
|
|
self.ui.menu:exitOrRestart()
|
|
|
|
elseif action == "restart" then
|
|
|
|
self.ui.menu:exitOrRestart(function() UIManager:restartKOReader() end)
|
2019-08-15 12:49:15 +00:00
|
|
|
elseif action == "reboot" then
|
|
|
|
UIManager:show(ConfirmBox:new{
|
|
|
|
text = _("Are you sure you want to reboot the device?"),
|
|
|
|
ok_text = _("Reboot"),
|
|
|
|
ok_callback = function()
|
|
|
|
UIManager:nextTick(UIManager.reboot_action)
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
elseif action == "poweroff" then
|
|
|
|
UIManager:show(ConfirmBox:new{
|
|
|
|
text = _("Are you sure you want to power off the device?"),
|
|
|
|
ok_text = _("Power off"),
|
|
|
|
ok_callback = function()
|
|
|
|
UIManager:nextTick(UIManager.poweroff_action)
|
|
|
|
end,
|
|
|
|
})
|
2019-02-20 12:45:14 +00:00
|
|
|
elseif action == "zoom_contentwidth" then
|
|
|
|
self.ui:handleEvent(Event:new("SetZoomMode", "contentwidth"))
|
|
|
|
elseif action == "zoom_contentheight" then
|
|
|
|
self.ui:handleEvent(Event:new("SetZoomMode", "contentheight"))
|
|
|
|
elseif action == "zoom_pagewidth" then
|
|
|
|
self.ui:handleEvent(Event:new("SetZoomMode", "pagewidth"))
|
|
|
|
elseif action == "zoom_pageheight" then
|
|
|
|
self.ui:handleEvent(Event:new("SetZoomMode", "pageheight"))
|
|
|
|
elseif action == "zoom_column" then
|
|
|
|
self.ui:handleEvent(Event:new("SetZoomMode", "column"))
|
|
|
|
elseif action == "zoom_content" then
|
|
|
|
self.ui:handleEvent(Event:new("SetZoomMode", "content"))
|
|
|
|
elseif action == "zoom_page" then
|
|
|
|
self.ui:handleEvent(Event:new("SetZoomMode", "page"))
|
2019-03-05 12:40:07 +00:00
|
|
|
elseif action == "wallabag_download" then
|
|
|
|
self.ui:handleEvent(Event:new("SynchronizeWallabag"))
|
2019-03-16 10:24:11 +00:00
|
|
|
elseif action == "cycle_highlight_action" then
|
2019-03-14 14:33:04 +00:00
|
|
|
self.ui:handleEvent(Event:new("CycleHighlightAction"))
|
2019-04-18 10:12:38 +00:00
|
|
|
elseif action == "cycle_highlight_style" then
|
|
|
|
self.ui:handleEvent(Event:new("CycleHighlightStyle"))
|
2018-09-29 21:15:57 +00:00
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2019-03-02 20:23:40 +00:00
|
|
|
function ReaderGesture:multiswipeAction(multiswipe_directions, ges)
|
2019-02-28 15:27:09 +00:00
|
|
|
if not self.multiswipes_enabled then return end
|
2019-02-17 20:38:02 +00:00
|
|
|
local gesture_manager = G_reader_settings:readSetting(self.ges_mode)
|
|
|
|
local multiswipe_gesture_name = "multiswipe_"..self:safeMultiswipeName(multiswipe_directions)
|
2019-03-04 17:46:58 +00:00
|
|
|
local action = gesture_manager[multiswipe_gesture_name]
|
|
|
|
if action and action ~= "nothing" then
|
|
|
|
return self:gestureAction(action, ges)
|
2019-02-17 20:38:02 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-09-29 21:15:57 +00:00
|
|
|
function ReaderGesture:pageUpdate(page)
|
|
|
|
local curr_page
|
|
|
|
if self.document.info.has_pages then
|
|
|
|
curr_page = self.ui.paging.current_page
|
|
|
|
else
|
|
|
|
curr_page = self.document:getCurrentPage()
|
|
|
|
end
|
|
|
|
if curr_page and page then
|
|
|
|
curr_page = curr_page + page
|
|
|
|
self.ui:handleEvent(Event:new("GotoPage", curr_page))
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
function ReaderGesture:onShowFLOnOff()
|
|
|
|
local powerd = Device:getPowerDevice()
|
|
|
|
local new_text
|
|
|
|
if powerd.is_fl_on then
|
|
|
|
new_text = _("Frontlight is on.")
|
|
|
|
else
|
|
|
|
new_text = _("Frontlight is off.")
|
|
|
|
end
|
|
|
|
UIManager:show(Notification:new{
|
|
|
|
text = new_text,
|
|
|
|
timeout = 1.0,
|
|
|
|
})
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2019-01-08 01:59:47 +00:00
|
|
|
function ReaderGesture:onGSensorToggle()
|
|
|
|
local new_text
|
|
|
|
if G_reader_settings:isTrue("input_ignore_gsensor") then
|
|
|
|
new_text = _("Accelerometer rotation events will now be ignored.")
|
|
|
|
else
|
|
|
|
new_text = _("Accelerometer rotation events will now be honored.")
|
|
|
|
end
|
|
|
|
UIManager:show(Notification:new{
|
|
|
|
text = new_text,
|
|
|
|
timeout = 1.0,
|
|
|
|
})
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2018-09-29 21:15:57 +00:00
|
|
|
return ReaderGesture
|