[UX] Gestures: add action "Statistics calendar view"

Also flush current stats when showing calendar view.
reviewable/pr6040/r1
poire-z 4 years ago
parent 41aad475ce
commit 635f784dfd

@ -47,6 +47,7 @@ local action_strings = {
book_info = _("Book information"),
book_description = _("Book description"),
book_cover = _("Book cover"),
stats_calendar_view = _("Statistics calendar view"),
history = _("History"),
open_previous_document = _("Open previous document"),
@ -719,7 +720,7 @@ function ReaderGesture:buildMenu(ges, default)
{"show_plus_menu", self.is_docless},
{"folder_shortcuts", true, true},
{ "toc", not self.is_docless},
{"toc", not self.is_docless},
{"bookmarks", not self.is_docless},
{"reading_progress", ReaderGesture.getReaderProgress ~= nil},
{"book_statistics", not self.is_docless},
@ -733,6 +734,7 @@ function ReaderGesture:buildMenu(ges, default)
{"open_previous_document", true, true},
{"favorites", true},
{"filemanager", not self.is_docless, true},
{"stats_calendar_view", true, true},
{"dictionary_lookup", true},
{"wikipedia_lookup", true, true},
@ -1265,6 +1267,8 @@ function ReaderGesture:gestureAction(action, ges)
UIManager:show(ReaderGesture.getReaderProgress())
elseif action == "book_statistics" and ReaderGesture.getBookStats then
UIManager:show(ReaderGesture.getBookStats())
elseif action == "stats_calendar_view" and ReaderGesture.getCalendarView then
UIManager:show(ReaderGesture.getCalendarView())
elseif action == "toc" then
self.ui:handleEvent(Event:new("ShowToc"))
elseif action == "night_mode" then

@ -176,6 +176,10 @@ function ReaderStatistics:init()
}
return stats
end
ReaderGesture.getCalendarView = function()
return self:getCalendarView()
end
end
function ReaderStatistics:initData()
@ -866,17 +870,7 @@ The max value ensures a page you stay on for a long time (because you fell aslee
text = _("Calendar view"),
keep_menu_open = true,
callback = function()
local CalendarView = require("calendarview")
UIManager:show(CalendarView:new{
reader_statistics = self,
monthTranslation = monthTranslation,
shortDayOfWeekTranslation = shortDayOfWeekTranslation,
longDayOfWeekTranslation = longDayOfWeekTranslation,
start_day_of_week = self.calendar_start_day_of_week,
nb_book_spans = self.calendar_nb_book_spans,
show_hourly_histogram = self.calendar_show_histogram,
browse_future_months = self.calendar_browse_future_months,
})
UIManager:show(self:getCalendarView())
end,
},
},
@ -1977,6 +1971,21 @@ function ReaderStatistics:onReaderReady()
self.view.footer:updateFooter()
end
function ReaderStatistics:getCalendarView()
self:insertDB(self.id_curr_book)
local CalendarView = require("calendarview")
return CalendarView:new{
reader_statistics = self,
monthTranslation = monthTranslation,
shortDayOfWeekTranslation = shortDayOfWeekTranslation,
longDayOfWeekTranslation = longDayOfWeekTranslation,
start_day_of_week = self.calendar_start_day_of_week,
nb_book_spans = self.calendar_nb_book_spans,
show_hourly_histogram = self.calendar_show_histogram,
browse_future_months = self.calendar_browse_future_months,
}
end
-- Used by calendarview.lua CalendarView
function ReaderStatistics:getFirstTimestamp()
local sql_stmt = [[

Loading…
Cancel
Save