Cloud storage UX improvements (#5613)

* Overwrite confirmbox order

* Restore confirmbox option to read the downloaded book
reviewable/pr5623/r1
Robert 5 years ago committed by Frans de Jonge
parent 15fe0fef07
commit e655616876

@ -210,21 +210,43 @@ function CloudStorage:downloadFile(item)
local cs_settings = self:readSettings()
local download_dir = cs_settings:readSetting("download_dir") or lastdir
local path = download_dir .. '/' .. item.text
if lfs.attributes(path) then
UIManager:show(ConfirmBox:new{
text = _("File already exists. Would you like to overwrite it?"),
ok_callback = function()
self:cloudFile(item, path)
end
})
else
self:cloudFile(item, path)
end
self:cloudFile(item, path)
end
function CloudStorage:cloudFile(item, path)
local path_dir = path
local download_text = _("Downloading. This might take a moment.")
local function dropboxDownloadFile(unit_item, password, path_dir, callback_close)
UIManager:scheduleIn(1, function()
DropBox:downloadFile(unit_item, password, path_dir, callback_close)
end)
UIManager:show(InfoMessage:new{
text = download_text,
timeout = 1,
})
end
local function ftpDownloadFile(unit_item, address, username, password, path_dir, callback_close)
UIManager:scheduleIn(1, function()
Ftp:downloadFile(unit_item, address, username, password, path_dir, callback_close)
end)
UIManager:show(InfoMessage:new{
text = download_text,
timeout = 1,
})
end
local function webdavDownloadFile(unit_item, address, username, password, path_dir, callback_close)
UIManager:scheduleIn(1, function()
WebDav:downloadFile(unit_item, address, username, password, path_dir, callback_close)
end)
UIManager:show(InfoMessage:new{
text = download_text,
timeout = 1,
})
end
local path_dir = path
local overwrite_text = _("File already exists. Would you like to overwrite it?")
local buttons = {
{
{
@ -234,38 +256,47 @@ function CloudStorage:cloudFile(item, path)
local callback_close = function()
self:onClose()
end
UIManager:scheduleIn(1, function()
DropBox:downloadFile(item, self.password, path_dir, callback_close)
end)
UIManager:close(self.download_dialog)
UIManager:show(InfoMessage:new{
text = download_text,
timeout = 1,
})
if lfs.attributes(path) then
UIManager:show(ConfirmBox:new{
text = overwrite_text,
ok_callback = function()
dropboxDownloadFile(item, self.password, path_dir, callback_close)
end
})
else
dropboxDownloadFile(item, self.password, path_dir, callback_close)
end
elseif self.type == "ftp" then
local callback_close = function()
self:onClose()
end
UIManager:scheduleIn(1, function()
Ftp:downloadFile(item, self.address, self.username, self.password, path_dir, callback_close)
end)
UIManager:close(self.download_dialog)
UIManager:show(InfoMessage:new{
text = download_text,
timeout = 1,
})
if lfs.attributes(path) then
UIManager:show(ConfirmBox:new{
text = overwrite_text,
ok_callback = function()
ftpDownloadFile(item, self.address, self.username, self.password, path_dir, callback_close)
end
})
else
ftpDownloadFile(item, self.address, self.username, self.password, path_dir, callback_close)
end
elseif self.type == "webdav" then
local callback_close = function()
self:onClose()
end
UIManager:scheduleIn(1, function()
WebDav:downloadFile(item, self.address, self.username, self.password, path_dir, callback_close)
end)
UIManager:close(self.download_dialog)
UIManager:show(InfoMessage:new{
text = download_text,
timeout = 1,
})
if lfs.attributes(path) then
UIManager:show(ConfirmBox:new{
text = overwrite_text,
ok_callback = function()
webdavDownloadFile(item, self.address, self.username, self.password, path_dir, callback_close)
end
})
else
webdavDownloadFile(item, self.address, self.username, self.password, path_dir, callback_close)
end
end
end,
},

@ -1,9 +1,11 @@
local DropBoxApi = require("apps/cloudstorage/dropboxapi")
local ConfirmBox = require("ui/widget/confirmbox")
local DocumentRegistry = require("document/documentregistry")
local DropBoxApi = require("apps/cloudstorage/dropboxapi")
local InfoMessage = require("ui/widget/infomessage")
local MultiInputDialog = require("ui/widget/multiinputdialog")
local UIManager = require("ui/uimanager")
local ReaderUI = require("apps/reader/readerui")
local util = require("util")
local Screen = require("device").screen
local T = require("ffi/util").template
local _ = require("gettext")
@ -21,7 +23,8 @@ end
function DropBox:downloadFile(item, password, path, close)
local code_response = DropBoxApi:downloadFile(item.url, password, path)
if code_response == 200 then
if G_reader_settings:isTrue("show_unsupported") then
local __, filename = util.splitFilePathName(path)
if G_reader_settings:isTrue("show_unsupported") and not DocumentRegistry:hasProvider(filename) then
UIManager:show(InfoMessage:new{
text = T(_("File saved to:\n%1"), path),
})

@ -1,4 +1,5 @@
local ConfirmBox = require("ui/widget/confirmbox")
local DocumentRegistry = require("document/documentregistry")
local FtpApi = require("apps/cloudstorage/ftpapi")
local InfoMessage = require("ui/widget/infomessage")
local MultiInputDialog = require("ui/widget/multiinputdialog")
@ -26,7 +27,8 @@ function Ftp:downloadFile(item, address, user, pass, path, close)
local file = io.open(path, "w")
file:write(response)
file:close()
if G_reader_settings:isTrue("show_unsupported") then
local __, filename = util.splitFilePathName(path)
if G_reader_settings:isTrue("show_unsupported") and not DocumentRegistry:hasProvider(filename) then
UIManager:show(InfoMessage:new{
text = T(_("File saved to:\n%1"), path),
})

@ -1,9 +1,11 @@
local ConfirmBox = require("ui/widget/confirmbox")
local DocumentRegistry = require("document/documentregistry")
local InfoMessage = require("ui/widget/infomessage")
local MultiInputDialog = require("ui/widget/multiinputdialog")
local UIManager = require("ui/uimanager")
local ReaderUI = require("apps/reader/readerui")
local WebDavApi = require("apps/cloudstorage/webdavapi")
local util = require("util")
local _ = require("gettext")
local Screen = require("device").screen
local T = require("ffi/util").template
@ -17,7 +19,8 @@ end
function WebDav:downloadFile(item, address, username, password, local_path, close)
local code_response = WebDavApi:downloadFile(address .. WebDavApi:urlEncode( item.url ), username, password, local_path)
if code_response == 200 then
if G_reader_settings:isTrue("show_unsupported") then
local __, filename = util.splitFilePathName(local_path)
if G_reader_settings:isTrue("show_unsupported") and not DocumentRegistry:hasProvider(filename) then
UIManager:show(InfoMessage:new{
text = T(_("File saved to:\n%1"), local_path),
})

Loading…
Cancel
Save