mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Change random document to open any random document, long-press for any unopened document (#13160)
This commit is contained in:
@@ -705,7 +705,13 @@ function FileManager:tapPlus()
|
||||
text = _("Open random document"),
|
||||
callback = function()
|
||||
UIManager:close(plus_dialog)
|
||||
self:openRandomFile(self.file_chooser.path)
|
||||
-- any random document
|
||||
self:openRandomFile(self.file_chooser.path, false)
|
||||
end,
|
||||
hold_callback = function()
|
||||
UIManager:close(plus_dialog)
|
||||
-- only previously unopened
|
||||
self:openRandomFile(self.file_chooser.path, true)
|
||||
end
|
||||
},
|
||||
},
|
||||
@@ -863,9 +869,13 @@ function FileManager:setHome(path)
|
||||
return true
|
||||
end
|
||||
|
||||
function FileManager:openRandomFile(dir)
|
||||
local match_func = function(file) -- documents, not yet opened
|
||||
return DocumentRegistry:hasProvider(file) and not BookList.hasBookBeenOpened(file)
|
||||
function FileManager:openRandomFile(dir, unopened_only)
|
||||
local match_func = function(file)
|
||||
if unopened_only then
|
||||
return DocumentRegistry:hasProvider(file) and not BookList.hasBookBeenOpened(file)
|
||||
else
|
||||
return DocumentRegistry:hasProvider(file)
|
||||
end
|
||||
end
|
||||
local random_file = filemanagerutil.getRandomFile(dir, match_func)
|
||||
if random_file then
|
||||
@@ -879,7 +889,7 @@ function FileManager:openRandomFile(dir)
|
||||
-- @translators Another file. This is a button on the open random file dialog. It presents a file with the choices Open/Another.
|
||||
choice2_text = _("Another"),
|
||||
choice2_callback = function()
|
||||
self:openRandomFile(dir)
|
||||
self:openRandomFile(dir, unopened_only)
|
||||
end,
|
||||
})
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user