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))
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ Generic device abstraction.
|
||||
This module defines stubs for common methods.
|
||||
--]]
|
||||
|
||||
local DataStorage = require("datastorage")
|
||||
local logger = require("logger")
|
||||
local util = require("util")
|
||||
local _ = require("gettext")
|
||||
@@ -503,6 +504,10 @@ function Device:isStartupScriptUpToDate()
|
||||
return true
|
||||
end
|
||||
|
||||
function Device:getDefaultCoverPath()
|
||||
return DataStorage:getDataDir() .. "/cover.jpg"
|
||||
end
|
||||
|
||||
--- Unpack an archive.
|
||||
-- Extract the contents of an archive, detecting its format by
|
||||
-- filename extension. Inspired by luarocks archive_unpack()
|
||||
|
||||
@@ -363,6 +363,10 @@ function PocketBook:getDeviceModel()
|
||||
return ffi.string(inkview.GetDeviceModel())
|
||||
end
|
||||
|
||||
function PocketBook:getDefaultCoverPath()
|
||||
return "/mnt/ext1/system/logo/offlogo/cover.bmp"
|
||||
end
|
||||
|
||||
-- Pocketbook HW rotation modes start from landsape, CCW
|
||||
local function landscape_ccw() return {
|
||||
1, 0, 3, 2, -- PORTRAIT, LANDSCAPE, PORTRAIT_180, LANDSCAPE_180
|
||||
|
||||
@@ -200,6 +200,10 @@ end
|
||||
|
||||
logger.info(string.format("Starting %s", rm_model))
|
||||
|
||||
function Remarkable:getDefaultCoverPath()
|
||||
return "/usr/share/remarkable/poweroff.png"
|
||||
end
|
||||
|
||||
if isRm2 then
|
||||
if not os.getenv("RM2FB_SHIM") then
|
||||
error("reMarkable2 requires RM2FB to work (https://github.com/ddvk/remarkable2-framebuffer)")
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user