2013-10-18 20:38:07 +00:00
|
|
|
local EventListener = require("ui/widget/eventlistener")
|
2014-10-30 18:42:18 +00:00
|
|
|
local Device = require("device")
|
2014-06-04 09:22:45 +00:00
|
|
|
local util = require("ffi/util")
|
2013-10-18 20:38:07 +00:00
|
|
|
-- lipc
|
2013-04-21 08:54:59 +00:00
|
|
|
|
2013-10-18 20:38:07 +00:00
|
|
|
local ReaderActivityIndicator = EventListener:new{}
|
2013-04-21 08:54:59 +00:00
|
|
|
|
|
|
|
function ReaderActivityIndicator:init()
|
2014-10-30 18:42:18 +00:00
|
|
|
local dev_mod = Device.model
|
2015-09-05 01:33:11 +00:00
|
|
|
if dev_mod == "KindlePaperWhite" or dev_mod == "KindlePaperWhite2" or dev_mod == "KindleVoyage" or dev_mod == "KindleBasic" or dev_mod == "KindlePaperWhite3" or dev_mod == "KindleTouch" then
|
2015-01-12 16:14:56 +00:00
|
|
|
if (pcall(require, "liblipclua")) then
|
|
|
|
self.lipc_handle = lipc.init("com.github.koreader.activityindicator")
|
|
|
|
end
|
2014-03-13 13:52:43 +00:00
|
|
|
end
|
2013-04-21 08:54:59 +00:00
|
|
|
end
|
|
|
|
|
2014-06-04 09:22:45 +00:00
|
|
|
function ReaderActivityIndicator:onStartActivityIndicator()
|
2014-03-13 13:52:43 +00:00
|
|
|
if self.lipc_handle then
|
|
|
|
-- check if activity indicator is needed
|
|
|
|
if self.document.configurable.text_wrap == 1 then
|
|
|
|
-- start indicator depends on pillow being enabled
|
|
|
|
self.lipc_handle:set_string_property(
|
|
|
|
"com.lab126.pillow", "activityIndicator",
|
|
|
|
'{"activityIndicator":{ \
|
|
|
|
"action":"start","timeout":10000, \
|
|
|
|
"clientId":"com.github.koreader.activityindicator", \
|
|
|
|
"priority":true}}')
|
|
|
|
self.indicator_started = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return true
|
2013-04-21 08:54:59 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function ReaderActivityIndicator:onStopActivityIndicator()
|
2014-03-13 13:52:43 +00:00
|
|
|
if self.lipc_handle and self.indicator_started then
|
|
|
|
-- stop indicator depends on pillow being enabled
|
|
|
|
self.lipc_handle:set_string_property(
|
|
|
|
"com.lab126.pillow", "activityIndicator",
|
|
|
|
'{"activityIndicator":{ \
|
|
|
|
"action":"stop","timeout":10000, \
|
|
|
|
"clientId":"com.github.koreader.activityindicator", \
|
|
|
|
"priority":true}}')
|
|
|
|
self.indicator_started = false
|
|
|
|
util.usleep(1000000)
|
|
|
|
end
|
|
|
|
return true
|
2013-04-21 08:54:59 +00:00
|
|
|
end
|
2013-10-18 20:38:07 +00:00
|
|
|
|
2014-07-04 18:10:38 +00:00
|
|
|
function ReaderActivityIndicator:coda()
|
|
|
|
if self.lipc_handle then
|
|
|
|
self.lipc_handle:close()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-10-18 20:38:07 +00:00
|
|
|
return ReaderActivityIndicator
|