[UX] Add Mark as read to end of document action (#5596)

pull/5603/head
Robert 5 years ago committed by Frans de Jonge
parent b21b4c8776
commit 679b592c80

@ -56,8 +56,15 @@ function ReaderStatus:onEndOfBook()
local buttons = {
{
{
text = _("Cancel"),
text_func = function()
if self.settings.data.summary and self.settings.data.summary.status == "complete" then
return _("Mark as reading")
else
return _("Mark as read")
end
end,
callback = function()
self:onMarkBook()
UIManager:close(choose_action)
end,
},
@ -88,6 +95,12 @@ function ReaderStatus:onEndOfBook()
},
},
{
{
text = _("Cancel"),
callback = function()
UIManager:close(choose_action)
end,
},
{
text = _("File browser"),
callback = function()
@ -122,6 +135,12 @@ function ReaderStatus:onEndOfBook()
end
elseif settings == "file_browser" then
self:openFileBrowser()
elseif settings == "mark_read" then
self:onMarkBook(true)
UIManager:show(InfoMessage:new{
text = _("You've reached the end of the document.\nThe current book is marked as read."),
timeout = 3
})
elseif settings == "book_status_file_browser" then
local before_show_callback = function() self:openFileBrowser() end
self:onShowBookStatus(before_show_callback)
@ -192,6 +211,27 @@ function ReaderStatus:onShowBookStatus(before_show_callback)
return true
end
-- If mark_read is true then we change status only from reading/abandoned to read (complete).
-- Otherwise we change status from reading/abandoned to read or from read to reading.
function ReaderStatus:onMarkBook(mark_read)
if self.settings.data.summary and self.settings.data.summary.status then
local current_status = self.settings.data.summary.status
if current_status == "complete" then
if mark_read then
-- Keep mark as read.
self.settings.data.summary.status = "complete"
else
-- Change current status from read (complete) to reading
self.settings.data.summary.status = "reading"
end
else
self.settings.data.summary.status = "complete"
end
else
self.settings.data.summary = {status = "complete"}
end
end
function ReaderStatus:onReadSettings(config)
self.settings = config
end

@ -445,6 +445,15 @@ common_settings.document = {
G_reader_settings:saveSetting("end_document_action", "file_browser")
end,
},
{
text = _("Mark book as read"),
checked_func = function()
return G_reader_settings:readSetting("end_document_action") == "mark_read"
end,
callback = function()
G_reader_settings:saveSetting("end_document_action", "mark_read")
end,
},
{
text = _("Book status and return to file browser"),
checked_func = function()

Loading…
Cancel
Save