mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
[plugin] Add a caching mechanism for CoverImage (#7510)
This commit is contained in:
@@ -392,7 +392,20 @@ function Device:canExecuteScript(file)
|
||||
end
|
||||
|
||||
function Device:isValidPath(path)
|
||||
return android.isPathInsideSandbox(path)
|
||||
-- the fast check
|
||||
if android.isPathInsideSandbox(path) then
|
||||
return true
|
||||
end
|
||||
|
||||
-- the thorough check
|
||||
local real_ext_storage = FFIUtil.realpath(android.getExternalStoragePath())
|
||||
local real_path = FFIUtil.realpath(path)
|
||||
|
||||
if real_path then
|
||||
return real_path:sub(1, #real_ext_storage) == real_ext_storage
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function Device:showLightDialog()
|
||||
@@ -432,6 +445,15 @@ function Device:untar(archive, extract_to)
|
||||
return android.untar(archive, extract_to)
|
||||
end
|
||||
|
||||
-- todo: Wouldn't we like an android.deviceIdentifier() method, so we can use better default paths?
|
||||
function Device:getDefaultCoverPath()
|
||||
if android.prop.product == "ntx_6sl" then -- Tolino HD4 and other
|
||||
return android.getExternalStoragePath() .. "/suspend_others.jpg"
|
||||
else
|
||||
return android.getExternalStoragePath() .. "/cover.jpg"
|
||||
end
|
||||
end
|
||||
|
||||
android.LOGI(string.format("Android %s - %s (API %d) - flavor: %s",
|
||||
android.prop.version, getCodename(), Device.firmware_rev, android.prop.flavor))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user