[finished]Android fullscreen switcher #2938
Conversation
| require("ui/elements/screen_eink_opt_menu_table"), | ||
| require("ui/elements/screen_disable_double_tap_table"), | ||
| require("ui/elements/refresh_menu_table"), | ||
| require("ui/elements/refresh_menu_table") |
| G_reader_settings:saveSetting("disable_fullscreen", not disabled) | ||
| android.setFullscreen(disabled) | ||
| UIManager:show(InfoMessage:new{ | ||
| text = _("This will take effect on next restart."), |
There was a problem hiding this comment.
It's better to be specific. "The fullscreen setting (or whatever) will take effect…"
| require("ui/elements/screen_eink_opt_menu_table"), | ||
| require("ui/elements/screen_disable_double_tap_table"), | ||
| require("ui/elements/refresh_menu_table"), | ||
| require("ui/elements/refresh_menu_table") |
There was a problem hiding this comment.
Please note that adding a comma at the end of the last element of a table is a convention especially with each element in one line. The reason is that if we add another element git diff only shows 1 line of change.
|
You say it requires a luajit-launcher bump but you didn't include it? |
|
@Frenzie I thought Koreader's downloading latest master luajit. |
| }, | ||
| } | ||
| if Device:isAndroid() then | ||
| table.insert(common_settings.screen.sub_item_table, require("ui/elements/screen_fullscreen_menu_table")) |
There was a problem hiding this comment.
It seems there's a problem in that line.
I believe it's in common_settings.screen.sub_item_table could you help me get reference to above sub_item_table?
There was a problem hiding this comment.
On my phone atm and that seems to look okay but remember you can always quickly test simple things in a plain old Lua console.
There was a problem hiding this comment.
Could you be a little more specific about "a problem"? The reference to common_settings.screen.sub_item_table seems fine in a quick test.
There was a problem hiding this comment.
I did reset and its' working now (at least at my Ubuntu).
|
You go into the dir of the submodule and run git pull. Then you can commit that change. |
frontend/device/android/device.lua
Outdated
| Generic.init(self) | ||
| end | ||
|
|
||
|
|
|
Guys, how do you build working apk for android? Do you have to add any parameters to the build? I use I'm able to install it, but such created application never works on my phone. I'm building it on Ubuntu 16.04 LTS. |
|
Sorry, that's my fault (but I mostly blame Android itself). There is no such thing as an Android build that works on my phone, so I can only test if it builds. :-( If you manually use base from just prior to koreader/koreader-base#482 and use the Docker Ubuntu 14.04 box it should work but I think/hope @chrox is really close to a proper fix. |
|
Is there a docker container I can download? - - - edit : ok. I thought I need special koreader setup on Ubuntu, but it seems you're saying I just need 14.04 Ubuntu version. Hopefully koreader/koreader-base#482 will be finished soon as it's a blocker. |
|
There are Docker and Vagrant containers in https://github.com/koreader/virdevenv |
| }, | ||
| } | ||
| if Device:isAndroid() then | ||
| table.insert(common_settings.screen.sub_item_table, require("ui/elements/screen_fullscreen_menu_table")) |
There was a problem hiding this comment.
@Frenzie Just to be sure if it's failing or not I changed the line 44 to if not Device:isAndroid() (to test on PC).
And it fails:
./luajit: frontend/device/android/device.lua:16: missing declaration for symbol 'AConfiguration_getDensity'
stack traceback:
[C]: in function '__index'
frontend/device/android/device.lua:16: in main chunk
[C]: in function 'require'
frontend/ui/elements/screen_fullscreen_menu_table.lua:4: in main chunk
[C]: in function 'require'
frontend/ui/elements/common_settings_menu_table.lua:45: in main chunk
[C]: in function 'require'
frontend/apps/filemanager/filemanagermenu.lua:161: in function 'old_method'
frontend/dbg.lua:43: in function 'setUpdateItemTable'
frontend/apps/filemanager/filemanagermenu.lua:327: in function 'onShowMenu'
frontend/apps/filemanager/filemanagermenu.lua:375: in function 'handler'
frontend/ui/widget/container/inputcontainer.lua:197: in function 'handleEvent'
frontend/ui/widget/container/widgetcontainer.lua:87: in function 'propagateEvent'
frontend/ui/widget/container/widgetcontainer.lua:105: in function 'handleEvent'
frontend/ui/uimanager.lua:446: in function 'sendEvent'
frontend/ui/uimanager.lua:42: in function 'default'
frontend/ui/uimanager.lua:722: in function 'handleInput'
frontend/ui/uimanager.lua:767: in function 'run'
./reader.lua:193: in main chunk
[C]: at 0x00404750
not sure what's wrong there.
There was a problem hiding this comment.
With koreader/koreader-base#493 and koreader/android-luajit-launcher#52 you should be able to test on real Android device. Init android device requires android specific functions like AConfiguration_getDensity which do not exist on other platforms.
There was a problem hiding this comment.
@chrox I didn't know. Thanks.
So once those PR's are merged building android on Ubuntu 16.04 should work, right?
So it's just about code review before merge, right?
I think I'll hold on until then
There was a problem hiding this comment.
@chrox so now fix (Koreader build @ubuntu16.04) is in master, right?
So as I did git merge upstream/master it should work on my ubuntu 16.04, right?
Or should I do anything more as it's again freezed after install?
There was a problem hiding this comment.
comment out of date. This problem's already solved.
|
You'll need to make sure base is at the right commit. |
…droid_Fullscreen_switcher
|
Help needed. There's a problem:
Koreader frontend/ui/elements/screen_fullscreen_menu_table.lua :
Lua-jit launcher, android.lua lines 1353 and 1354:
I guess that variable ("disabled") exist in Koreader (and equals "true"), but then when it's transfered to Lua-jit launcher it's missing (it's "nil"). Right? |
|
There's no such thing as a "KOReader boolean". :-P There is of course a possibility that you saved it as a string at some point, but even if you did there's no difference between For checking if a key is true or false we have convenience functions like isTrue() and isFalse(). Glancing at the code I notice it's declared as |
|
As "koreader boolean" I thought about converting boolean between lua and Java. But right, this part of Lua-jit is still lua code. I used Greater:settings to read and store the full screen settings I thought it might be faster than calling android(java) code from lua to get that info. But maybe it's not?and should be replaced? That Java "final" key word you highlighted just means once you passed the attribute to function it reference cannot be changed inside the function. In simple words function itself cannot change passed boolean. So shouldn't make difference unless there's something wrong with passing lua variable to Java final parameter.. |
|
Oh I get what you mean that I "save a setting right after reading it". I'll fix that but the main problem is still to be solved.. |
| callback = function() | ||
| local disabled = G_reader_settings:readSetting("disable_fullscreen") ~= false | ||
| G_reader_settings:saveSetting("disable_fullscreen", not disabled) | ||
| android.setFullscreen(disabled) |
There was a problem hiding this comment.
Does it make a difference if you use : instead of .? Looking at the whole thing here rather than the sample you posted earlier I realized we were talking about the Device method rather than a direct reference. You might have to pass in a reference to the object if you do it this say. That'd be the less elegant android.setFullscreen(android, disabled).[1] In that case it'd think disabled is the object reference and fullscreen nil if you only pass android.setFullscreen(disabled).
[1] It'd also be the wrong android object as it's actually from Device.
|
Sorry, I'm not sure what could be the matter. Have you tried it as part of the Device init instead of trying to set it through a function later? Here's a screenshot of
Yes, that's to be expected. :-) |
|
The I tried simple : but it doesn't make any changes to viewport. The same result for code below: I believe the But there might be something missing in current implementation? but I didnt' spot screen.x and y ... I found In Searching for vieport in BB gave me result: But maybe the data is lost when passed from a lua file to another? |
Sure, but besides being slightly easier to test on the fly it makes no difference. It's the same as just writing
Right, as shown in my screenshot the viewport affects where on the framebuffer the picture is drawn. Since the problem seems to be that the statusbar overlays KOReader, my thinking is that it doesn't matter if the framebuffer is still the full size. All you need to do is push the KOReader viewport down slightly. I have no idea why that doesn't seem to be working, but I don't think it's related to the particular line you mention. |
|
Testing Android is tremendously annoying. Anyway, after some general inconvenience I can confirm that it just sticks it in the top left. The value I used for testing was PS It's been like a decade since I've done Java and signing jars wasn't required. What's that Android emulator thing? |
|
Yes It's a pain. Some time ago I asked for x86 build (#3046) so at least emulation would be faster. But getting back to main problem: ps: @Frenzie I use |
Whatever it is, it's in the repos and I used it. :-P I doubt jarsigner changed much over the years; I simply got myself the stuff I needed with the latest version number.
Compilation tools are useful in general including on my laptop. Gigabytes of Android stuff are not at all (to me). I'd just as lief not have them on my desktop but there I have enough space to spare. :-) |
|
@Frenzie I should have gradle as build tool in next work project.. |
|
Android disabling/enabling fullscreen works. Changing viewport has been extacted to #3148 Please review & merge. |
| @@ -0,0 +1,36 @@ | |||
| local _ = require("gettext") | |||
There was a problem hiding this comment.
The coding style says _ goes under those.
There was a problem hiding this comment.
I've glanced at https://github.com/koreader/koreader-base/wiki/Coding-style
but still don't understand what you mean.
There was a problem hiding this comment.
local Class = require("class") -- Uppercase class
local Device = require("device") -- Uppercase class
local func = require("func") -- Lowercase function
local glob = require("glob") -- Lowercase function
local _ = require("gettext") -- Symbol
local T = require("ffi/util").template -- One of the functions in a file
local V = require("utils2").version -- The other function, ordered by ASCII.There was a problem hiding this comment.
Order changed as you wanted.
| return { | ||
| text = _("Fullscreen"), | ||
| checked_func = function() | ||
| local disabled_fullscreen = G_reader_settings:readSetting("disabled_fullscreen") ~= false |
There was a problem hiding this comment.
local disabled_fullscreen = G_reader_settings:isTrue("disabled_fullscreen")
http://koreader.rocks/doc/modules/luasettings.html#LuaSettings:isTrue
| end, | ||
| callback = function() | ||
| local disabled_fullscreen = G_reader_settings:readSetting("disabled_fullscreen") ~= false | ||
| local enabled_fullscreen = not disabled_fullscreen |
There was a problem hiding this comment.
local enabled_fullscreen = G_reader_settings:isFalse("disabled_fullscreen")
And skip the useless disabled_fullscreen a line above.
| local screen_height = android.getScreenHeight() | ||
| logger.dbg("screen_fullscreen_menu_table.lua: Screen height: ", screen_height) | ||
|
|
||
| -- lines below should be uncommented once #3148 is resolved |
There was a problem hiding this comment.
These lines can wait for the follow-up PR.
| @@ -0,0 +1,36 @@ | |||
| local _ = require("gettext") | |||
| local android = require("device/android/device") | |||
There was a problem hiding this comment.
Perhaps local _, android = pcall(require, "android") and skip the Device stuff up there?
|
Looking pretty good. 👍 |
frontend/device/android/device.lua
Outdated
| Generic.init(self) | ||
| end | ||
|
|
||
| function Device:isFullscreen() |
There was a problem hiding this comment.
I don't get it. Can you be more verbose?;)
There was a problem hiding this comment.
Your use of local android = require("device/android/device") was confusing, because elsewhere that always means local _, android = pcall(require, "android").
Anyway, so either you should use Device properly or just stick with the specific Android stuff. Last night I made the judgment call that since this is all very Android-specific, there's probably no use in "littering" Device with it, plus it would be the easier change to make. But that means there's no need to add these methods to this file.
| @@ -0,0 +1,27 @@ | |||
| local _, android = pcall(require, "android") | |||
There was a problem hiding this comment.
My apologies (as I suggested this), but if you do it this way luacheck will complain.
Maybe a little safety check like this?
local isAndroid, android = pcall(require, "android")
if not isAndroid then return end|
@Frenzie I wasn't complaining about
but now it does about :
can I get back to previous solution? |
|
Then you'd still be upvalueing it, which is bad practice. (It might work but you shouldn't have to parse the code to know what a variable refers to.) But one should expect it to complain about unused variables, because I suggested to use that variable: local isAndroid, android = pcall(require, "android")
if not isAndroid then return end |
|
But I suppose it'll do. |




Require newest koreader/android-luajit-launcher#50
Marking this PR as w.i.p. (work in progress) as I wasn't able to test it.
Gives ability to see top menu bar in android (#2902)
Help appreciated.