From cbba7566b7fbb96a9eab9fd750102c81270b47a8 Mon Sep 17 00:00:00 2001 From: Robert Date: Sun, 21 Jul 2019 21:45:02 +0200 Subject: [PATCH] Cloudstorage - Add option to view unsupported files (#5131) Option to show all files in cloudstorage also not supported by KOReader. We can also download any file. To show all files in CS we need to enable option Show unsupported files in file manager (introducing in #5129) Close: #5006 --- frontend/apps/cloudstorage/dropbox.lua | 22 ++++++++++++++-------- frontend/apps/cloudstorage/dropboxapi.lua | 3 ++- frontend/apps/cloudstorage/ftp.lua | 22 ++++++++++++++-------- frontend/apps/cloudstorage/ftpapi.lua | 3 ++- frontend/apps/cloudstorage/webdav.lua | 22 ++++++++++++++-------- frontend/apps/cloudstorage/webdavapi.lua | 3 ++- 6 files changed, 48 insertions(+), 27 deletions(-) diff --git a/frontend/apps/cloudstorage/dropbox.lua b/frontend/apps/cloudstorage/dropbox.lua index 62fed5354..5113d27fc 100644 --- a/frontend/apps/cloudstorage/dropbox.lua +++ b/frontend/apps/cloudstorage/dropbox.lua @@ -17,14 +17,20 @@ end function DropBox:downloadFile(item, password, path, close) local code_response = DropBoxApi:downloadFile(item.url, password, path) if code_response == 200 then - UIManager:show(ConfirmBox:new{ - text = T(_("File saved to:\n %1\nWould you like to read the downloaded book now?"), - path), - ok_callback = function() - close() - ReaderUI:showReader(path) - end - }) + if G_reader_settings:isTrue("show_unsupported") then + UIManager:show(InfoMessage:new{ + text = T(_("File saved to:\n%1"), path), + }) + else + UIManager:show(ConfirmBox:new{ + text = T(_("File saved to:\n %1\nWould you like to read the downloaded book now?"), + path), + ok_callback = function() + close() + ReaderUI:showReader(path) + end + }) + end else UIManager:show(InfoMessage:new{ text = T(_("Could not save file to:\n%1"), path), diff --git a/frontend/apps/cloudstorage/dropboxapi.lua b/frontend/apps/cloudstorage/dropboxapi.lua index 212a5d68a..d7bcfc382 100644 --- a/frontend/apps/cloudstorage/dropboxapi.lua +++ b/frontend/apps/cloudstorage/dropboxapi.lua @@ -107,7 +107,8 @@ function DropBoxApi:listFolder(path, token) type = tag, }) --show only file with supported formats - elseif tag == "file" and DocumentRegistry:hasProvider(text) then + elseif tag == "file" and (DocumentRegistry:hasProvider(text) + or G_reader_settings:isTrue("show_unsupported")) then table.insert(dropbox_file, { text = text, url = files.path_display, diff --git a/frontend/apps/cloudstorage/ftp.lua b/frontend/apps/cloudstorage/ftp.lua index 2c4c7a7c4..7c2ff1435 100644 --- a/frontend/apps/cloudstorage/ftp.lua +++ b/frontend/apps/cloudstorage/ftp.lua @@ -26,14 +26,20 @@ function Ftp:downloadFile(item, address, user, pass, path, close) local file = io.open(path, "w") file:write(response) file:close() - UIManager:show(ConfirmBox:new{ - text = T(_("File saved to:\n %1\nWould you like to read the downloaded book now?"), - path), - ok_callback = function() - close() - ReaderUI:showReader(path) - end - }) + if G_reader_settings:isTrue("show_unsupported") then + UIManager:show(InfoMessage:new{ + text = T(_("File saved to:\n%1"), path), + }) + else + UIManager:show(ConfirmBox:new{ + text = T(_("File saved to:\n %1\nWould you like to read the downloaded book now?"), + path), + ok_callback = function() + close() + ReaderUI:showReader(path) + end + }) + end else UIManager:show(InfoMessage:new{ text = T(_("Could not save file to:\n%1"), path), diff --git a/frontend/apps/cloudstorage/ftpapi.lua b/frontend/apps/cloudstorage/ftpapi.lua index 5a4eac8fb..78115f8fa 100644 --- a/frontend/apps/cloudstorage/ftpapi.lua +++ b/frontend/apps/cloudstorage/ftpapi.lua @@ -54,7 +54,8 @@ function FtpApi:listFolder(address_path, folder_path) type = type, }) --show only file with supported formats - elseif extension and DocumentRegistry:hasProvider(item) then + elseif extension and (DocumentRegistry:hasProvider(item) + or G_reader_settings:isTrue("show_unsupported")) then type = "file" table.insert(ftp_file, { text = file_name, diff --git a/frontend/apps/cloudstorage/webdav.lua b/frontend/apps/cloudstorage/webdav.lua index 8388ed1b2..29a5d623a 100644 --- a/frontend/apps/cloudstorage/webdav.lua +++ b/frontend/apps/cloudstorage/webdav.lua @@ -17,14 +17,20 @@ 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 - UIManager:show(ConfirmBox:new{ - text = T(_("File saved to:\n%1\nWould you like to read the downloaded book now?"), - local_path), - ok_callback = function() - close() - ReaderUI:showReader(local_path) - end - }) + if G_reader_settings:isTrue("show_unsupported") then + UIManager:show(InfoMessage:new{ + text = T(_("File saved to:\n%1"), local_path), + }) + else + UIManager:show(ConfirmBox:new{ + text = T(_("File saved to:\n%1\nWould you like to read the downloaded book now?"), + local_path), + ok_callback = function() + close() + ReaderUI:showReader(local_path) + end + }) + end else UIManager:show(InfoMessage:new{ text = T(_("Could not save file to:\n%1"), local_path), diff --git a/frontend/apps/cloudstorage/webdavapi.lua b/frontend/apps/cloudstorage/webdavapi.lua index 41c45f041..dbb354a19 100644 --- a/frontend/apps/cloudstorage/webdavapi.lua +++ b/frontend/apps/cloudstorage/webdavapi.lua @@ -114,7 +114,8 @@ function WebDavApi:listFolder(address, user, pass, folder_path) type = "folder", }) end - elseif item:find("") and DocumentRegistry:hasProvider(item_name) then + elseif item:find("") and (DocumentRegistry:hasProvider(item_name) + or G_reader_settings:isTrue("show_unsupported")) then table.insert(webdav_file, { text = item_name, url = util.urlDecode( item_path ),