Avoid writting highlights into read-only PDFs (#5889)

This commit is contained in:
Martín Fernández
2020-02-25 21:26:19 +01:00
committed by GitHub
parent 825b22dd6b
commit 5d103a41f8
2 changed files with 21 additions and 1 deletions

View File

@@ -1167,8 +1167,20 @@ end
--]]
function ReaderHighlight:exportToDocument(page, item)
local setting = G_reader_settings:readSetting("save_document")
if setting == "disable" then return end
logger.dbg("export highlight to document", item)
self.ui.document:saveHighlight(page, item)
local can_write = self.ui.document:saveHighlight(page, item)
if can_write == false and not self.warned_once then
self.warned_once = true
UIManager:show(InfoMessage:new{
text = _([[
Highlights in this document will be saved in the settings file, but they won't be written in the document itself because the file is in a read-only location.
If you wish your highlights to be saved in the document, just move it to a writable directory first.]]),
timeout = 5,
})
end
end
function ReaderHighlight:addNote()