mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
ReaderGesture: cleanup (#6292)
convert all gesture actions to use events for better modularity add network event handlers and device event handlers
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
local BD = require("ui/bidi")
|
||||
local ConfirmBox = require("ui/widget/confirmbox")
|
||||
local Device = require("device")
|
||||
local Event = require("ui/event")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local _ = require("gettext")
|
||||
@@ -75,13 +75,7 @@ if Device:canReboot() then
|
||||
text = _("Reboot the device"),
|
||||
keep_menu_open = true,
|
||||
callback = function()
|
||||
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,
|
||||
})
|
||||
UIManager:broadcastEvent(Event:new("Reboot"))
|
||||
end
|
||||
}
|
||||
end
|
||||
@@ -90,13 +84,7 @@ if Device:canPowerOff() then
|
||||
text = _("Power off"),
|
||||
keep_menu_open = true,
|
||||
callback = function()
|
||||
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,
|
||||
})
|
||||
UIManager:broadcastEvent(Event:new("PowerOff"))
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
@@ -27,11 +27,10 @@ if Device:isCervantes() then
|
||||
end
|
||||
|
||||
if Device:hasFrontlight() then
|
||||
local ReaderFrontLight = require("apps/reader/modules/readerfrontlight")
|
||||
common_settings.frontlight = {
|
||||
text = _("Frontlight"),
|
||||
callback = function()
|
||||
ReaderFrontLight:onShowFlDialog()
|
||||
UIManager:broadcastEvent(Event:new("ShowFlDialog"))
|
||||
end,
|
||||
}
|
||||
end
|
||||
@@ -166,10 +165,7 @@ common_settings.night_mode = {
|
||||
text = _("Night mode"),
|
||||
checked_func = function() return G_reader_settings:isTrue("night_mode") end,
|
||||
callback = function()
|
||||
local night_mode = G_reader_settings:isTrue("night_mode")
|
||||
Screen:toggleNightMode()
|
||||
UIManager:setDirty(nil, "full")
|
||||
G_reader_settings:saveSetting("night_mode", not night_mode)
|
||||
UIManager:broadcastEvent(Event:new("ToggleNightMode"))
|
||||
end
|
||||
}
|
||||
common_settings.network = {
|
||||
|
||||
@@ -19,8 +19,7 @@ return {
|
||||
return G_reader_settings:isTrue("input_ignore_gsensor")
|
||||
end,
|
||||
callback = function()
|
||||
G_reader_settings:flipNilOrFalse("input_ignore_gsensor")
|
||||
Device:toggleGSensor(not G_reader_settings:isTrue("input_ignore_gsensor"))
|
||||
UIManager:broadcastEvent(Event:new("ToggleGSensor"))
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user