2014-09-05 13:02:13 +00:00
|
|
|
local InputContainer = require("ui/widget/container/inputcontainer")
|
|
|
|
local FrameContainer = require("ui/widget/container/framecontainer")
|
|
|
|
local OPDSBrowser = require("ui/widget/opdsbrowser")
|
|
|
|
local UIManager = require("ui/uimanager")
|
2014-10-30 18:42:18 +00:00
|
|
|
local Screen = require("device").screen
|
2016-12-29 08:10:38 +00:00
|
|
|
local logger = require("logger")
|
2014-09-05 13:02:13 +00:00
|
|
|
local _ = require("gettext")
|
2014-10-22 13:34:11 +00:00
|
|
|
local Blitbuffer = require("ffi/blitbuffer")
|
2016-11-27 15:06:24 +00:00
|
|
|
local ReaderUI = require("apps/reader/readerui")
|
|
|
|
local ConfirmBox = require("ui/widget/confirmbox")
|
|
|
|
local T = require("ffi/util").template
|
2014-09-05 13:02:13 +00:00
|
|
|
local OPDSCatalog = InputContainer:extend{
|
|
|
|
title = _("OPDS Catalog"),
|
|
|
|
onExit = function() end,
|
|
|
|
}
|
|
|
|
|
|
|
|
function OPDSCatalog:init()
|
|
|
|
local opds_browser = OPDSBrowser:new{
|
|
|
|
title = self.title,
|
|
|
|
show_parent = self,
|
|
|
|
is_popout = false,
|
|
|
|
is_borderless = true,
|
|
|
|
has_close_button = true,
|
|
|
|
close_callback = function() return self:onClose() end,
|
2016-11-27 15:06:24 +00:00
|
|
|
file_downloaded_callback = function(downloaded_file)
|
|
|
|
UIManager:show(ConfirmBox:new{
|
|
|
|
text = T(_("File saved to:\n %1\nWould you like to read the downloaded book now?"),
|
|
|
|
downloaded_file),
|
|
|
|
ok_callback = function()
|
|
|
|
self:onClose()
|
|
|
|
ReaderUI:showReader(downloaded_file)
|
|
|
|
end
|
|
|
|
})
|
|
|
|
end,
|
2014-09-05 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
self[1] = FrameContainer:new{
|
|
|
|
padding = 0,
|
|
|
|
bordersize = 0,
|
2014-10-22 13:34:11 +00:00
|
|
|
background = Blitbuffer.COLOR_WHITE,
|
2014-09-05 13:02:13 +00:00
|
|
|
opds_browser,
|
|
|
|
}
|
2014-12-01 14:39:41 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function OPDSCatalog:onShow()
|
|
|
|
UIManager:setDirty(self, function()
|
2015-04-26 18:07:17 +00:00
|
|
|
return "ui", self[1].dimen
|
2014-12-01 14:39:41 +00:00
|
|
|
end)
|
|
|
|
end
|
2014-09-05 13:02:13 +00:00
|
|
|
|
2014-12-01 14:39:41 +00:00
|
|
|
function OPDSCatalog:onCloseWidget()
|
|
|
|
UIManager:setDirty(nil, function()
|
|
|
|
return "partial", self[1].dimen
|
|
|
|
end)
|
2014-09-05 13:02:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function OPDSCatalog:showCatalog()
|
2016-12-29 08:10:38 +00:00
|
|
|
logger.dbg("show OPDS catalog")
|
2014-09-05 13:02:13 +00:00
|
|
|
UIManager:show(OPDSCatalog:new{
|
|
|
|
dimen = Screen:getSize(),
|
|
|
|
onExit = function()
|
|
|
|
--UIManager:quit()
|
|
|
|
end
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
function OPDSCatalog:onClose()
|
2016-12-29 08:10:38 +00:00
|
|
|
logger.dbg("close OPDS catalog")
|
2014-09-05 13:02:13 +00:00
|
|
|
UIManager:close(self)
|
|
|
|
if self.onExit then
|
|
|
|
self:onExit()
|
|
|
|
end
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
return OPDSCatalog
|