2020-01-04 00:18:51 +00:00
|
|
|
local BD = require("ui/bidi")
|
2017-04-29 14:30:16 +00:00
|
|
|
local Blitbuffer = require("ffi/blitbuffer")
|
|
|
|
local ConfirmBox = require("ui/widget/confirmbox")
|
2014-09-05 13:02:13 +00:00
|
|
|
local FrameContainer = require("ui/widget/container/framecontainer")
|
2017-04-29 14:30:16 +00:00
|
|
|
local InputContainer = require("ui/widget/container/inputcontainer")
|
2014-09-05 13:02:13 +00:00
|
|
|
local OPDSBrowser = require("ui/widget/opdsbrowser")
|
2017-04-29 14:30:16 +00:00
|
|
|
local ReaderUI = require("apps/reader/readerui")
|
2014-09-05 13:02:13 +00:00
|
|
|
local UIManager = require("ui/uimanager")
|
2016-12-29 08:10:38 +00:00
|
|
|
local logger = require("logger")
|
2014-09-05 13:02:13 +00:00
|
|
|
local _ = require("gettext")
|
2017-04-29 14:30:16 +00:00
|
|
|
local Screen = require("device").screen
|
2016-11-27 15:06:24 +00:00
|
|
|
local T = require("ffi/util").template
|
2017-04-29 14:30:16 +00:00
|
|
|
|
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{
|
2019-09-17 12:27:51 +00:00
|
|
|
text = T(_("File saved to:\n%1\nWould you like to read the downloaded book now?"),
|
2020-01-04 00:18:51 +00:00
|
|
|
BD.filepath(downloaded_file)),
|
2017-10-01 12:27:02 +00:00
|
|
|
ok_text = _("Read now"),
|
|
|
|
cancel_text = _("Read later"),
|
2016-11-27 15:06:24 +00:00
|
|
|
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(),
|
2018-03-17 22:02:32 +00:00
|
|
|
covers_fullscreen = true, -- hint for UIManager:_repaint()
|
2014-09-05 13:02:13 +00:00
|
|
|
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
|