From 171d40d28727a3e96e1f4f00ab90ccb60cb7b487 Mon Sep 17 00:00:00 2001 From: Robert Date: Sun, 27 Nov 2016 16:06:24 +0100 Subject: [PATCH] feat: Would you like to read the downloaded book for OPDS (#2370) --- frontend/apps/opdscatalog/opdscatalog.lua | 13 +++++++++++++ frontend/ui/widget/opdsbrowser.lua | 9 ++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/frontend/apps/opdscatalog/opdscatalog.lua b/frontend/apps/opdscatalog/opdscatalog.lua index 50ec13910..30620b9d5 100644 --- a/frontend/apps/opdscatalog/opdscatalog.lua +++ b/frontend/apps/opdscatalog/opdscatalog.lua @@ -6,6 +6,9 @@ local Screen = require("device").screen local DEBUG = require("dbg") local _ = require("gettext") local Blitbuffer = require("ffi/blitbuffer") +local ReaderUI = require("apps/reader/readerui") +local ConfirmBox = require("ui/widget/confirmbox") +local T = require("ffi/util").template local OPDSCatalog = InputContainer:extend{ title = _("OPDS Catalog"), @@ -43,6 +46,16 @@ function OPDSCatalog:init() is_borderless = true, has_close_button = true, close_callback = function() return self:onClose() end, + 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, } self[1] = FrameContainer:new{ diff --git a/frontend/ui/widget/opdsbrowser.lua b/frontend/ui/widget/opdsbrowser.lua index e20cae258..a110c01a3 100644 --- a/frontend/ui/widget/opdsbrowser.lua +++ b/frontend/ui/widget/opdsbrowser.lua @@ -479,10 +479,9 @@ function OPDSBrowser:downloadFile(item, format, remote_url) if c == 200 then DEBUG("file downloaded to", local_path) - UIManager:show(InfoMessage:new{ - text = _("File saved to:\n") .. local_path, - timeout = 3, - }) + if self.file_downloaded_callback then + self.file_downloaded_callback(local_path) + end else DEBUG("response", {r, c, h}) UIManager:show(InfoMessage:new{ @@ -514,7 +513,7 @@ function OPDSBrowser:showDownloads(item) UIManager:close(self.download_dialog) UIManager:show(InfoMessage:new{ text = _("Downloading may take several minutes…"), - timeout = 3, + timeout = 1, }) end table.insert(line, button)