mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Clarify our OOP semantics across the codebase (#9586)
Basically: * Use `extend` for class definitions * Use `new` for object instantiations That includes some minor code cleanups along the way: * Updated `Widget`'s docs to make the semantics clearer. * Removed `should_restrict_JIT` (it's been dead code since https://github.com/koreader/android-luajit-launcher/pull/283) * Minor refactoring of LuaSettings/LuaData/LuaDefaults/DocSettings to behave (mostly, they are instantiated via `open` instead of `new`) like everything else and handle inheritance properly (i.e., DocSettings is now a proper LuaSettings subclass). * Default to `WidgetContainer` instead of `InputContainer` for stuff that doesn't actually setup key/gesture events. * Ditto for explicit `*Listener` only classes, make sure they're based on `EventListener` instead of something uselessly fancier. * Unless absolutely necessary, do not store references in class objects, ever; only values. Instead, always store references in instances, to avoid both sneaky inheritance issues, and sneaky GC pinning of stale references. * ReaderUI: Fix one such issue with its `active_widgets` array, with critical implications, as it essentially pinned *all* of ReaderUI's modules, including their reference to the `Document` instance (i.e., that was a big-ass leak). * Terminal: Make sure the shell is killed on plugin teardown. * InputText: Fix Home/End/Del physical keys to behave sensibly. * InputContainer/WidgetContainer: If necessary, compute self.dimen at paintTo time (previously, only InputContainers did, which might have had something to do with random widgets unconcerned about input using it as a baseclass instead of WidgetContainer...). * OverlapGroup: Compute self.dimen at *init* time, because for some reason it needs to do that, but do it directly in OverlapGroup instead of going through a weird WidgetContainer method that it was the sole user of. * ReaderCropping: Under no circumstances should a Document instance member (here, self.bbox) risk being `nil`ed! * Kobo: Minor code cleanups.
This commit is contained in:
@@ -21,7 +21,7 @@ if not util.pathExists("dropbear") then
|
||||
return { disabled = true, }
|
||||
end
|
||||
|
||||
local SSH = WidgetContainer:new{
|
||||
local SSH = WidgetContainer:extend{
|
||||
name = "SSH",
|
||||
is_doc_only = false,
|
||||
}
|
||||
|
||||
@@ -23,7 +23,9 @@ local DEFAULT_AUTODIM_DURATION_S = 5
|
||||
local DEFAULT_AUTODIM_FRACTION = 20
|
||||
local AUTODIM_EVENT_FREQUENCY = 2 -- in Hz; Frequenzy for FrontlightChangedEvent on E-Ink devices
|
||||
|
||||
local AutoDim = WidgetContainer:new{ name = "autodim" }
|
||||
local AutoDim = WidgetContainer:extend{
|
||||
name = "autodim",
|
||||
}
|
||||
|
||||
function AutoDim:init()
|
||||
self.autodim_starttime_m = G_reader_settings:readSetting("autodim_starttime_minutes", -1)
|
||||
|
||||
@@ -92,7 +92,7 @@ end
|
||||
|
||||
AutoFrontlight:init()
|
||||
|
||||
local AutoFrontlightWidget = WidgetContainer:new{
|
||||
local AutoFrontlightWidget = WidgetContainer:extend{
|
||||
name = "autofrontlight",
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ local SpinWidget = require("ui/widget/spinwidget")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
|
||||
local AutoStandby = WidgetContainer:new{
|
||||
local AutoStandby = WidgetContainer:extend{
|
||||
is_doc_only = false,
|
||||
name = "autostandby",
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ local default_autoshutdown_timeout_seconds = 3*24*60*60 -- three days
|
||||
local default_auto_suspend_timeout_seconds = 15*60 -- 15 minutes
|
||||
local default_auto_standby_timeout_seconds = 4 -- 4 seconds; should be safe on Kobo/Sage
|
||||
|
||||
local AutoSuspend = WidgetContainer:new{
|
||||
local AutoSuspend = WidgetContainer:extend{
|
||||
name = "autosuspend",
|
||||
is_doc_only = false,
|
||||
autoshutdown_timeout_seconds = default_autoshutdown_timeout_seconds,
|
||||
|
||||
@@ -9,7 +9,7 @@ local util = require("util")
|
||||
local _ = require("gettext")
|
||||
local T = require("ffi/util").template
|
||||
|
||||
local AutoTurn = WidgetContainer:new{
|
||||
local AutoTurn = WidgetContainer:extend{
|
||||
name = "autoturn",
|
||||
is_doc_only = true,
|
||||
autoturn_sec = 0,
|
||||
|
||||
@@ -43,10 +43,10 @@ local function frac(x)
|
||||
return x - math.floor(x)
|
||||
end
|
||||
|
||||
local AutoWarmth = WidgetContainer:new{
|
||||
local AutoWarmth = WidgetContainer:extend{
|
||||
name = "autowarmth",
|
||||
sched_times_s = {},
|
||||
sched_warmths = {},
|
||||
sched_times_s = nil, -- array
|
||||
sched_warmths = nil, -- array
|
||||
fl_turned_off = nil -- true/false if autowarmth has toggled the frontlight
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ function CommandRunner:createEnvironment()
|
||||
end
|
||||
|
||||
function CommandRunner:start(job)
|
||||
assert(self ~= nil)
|
||||
assert(self.pio == nil)
|
||||
assert(self.job == nil)
|
||||
self.job = job
|
||||
@@ -51,7 +50,6 @@ end
|
||||
-- @return a table contains the result from luawrapper.sh. Returns nil if the
|
||||
-- command has not been finished.
|
||||
function CommandRunner:poll()
|
||||
assert(self ~= nil)
|
||||
assert(self.pio ~= nil)
|
||||
assert(self.job ~= nil)
|
||||
local line = self.pio:read()
|
||||
@@ -87,7 +85,6 @@ end
|
||||
--- Whether this is a running job.
|
||||
-- @treturn boolean
|
||||
function CommandRunner:pending()
|
||||
assert(self ~= nil)
|
||||
return self.pio ~= nil
|
||||
end
|
||||
|
||||
|
||||
@@ -115,7 +115,6 @@ function BackgroundRunner:_shouldRepeat(job)
|
||||
end
|
||||
|
||||
function BackgroundRunner:_finishJob(job)
|
||||
assert(self ~= nil)
|
||||
if type(job.executable) == "function" then
|
||||
local time_diff = job.end_time - job.start_time
|
||||
local threshold = time.s(1)
|
||||
@@ -159,7 +158,6 @@ end
|
||||
|
||||
--- Polls the status of the pending CommandRunner.
|
||||
function BackgroundRunner:_poll()
|
||||
assert(self ~= nil)
|
||||
assert(CommandRunner:pending())
|
||||
local result = CommandRunner:poll()
|
||||
if result == nil then return end
|
||||
@@ -169,7 +167,6 @@ end
|
||||
|
||||
function BackgroundRunner:_execute()
|
||||
logger.dbg("BackgroundRunner: _execute() @ ", os.time())
|
||||
assert(self ~= nil)
|
||||
if CommandRunner:pending() then
|
||||
self:_poll()
|
||||
else
|
||||
@@ -236,7 +233,6 @@ function BackgroundRunner:_execute()
|
||||
end
|
||||
|
||||
function BackgroundRunner:_schedule()
|
||||
assert(self ~= nil)
|
||||
if self.running == false then
|
||||
if #self.jobs == 0 and not CommandRunner:pending() then
|
||||
logger.dbg("BackgroundRunnerWidget: no job, not running @ ", os.time())
|
||||
@@ -252,14 +248,13 @@ function BackgroundRunner:_schedule()
|
||||
end
|
||||
|
||||
function BackgroundRunner:_insert(job)
|
||||
assert(self ~= nil)
|
||||
job.insert_time = UIManager:getTime()
|
||||
table.insert(self.jobs, job)
|
||||
end
|
||||
|
||||
BackgroundRunner:_schedule()
|
||||
|
||||
local BackgroundRunnerWidget = WidgetContainer:new{
|
||||
local BackgroundRunnerWidget = WidgetContainer:extend{
|
||||
name = "backgroundrunner",
|
||||
runner = BackgroundRunner,
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ end
|
||||
|
||||
BatteryStat:init()
|
||||
|
||||
local BatteryStatWidget = WidgetContainer:new{
|
||||
local BatteryStatWidget = WidgetContainer:extend{
|
||||
name = "batterystat",
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ local util = require("util")
|
||||
local _ = require("gettext")
|
||||
local T = FFIUtil.template
|
||||
|
||||
local BookShortcuts = WidgetContainer:new{
|
||||
local BookShortcuts = WidgetContainer:extend{
|
||||
name = "bookshortcuts",
|
||||
shortcuts = LuaSettings:open(DataStorage:getSettingsDir() .. "/bookshortcuts.lua"),
|
||||
updated = false,
|
||||
|
||||
@@ -20,7 +20,7 @@ local _ = require("gettext")
|
||||
local C_ = _.pgettext
|
||||
local T = require("ffi/util").template
|
||||
|
||||
local Calibre = WidgetContainer:new{
|
||||
local Calibre = WidgetContainer:extend{
|
||||
name = "calibre",
|
||||
is_doc_only = false,
|
||||
}
|
||||
|
||||
@@ -9,11 +9,11 @@ local Device = require("device")
|
||||
local DocumentRegistry = require("document/documentregistry")
|
||||
local InputDialog = require("ui/widget/inputdialog")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local Menu = require("ui/widget/menu")
|
||||
local Persist = require("persist")
|
||||
local Screen = require("device").screen
|
||||
local UIManager = require("ui/uimanager")
|
||||
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
||||
local lfs = require("libs/libkoreader-lfs")
|
||||
local logger = require("logger")
|
||||
local rapidjson = require("rapidjson")
|
||||
@@ -155,7 +155,8 @@ local function getBookInfo(book)
|
||||
size)
|
||||
end
|
||||
|
||||
local CalibreSearch = InputContainer:new{
|
||||
-- This is a singleton
|
||||
local CalibreSearch = WidgetContainer:extend{
|
||||
books = {},
|
||||
libraries = {},
|
||||
last_scan = {},
|
||||
|
||||
@@ -10,11 +10,11 @@ local CalibreSearch = require("search")
|
||||
local ConfirmBox = require("ui/widget/confirmbox")
|
||||
local Device = require("device")
|
||||
local FFIUtil = require("ffi/util")
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local InputDialog = require("ui/widget/inputdialog")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local NetworkMgr = require("ui/network/manager")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
||||
local lfs = require("libs/libkoreader-lfs")
|
||||
local logger = require("logger")
|
||||
local rapidjson = require("rapidjson")
|
||||
@@ -55,7 +55,7 @@ local function updateDir(dir)
|
||||
end
|
||||
end
|
||||
|
||||
local CalibreWireless = InputContainer:new{
|
||||
local CalibreWireless = WidgetContainer:extend{
|
||||
id = "KOReader",
|
||||
model = require("device").model,
|
||||
version = require("version"):getCurrentRevision(),
|
||||
@@ -85,10 +85,11 @@ local CalibreWireless = InputContainer:new{
|
||||
SET_CALIBRE_DEVICE_NAME = 2,
|
||||
TOTAL_SPACE = 4,
|
||||
},
|
||||
calibre = {},
|
||||
calibre = nil, -- hash
|
||||
}
|
||||
|
||||
function CalibreWireless:init()
|
||||
self.calibre = {}
|
||||
-- reversed operator codes and names dictionary
|
||||
self.opnames = {}
|
||||
for name, code in pairs(self.opcodes) do
|
||||
|
||||
@@ -51,7 +51,7 @@ local scale_by_size = Screen:scaleBySize(1000000) / 1000000
|
||||
|
||||
-- ItemShortCutIcon (for keyboard navigation) is private to menu.lua and can't be accessed,
|
||||
-- so we need to redefine it
|
||||
local ItemShortCutIcon = WidgetContainer:new{
|
||||
local ItemShortCutIcon = WidgetContainer:extend{
|
||||
dimen = Geom:new{ w = Screen:scaleBySize(22), h = Screen:scaleBySize(22) },
|
||||
key = nil,
|
||||
bordersize = Size.border.default,
|
||||
@@ -94,8 +94,8 @@ end
|
||||
|
||||
|
||||
-- Based on menu.lua's MenuItem
|
||||
local ListMenuItem = InputContainer:new{
|
||||
entry = {},
|
||||
local ListMenuItem = InputContainer:extend{
|
||||
entry = nil, -- hash, mandatory
|
||||
text = nil,
|
||||
show_parent = nil,
|
||||
detail = nil,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
local BookInfoManager = require("bookinfomanager")
|
||||
@@ -45,7 +45,7 @@ local history_display_mode = false -- not initialized yet
|
||||
local collection_display_mode = false -- not initialized yet
|
||||
local series_mode = nil -- defaults to not display series
|
||||
|
||||
local CoverBrowser = InputContainer:new{
|
||||
local CoverBrowser = WidgetContainer:extend{
|
||||
name = "coverbrowser",
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ local progress_widget
|
||||
|
||||
-- ItemShortCutIcon (for keyboard navigation) is private to menu.lua and can't be accessed,
|
||||
-- so we need to redefine it
|
||||
local ItemShortCutIcon = WidgetContainer:new{
|
||||
local ItemShortCutIcon = WidgetContainer:extend{
|
||||
dimen = Geom:new{ w = Screen:scaleBySize(22), h = Screen:scaleBySize(22) },
|
||||
key = nil,
|
||||
bordersize = Size.border.default,
|
||||
@@ -95,7 +95,7 @@ end
|
||||
-- The rendering of the TextBoxWidget we're doing below
|
||||
-- with decreasing font sizes till it fits is quite expensive.
|
||||
|
||||
local FakeCover = FrameContainer:new{
|
||||
local FakeCover = FrameContainer:extend{
|
||||
width = nil,
|
||||
height = nil,
|
||||
margin = 0,
|
||||
@@ -343,8 +343,8 @@ end
|
||||
|
||||
|
||||
-- Based on menu.lua's MenuItem
|
||||
local MosaicMenuItem = InputContainer:new{
|
||||
entry = {},
|
||||
local MosaicMenuItem = InputContainer:extend{
|
||||
entry = nil, -- table, mandatory
|
||||
text = nil,
|
||||
show_parent = nil,
|
||||
detail = nil,
|
||||
|
||||
@@ -62,7 +62,7 @@ local function getExtension(filename)
|
||||
return util.getFileNameSuffix(name):lower()
|
||||
end
|
||||
|
||||
local CoverImage = WidgetContainer:new{
|
||||
local CoverImage = WidgetContainer:extend{
|
||||
name = "coverimage",
|
||||
is_doc_only = true,
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ local filemanagerutil = require("apps/filemanager/filemanagerutil")
|
||||
local lfs = require("libs/libkoreader-lfs")
|
||||
local util = require("util")
|
||||
|
||||
local DocSettingTweak = WidgetContainer:new{
|
||||
local DocSettingTweak = WidgetContainer:extend{
|
||||
name = "docsettingtweak",
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@
|
||||
local DataStorage = require("datastorage")
|
||||
local Device = require("device")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local MyClipping = require("clip")
|
||||
local NetworkMgr = require("ui/network/manager")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
|
||||
@@ -93,7 +93,7 @@ local function updateMyClippings(clippings, new_clippings)
|
||||
return clippings
|
||||
end
|
||||
|
||||
local Exporter = InputContainer:new {
|
||||
local Exporter = WidgetContainer:extend{
|
||||
name = "exporter",
|
||||
clipping_dir = DataStorage:getDataDir() .. "/clipboard",
|
||||
targets = {
|
||||
|
||||
@@ -9,12 +9,12 @@ local Geom = require("ui/geometry")
|
||||
local GestureDetector = require("device/gesturedetector")
|
||||
local GestureRange = require("ui/gesturerange")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local InputDialog = require("ui/widget/inputdialog")
|
||||
local LuaSettings = require("luasettings")
|
||||
local Screen = require("device").screen
|
||||
local SpinWidget = require("ui/widget/spinwidget")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
||||
local lfs = require("libs/libkoreader-lfs")
|
||||
local logger = require("logger")
|
||||
local util = require("util")
|
||||
@@ -27,7 +27,7 @@ if not Device:isTouchDevice() then
|
||||
return { disabled = true, }
|
||||
end
|
||||
|
||||
local Gestures = InputContainer:new{
|
||||
local Gestures = WidgetContainer:extend{
|
||||
name = "gestures",
|
||||
settings_data = nil,
|
||||
gestures = nil,
|
||||
|
||||
@@ -4,7 +4,7 @@ local LuaData = require("luadata")
|
||||
local Migration = {}
|
||||
|
||||
local custom_multiswipes_path = DataStorage:getSettingsDir().."/multiswipes.lua"
|
||||
local custom_multiswipes = LuaData:open(custom_multiswipes_path, { name = "MultiSwipes" })
|
||||
local custom_multiswipes = LuaData:open(custom_multiswipes_path, "MultiSwipes")
|
||||
local custom_multiswipes_table = custom_multiswipes:readSetting("multiswipes")
|
||||
|
||||
function Migration:convertAction(location, ges, action)
|
||||
|
||||
@@ -15,7 +15,7 @@ local UIManager = require("ui/uimanager")
|
||||
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
||||
local _ = require("gettext")
|
||||
|
||||
local Hello = WidgetContainer:new{
|
||||
local Hello = WidgetContainer:extend{
|
||||
name = "hello",
|
||||
is_doc_only = false,
|
||||
}
|
||||
|
||||
@@ -29,12 +29,12 @@ local _ = require("gettext")
|
||||
local N_ = _.ngettext
|
||||
local T = require("ffi/util").template
|
||||
|
||||
local SingleInstanceDeinflector = Deinflector:new()
|
||||
local SingleInstanceDeinflector = Deinflector:new{}
|
||||
|
||||
local Japanese = WidgetContainer:new({
|
||||
local Japanese = WidgetContainer:extend{
|
||||
name = "japanese",
|
||||
pretty_name = "Japanese",
|
||||
})
|
||||
}
|
||||
|
||||
-- Yomichan uses 10 characters as the default look-ahead, but crengine's
|
||||
-- getNextVisibleChar counts furigana if any are present, so use a higher
|
||||
|
||||
@@ -59,7 +59,7 @@ menuItem.callback = function()
|
||||
showConfirmBox()
|
||||
end
|
||||
|
||||
local KeepAlive = WidgetContainer:new{
|
||||
local KeepAlive = WidgetContainer:extend{
|
||||
name = "keepalive",
|
||||
}
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
local Dispatcher = require("dispatcher")
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local LoginDialog = require("ui/widget/logindialog")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local ConfirmBox = require("ui/widget/confirmbox")
|
||||
local Device = require("device")
|
||||
local Dispatcher = require("dispatcher")
|
||||
local Event = require("ui/event")
|
||||
local InfoMessage = require("ui/widget/infomessage")
|
||||
local LoginDialog = require("ui/widget/logindialog")
|
||||
local Math = require("optmath")
|
||||
local NetworkMgr = require("ui/network/manager")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local Device = require("device")
|
||||
local Event = require("ui/event")
|
||||
local Math = require("optmath")
|
||||
local Screen = Device.screen
|
||||
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
||||
local logger = require("logger")
|
||||
local md5 = require("ffi/sha2").md5
|
||||
local random = require("random")
|
||||
local util = require("util")
|
||||
local Screen = Device.screen
|
||||
local T = require("ffi/util").template
|
||||
local _ = require("gettext")
|
||||
|
||||
@@ -20,7 +20,7 @@ if G_reader_settings:hasNot("device_id") then
|
||||
G_reader_settings:saveSetting("device_id", random.uuid())
|
||||
end
|
||||
|
||||
local KOSync = InputContainer:new{
|
||||
local KOSync = WidgetContainer:extend{
|
||||
name = "kosync",
|
||||
is_doc_only = true,
|
||||
title = _("Register/login to KOReader server"),
|
||||
|
||||
@@ -13,7 +13,7 @@ local util = require("frontend/util")
|
||||
local BaseUtil = require("ffi/util")
|
||||
local _ = require("gettext")
|
||||
|
||||
local MoveToArchive = WidgetContainer:new{
|
||||
local MoveToArchive = WidgetContainer:extend{
|
||||
name = "movetoarchive",
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ local util = require("util")
|
||||
local _ = require("gettext")
|
||||
local T = FFIUtil.template
|
||||
|
||||
local NewsDownloader = WidgetContainer:new{
|
||||
local NewsDownloader = WidgetContainer:extend{
|
||||
name = "news_downloader",
|
||||
initialized = false,
|
||||
feed_config_file = "feed_config.lua",
|
||||
@@ -41,7 +41,7 @@ local NewsDownloader = WidgetContainer:new{
|
||||
enable_filter = false,
|
||||
filter_element = ""
|
||||
},
|
||||
kv = {}
|
||||
kv = nil, -- KeyValuePage
|
||||
}
|
||||
|
||||
local FEED_TYPE_RSS = "rss"
|
||||
|
||||
@@ -3,7 +3,7 @@ local UIManager = require("ui/uimanager")
|
||||
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
||||
local _ = require("gettext")
|
||||
|
||||
local OPDS = WidgetContainer:new{
|
||||
local OPDS = WidgetContainer:extend{
|
||||
name = "opds",
|
||||
is_doc_only = false,
|
||||
}
|
||||
|
||||
@@ -2,15 +2,15 @@ local BD = require("ui/bidi")
|
||||
local Blitbuffer = require("ffi/blitbuffer")
|
||||
local ConfirmBox = require("ui/widget/confirmbox")
|
||||
local FrameContainer = require("ui/widget/container/framecontainer")
|
||||
local InputContainer = require("ui/widget/container/inputcontainer")
|
||||
local OPDSBrowser = require("opdsbrowser")
|
||||
local UIManager = require("ui/uimanager")
|
||||
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
||||
local logger = require("logger")
|
||||
local _ = require("gettext")
|
||||
local Screen = require("device").screen
|
||||
local T = require("ffi/util").template
|
||||
|
||||
local OPDSCatalog = InputContainer:extend{
|
||||
local OPDSCatalog = WidgetContainer:extend{
|
||||
title = _("OPDS Catalog"),
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ local util = require("util")
|
||||
|
||||
local autostart_done = false
|
||||
|
||||
local Profiles = WidgetContainer:new{
|
||||
local Profiles = WidgetContainer:extend{
|
||||
name = "profiles",
|
||||
profiles_file = DataStorage:getSettingsDir() .. "/profiles.lua",
|
||||
profiles = nil,
|
||||
|
||||
@@ -10,7 +10,7 @@ local UIManager = require("ui/uimanager")
|
||||
local WidgetContainer = require("ui/widget/container/widgetcontainer")
|
||||
local _ = require("gettext")
|
||||
|
||||
local QRClipboard = WidgetContainer:new{
|
||||
local QRClipboard = WidgetContainer:extend{
|
||||
name = "qrclipboard",
|
||||
is_doc_only = false,
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ local util = require("util")
|
||||
local _ = require("gettext")
|
||||
local T = require("ffi/util").template
|
||||
|
||||
local ReadTimer = WidgetContainer:new{
|
||||
local ReadTimer = WidgetContainer:extend{
|
||||
name = "readtimer",
|
||||
time = 0, -- The expected time of alarm if enabled, or 0.
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ local Input = Device.input
|
||||
local Screen = Device.screen
|
||||
local _ = require("gettext")
|
||||
|
||||
local HistogramWidget = Widget:new{
|
||||
local HistogramWidget = Widget:extend{
|
||||
width = nil,
|
||||
height = nil,
|
||||
color = Blitbuffer.COLOR_BLACK,
|
||||
@@ -76,7 +76,7 @@ function HistogramWidget:paintTo(bb, x, y)
|
||||
end
|
||||
|
||||
|
||||
local CalendarDay = InputContainer:new{
|
||||
local CalendarDay = InputContainer:extend{
|
||||
daynum = nil,
|
||||
ratio_per_hour = nil,
|
||||
filler = false,
|
||||
@@ -170,7 +170,7 @@ function CalendarDay:onHold()
|
||||
end
|
||||
|
||||
|
||||
local CalendarWeek = InputContainer:new{
|
||||
local CalendarWeek = InputContainer:extend{
|
||||
width = nil,
|
||||
height = nil,
|
||||
day_width = 0,
|
||||
@@ -367,7 +367,7 @@ end
|
||||
-- Fetched from db, cached as local as it might be expensive
|
||||
local MIN_MONTH = nil
|
||||
|
||||
local CalendarView = FocusManager:new{
|
||||
local CalendarView = FocusManager:extend{
|
||||
reader_statistics = nil,
|
||||
monthTranslation = nil,
|
||||
shortDayOfWeekTranslation = nil,
|
||||
|
||||
@@ -70,19 +70,8 @@ local ReaderStatistics = Widget:extend{
|
||||
book_read_pages = 0,
|
||||
book_read_time = 0,
|
||||
avg_time = nil,
|
||||
page_stat = {}, -- Dictionary, indexed by page (hash), contains a list (array) of { timestamp, duration } tuples.
|
||||
data = {
|
||||
title = "",
|
||||
authors = "N/A",
|
||||
language = "N/A",
|
||||
series = "N/A",
|
||||
performance_in_pages = {},
|
||||
total_time_in_sec = 0,
|
||||
highlights = 0,
|
||||
notes = 0,
|
||||
pages = 0,
|
||||
md5 = nil,
|
||||
},
|
||||
page_stat = nil, -- Dictionary, indexed by page (hash), contains a list (array) of { timestamp, duration } tuples.
|
||||
data = nil, -- table
|
||||
}
|
||||
|
||||
local weekDays = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" } -- in Lua wday order
|
||||
@@ -150,6 +139,20 @@ function ReaderStatistics:init()
|
||||
return
|
||||
end
|
||||
|
||||
-- Placeholder until onReaderReady
|
||||
self.data = {
|
||||
title = "",
|
||||
authors = "N/A",
|
||||
language = "N/A",
|
||||
series = "N/A",
|
||||
performance_in_pages = {},
|
||||
total_time_in_sec = 0,
|
||||
highlights = 0,
|
||||
notes = 0,
|
||||
pages = 0,
|
||||
md5 = nil,
|
||||
}
|
||||
|
||||
self.start_current_period = os.time()
|
||||
self:resetVolatileStats()
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@ local Screen = Device.screen
|
||||
local LINE_COLOR = Blitbuffer.COLOR_WEB_GRAY
|
||||
local BG_COLOR = Blitbuffer.COLOR_LIGHT_GRAY
|
||||
|
||||
local ReaderProgress = InputContainer:new{
|
||||
-- Oh, hey, this one actually *is* an InputContainer!
|
||||
local ReaderProgress = InputContainer:extend{
|
||||
padding = Size.padding.fullscreen,
|
||||
}
|
||||
|
||||
|
||||
@@ -291,7 +291,7 @@ end
|
||||
|
||||
SystemStat:init()
|
||||
|
||||
local SystemStatWidget = WidgetContainer:new{
|
||||
local SystemStatWidget = WidgetContainer:extend{
|
||||
name = "systemstat",
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ local T = require("ffi/util").template
|
||||
|
||||
local CHUNK_SIZE = 80 * 40 -- max. nb of read bytes (reduce this, if taps are not detected)
|
||||
|
||||
local Terminal = WidgetContainer:new{
|
||||
local Terminal = WidgetContainer:extend{
|
||||
name = "terminal",
|
||||
history = "",
|
||||
is_shell_open = false,
|
||||
@@ -429,6 +429,11 @@ function Terminal:onClose()
|
||||
self:killShell()
|
||||
end
|
||||
|
||||
-- Kill the shell on plugin teardown
|
||||
function Terminal:onCloseWidget()
|
||||
self:killShell()
|
||||
end
|
||||
|
||||
function Terminal:onTerminalStart(touchmenu_instance)
|
||||
self.touchmenu_instance = touchmenu_instance
|
||||
|
||||
|
||||
@@ -52,10 +52,16 @@ local TermInputText = InputText:extend{
|
||||
|
||||
wrap = true,
|
||||
|
||||
alternate_buffer = {},
|
||||
save_buffer = {},
|
||||
alternate_buffer = nil, -- table
|
||||
save_buffer = nil, -- table
|
||||
}
|
||||
|
||||
function TermInputText:init()
|
||||
self.alternate_buffer = {}
|
||||
self.save_buffer = {}
|
||||
InputText.init(self)
|
||||
end
|
||||
|
||||
-- disable positioning cursor by tap in emulator mode
|
||||
function TermInputText:onTapTextBox(arg, ges)
|
||||
return true
|
||||
|
||||
@@ -26,7 +26,7 @@ local _ = require("gettext")
|
||||
local Screen = require("device").screen
|
||||
local T = ffiutil.template
|
||||
|
||||
local TextEditor = WidgetContainer:new{
|
||||
local TextEditor = WidgetContainer:extend{
|
||||
name = "texteditor",
|
||||
settings_file = DataStorage:getSettingsDir() .. "/text_editor.lua",
|
||||
settings = nil, -- loaded only when needed
|
||||
|
||||
@@ -17,7 +17,7 @@ local T = require("ffi/util").template
|
||||
local _ = require("gettext")
|
||||
local NetworkMgr = require("ui/network/manager")
|
||||
|
||||
local TimeSync = WidgetContainer:new{
|
||||
local TimeSync = WidgetContainer:extend{
|
||||
name = "timesync",
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ end
|
||||
function VocabularyBuilder:insertLookupData(db_conn)
|
||||
local file_path = DataStorage:getSettingsDir() .. "/lookup_history.lua"
|
||||
|
||||
local lookup_history = LuaData:open(file_path, { name = "LookupHistory" })
|
||||
local lookup_history = LuaData:open(file_path, "LookupHistory")
|
||||
if lookup_history:has("lookup_history") then
|
||||
local lookup_history_table = lookup_history:readSetting("lookup_history")
|
||||
local book_titles = {}
|
||||
|
||||
@@ -137,7 +137,7 @@ end
|
||||
--[[--
|
||||
Menu dialogue widget
|
||||
--]]--
|
||||
local MenuDialog = FocusManager:new{
|
||||
local MenuDialog = FocusManager:extend{
|
||||
padding = Size.padding.large,
|
||||
is_edit_mode = false,
|
||||
edit_callback = nil,
|
||||
@@ -381,7 +381,7 @@ end
|
||||
--[[--
|
||||
Individual word info dialogue widget
|
||||
--]]--
|
||||
local WordInfoDialog = InputContainer:new{
|
||||
local WordInfoDialog = InputContainer:extend{
|
||||
title = nil,
|
||||
book_title = nil,
|
||||
dates = nil,
|
||||
@@ -594,7 +594,7 @@ local point_widget = TextWidget:new{
|
||||
--[[--
|
||||
Individual word item widget
|
||||
--]]--
|
||||
local VocabItemWidget = InputContainer:new{
|
||||
local VocabItemWidget = InputContainer:extend{
|
||||
face = Font:getFace("smallinfofont"),
|
||||
width = nil,
|
||||
height = nil,
|
||||
@@ -985,7 +985,7 @@ end
|
||||
--[[--
|
||||
Container widget. Same as sortwidget
|
||||
--]]--
|
||||
local VocabularyBuilderWidget = FocusManager:new{
|
||||
local VocabularyBuilderWidget = FocusManager:extend{
|
||||
title = "",
|
||||
width = nil,
|
||||
height = nil,
|
||||
@@ -1414,7 +1414,7 @@ end
|
||||
--[[--
|
||||
Item shown in main menu
|
||||
--]]--
|
||||
local VocabBuilder = WidgetContainer:new{
|
||||
local VocabBuilder = WidgetContainer:extend{
|
||||
name = "vocabulary_builder",
|
||||
is_doc_only = false
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ local article_id_prefix = "[w-id_"
|
||||
local article_id_postfix = "] "
|
||||
local failed, skipped, downloaded = 1, 2, 3
|
||||
|
||||
local Wallabag = WidgetContainer:new{
|
||||
local Wallabag = WidgetContainer:extend{
|
||||
name = "wallabag",
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user