2016-02-02 17:38:14 +00:00
|
|
|
local InputContainer = require("ui/widget/container/inputcontainer")
|
2016-03-07 05:38:20 +00:00
|
|
|
local BookStatusWidget = require("ui/widget/bookstatuswidget")
|
2016-02-02 17:38:14 +00:00
|
|
|
|
|
|
|
local UIManager = require("ui/uimanager")
|
|
|
|
local _ = require("gettext")
|
|
|
|
|
|
|
|
local ReaderStatus = InputContainer:new {
|
|
|
|
document = nil,
|
|
|
|
summary = {
|
|
|
|
rating = 0,
|
|
|
|
note = nil,
|
|
|
|
status = "",
|
|
|
|
modified = "",
|
|
|
|
},
|
|
|
|
enabled = true,
|
2016-02-09 12:51:55 +00:00
|
|
|
total_pages = 0
|
2016-02-02 17:38:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function ReaderStatus:init()
|
2016-07-15 14:58:41 +00:00
|
|
|
if self.ui.document.is_pic then
|
2016-02-02 17:38:14 +00:00
|
|
|
self.enabled = false
|
|
|
|
return
|
2016-03-07 05:52:53 +00:00
|
|
|
else
|
|
|
|
self.total_pages = self.document:getPageCount()
|
2016-02-10 07:17:53 +00:00
|
|
|
self.ui.menu:registerToMainMenu(self)
|
2016-03-07 05:52:53 +00:00
|
|
|
-- register event listener if enabled
|
2016-11-21 14:26:11 +00:00
|
|
|
if G_reader_settings:nilOrTrue("auto_book_status") then
|
|
|
|
self.onEndOfBook = function()
|
|
|
|
self:showStatus()
|
|
|
|
end
|
2016-03-07 05:52:53 +00:00
|
|
|
end
|
|
|
|
end
|
2016-02-02 17:38:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function ReaderStatus:addToMainMenu(tab_item_table)
|
2016-03-07 05:52:53 +00:00
|
|
|
table.insert(tab_item_table.info, {
|
|
|
|
text = _("Book status"),
|
2016-02-02 17:38:14 +00:00
|
|
|
callback = function()
|
|
|
|
self:showStatus()
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
function ReaderStatus:showStatus()
|
2016-03-07 05:38:20 +00:00
|
|
|
local status_page = BookStatusWidget:new {
|
2016-02-02 17:38:14 +00:00
|
|
|
thumbnail = self.document:getCoverPageImage(),
|
|
|
|
props = self.document:getProps(),
|
|
|
|
document = self.document,
|
|
|
|
settings = self.settings,
|
2016-02-12 14:55:02 +00:00
|
|
|
view = self.view,
|
2016-02-02 17:38:14 +00:00
|
|
|
}
|
2016-02-15 07:52:34 +00:00
|
|
|
UIManager:show(status_page)
|
2016-02-02 17:38:14 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function ReaderStatus:onReadSettings(config)
|
|
|
|
self.settings = config
|
|
|
|
end
|
|
|
|
|
|
|
|
return ReaderStatus
|