2017-09-17 18:29:49 +00:00
|
|
|
local isAndroid, android = pcall(require, "android")
|
2017-10-21 22:37:58 +00:00
|
|
|
local Device = require("device")
|
2017-10-21 20:52:06 +00:00
|
|
|
local Geom = require("ui/geometry")
|
2017-09-17 18:29:49 +00:00
|
|
|
local logger = require("logger")
|
|
|
|
local _ = require("gettext")
|
2017-10-21 22:37:58 +00:00
|
|
|
local Input = Device.input
|
|
|
|
local Screen = Device.screen
|
2017-09-17 18:29:49 +00:00
|
|
|
|
|
|
|
if not isAndroid then return end
|
|
|
|
|
|
|
|
return {
|
|
|
|
text = _("Fullscreen"),
|
|
|
|
checked_func = function()
|
2017-10-21 22:37:58 +00:00
|
|
|
return G_reader_settings:isFalse("disabled_fullscreen")
|
2017-09-17 18:29:49 +00:00
|
|
|
end,
|
|
|
|
callback = function()
|
2017-10-21 22:37:58 +00:00
|
|
|
local disabled_fullscreen = G_reader_settings:isTrue("disabled_fullscreen")
|
2017-09-17 18:29:49 +00:00
|
|
|
|
2017-10-21 22:37:58 +00:00
|
|
|
logger.dbg("screen_fullscreen_menu_table.lua: Fullscreen swiching to: ", disabled_fullscreen)
|
|
|
|
android.setFullscreen(disabled_fullscreen)
|
2017-09-17 18:29:49 +00:00
|
|
|
|
|
|
|
local status_bar_height = android.getStatusBarHeight()
|
|
|
|
logger.dbg("screen_fullscreen_menu_table.lua: Status bar height: ", status_bar_height)
|
|
|
|
local screen_width = android.getScreenWidth()
|
|
|
|
logger.dbg("screen_fullscreen_menu_table.lua: Screen width: ", screen_width)
|
|
|
|
local screen_height = android.getScreenHeight()
|
|
|
|
logger.dbg("screen_fullscreen_menu_table.lua: Screen height: ", screen_height)
|
|
|
|
|
2017-10-21 20:52:06 +00:00
|
|
|
local new_height = screen_height - status_bar_height
|
|
|
|
local viewport = Geom:new{x=0, y=status_bar_height, w=screen_width, h=new_height}
|
2017-10-21 22:37:58 +00:00
|
|
|
|
|
|
|
if not disabled_fullscreen and Screen.viewport then
|
|
|
|
-- reset touchTranslate to normal
|
|
|
|
Input:registerEventAdjustHook(
|
|
|
|
Input.adjustTouchTranslate,
|
|
|
|
{x = 0 + Screen.viewport.x, y = 0 + Screen.viewport.y})
|
|
|
|
end
|
2017-10-21 20:52:06 +00:00
|
|
|
Screen:setViewport(viewport)
|
2017-10-21 22:37:58 +00:00
|
|
|
if disabled_fullscreen then
|
|
|
|
Input:registerEventAdjustHook(
|
|
|
|
Input.adjustTouchTranslate,
|
|
|
|
{x = 0 - Screen.viewport.x, y = 0 - Screen.viewport.y})
|
|
|
|
end
|
2017-10-21 20:52:06 +00:00
|
|
|
|
2017-10-21 22:37:58 +00:00
|
|
|
G_reader_settings:saveSetting("disabled_fullscreen", not disabled_fullscreen)
|
2017-09-17 18:29:49 +00:00
|
|
|
end,
|
|
|
|
}
|