diff --git a/frontend/apps/reader/modules/readerstatus.lua b/frontend/apps/reader/modules/readerstatus.lua index ed85f5e70..6f41801fe 100644 --- a/frontend/apps/reader/modules/readerstatus.lua +++ b/frontend/apps/reader/modules/readerstatus.lua @@ -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 diff --git a/frontend/ui/elements/common_settings_menu_table.lua b/frontend/ui/elements/common_settings_menu_table.lua index 30453e5b0..2a5e375f0 100644 --- a/frontend/ui/elements/common_settings_menu_table.lua +++ b/frontend/ui/elements/common_settings_menu_table.lua @@ -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()