Commit Graph

25 Commits (master)

Author SHA1 Message Date
melyux 8b99c50b2d
Duration format: add "Letters" format (1h30m10s) (#9924) 1 year ago
zwim 192a243b4d Add datetime.lua
Move date and time related functions from util.lua
(and the statistics plugin) to a new datetime.lua.
1 year ago
melyux 78772fcbb1
BatteryStat: show current battery percentage (#9814) 1 year ago
NiLuJe fadee1f5dc
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.
2 years ago
NiLuJe f0582dd37f
SystemStat: Show awake/suspend/standby breakdown in % (#9257)
Add an "awake" field in the process, and switch to `time` to prevent precision loss ;)
2 years ago
yparitcher 295ef6b9f7
Battery Stat: for real (#8694)
Thanks @hius07
2 years ago
yparitcher 517dfa3549
Battery Stat: Fix remaining & per hour numbers (#8688)
regression from #8491
papered over in #8582
Fixes #8644 #8687

Root cause was util.secondsToClockDuration (called by duration) takes seconds and we were giving it hours as `Change per hour` needs hours
2 years ago
hius07 c7715aa7d5
[fix] batterystat: change per hour (#8582) 2 years ago
zwim ef4d88ccd6
Battery stats plugin: tidy up, single page (#8491)
KeyValuePage: add a 'single_page' option to force
showing all items on a single page.
2 years ago
yparitcher eb949d6ebf Dispatcher: add Battery & System statistics 3 years ago
poire-z 8a0d798e9e KeyValuePage: configurable items per page
Tweak building to start from items per page instead of
a fixed item height.
Guess the best font size that fit.
Update separator specification from using a "----" to
the now generic separator=true (this allows not wasting
a slot for each separator in the page and not have
only 12 items and 2 small lines in a 14 items page).
3 years ago
Frans de Jonge b031d1c359
[Plugin] BatteryStat: consumed → charged for charging (#6646)
Closes <https://github.com/koreader/koreader/issues/6057>.
4 years ago
Robert 830fc790f1 Battery stats plugin: fix and improvements (#5626)
- fix incorrectly shown awake, sleeping, charging and discharging,
- remove unneeded debug mode and logging to external file,
- prevent showing values like inf, -inf, nan in estimated times
  (we now show "n/a"), and values below zero,
- show extra confirm box when we want to reset data,
- show time in format xxhxxm instead of only pure minutes,
- check at initialization that the device was charging when it was
  turned off (battery level larger than at the time of exit).
5 years ago
poire-z 850be52177
Keep some menus open when Tap or Hold (#4189)
TouchMenu: added options to menu items with the following defaults:
    keep_menu_open = false
    hold_keep_menu_open = true
So, default for Tap callback is to close menu, and for Hold callback
to keep menu open.
In both cases, provide the TouchMenu instance as the 1st argument to
the callback functions (instead of a refresh_menu_func I added in #3941)
so the callback can do more things, like closing, refreshing,
changing menu items text and re-ordering...

ReaderZooming: show symbol for default (like it was done for
ReaderFont, ReaderHyphenation...)
TextEditor plugin: update the previously opened files list in real
time, so the menu can be kept open and used as the TextEditor main
interface.
SSH plugin: keep menu open and update the Start/Stop state in real time
ReadTimer plugin: tried to do what feels right (but I don't use it)

Also remove forgotten cp in the move/paste file code
6 years ago
Robert 5344e0b672 [Fix] Don't load disabled plugins (#4169) 6 years ago
Robert 4428ecb422 Plugin manager (#4159)
Also adds descriptions to all plugins.
6 years ago
Hzj_jie a8513c95b6 Several minor fixes (#3057)
1. Android.getScreenBrightness() is used in frontend/device/android/powerd.lua to retrieve the frontlight intensity.
2. kosync.koplugin won't save settings for whisper sync.
3. batterstat.koplugin won't work correctly if several on* events are fired.
7 years ago
Hzj_jie 4ec96e377a Use getCapacityHW() to ensure latest battery capacity can be retrieved 7 years ago
Zijie He 0a02b529ae Remove BatteryStat:initCurrentState() 7 years ago
Hzj_jie d4756d777f (chore)Fix A typo in BatteryStat plugin (#2912) 7 years ago
Hzj_jie 30378eb2a8 Add restart koreader function and ensure FlushSettings event can be delivered to all widgets (#2772) 7 years ago
Hzj_jie 3ad3452d1a System Stat plugin (#2699) 7 years ago
Frans de Jonge e0c2232237 Menus plugin typo fix 7 years ago
Frans de Jonge f22dcebb13 MenuSorter: fix overlooked new plugins
* frontlight gesture controller
* battery statistics
7 years ago
Hzj_jie 0b29e73e2e BatteryStat plugin and instruction of KoboLight plugin (#2643)
* Start battery stat plugin

* BatteryStat & kobolight

* Several minor improvements

* Remove a useless function

* flush settings

* Some review feedbacks

* Resolve review comments

* Remaining Minutes -> Remaining Hours

* Add dump_file

* typo

* realpath

* realpath on folder

* Remove useless os.time()

* Resolve review comments

* warning

* Add BatteryStat.debugging flag

* treat log as txt

* Minor improvement

* Charging hour should be positive

* Use warn instead of info

* onSuspend in Kobo

* Charging events for kobo and kindle

* More events

* dumpOrLog

* Warnings

* Typo

* More space

* Singleton

* slightly format change

* BatteryStat singleton

* Init

* Remove debugging flag

* sleeping percentage is still negative

* Read settings

* Do not need to change was_suspending and was_charging

* Typo

* Remove debugging flag

* Not charging should happen before suspend

* Resolve review comments

* was_suspend and was_charging should be updated each time in onCallback()
7 years ago