Statistics plugin v2 (SQLite) (#2893)

This commit is contained in:
Robert
2017-08-29 17:34:49 +02:00
committed by Frans de Jonge
parent efac2721bf
commit 0e2d20353a
3 changed files with 949 additions and 401 deletions

View File

@@ -208,6 +208,7 @@ function ReaderFooter:init()
if self.settings.auto_refresh_time then
self:setupAutoRefreshTime()
end
self.average_time_per_page = nil
end
function ReaderFooter:setupAutoRefreshTime()
@@ -496,12 +497,9 @@ function ReaderFooter:setTocMarkers()
end
function ReaderFooter:getDataFromStatistics(title, pages)
local statistics_data = self.ui.doc_settings:readSetting("stats")
local sec = 'na'
if statistics_data and statistics_data.performance_in_pages then
local read_pages = util.tableSize(statistics_data.performance_in_pages)
local average_time_per_page = statistics_data.total_time_in_sec / read_pages
sec = util.secondsToClock(pages * average_time_per_page, true)
if self.average_time_per_page then
sec = util.secondsToClock(pages * self.average_time_per_page, true)
end
return title .. sec
end
@@ -684,6 +682,11 @@ function ReaderFooter:onSuspend()
end
end
function ReaderFooter:onUpdateStats(avg_time_page)
self.average_time_per_page = avg_time_page
return true
end
function ReaderFooter:onFrontlightStateChanged()
if self.settings.frontlight then
self:updateFooter()