2017-04-29 08:38:09 +00:00
|
|
|
local Blitbuffer = require("ffi/blitbuffer")
|
2016-11-04 21:35:20 +00:00
|
|
|
local CenterContainer = require("ui/widget/container/centercontainer")
|
2018-03-14 21:16:38 +00:00
|
|
|
local Device = require("device")
|
2017-04-29 08:38:09 +00:00
|
|
|
local Font = require("ui/font")
|
|
|
|
local FrameContainer = require("ui/widget/container/framecontainer")
|
2017-08-29 15:34:49 +00:00
|
|
|
local Geom = require("ui/geometry")
|
2018-09-21 13:48:40 +00:00
|
|
|
local GestureRange = require("ui/gesturerange")
|
2016-11-04 21:35:20 +00:00
|
|
|
local HorizontalGroup = require("ui/widget/horizontalgroup")
|
|
|
|
local HorizontalSpan = require("ui/widget/horizontalspan")
|
2017-04-29 08:38:09 +00:00
|
|
|
local InputContainer = require("ui/widget/container/inputcontainer")
|
|
|
|
local LeftContainer = require("ui/widget/container/leftcontainer")
|
2016-11-04 21:35:20 +00:00
|
|
|
local LineWidget = require("ui/widget/linewidget")
|
2017-04-29 08:38:09 +00:00
|
|
|
local ProgressWidget = require("ui/widget/progresswidget")
|
2017-09-13 14:56:20 +00:00
|
|
|
local Size = require("ui/size")
|
2016-11-04 21:35:20 +00:00
|
|
|
local TextWidget = require("ui/widget/textwidget")
|
2022-05-25 15:44:14 +00:00
|
|
|
local TextBoxWidget = require("ui/widget/textboxwidget")
|
2022-02-02 15:18:43 +00:00
|
|
|
local TitleBar = require("ui/widget/titlebar")
|
2016-11-04 21:35:20 +00:00
|
|
|
local UIManager = require("ui/uimanager")
|
2017-04-29 08:38:09 +00:00
|
|
|
local VerticalGroup = require("ui/widget/verticalgroup")
|
|
|
|
local VerticalSpan = require("ui/widget/verticalspan")
|
2016-11-04 21:35:20 +00:00
|
|
|
local util = require("util")
|
2017-04-29 08:38:09 +00:00
|
|
|
local _ = require("gettext")
|
2018-03-14 21:16:38 +00:00
|
|
|
local Screen = Device.screen
|
2016-11-04 21:35:20 +00:00
|
|
|
|
2019-03-14 19:58:45 +00:00
|
|
|
local LINE_COLOR = Blitbuffer.COLOR_WEB_GRAY
|
|
|
|
local BG_COLOR = Blitbuffer.COLOR_LIGHT_GRAY
|
2016-11-04 21:35:20 +00:00
|
|
|
|
|
|
|
local ReaderProgress = InputContainer:new{
|
2017-09-13 14:56:20 +00:00
|
|
|
padding = Size.padding.fullscreen,
|
2016-11-04 21:35:20 +00:00
|
|
|
}
|
|
|
|
|
2017-02-19 21:12:45 +00:00
|
|
|
local dayOfWeekTranslation = {
|
|
|
|
["Monday"] = _("Monday"),
|
|
|
|
["Tuesday"] = _("Tuesday"),
|
|
|
|
["Wednesday"] = _("Wednesday"),
|
|
|
|
["Thursday"] = _("Thursday"),
|
|
|
|
["Friday"] = _("Friday"),
|
|
|
|
["Saturday"] = _("Saturday"),
|
|
|
|
["Sunday"] = _("Sunday"),
|
|
|
|
}
|
|
|
|
|
2016-11-04 21:35:20 +00:00
|
|
|
function ReaderProgress:init()
|
2019-11-19 20:06:03 +00:00
|
|
|
self.current_pages = tostring(self.current_pages)
|
|
|
|
self.today_pages = tostring(self.today_pages)
|
2017-04-29 08:38:09 +00:00
|
|
|
self.small_font_face = Font:getFace("smallffont")
|
|
|
|
self.medium_font_face = Font:getFace("ffont")
|
|
|
|
self.large_font_face = Font:getFace("largeffont")
|
2017-09-13 14:56:20 +00:00
|
|
|
self.screen_width = Screen:getWidth()
|
|
|
|
self.screen_height = Screen:getHeight()
|
2020-06-12 23:56:36 +00:00
|
|
|
if self.screen_width < self.screen_height then
|
2018-07-15 08:04:48 +00:00
|
|
|
self.header_span = 25
|
|
|
|
self.stats_span = 20
|
|
|
|
else
|
|
|
|
self.header_span = 0
|
|
|
|
self.stats_span = 10
|
|
|
|
end
|
2016-11-04 21:35:20 +00:00
|
|
|
UIManager:setDirty(self, function()
|
|
|
|
return "ui", self.dimen
|
|
|
|
end)
|
2018-03-14 21:16:38 +00:00
|
|
|
if Device:hasKeys() then
|
|
|
|
self.key_events = {
|
|
|
|
--don't get locked in on non touch devices
|
|
|
|
AnyKeyPressed = { { Device.input.group.Any },
|
|
|
|
seqtext = "any key", doc = "close dialog" }
|
|
|
|
}
|
|
|
|
end
|
2018-09-21 13:48:40 +00:00
|
|
|
if Device:isTouchDevice() then
|
|
|
|
self.ges_events.Swipe = {
|
|
|
|
GestureRange:new{
|
|
|
|
ges = "swipe",
|
|
|
|
range = function() return self.dimen end,
|
|
|
|
}
|
|
|
|
}
|
2022-01-25 14:24:06 +00:00
|
|
|
self.ges_events.MultiSwipe = {
|
|
|
|
GestureRange:new{
|
|
|
|
ges = "multiswipe",
|
|
|
|
range = function() return self.dimen end,
|
|
|
|
}
|
|
|
|
}
|
2018-09-21 13:48:40 +00:00
|
|
|
end
|
Revamp "flash_ui" handling (#7118)
* Wherever possible, do an actual dumb invert on the Screen BB instead of repainting the widget, *then* inverting it (which is what the "invert" flag does).
* Instead of playing with nextTick/tickAfterNext delays, explicitly fence stuff with forceRePaint
* And, in the few cases where said Mk. 7 quirk kicks in, make the fences more marked by using a well-placed WAIT_FOR_UPDATE_COMPLETE
* Fix an issue in Button where show/hide & enable/disable where actually all toggles, which meant that duplicate calls or timing issues would do the wrong thing. (This broke dimming some icons, and mistakenly dropped the background from FM chevrons, for example).
* Speaking of, fix Button's hide/show to actually restore the background properly (there was a stupid typo in the variable name)
* Still in Button, fix the insanity of the double repaint on rounded buttons. Turns out it made sense, after all (and was related to said missing background, and bad interaction with invert & text with no background).
* KeyValuePage suffered from a similar issue with broken highlights (all black) because of missing backgrounds.
* In ConfigDialog, only instanciate IconButtons once (because every tab switch causes a full instantiation; and the initial display implies a full instanciation and an initial tab switch). Otherwise, both instances linger, and catch taps, and as such, double highlights.
* ConfigDialog: Restore the "don't repaint ReaderUI" when switching between similarly sized tabs (re #6131). I never could reproduce that on eInk, and I can't now on the emulator, so I'm assuming @poire-z fixed it during the swap to SVG icons.
* KeyValuePage: Only instanciate Buttons once (again, this is a widget that goes through a full init every page). Again, caused highlight/dimming issues because buttons were stacked.
* Menu: Ditto.
* TouchMenu: Now home of the gnarliest unhilight heuristics, because of the sheer amount of different things that can happen (and/or thanks to stuff not flagged covers_fullscreen properly ;p).
* Bump base
https://github.com/koreader/koreader-base/pull/1280
https://github.com/koreader/koreader-base/pull/1282
https://github.com/koreader/koreader-base/pull/1283
https://github.com/koreader/koreader-base/pull/1284
* Bump android-luajit-launcher
https://github.com/koreader/android-luajit-launcher/pull/284
https://github.com/koreader/android-luajit-launcher/pull/285
https://github.com/koreader/android-luajit-launcher/pull/286
https://github.com/koreader/android-luajit-launcher/pull/287
2021-01-10 00:51:09 +00:00
|
|
|
self.covers_fullscreen = true -- hint for UIManager:_repaint()
|
2016-11-04 21:35:20 +00:00
|
|
|
self[1] = FrameContainer:new{
|
|
|
|
width = self.width,
|
|
|
|
height = self.height,
|
|
|
|
background = Blitbuffer.COLOR_WHITE,
|
|
|
|
bordersize = 0,
|
|
|
|
padding = 0,
|
|
|
|
self:getStatusContent(self.screen_width),
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2017-08-29 15:34:49 +00:00
|
|
|
function ReaderProgress:getTotalStats(stats_day)
|
2016-11-04 21:35:20 +00:00
|
|
|
local total_time = 0
|
|
|
|
local total_pages = 0
|
2017-08-29 15:34:49 +00:00
|
|
|
for i=1, stats_day do
|
|
|
|
total_pages = total_pages + self.dates[i][1]
|
|
|
|
total_time = total_time + self.dates[i][2]
|
2016-11-04 21:35:20 +00:00
|
|
|
end
|
|
|
|
return total_time, total_pages
|
|
|
|
end
|
|
|
|
|
|
|
|
function ReaderProgress:getStatusContent(width)
|
2022-02-02 15:18:43 +00:00
|
|
|
local title_bar = TitleBar:new{
|
|
|
|
width = width,
|
|
|
|
bottom_v_padding = 0,
|
|
|
|
close_callback = not self.readonly and function() self:onClose() end,
|
|
|
|
show_parent = self,
|
|
|
|
}
|
2016-11-04 21:35:20 +00:00
|
|
|
return VerticalGroup:new{
|
|
|
|
align = "left",
|
2022-02-02 15:18:43 +00:00
|
|
|
title_bar,
|
2016-11-04 21:35:20 +00:00
|
|
|
self:genSingleHeader(_("Last week")),
|
|
|
|
self:genSummaryWeek(width),
|
|
|
|
self:genSingleHeader(_("Week progress")),
|
|
|
|
self:genWeekStats(7),
|
|
|
|
self:genDoubleHeader(_("Current"), _("Today") ),
|
|
|
|
self:genSummaryDay(width),
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
function ReaderProgress:genSingleHeader(title)
|
|
|
|
local header_title = TextWidget:new{
|
|
|
|
text = title,
|
|
|
|
face = self.medium_font_face,
|
|
|
|
fgcolor = LINE_COLOR,
|
|
|
|
}
|
|
|
|
local padding_span = HorizontalSpan:new{ width = self.padding }
|
|
|
|
local line_width = (self.screen_width - header_title:getSize().w) / 2 - self.padding * 2
|
|
|
|
local line_container = LeftContainer:new{
|
|
|
|
dimen = Geom:new{ w = line_width, h = self.screen_height / 25 },
|
|
|
|
LineWidget:new{
|
|
|
|
background = BG_COLOR,
|
|
|
|
dimen = Geom:new{
|
|
|
|
w = line_width,
|
2017-09-13 14:56:20 +00:00
|
|
|
h = Size.line.thick,
|
2016-11-04 21:35:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return VerticalGroup:new{
|
2018-07-15 08:04:48 +00:00
|
|
|
VerticalSpan:new{ width = Screen:scaleBySize(self.header_span), height = self.screen_height / 25 },
|
2016-11-04 21:35:20 +00:00
|
|
|
HorizontalGroup:new{
|
|
|
|
align = "center",
|
|
|
|
padding_span,
|
|
|
|
line_container,
|
|
|
|
padding_span,
|
|
|
|
header_title,
|
|
|
|
padding_span,
|
|
|
|
line_container,
|
|
|
|
padding_span,
|
|
|
|
},
|
2017-09-13 14:56:20 +00:00
|
|
|
VerticalSpan:new{ width = Size.span.vertical_large, height = self.screen_height / 25 },
|
2016-11-04 21:35:20 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
function ReaderProgress:genDoubleHeader(title_left, title_right)
|
|
|
|
local header_title_left = TextWidget:new{
|
|
|
|
text = title_left,
|
|
|
|
face = self.medium_font_face,
|
|
|
|
fgcolor = LINE_COLOR,
|
|
|
|
}
|
|
|
|
local header_title_right = TextWidget:new{
|
|
|
|
text = title_right,
|
|
|
|
face = self.medium_font_face,
|
|
|
|
fgcolor = LINE_COLOR,
|
|
|
|
}
|
|
|
|
local padding_span = HorizontalSpan:new{ width = self.padding }
|
|
|
|
local line_width = (self.screen_width - header_title_left:getSize().w - header_title_right:getSize().w - self.padding * 7) / 4
|
|
|
|
local line_container = LeftContainer:new{
|
|
|
|
dimen = Geom:new{ w = line_width, h = self.screen_height / 25 },
|
|
|
|
LineWidget:new{
|
|
|
|
background = BG_COLOR,
|
|
|
|
dimen = Geom:new{
|
|
|
|
w = line_width,
|
2017-09-13 14:56:20 +00:00
|
|
|
h = Size.line.thick,
|
2016-11-04 21:35:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return VerticalGroup:new{
|
|
|
|
VerticalSpan:new{ width = Screen:scaleBySize(25), height = self.screen_height / 25 },
|
|
|
|
HorizontalGroup:new{
|
|
|
|
align = "center",
|
|
|
|
padding_span,
|
|
|
|
line_container,
|
|
|
|
padding_span,
|
|
|
|
header_title_left,
|
|
|
|
padding_span,
|
|
|
|
line_container,
|
|
|
|
padding_span,
|
|
|
|
line_container,
|
|
|
|
padding_span,
|
|
|
|
header_title_right,
|
|
|
|
padding_span,
|
|
|
|
line_container,
|
|
|
|
padding_span,
|
|
|
|
},
|
2017-09-13 14:56:20 +00:00
|
|
|
VerticalSpan:new{ width = Size.span.vertical_large, height = self.screen_height / 25 },
|
2016-11-04 21:35:20 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
function ReaderProgress:genWeekStats(stats_day)
|
|
|
|
local second_in_day = 86400
|
|
|
|
local date_format_show
|
|
|
|
local select_day_time
|
2017-02-19 21:12:45 +00:00
|
|
|
local diff_time
|
2016-11-04 21:35:20 +00:00
|
|
|
local now_time = os.time()
|
2021-06-29 23:45:34 +00:00
|
|
|
local user_duration_format = G_reader_settings:readSetting("duration_format")
|
2016-11-04 21:35:20 +00:00
|
|
|
local height = Screen:scaleBySize(60)
|
|
|
|
local statistics_container = CenterContainer:new{
|
|
|
|
dimen = Geom:new{ w = self.screen_width , h = height },
|
|
|
|
}
|
|
|
|
local statistics_group = VerticalGroup:new{ align = "left" }
|
|
|
|
local max_week_time = -1
|
2017-08-29 15:34:49 +00:00
|
|
|
local day_time
|
|
|
|
for i=1, stats_day do
|
|
|
|
day_time = self.dates[i][2]
|
|
|
|
if day_time > max_week_time then max_week_time = day_time end
|
2016-11-04 21:35:20 +00:00
|
|
|
end
|
|
|
|
local top_padding_span = HorizontalSpan:new{ width = Screen:scaleBySize(15) }
|
|
|
|
local top_span_group = HorizontalGroup:new{
|
|
|
|
align = "center",
|
|
|
|
LeftContainer:new{
|
|
|
|
dimen = Geom:new{ h = Screen:scaleBySize(30) },
|
|
|
|
top_padding_span
|
|
|
|
},
|
|
|
|
}
|
|
|
|
table.insert(statistics_group, top_span_group)
|
|
|
|
|
|
|
|
local padding_span = HorizontalSpan:new{ width = Screen:scaleBySize(15) }
|
|
|
|
local span_group = HorizontalGroup:new{
|
|
|
|
align = "center",
|
|
|
|
LeftContainer:new{
|
2018-07-15 08:04:48 +00:00
|
|
|
dimen = Geom:new{ h = Screen:scaleBySize(self.stats_span) },
|
2016-11-04 21:35:20 +00:00
|
|
|
padding_span
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2017-08-29 15:34:49 +00:00
|
|
|
local j = 1
|
|
|
|
for i = 1, stats_day do
|
2017-02-19 21:12:45 +00:00
|
|
|
diff_time = now_time - second_in_day * (i - 1)
|
2017-08-29 15:34:49 +00:00
|
|
|
if self.dates[j][3] == os.date("%Y-%m-%d", diff_time) then
|
|
|
|
select_day_time = self.dates[j][2]
|
|
|
|
j = j + 1
|
2016-11-04 21:35:20 +00:00
|
|
|
else
|
|
|
|
select_day_time = 0
|
|
|
|
end
|
2017-02-19 21:12:45 +00:00
|
|
|
date_format_show = dayOfWeekTranslation[os.date("%A", diff_time)] .. os.date(" (%d.%m)", diff_time)
|
2016-11-04 21:35:20 +00:00
|
|
|
local total_group = HorizontalGroup:new{
|
|
|
|
align = "center",
|
2017-09-13 14:56:20 +00:00
|
|
|
padding = Size.padding.small,
|
2016-11-04 21:35:20 +00:00
|
|
|
LeftContainer:new{
|
|
|
|
dimen = Geom:new{ w = self.screen_width , h = height / 3 },
|
|
|
|
TextWidget:new{
|
2017-09-13 14:56:20 +00:00
|
|
|
padding = Size.padding.small,
|
2021-06-29 23:45:34 +00:00
|
|
|
text = date_format_show .. " - " .. util.secondsToClockDuration(user_duration_format, select_day_time, true),
|
2017-04-29 08:38:09 +00:00
|
|
|
face = Font:getFace("smallffont"),
|
2016-11-04 21:35:20 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
local titles_group = HorizontalGroup:new{
|
|
|
|
align = "center",
|
|
|
|
LeftContainer:new{
|
|
|
|
dimen = Geom:new{ w = self.screen_width , h = height / 3 },
|
|
|
|
ProgressWidget:new{
|
2020-06-12 23:56:36 +00:00
|
|
|
width = math.floor((self.screen_width * 0.005) + (self.screen_width * 0.9 * select_day_time / max_week_time)),
|
2016-11-04 21:35:20 +00:00
|
|
|
height = Screen:scaleBySize(14),
|
|
|
|
percentage = 1.0,
|
|
|
|
ticks = nil,
|
|
|
|
last = nil,
|
|
|
|
margin_h = 0,
|
|
|
|
margin_v = 0,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
table.insert(statistics_group, total_group)
|
|
|
|
table.insert(statistics_group, titles_group)
|
|
|
|
table.insert(statistics_group, span_group)
|
|
|
|
end --for i=1
|
|
|
|
table.insert(statistics_container, statistics_group)
|
|
|
|
return CenterContainer:new{
|
2020-06-12 23:56:36 +00:00
|
|
|
dimen = Geom:new{ w = math.floor(self.screen_width * 1.1), h = math.floor(self.screen_height * 0.5) },
|
2016-11-04 21:35:20 +00:00
|
|
|
statistics_container,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
function ReaderProgress:genSummaryDay(width)
|
|
|
|
local height = Screen:scaleBySize(60)
|
|
|
|
local statistics_container = CenterContainer:new{
|
|
|
|
dimen = Geom:new{ w = width, h = height },
|
|
|
|
}
|
|
|
|
local statistics_group = VerticalGroup:new{ align = "left" }
|
|
|
|
local tile_width = width / 4
|
|
|
|
local tile_height = height / 3
|
2021-06-29 23:45:34 +00:00
|
|
|
local user_duration_format = G_reader_settings:readSetting("duration_format")
|
2016-11-04 21:35:20 +00:00
|
|
|
|
|
|
|
local titles_group = HorizontalGroup:new{
|
|
|
|
align = "center",
|
|
|
|
CenterContainer:new{
|
|
|
|
dimen = Geom:new{ w = tile_width, h = tile_height },
|
|
|
|
TextWidget:new{
|
|
|
|
text = _("Pages"),
|
|
|
|
face = self.small_font_face,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
CenterContainer:new{
|
|
|
|
dimen = Geom:new{ w = tile_width, h = tile_height },
|
|
|
|
TextWidget:new{
|
|
|
|
text = _("Time"),
|
|
|
|
face = self.small_font_face,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
CenterContainer:new{
|
|
|
|
dimen = Geom:new{ w = tile_width, h = tile_height },
|
|
|
|
TextWidget:new{
|
|
|
|
text = _("Pages"),
|
|
|
|
face = self.small_font_face,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
CenterContainer:new{
|
|
|
|
dimen = Geom:new{ w = tile_width, h = tile_height },
|
|
|
|
TextWidget:new{
|
|
|
|
text = _("Time"),
|
|
|
|
face = self.small_font_face,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
local padding_span = HorizontalSpan:new{ width = Screen:scaleBySize(15) }
|
|
|
|
local span_group = HorizontalGroup:new{
|
|
|
|
align = "center",
|
|
|
|
LeftContainer:new{
|
2017-09-13 14:56:20 +00:00
|
|
|
dimen = Geom:new{ h = Size.span.horizontal_default },
|
2016-11-04 21:35:20 +00:00
|
|
|
padding_span
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
local data_group = HorizontalGroup:new{
|
|
|
|
align = "center",
|
|
|
|
CenterContainer:new{
|
|
|
|
dimen = Geom:new{ w = tile_width, h = tile_height },
|
|
|
|
TextWidget:new{
|
|
|
|
text = self.current_pages,
|
|
|
|
face = self.medium_font_face,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
CenterContainer:new{
|
|
|
|
dimen = Geom:new{ w = tile_width, h = tile_height },
|
|
|
|
TextWidget:new{
|
2021-06-29 23:45:34 +00:00
|
|
|
text = util.secondsToClockDuration(user_duration_format, self.current_duration, true),
|
2016-11-04 21:35:20 +00:00
|
|
|
face = self.medium_font_face,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
CenterContainer:new{
|
|
|
|
dimen = Geom:new{ w = tile_width, h = tile_height },
|
|
|
|
TextWidget:new{
|
2017-08-29 15:34:49 +00:00
|
|
|
text = self.today_pages,
|
2016-11-04 21:35:20 +00:00
|
|
|
face = self.medium_font_face,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
CenterContainer:new{
|
|
|
|
dimen = Geom:new{ w = tile_width, h = tile_height },
|
|
|
|
TextWidget:new{
|
2021-06-29 23:45:34 +00:00
|
|
|
text = util.secondsToClockDuration(user_duration_format, self.today_duration, true),
|
2016-11-04 21:35:20 +00:00
|
|
|
face = self.medium_font_face,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
table.insert(statistics_group, titles_group)
|
|
|
|
table.insert(statistics_group, span_group)
|
|
|
|
table.insert(statistics_group, data_group)
|
|
|
|
table.insert(statistics_group, span_group)
|
|
|
|
table.insert(statistics_group, span_group)
|
|
|
|
table.insert(statistics_container, statistics_group)
|
|
|
|
return CenterContainer:new{
|
2020-06-12 23:56:36 +00:00
|
|
|
dimen = Geom:new{ w = self.screen_width , h = math.floor(self.screen_height * 0.13) },
|
2016-11-04 21:35:20 +00:00
|
|
|
statistics_container,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
function ReaderProgress:genSummaryWeek(width)
|
|
|
|
local height = Screen:scaleBySize(60)
|
2017-08-29 15:34:49 +00:00
|
|
|
local total_time, total_pages = self:getTotalStats(#self.dates)
|
2016-11-04 21:35:20 +00:00
|
|
|
local statistics_container = CenterContainer:new{
|
|
|
|
dimen = Geom:new{ w = width, h = height },
|
|
|
|
}
|
|
|
|
local statistics_group = VerticalGroup:new{ align = "left" }
|
|
|
|
local tile_width = width / 4
|
|
|
|
local tile_height = height / 3
|
2021-06-29 23:45:34 +00:00
|
|
|
local user_duration_format = G_reader_settings:readSetting("duration_format")
|
2016-11-04 21:35:20 +00:00
|
|
|
local total_group = HorizontalGroup:new{
|
|
|
|
align = "center",
|
|
|
|
CenterContainer:new{
|
|
|
|
dimen = Geom:new{ w = tile_width, h = tile_height },
|
2022-05-25 15:44:14 +00:00
|
|
|
TextBoxWidget:new{
|
|
|
|
alignment = "center",
|
|
|
|
text = _("Total\npages"),
|
2016-11-04 21:35:20 +00:00
|
|
|
face = self.small_font_face,
|
2022-05-25 15:44:14 +00:00
|
|
|
width = tile_width * 0.95,
|
2016-11-04 21:35:20 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
CenterContainer:new{
|
|
|
|
dimen = Geom:new{ w = tile_width, h = tile_height },
|
2022-05-25 15:44:14 +00:00
|
|
|
TextBoxWidget:new{
|
|
|
|
alignment = "center",
|
|
|
|
text = _("Total\ntime"),
|
2016-11-04 21:35:20 +00:00
|
|
|
face = self.small_font_face,
|
2022-05-25 15:44:14 +00:00
|
|
|
width = tile_width * 0.95,
|
2016-11-04 21:35:20 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
CenterContainer:new{
|
|
|
|
dimen = Geom:new{ w = tile_width, h = tile_height },
|
2022-05-25 15:44:14 +00:00
|
|
|
TextBoxWidget:new{
|
|
|
|
alignment = "center",
|
|
|
|
text = _("Average\npages"),
|
2016-11-04 21:35:20 +00:00
|
|
|
face = self.small_font_face,
|
2022-05-25 15:44:14 +00:00
|
|
|
width = tile_width * 0.95,
|
2016-11-04 21:35:20 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
CenterContainer:new{
|
|
|
|
dimen = Geom:new{ w = tile_width, h = tile_height },
|
2022-05-25 15:44:14 +00:00
|
|
|
TextBoxWidget:new{
|
|
|
|
alignment = "center",
|
|
|
|
text = _("Average\ntime"),
|
2016-11-04 21:35:20 +00:00
|
|
|
face = self.small_font_face,
|
2022-05-25 15:44:14 +00:00
|
|
|
width = tile_width * 0.95,
|
2016-11-04 21:35:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
local padding_span = HorizontalSpan:new{ width = Screen:scaleBySize(15) }
|
|
|
|
local span_group = HorizontalGroup:new{
|
|
|
|
align = "center",
|
|
|
|
LeftContainer:new{
|
2017-09-13 14:56:20 +00:00
|
|
|
dimen = Geom:new{ h = Size.span.horizontal_default },
|
2016-11-04 21:35:20 +00:00
|
|
|
padding_span
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
local data_group = HorizontalGroup:new{
|
|
|
|
align = "center",
|
|
|
|
CenterContainer:new{
|
|
|
|
dimen = Geom:new{ w = tile_width, h = tile_height },
|
|
|
|
TextWidget:new{
|
2019-11-19 20:06:03 +00:00
|
|
|
text = tostring(total_pages),
|
2016-11-04 21:35:20 +00:00
|
|
|
face = self.medium_font_face,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
CenterContainer:new{
|
|
|
|
dimen = Geom:new{ w = tile_width, h = tile_height },
|
|
|
|
TextWidget:new{
|
2021-06-29 23:45:34 +00:00
|
|
|
text = util.secondsToClockDuration(user_duration_format, math.floor(total_time), true),
|
2016-11-04 21:35:20 +00:00
|
|
|
face = self.medium_font_face,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
CenterContainer:new{
|
|
|
|
dimen = Geom:new{ w = tile_width, h = tile_height },
|
|
|
|
TextWidget:new{
|
2019-11-19 20:06:03 +00:00
|
|
|
text = tostring(math.floor(total_pages / 7)),
|
2016-11-04 21:35:20 +00:00
|
|
|
face = self.medium_font_face,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
CenterContainer:new{
|
|
|
|
dimen = Geom:new{ w = tile_width, h = tile_height },
|
|
|
|
TextWidget:new{
|
2021-06-29 23:45:34 +00:00
|
|
|
text = util.secondsToClockDuration(user_duration_format, math.floor(total_time) / 7, true),
|
2016-11-04 21:35:20 +00:00
|
|
|
face = self.medium_font_face,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
table.insert(statistics_group, total_group)
|
|
|
|
table.insert(statistics_group, span_group)
|
|
|
|
table.insert(statistics_group, data_group)
|
|
|
|
table.insert(statistics_container, statistics_group)
|
|
|
|
return CenterContainer:new{
|
2020-06-12 23:56:36 +00:00
|
|
|
dimen = Geom:new{ w = self.screen_width , h = math.floor(self.screen_height * 0.10) },
|
2016-11-04 21:35:20 +00:00
|
|
|
statistics_container,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
function ReaderProgress:onAnyKeyPressed()
|
|
|
|
return self:onClose()
|
|
|
|
end
|
|
|
|
|
2018-09-21 13:48:40 +00:00
|
|
|
function ReaderProgress:onSwipe(arg, ges_ev)
|
|
|
|
if ges_ev.direction == "south" then
|
|
|
|
-- Allow easier closing with swipe up/down
|
|
|
|
self:onClose()
|
|
|
|
elseif ges_ev.direction == "east" or ges_ev.direction == "west" or ges_ev.direction == "north" then
|
|
|
|
-- no use for now
|
|
|
|
do end -- luacheck: ignore 541
|
|
|
|
else -- diagonal swipe
|
|
|
|
-- trigger full refresh
|
|
|
|
UIManager:setDirty(nil, "full")
|
|
|
|
-- a long diagonal swipe may also be used for taking a screenshot,
|
|
|
|
-- so let it propagate
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-01-25 14:24:06 +00:00
|
|
|
function ReaderProgress:onMultiSwipe(arg, ges_ev)
|
|
|
|
-- For consistency with other fullscreen widgets where swipe south can't be
|
|
|
|
-- used to close and where we then allow any multiswipe to close, allow any
|
|
|
|
-- multiswipe to close this widget too.
|
|
|
|
self:onClose()
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2016-11-04 21:35:20 +00:00
|
|
|
function ReaderProgress:onClose()
|
|
|
|
UIManager:close(self)
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
|
|
|
return ReaderProgress
|