2014-06-01 15:53:09 +00:00
|
|
|
local A = require("android")
|
2014-06-03 14:35:29 +00:00
|
|
|
A.dl.library_path = A.dl.library_path .. ":" .. A.dir .. "/libs"
|
2016-03-14 02:49:13 +00:00
|
|
|
A.log_name = 'KOReader'
|
2014-06-01 15:53:09 +00:00
|
|
|
|
2015-06-15 08:46:43 +00:00
|
|
|
local ffi = require("ffi")
|
2018-06-02 16:10:55 +00:00
|
|
|
local C = ffi.C
|
2015-06-15 08:46:43 +00:00
|
|
|
ffi.cdef[[
|
|
|
|
char *getenv(const char *name);
|
|
|
|
int putenv(const char *envvar);
|
|
|
|
]]
|
|
|
|
|
2014-10-28 18:27:29 +00:00
|
|
|
-- check uri of the intent that starts this application
|
|
|
|
local file = A.jni:context(A.app.activity.vm, function(JNI)
|
|
|
|
local uri = JNI:callObjectMethod(
|
|
|
|
JNI:callObjectMethod(
|
|
|
|
A.app.activity.clazz,
|
|
|
|
"getIntent",
|
|
|
|
"()Landroid/content/Intent;"
|
|
|
|
),
|
|
|
|
"getData",
|
|
|
|
"()Landroid/net/Uri;"
|
|
|
|
)
|
|
|
|
if uri ~= nil then
|
|
|
|
local path = JNI:callObjectMethod(
|
|
|
|
uri,
|
|
|
|
"getPath",
|
|
|
|
"()Ljava/lang/String;"
|
|
|
|
)
|
|
|
|
return JNI:to_string(path)
|
|
|
|
end
|
|
|
|
end)
|
2018-12-29 19:48:19 +00:00
|
|
|
|
|
|
|
if file ~= nil then
|
|
|
|
A.LOGI("intent file path " .. file)
|
|
|
|
end
|
2014-10-28 18:27:29 +00:00
|
|
|
|
2016-03-13 15:42:58 +00:00
|
|
|
-- update koreader from ota
|
|
|
|
local function update()
|
|
|
|
local new_update = "/sdcard/koreader/ota/koreader.update.tar"
|
|
|
|
local installed = "/sdcard/koreader/ota/koreader.installed.tar"
|
|
|
|
local update_file = io.open(new_update, "r")
|
|
|
|
if update_file ~= nil then
|
|
|
|
io.close(update_file)
|
2016-06-23 17:50:24 +00:00
|
|
|
A.showProgress()
|
2016-03-13 15:42:58 +00:00
|
|
|
if os.execute("tar xf " .. new_update) == 0 then
|
|
|
|
os.execute("mv " .. new_update .. " " .. installed)
|
|
|
|
end
|
2016-06-23 17:50:24 +00:00
|
|
|
A.dismissProgress()
|
2016-03-13 15:42:58 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2017-09-23 21:58:34 +00:00
|
|
|
-- (Disabled, since we hide navbar on start now no need for this hack)
|
2015-03-20 02:03:17 +00:00
|
|
|
-- run koreader patch before koreader startup
|
2017-09-27 19:45:07 +00:00
|
|
|
pcall(dofile, "/sdcard/koreader/patch.lua")
|
2015-03-20 02:03:17 +00:00
|
|
|
|
2015-04-15 12:28:32 +00:00
|
|
|
-- set proper permission for sdcv
|
2015-04-22 06:27:05 +00:00
|
|
|
A.execute("chmod", "755", "./sdcv")
|
2016-03-13 15:42:58 +00:00
|
|
|
A.execute("chmod", "755", "./tar")
|
|
|
|
A.execute("chmod", "755", "./zsync")
|
2015-04-15 12:28:32 +00:00
|
|
|
|
2015-06-15 08:46:43 +00:00
|
|
|
-- set TESSDATA_PREFIX env var
|
2018-06-02 16:10:55 +00:00
|
|
|
C.putenv("TESSDATA_PREFIX=/sdcard/koreader/data")
|
2015-06-15 08:46:43 +00:00
|
|
|
|
2014-10-16 01:24:59 +00:00
|
|
|
-- create fake command-line arguments
|
2014-10-28 18:27:29 +00:00
|
|
|
arg = {"-d", file or "/sdcard"}
|
2014-06-01 15:53:09 +00:00
|
|
|
dofile(A.dir.."/reader.lua")
|