2021-07-25 21:59:06 +00:00
|
|
|
local Device = require("device")
|
|
|
|
local Event = require("ui/event")
|
2021-11-23 17:16:10 +00:00
|
|
|
local ReaderUI = require("apps/reader/readerui")
|
2021-07-25 21:59:06 +00:00
|
|
|
local UIManager = require("ui/uimanager")
|
2021-04-22 16:35:08 +00:00
|
|
|
local _ = require("gettext")
|
2021-11-23 17:16:10 +00:00
|
|
|
local T = require("ffi/util").template
|
|
|
|
|
|
|
|
local page_turns_tap_zones_sub_items = {} -- build the Tap zones submenu
|
|
|
|
local tap_zones = {
|
|
|
|
default = _("Default"),
|
|
|
|
left_right = _("Left/right"),
|
|
|
|
top_bottom = _("Top/bottom"),
|
|
|
|
}
|
|
|
|
local function genTapZonesMenu(tap_zones_type)
|
|
|
|
table.insert(page_turns_tap_zones_sub_items, {
|
|
|
|
text = tap_zones[tap_zones_type],
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:readSetting("page_turns_tap_zones", "default") == tap_zones_type
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:saveSetting("page_turns_tap_zones", tap_zones_type)
|
|
|
|
ReaderUI.instance.view:setupTouchZones()
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
genTapZonesMenu("default")
|
|
|
|
genTapZonesMenu("left_right")
|
|
|
|
genTapZonesMenu("top_bottom")
|
|
|
|
table.insert(page_turns_tap_zones_sub_items, {
|
|
|
|
text_func = function()
|
2022-09-27 23:10:50 +00:00
|
|
|
local size = math.floor(G_reader_settings:readSetting("page_turns_tap_zone_forward_size_ratio", G_defaults:readSetting("DTAP_ZONE_FORWARD").w) * 100)
|
2021-11-23 17:16:10 +00:00
|
|
|
return T(_("Forward tap zone size: %1%"), size)
|
|
|
|
end,
|
|
|
|
enabled_func = function()
|
|
|
|
return G_reader_settings:readSetting("page_turns_tap_zones", "default") ~= "default"
|
|
|
|
end,
|
|
|
|
keep_menu_open = true,
|
|
|
|
callback = function(touchmenu_instance)
|
|
|
|
local is_left_right = G_reader_settings:readSetting("page_turns_tap_zones") == "left_right"
|
2022-09-27 23:10:50 +00:00
|
|
|
local size = math.floor(G_reader_settings:readSetting("page_turns_tap_zone_forward_size_ratio", G_defaults:readSetting("DTAP_ZONE_FORWARD").w) * 100)
|
2021-11-23 17:16:10 +00:00
|
|
|
UIManager:show(require("ui/widget/spinwidget"):new{
|
|
|
|
title_text = is_left_right and _("Forward tap zone width") or _("Forward tap zone height"),
|
|
|
|
info_text = is_left_right and _("Percentage of screen width") or _("Percentage of screen height"),
|
|
|
|
value = size,
|
|
|
|
value_min = 0,
|
|
|
|
value_max = 100,
|
2022-09-27 23:10:50 +00:00
|
|
|
default_value = math.floor(G_defaults:readSetting("DTAP_ZONE_FORWARD").w * 100),
|
2021-11-23 17:16:10 +00:00
|
|
|
callback = function(spin)
|
2022-10-10 20:21:27 +00:00
|
|
|
G_reader_settings:saveSetting("page_turns_tap_zone_forward_size_ratio", spin.value * (1/100))
|
2021-11-23 17:16:10 +00:00
|
|
|
ReaderUI.instance.view:setupTouchZones()
|
|
|
|
if touchmenu_instance then touchmenu_instance:updateItems() end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
end,
|
|
|
|
})
|
2021-04-22 16:35:08 +00:00
|
|
|
|
2021-07-25 21:59:06 +00:00
|
|
|
local PageTurns = {
|
2021-04-22 16:35:08 +00:00
|
|
|
text = _("Page turns"),
|
|
|
|
sub_item_table = {
|
|
|
|
{
|
2021-07-25 21:59:06 +00:00
|
|
|
text = _("With taps"),
|
2021-04-22 16:35:08 +00:00
|
|
|
checked_func = function()
|
2021-07-25 21:59:06 +00:00
|
|
|
return G_reader_settings:nilOrFalse("page_turns_disable_tap")
|
2021-04-22 16:35:08 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
2021-07-25 21:59:06 +00:00
|
|
|
G_reader_settings:flipNilOrFalse("page_turns_disable_tap")
|
|
|
|
end,
|
2021-04-22 16:35:08 +00:00
|
|
|
},
|
|
|
|
{
|
2021-07-25 21:59:06 +00:00
|
|
|
text = _("With swipes"),
|
2021-04-22 16:35:08 +00:00
|
|
|
checked_func = function()
|
2021-07-25 21:59:06 +00:00
|
|
|
return G_reader_settings:nilOrFalse("page_turns_disable_swipe")
|
2021-04-22 16:35:08 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
2021-07-25 21:59:06 +00:00
|
|
|
G_reader_settings:flipNilOrFalse("page_turns_disable_swipe")
|
|
|
|
end,
|
2021-11-23 17:16:10 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text_func = function()
|
|
|
|
local tap_zones_type = G_reader_settings:readSetting("page_turns_tap_zones", "default")
|
|
|
|
return T(_("Tap zones: %1"), tap_zones[tap_zones_type]:lower())
|
|
|
|
end,
|
|
|
|
enabled_func = function()
|
|
|
|
return G_reader_settings:nilOrFalse("page_turns_disable_tap")
|
|
|
|
end,
|
|
|
|
sub_item_table = page_turns_tap_zones_sub_items,
|
2021-07-25 21:59:06 +00:00
|
|
|
separator = true,
|
2021-04-22 16:35:08 +00:00
|
|
|
},
|
2021-07-25 21:59:06 +00:00
|
|
|
{
|
|
|
|
text_func = function()
|
|
|
|
local text = _("Invert page turn taps and swipes")
|
|
|
|
if G_reader_settings:isTrue("inverse_reading_order") then
|
|
|
|
text = text .. " ★"
|
|
|
|
end
|
|
|
|
return text
|
|
|
|
end,
|
|
|
|
checked_func = function()
|
2021-11-23 17:16:10 +00:00
|
|
|
return ReaderUI.instance.view.inverse_reading_order
|
2021-07-25 21:59:06 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
UIManager:broadcastEvent(Event:new("ToggleReadingOrder"))
|
|
|
|
end,
|
|
|
|
hold_callback = function(touchmenu_instance)
|
|
|
|
local inverse_reading_order = G_reader_settings:isTrue("inverse_reading_order")
|
|
|
|
local MultiConfirmBox = require("ui/widget/multiconfirmbox")
|
|
|
|
UIManager:show(MultiConfirmBox:new{
|
|
|
|
text = inverse_reading_order and _("The default (★) for newly opened books is right-to-left (RTL) page turning.\n\nWould you like to change it?")
|
|
|
|
or _("The default (★) for newly opened books is left-to-right (LTR) page turning.\n\nWould you like to change it?"),
|
|
|
|
choice1_text_func = function()
|
|
|
|
return inverse_reading_order and _("LTR") or _("LTR (★)")
|
|
|
|
end,
|
|
|
|
choice1_callback = function()
|
|
|
|
G_reader_settings:makeFalse("inverse_reading_order")
|
|
|
|
if touchmenu_instance then touchmenu_instance:updateItems() end
|
|
|
|
end,
|
|
|
|
choice2_text_func = function()
|
|
|
|
return inverse_reading_order and _("RTL (★)") or _("RTL")
|
|
|
|
end,
|
|
|
|
choice2_callback = function()
|
|
|
|
G_reader_settings:makeTrue("inverse_reading_order")
|
|
|
|
if touchmenu_instance then touchmenu_instance:updateItems() end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
end,
|
2022-01-15 23:50:58 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
text = _("Also invert document-related dialogs"),
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:isTrue("invert_ui_layout_mirroring")
|
|
|
|
end,
|
|
|
|
enabled_func = function()
|
|
|
|
return ReaderUI.instance.view.inverse_reading_order
|
|
|
|
end,
|
|
|
|
callback = function()
|
|
|
|
G_reader_settings:flipNilOrFalse("invert_ui_layout_mirroring")
|
|
|
|
end,
|
|
|
|
help_text = _([[
|
|
|
|
When enabled the UI direction for the Table of Contents, Book Map, and Page Browser dialogs will follow the page turn direction instead of the default UI direction.]]),
|
|
|
|
separator = true,
|
2021-07-25 21:59:06 +00:00
|
|
|
}
|
2021-04-22 16:35:08 +00:00
|
|
|
}
|
|
|
|
}
|
2021-07-25 21:59:06 +00:00
|
|
|
|
2022-04-06 14:42:29 +00:00
|
|
|
if Device:canDoSwipeAnimation() then
|
|
|
|
table.insert(PageTurns.sub_item_table, {
|
|
|
|
text =_("Page Turn Animations"),
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:isTrue("swipe_animations")
|
|
|
|
end,
|
|
|
|
callback = function()
|
2022-05-23 07:19:47 +00:00
|
|
|
UIManager:broadcastEvent(Event:new("TogglePageChangeAnimation"))
|
2022-04-06 14:42:29 +00:00
|
|
|
end,
|
|
|
|
separator = true,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2021-07-25 21:59:06 +00:00
|
|
|
if Device:hasKeys() then
|
|
|
|
table.insert(PageTurns.sub_item_table, {
|
|
|
|
text = _("Invert page turn buttons"),
|
|
|
|
checked_func = function()
|
|
|
|
return G_reader_settings:isTrue("input_invert_page_turn_keys")
|
|
|
|
end,
|
|
|
|
callback = function()
|
2022-09-08 02:19:34 +00:00
|
|
|
UIManager:broadcastEvent(Event:new("SwapPageTurnButtons"))
|
2021-07-25 21:59:06 +00:00
|
|
|
end,
|
|
|
|
})
|
|
|
|
end
|
2021-11-23 17:16:10 +00:00
|
|
|
|
2022-01-02 14:01:08 +00:00
|
|
|
if not Device:isTouchDevice() then
|
|
|
|
if Device:hasKeys() then
|
|
|
|
-- We just need the last item added above.
|
|
|
|
PageTurns = PageTurns.sub_item_table[#PageTurns.sub_item_table]
|
|
|
|
else
|
|
|
|
PageTurns = {} -- no menu item
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-07-25 21:59:06 +00:00
|
|
|
return PageTurns
|