From 825a3c4b52e61ff0398de533fce4954829419eed Mon Sep 17 00:00:00 2001 From: Robert Date: Sat, 3 Aug 2019 10:40:20 +0200 Subject: [PATCH] Add gesture - show current book statistics (#5167) --- frontend/apps/reader/modules/readergesture.lua | 5 +++++ plugins/statistics.koplugin/main.lua | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/frontend/apps/reader/modules/readergesture.lua b/frontend/apps/reader/modules/readergesture.lua index 2a0913b11..719342bcc 100644 --- a/frontend/apps/reader/modules/readergesture.lua +++ b/frontend/apps/reader/modules/readergesture.lua @@ -38,6 +38,7 @@ local action_strings = { toc = _("Table of contents"), bookmarks = _("Bookmarks"), reading_progress = _("Reading progress"), + book_statistics = _("Book statistics"), book_status = _("Book status"), book_info = _("Book information"), book_description = _("Book description"), @@ -617,6 +618,8 @@ function ReaderGesture:buildMenu(ges, default) { "toc", not self.is_docless}, {"bookmarks", not self.is_docless}, {"reading_progress", ReaderGesture.getReaderProgress ~= nil}, + {"book_statistics", not self.is_docless}, + {"book_status", not self.is_docless}, {"book_info", not self.is_docless}, {"book_description", not self.is_docless}, @@ -1076,6 +1079,8 @@ function ReaderGesture:gestureAction(action, ges) return elseif action == "reading_progress" and ReaderGesture.getReaderProgress then UIManager:show(ReaderGesture.getReaderProgress()) + elseif action == "book_statistics" and ReaderGesture.getBookStats then + UIManager:show(ReaderGesture.getBookStats()) elseif action == "toc" then self.ui:handleEvent(Event:new("ShowToc")) elseif action == "night_mode" then diff --git a/plugins/statistics.koplugin/main.lua b/plugins/statistics.koplugin/main.lua index 684932c91..321c5cb61 100755 --- a/plugins/statistics.koplugin/main.lua +++ b/plugins/statistics.koplugin/main.lua @@ -145,6 +145,14 @@ function ReaderStatistics:init() return readingprogress end + ReaderGesture.getBookStats = function() + if self:isDocless() or not self.is_enabled then return end + local stats = KeyValuePage:new{ + title = _("Statistics"), + kv_pairs = self:getCurrentStat(self.id_curr_book), + } + return stats + end end function ReaderStatistics:initData()