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:
@@ -5,6 +5,7 @@ local ButtonDialogTitle = require("ui/widget/buttondialogtitle")
|
||||
local CenterContainer = require("ui/widget/container/centercontainer")
|
||||
local ConfirmBox = require("ui/widget/confirmbox")
|
||||
local Device = require("device")
|
||||
local DeviceListener = require("device/devicelistener")
|
||||
local DocSettings = require("docsettings")
|
||||
local DocumentRegistry = require("document/documentregistry")
|
||||
local Event = require("ui/event")
|
||||
@@ -463,6 +464,7 @@ function FileManager:init()
|
||||
table.insert(self, ReaderDictionary:new{ ui = self })
|
||||
table.insert(self, ReaderWikipedia:new{ ui = self })
|
||||
table.insert(self, ReaderDeviceStatus:new{ ui = self })
|
||||
table.insert(self, DeviceListener:new{ ui = self })
|
||||
|
||||
-- koreader plugins
|
||||
for _,plugin_module in ipairs(PluginLoader:loadPlugins()) do
|
||||
@@ -484,6 +486,11 @@ function FileManager:init()
|
||||
table.insert(self, ReaderGesture:new{ ui = self })
|
||||
end
|
||||
|
||||
if Device:hasWifiToggle() then
|
||||
local NetworkListener = require("ui/network/networklistener")
|
||||
table.insert(self, NetworkListener:new{ ui = self })
|
||||
end
|
||||
|
||||
if Device:hasKeys() then
|
||||
self.key_events.Home = { {"Home"}, doc = "go home" }
|
||||
--Override the menu.lua way of handling the back key
|
||||
|
||||
@@ -105,7 +105,7 @@ function FileSearcher:close()
|
||||
end
|
||||
end
|
||||
|
||||
function FileSearcher:onShowFileSearch(search_path)
|
||||
function FileSearcher:onShowFileSearch()
|
||||
local dummy = self.search_value
|
||||
local enabled_search_home_dir = true
|
||||
if not G_reader_settings:readSetting("home_dir") then
|
||||
@@ -129,7 +129,7 @@ function FileSearcher:onShowFileSearch(search_path)
|
||||
text = _("Current folder"),
|
||||
enabled = true,
|
||||
callback = function()
|
||||
self.path = search_path or lfs.currentdir()
|
||||
self.path = self.ui.file_chooser and self.ui.file_chooser.path or self.ui:getLastDirFile()
|
||||
self.search_value = self.search_dialog:getInputText()
|
||||
if self.search_value == dummy then -- probably DELETE this if/else block
|
||||
self.use_previous_search_results = true
|
||||
|
||||
@@ -87,7 +87,7 @@ function FileManagerMenu:initGesListener()
|
||||
})
|
||||
end
|
||||
|
||||
function FileManagerMenu:openLastDoc()
|
||||
function FileManagerMenu:onOpenLastDoc()
|
||||
local last_file = G_reader_settings:readSetting("lastfile")
|
||||
if not last_file or lfs.attributes(last_file, "mode") ~= "file" then
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
@@ -478,7 +478,7 @@ function FileManagerMenu:setUpdateItemTable()
|
||||
-- @translators Search for files by name.
|
||||
text = _("Find a file"),
|
||||
callback = function()
|
||||
self.ui:handleEvent(Event:new("ShowFileSearch", self.ui.file_chooser.path))
|
||||
self.ui:handleEvent(Event:new("ShowFileSearch"))
|
||||
end
|
||||
}
|
||||
|
||||
@@ -496,7 +496,7 @@ function FileManagerMenu:setUpdateItemTable()
|
||||
return G_reader_settings:readSetting("lastfile") ~= nil
|
||||
end,
|
||||
callback = function()
|
||||
self:openLastDoc()
|
||||
self:onOpenLastDoc()
|
||||
end,
|
||||
hold_callback = function()
|
||||
local last_file = G_reader_settings:readSetting("lastfile")
|
||||
@@ -504,7 +504,7 @@ function FileManagerMenu:setUpdateItemTable()
|
||||
text = T(_("Would you like to open the last document: %1?"), BD.filepath(last_file)),
|
||||
ok_text = _("OK"),
|
||||
ok_callback = function()
|
||||
self:openLastDoc()
|
||||
self:onOpenLastDoc()
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user