add activity indicator when configuring in reflow mode

For now pillow activityIndicator is used to draw animated waiting icon
at the upper left corner of the screen. So pillow service should be
enabled to use this feature, but eventually we should implement an
activity indicator that is independent of native system.
pull/82/head
chrox 11 years ago
parent 313525e961
commit 7f53ddacbe

@ -0,0 +1,43 @@
require "ui/device"
ReaderActivityIndicator = EventListener:new{}
function ReaderActivityIndicator:init()
local dev_mod = Device:getModel()
if dev_mod == "KindlePaperWhite" or dev_mod == "KindleTouch" then
require "liblipclua"
self.lipc_handle = lipc.init("com.github.koreader.activityindicator")
end
end
function ReaderActivityIndicator:onStartActivityIndicator()
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
end
function ReaderActivityIndicator:onStopActivityIndicator()
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
end

@ -109,6 +109,8 @@ function ReaderView:paintTo(bb, x, y)
if self.flipping_visible then
self.flipping:paintTo(bb, x, y)
end
-- stop activity indicator
self.ui:handleEvent(Event:new("StopActivityIndicator"))
end
function ReaderView:drawPageBackground(bb, x, y)

@ -17,6 +17,7 @@ require "ui/reader/readerhinting"
require "ui/reader/readerscreenshot"
require "ui/reader/readerfrontlight"
require "ui/reader/readerhyphenation"
require "ui/reader/readeractivityindicator"
--[[
This is an abstraction for a reader interface
@ -209,6 +210,14 @@ function ReaderUI:init()
document = self.document,
}
table.insert(self, coptlistener)
-- activity indicator
local activity_listener = ReaderActivityIndicator:new{
dialog = self.dialog,
view = self[1],
ui = self,
document = self.document,
}
table.insert(self, activity_listener)
end
--DEBUG(self.doc_settings)
-- we only read settings after all the widgets are initialized

@ -473,6 +473,7 @@ end
function ConfigDialog:onConfigChoice(option_name, option_value)
--DEBUG("config option value", option_name, option_value)
self.configurable[option_name] = option_value
self.ui:handleEvent(Event:new("StartActivityIndicator"))
end
function ConfigDialog:onConfigEvent(option_event, option_arg)

Loading…
Cancel
Save