Fix and improvements of battery stats plugin#5626
Conversation
|
|
||
| function Usage:dumpCharging(kv_pairs) | ||
| table.insert(kv_pairs, {_(" Estimated hours for charging"), shorten(self:chargingHours())}) | ||
| table.insert(kv_pairs, {string.format("%s%s",INDENTATION, _("Estimated hours for charging")), shorten(self:chargingHours())}) |
There was a problem hiding this comment.
Possibly not - but go ahead with that as it is, it is done the same way in the System Statistics plugin:

There are much more stuff than I expected that will need to be adapted for proper and code-clean RTL mirroring, and I have yet no idea how we'll go with these indented keys in Keyvaluepage...
We'll fix all these, either manually in each of them, or globally if we find a trick to have that done in KeyValuePage or even upper.
As an example, our lazy aligment tricks to use a different padding_left vs padding_right in FrameContainer - would need to be replaced by a HorizontalSpan and the FrameContainer in a HorizontalGroup, so HorizontalGroup is the only one that'd need to deal with mirroring.
Edit: or may be not :) we can just invert padding_left and padding_right in FrameContainer... Still experimenting to see what can/needs to be mirrored for less change outside low level widgets.
My wish is that we should continue to just think LTR when developping, with some simple rules to follow for special cases (like chevron, or string bits to be BD.wrap() before concatenating them - and all should be done automagically by low level widgets when switching to some RTL language.
There was a problem hiding this comment.
What I mean is that lazy
some spaces for alignment
can be translated however it needs to be in RTL if they're part of the string, as they are now. If this code would require extra code for inverting then this is a bad change.
There was a problem hiding this comment.
Note that a string like الذاكرة الإجمالية (MB) overlooked and left out the spaces, unless it was a conscious decision. This is a Transifex flaw.
There was a problem hiding this comment.
left out the spaces.
Oh, right. If I add the leading spaces back in ar_AA/koreader.po, then it looks ok! So, no issue with RTL at having spaces at start for indentation (I thought the bidi algo might push all spaces at end, but it doesn't). So good.
Anyway, the way this PR does it (indentation outside of translated string) is fine. (The way System statistics plugin does it is not.)
There was a problem hiding this comment.
Right, but does
" ".."RTL string"
actually put them at the start or at the end?
There was a problem hiding this comment.
At the start of the logical order of bytes. So it will be on the right (so at the RTL start) when text is rendered RTL (the bidi algo consider the spaces neutral, so all RTL when next real char is RTL).
There are many things the bidi algo (and/or xtexp.cpp :) do just right - we can still keep thinking LTR, and assume it will work ok with RTL.
There was a problem hiding this comment.
Alright, in that case this bit of programmatic cleverness should okay. But in matters of internationalization anything clever is suspect by default. :-)
Co-Authored-By: Frans de Jonge <fransdejonge@gmail.com>
NiLuJe
left a comment
There was a problem hiding this comment.
Reviewed 1 of 2 files at r1, 1 of 1 files at r2.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Frenzie and @robert00s)
|
plugins/batterystat.koplugin/main.lua, line 30 at r1 (raw file): Previously, Frenzie (Frans de Jonge) wrote…
Done. |
Frenzie
left a comment
There was a problem hiding this comment.
Reviewable status:
complete! all files reviewed, all discussions resolved
plugins/batterystat.koplugin/main.lua, line 83 at r2 (raw file):
function Usage:dump(kv_pairs) table.insert(kv_pairs, {string.format("%s%s",INDENTATION, _("Consumed %")), shorten(self.percentage)})
Btw, we used to have to use string.format because .. wasn't JIT compiled, but that's changed in LuaJIT 2.1 so we can safely use the imo more legible INDENTATION .. _("Consumed").
poire-z
left a comment
There was a problem hiding this comment.
Don't want to dig into the logic and maths :) so, trusting you on these changes :)
| end | ||
|
|
||
| local BatteryStat = { | ||
| settings = LuaSettings:open(DataStorage:getSettingsDir() .. "/batterstat.lua"), |
There was a problem hiding this comment.
Can we fix that filename to "battery_stats.lua" ?
(I guess we don't need to care about migration for such transient stuff.)
|
Merge'able? Was about to, but just saw your:
|
|
Yes, it's ready to merge. |
|
(A little request @robert00s : can you try deleting your branchs soon after they are merged? Instead of deleting a whole batch of branches a few times a year :) which makes the "sort PR/issues by recently updated" push all the alive issues below all your PRs of the trimester :) - unless you have a reason to do it that way) |
|
Deleting the branch after merge "updates" the PR? Sounds more like a GH bug/misfeature tbh. Btw, since we never (?) have more than about a dozen PRs what's the use case precisely? They all fit on one page. :-) |
|
Ok, I'll try to. |
|
Thanks! :)
My landing page is https://github.com/koreader/koreader/issues?q=sort:updated-desc - where I see all the active PRs and issues - and I just have to look for "updated X minutes/hours ago" to see what has happened :) or quickly find out older but recent stuff I planned on commenting on.
Surely is - but it has been like that for years :) |
- 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).
Close: #3031, #2937
What was done:
ToDo:
Before:


After:


This change is