mirror of
https://github.com/koreader/koreader
synced 2024-11-10 01:10:34 +00:00
0599c440cc
bidi.lua:
- Revert "Alias everything to Bidi.nowrap() when in LTR UI,
as using LTR isolates seems uneeded when already LTR" (part
of a628714f
) which was a wrong assumption: we need proper
wrappers for all things paths. Enhance some of these wrappers.
- Fix GetText RTL wrapping which was losing empty lines and
trailing \n.
- Wrap all paths, directories, filenames in the code with
these wrappers.
- Wrap all book metadata (title, authors...) with BD.auto(),
as it helps fixing some edge cases (like open/close quotation
marks which are not considered as bracket types by FriBiDi).
(Needed some minor logic changes in CoverBrowser.)
- Tweak hyphenation menu text
- Update forgotten SortWidget for UI mirroring
- KoptConfig: update "justification" index for RTL re-ordering,
following the recent addition of the page_gap_height option.
157 lines
5.3 KiB
Lua
157 lines
5.3 KiB
Lua
local BD = require("ui/bidi")
|
|
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
|
|
|
|
local WebDav = {}
|
|
|
|
function WebDav:run(address, user, pass, path)
|
|
return WebDavApi:listFolder(address, user, pass, path)
|
|
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
|
|
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"), BD.filepath(local_path)),
|
|
})
|
|
else
|
|
UIManager:show(ConfirmBox:new{
|
|
text = T(_("File saved to:\n%1\nWould you like to read the downloaded book now?"),
|
|
BD.filepath(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"), BD.filepath(local_path)),
|
|
timeout = 3,
|
|
})
|
|
end
|
|
end
|
|
|
|
function WebDav:config(item, callback)
|
|
local text_info = _([[Server address must be of the form http(s)://domain.name/path
|
|
This can point to a sub-directory of the WebDAV server.
|
|
The start folder is appended to the server path.]])
|
|
|
|
local hint_name = _("Server display name")
|
|
local text_name = ""
|
|
local hint_address = _("WebDAV address eg https://example.com/dav")
|
|
local text_address = ""
|
|
local hint_username = _("Username")
|
|
local text_username = ""
|
|
local hint_password = _("Password")
|
|
local text_password = ""
|
|
local hint_folder = _("Start folder")
|
|
local text_folder = ""
|
|
local title
|
|
local text_button_ok = _("Add")
|
|
if item then
|
|
title = _("Edit WebDAV account")
|
|
text_button_ok = _("Apply")
|
|
text_name = item.text
|
|
text_address = item.address
|
|
text_username = item.username
|
|
text_password = item.password
|
|
text_folder = item.url
|
|
else
|
|
title = _("Add WebDAV account")
|
|
end
|
|
self.settings_dialog = MultiInputDialog:new {
|
|
title = title,
|
|
fields = {
|
|
{
|
|
text = text_name,
|
|
input_type = "string",
|
|
hint = hint_name ,
|
|
},
|
|
{
|
|
text = text_address,
|
|
input_type = "string",
|
|
hint = hint_address ,
|
|
},
|
|
{
|
|
text = text_username,
|
|
input_type = "string",
|
|
hint = hint_username,
|
|
},
|
|
{
|
|
text = text_password,
|
|
input_type = "string",
|
|
text_type = "password",
|
|
hint = hint_password,
|
|
},
|
|
{
|
|
text = text_folder,
|
|
input_type = "string",
|
|
hint = hint_folder,
|
|
},
|
|
},
|
|
buttons = {
|
|
{
|
|
{
|
|
text = _("Cancel"),
|
|
callback = function()
|
|
self.settings_dialog:onClose()
|
|
UIManager:close(self.settings_dialog)
|
|
end
|
|
},
|
|
{
|
|
text = _("Info"),
|
|
callback = function()
|
|
UIManager:show(InfoMessage:new{ text = text_info })
|
|
end
|
|
},
|
|
{
|
|
text = text_button_ok,
|
|
callback = function()
|
|
local fields = MultiInputDialog:getFields()
|
|
if fields[1] ~= "" and fields[2] ~= "" then
|
|
if item then
|
|
-- edit
|
|
callback(item, fields)
|
|
else
|
|
-- add new
|
|
callback(fields)
|
|
end
|
|
self.settings_dialog:onClose()
|
|
UIManager:close(self.settings_dialog)
|
|
else
|
|
UIManager:show(InfoMessage:new{
|
|
text = _("Please fill in all fields.")
|
|
})
|
|
end
|
|
end
|
|
},
|
|
},
|
|
},
|
|
width = Screen:getWidth() * 0.95,
|
|
height = Screen:getHeight() * 0.2,
|
|
input_type = "text",
|
|
}
|
|
UIManager:show(self.settings_dialog)
|
|
self.settings_dialog:onShowKeyboard()
|
|
|
|
end
|
|
|
|
function WebDav:info(item)
|
|
local info_text = T(_"Type: %1\nName: %2\nAddress: %3", "WebDAV", item.text, item.address)
|
|
UIManager:show(InfoMessage:new{text = info_text})
|
|
end
|
|
|
|
return WebDav
|