Created
April 26, 2018 21:43
-
-
Save Benzeliden/537e9e9a431e422545e03d9aa828f748 to your computer and use it in GitHub Desktop.
Corona androidSystemUiVisibility
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- For more information on config.lua see the Project Configuration Guide at: | |
-- https://docs.coronalabs.com/guide/basics/configSettings | |
-- | |
application = | |
{ | |
content = | |
{ | |
--width = 320, | |
--height = 480, | |
scale = "adaptive", | |
fps = 30, | |
--[[ | |
imageSuffix = | |
{ | |
["@2x"] = 2, | |
["@4x"] = 4, | |
}, | |
--]] | |
}, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local circle | |
local mode = "immersiveSticky" | |
local function drawCircle() | |
local c = display.newCircle(display.contentWidth * 0.5, display.contentHeight * 0.5, display.contentWidth * 0.4) | |
c:addEventListener("tap", function() | |
if (mode == "immersiveSticky") then | |
mode = "default" | |
else | |
mode = "immersiveSticky" | |
end | |
print("mode changed") | |
end) | |
return c | |
end | |
local function printSizes() | |
print("===================== printSizes ============================") | |
print("androidSystemUiVisibility = ", native.getProperty("androidSystemUiVisibility")) | |
print("content", display.contentWidth, display.contentHeight) | |
print("viewable content", display.viewableContentWidth, display.viewableContentHeight) | |
print("actual content", display.actualContentWidth, display.actualContentHeight) | |
print("pixel", display.pixelWidth, display.pixelHeight) | |
print("===================== printSizes ends =======================") | |
end | |
printSizes() | |
display.setStatusBar(display.HiddenStatusBar) | |
display.setDefault("magTextureFilter", "nearest") | |
display.setDefault("minTextureFilter", "nearest") | |
printSizes() | |
local function onSystemEvent(event) | |
local eventType = event.type | |
if (eventType == "applicationStart") then | |
elseif (eventType == "applicationResume") then | |
print("resume") | |
native.setProperty("androidSystemUiVisibility", mode) | |
end | |
end | |
local function onResize(event) | |
print("resize2") | |
printSizes() | |
display.remove(circle) | |
circle = drawCircle() | |
end | |
-- Add the "resize" event listener | |
Runtime:addEventListener("resize", onResize) | |
Runtime:addEventListener("system", onSystemEvent) | |
print("set ui visibility mode", mode) | |
native.setProperty("androidSystemUiVisibility", mode) | |
--end | |
circle = drawCircle() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment