2
0
mirror of https://github.com/koreader/koreader synced 2024-11-13 19:11:25 +00:00

[ReaderFooter] Update status bar in real time when inverting page turning (#12424)

This commit is contained in:
David 2024-09-25 20:16:06 +01:00 committed by GitHub
parent beaad4d337
commit 08205c47c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 67 additions and 14 deletions

View File

@ -2445,6 +2445,15 @@ function ReaderFooter:onNetworkConnected()
end
ReaderFooter.onNetworkDisconnected = ReaderFooter.onNetworkConnected
function ReaderFooter:onSwapPageTurnButtons()
if self.settings.page_turning_inverted then
-- We may receive the event *before* DeviceListener, so delay this to make sure it had a chance to actually swap the settings.
-- Also delay it further to avoid screwing with TouchMenu highlights...
UIManager:scheduleIn(0.5, self.maybeUpdateFooter, self)
end
end
ReaderFooter.onToggleReadingOrder = ReaderFooter.onSwapPageTurnButtons
function ReaderFooter:onSetRotationMode()
self:updateFooterContainer()
self:resetLayout(true)

View File

@ -325,18 +325,60 @@ function DeviceListener:onToggleFlashOnPagesWithImages()
G_reader_settings:flipNilOrTrue("refresh_on_pages_with_images")
end
function DeviceListener:onSwapPageTurnButtons(show_notification)
G_reader_settings:flipNilOrFalse("input_invert_page_turn_keys")
Device:invertButtons()
if show_notification then
local new_text
function DeviceListener:onSwapPageTurnButtons(side)
local new_text
if side == "left" then
-- Revert any prior global inversions first, as we could end up with an all greyed out menu.
if G_reader_settings:isTrue("input_invert_page_turn_keys") then
G_reader_settings:makeFalse("input_invert_page_turn_keys")
Device:invertButtons()
end
G_reader_settings:flipNilOrFalse("input_invert_left_page_turn_keys")
Device:invertButtonsLeft()
if G_reader_settings:isTrue("input_invert_left_page_turn_keys") then
new_text = _("Left-side page-turn buttons inverted.")
else
new_text = _("Left-side page-turn buttons no longer inverted.")
end
elseif side == "right" then
-- Revert any prior global inversions first, as we could end up with an all greyed out menu.
if G_reader_settings:isTrue("input_invert_page_turn_keys") then
G_reader_settings:makeFalse("input_invert_page_turn_keys")
Device:invertButtons()
end
G_reader_settings:flipNilOrFalse("input_invert_right_page_turn_keys")
Device:invertButtonsRight()
if G_reader_settings:isTrue("input_invert_right_page_turn_keys") then
new_text = _("Right-side page-turn buttons inverted.")
else
new_text = _("Right-side page-turn buttons no longer inverted.")
end
else
-- Revert any prior inversions first, as we could end up with an all greyed out menu.
if G_reader_settings:isTrue("input_invert_left_page_turn_keys") and G_reader_settings:isTrue("input_invert_right_page_turn_keys") then
G_reader_settings:makeFalse("input_invert_left_page_turn_keys")
G_reader_settings:makeFalse("input_invert_right_page_turn_keys")
G_reader_settings:makeFalse("input_invert_page_turn_keys")
Device:invertButtons()
new_text = _("Page-turn buttons no longer inverted.")
Notification:notify(new_text)
return true
elseif G_reader_settings:isTrue("input_invert_left_page_turn_keys") then
G_reader_settings:makeFalse("input_invert_left_page_turn_keys")
Device:invertButtonsLeft()
elseif G_reader_settings:isTrue("input_invert_right_page_turn_keys") then
G_reader_settings:makeFalse("input_invert_right_page_turn_keys")
Device:invertButtonsRight()
end
G_reader_settings:flipNilOrFalse("input_invert_page_turn_keys")
Device:invertButtons()
if G_reader_settings:isTrue("input_invert_page_turn_keys") then
new_text = _("Page-turn buttons inverted.")
else
new_text = _("Page-turn buttons no longer inverted.")
end
Notification:notify(new_text)
end
Notification:notify(new_text)
return true
end

View File

@ -80,7 +80,9 @@ local settingsList = {
touch_input_off = {category="none", event="IgnoreTouchInput", arg=true, title=_("Disable touch input"), device=true, condition=Device:isTouchDevice()},
toggle_touch_input = {category="none", event="IgnoreTouchInput", title=_("Toggle touch input"), device=true, separator=true, condition=Device:isTouchDevice()},
----
swap_page_turn_buttons = {category="none", event="SwapPageTurnButtons", arg=true, title=_("Invert page turn buttons"), device=true, condition=Device:hasKeys(), separator=true},
swap_left_page_turn_buttons = {category="none", event="SwapPageTurnButtons", arg="left", title=_("Invert left-side page-turn buttons"), device=true, condition= Device:hasDPad() and Device:useDPadAsActionKeys()},
swap_right_page_turn_buttons = {category="none", event="SwapPageTurnButtons", arg="right", title=_("Invert right-side page-turn buttons"), device=true, condition= Device:hasDPad() and Device:useDPadAsActionKeys()},
swap_page_turn_buttons = {category="none", event="SwapPageTurnButtons", title=_("Invert page-turn buttons"), device=true, condition=Device:hasKeys(), separator=true},
----
toggle_key_repeat = {category="none", event="ToggleKeyRepeat", title=_("Toggle key repeat"), device=true, condition=Device:hasKeys() and Device:canKeyRepeat(), separator=true},
toggle_gsensor = {category="none", event="ToggleGSensor", title=_("Toggle accelerometer"), device=true, condition=Device:hasGSensor()},
@ -310,6 +312,8 @@ local dispatcher_menu_order = {
"toggle_touch_input",
----
"swap_page_turn_buttons",
"swap_left_page_turn_buttons",
"swap_right_page_turn_buttons",
----
"toggle_key_repeat",
"toggle_gsensor",

View File

@ -8,7 +8,7 @@ local PhysicalButtons = {
text = _("Physical buttons"), -- Mainly so as to differentiate w/ "Page Turns" when in readermenu...
sub_item_table = {
{
text = _("Invert page turn buttons"),
text = _("Invert page-turn buttons"),
enabled_func = function()
return not (G_reader_settings:isTrue("input_invert_left_page_turn_keys") or G_reader_settings:isTrue("input_invert_right_page_turn_keys"))
end,
@ -25,7 +25,7 @@ local PhysicalButtons = {
if Device:hasDPad() and Device:useDPadAsActionKeys() then
table.insert(PhysicalButtons.sub_item_table, {
text = _("Invert left-side page turn buttons"),
text = _("Invert left-side page-turn buttons"),
enabled_func = function()
return not G_reader_settings:isTrue("input_invert_page_turn_keys")
end,
@ -33,12 +33,11 @@ if Device:hasDPad() and Device:useDPadAsActionKeys() then
return G_reader_settings:isTrue("input_invert_left_page_turn_keys")
end,
callback = function()
G_reader_settings:flipNilOrFalse("input_invert_left_page_turn_keys")
Device:invertButtonsLeft()
UIManager:broadcastEvent(Event:new("SwapPageTurnButtons", "left"))
end,
})
table.insert(PhysicalButtons.sub_item_table, {
text = _("Invert right-side page turn buttons"),
text = _("Invert right-side page-turn buttons"),
enabled_func = function()
return not G_reader_settings:isTrue("input_invert_page_turn_keys")
end,
@ -46,8 +45,7 @@ if Device:hasDPad() and Device:useDPadAsActionKeys() then
return G_reader_settings:isTrue("input_invert_right_page_turn_keys")
end,
callback = function()
G_reader_settings:flipNilOrFalse("input_invert_right_page_turn_keys")
Device:invertButtonsRight()
UIManager:broadcastEvent(Event:new("SwapPageTurnButtons", "right"))
end,
separator = true,
})