Page 1 of 1
Create Android App Fullscreen
Posted: Fri Jun 09, 2017 2:19 pm
by IdeasVacuum
In Create App, there is a Fullscreen option next to the primary orientation option. I assumed it meant that my app window would be auto-sized to fit the device screen, but that doesn't happen.
- What then, is that option for?
Can or could the Desktop Library be used (DesktopHeight/DesktopWidth) to size a Window for the Android device?
Or could we have the #PB_Window_Maximize flag that PB has for Windows applications?
It's quite rare for an app not to command the whole screen on smartphones and tablets.
Edit: If Create App/Android/Fullscreen is not picked I get a Compiler error:
[COMPILER] Can't deploy the app: [INSTALL_FAILED_VERIFICATION_FAILURE].
Re: Create Android App Fullscreen
Posted: Sat Jun 10, 2017 9:40 am
by IdeasVacuum
So, found this:
http://ryanve.com/lab/dimensions
.... but I don't know how to use it in SB:
Code: Select all
Global igAvailW.i, igAvailH.i, igWinH.i, igWinW.i
!igAvailW = window.screen.availWidth
!igAvailH = window.screen.availHeight
!igWinW = window.screen.width
!igWinH = window.screen.height
Debug igAvailW
Debug igAvailH
Debug igWinW
Debug igWinH
Re: Create Android App Fullscreen
Posted: Sat Jun 10, 2017 2:25 pm
by IdeasVacuum
ExamineDesktops() works!
Re: Create Android App Fullscreen
Posted: Sat Jun 10, 2017 5:04 pm
by Peter
IdeasVacuum wrote:ExamineDesktops() works!
ExamineDesktops() is a dummy - function and exists only for code-compatibility with PureBasic.
Code: Select all
function spider_ExamineDesktops() {
return 1
}
Greetings ... Peter
Re: Create Android App Fullscreen
Posted: Sat Jun 10, 2017 7:12 pm
by IdeasVacuum
..... that must have changed Peter because the following code results in the window fitting my smartphone screen precisely?
Code: Select all
EnableExplicit
CloseDebugOutput()
ExamineDesktops()
#Desktop = 0
Enumeration
#Win
#Btn1
#Btn2
#Btn3
#BtnExit
#Scroll
#Msg
#Txt
EndEnumeration
Global igAvailW.i, igAvailH.i, igWinH.i, igWinW.i
;!igAvailW = window.screen.availWidth
;!igAvailH = window.screen.availHeight
;!igWinW = window.screen.width
;!igWinH = window.screen.height
igWinW = DesktopWidth(#Desktop)
igWinH = DesktopHeight(#Desktop)
;Debug igAvailW
;Debug igAvailH
;Debug igWinW
;Debug igWinH
Procedure CloseWindowEvent()
;#---------------------------
CloseWindow(EventWindow()) ; Close the specific window
EndProcedure
Procedure MyGadgetEvent()
;#------------------------
SetGadgetText(#Msg, "Button" + Str(EventGadget()) + " pressed!")
EndProcedure
If OpenWindow(#Win, 0, 0, igWinW, igWinH, "", #PB_Window_BorderLess|#PB_Window_ScreenCentered)
ScrollAreaGadget(#Scroll, 0, 0, igWinW, igWinH, 1920, 1080, 40)
ButtonGadget(#Btn1, 10, 10, 255, 38,"Button 1")
ButtonGadget(#Btn2, 10, 50, 255, 38,"Button 2")
ButtonGadget(#Btn3, 10, 90, 255, 38,"Button 3")
ButtonGadget(#BtnExit, 10, 130, 255, 38,"Exit")
TextGadget(#Msg, 10, 180, 255, 26, "", #PB_Text_Center | #PB_Text_Border)
TextGadget(#Txt, 200, 210, 230, 26, "Scroll to see all of the Text Here", #PB_Text_Right | #PB_Text_Border)
BindEvent(#PB_Event_Gadget, @MyGadgetEvent(), #Win, #Btn1)
BindEvent(#PB_Event_Gadget, @MyGadgetEvent(), #Win, #Btn2)
BindEvent(#PB_Event_Gadget, @MyGadgetEvent(), #Win, #Btn3)
BindEvent(#PB_Event_Gadget, @CloseWindowEvent(), #Win, #BtnExit)
CloseGadgetList()
EndIf
Re: Create Android App Fullscreen
Posted: Sat Jun 10, 2017 7:30 pm
by Peter
interesting! It seems, that the compilers generate target-specific code.
Could you be so kind and execute the following code on your device?
Code: Select all
Define F.s
! v_f = eval(spider_ExamineDesktops).toString();
Debug F
Thanks in advance & Greetings ... Peter
Re: Create Android App Fullscreen
Posted: Sat Jun 10, 2017 7:59 pm
by falsam
IdeasVacuum wrote:ExamineDesktops() works!
Hum i think this is not the real screen resolution.
On my device, DesktopWidth() return 360. My real screen width is 1280
Re: Create Android App Fullscreen
Posted: Sat Jun 10, 2017 9:09 pm
by IdeasVacuum
Peter:
function spider_ExaminDesktops() {return 1}
falsam:
Code: Select all
ExamineDesktops()
Debug DesktopWidth(0)
Debug DesktopHeight(0)
640
335
(Actual: 960*540)
...but why does DesktopWidth/DesktopHeight return values?
So guys - what is the solution? How can I ensure that my app is fullscreen?
Re: Create Android App Fullscreen
Posted: Sat Jun 10, 2017 9:16 pm
by falsam
[SB 2.00] Orientation : Any - Fullscreen : check
I'm trying to test this code.
Code: Select all
Enumeration
#mf
#mfResolution0
#mfResolution1
#mfExit
EndEnumeration
Declare Start()
Declare onChangeOrientation()
Declare Exit()
;No Zoom
!$('head').append('<meta name="viewport" content="width=device-width, maximum-scale=1.0, user-scalable=0">');
Start()
Procedure Start()
Protected font = LoadFont(#PB_Any, "", 22), Gadget
CloseDebugOutput()
OpenWindow(#mf, 0, 0, 0, 0, "", #PB_Window_Background)
Gadget = TextGadget(#PB_Any, 10, 20, 150, 40, "Resolution")
SetGadgetFont(Gadget, FontID(font))
TextGadget(#mfResolution0, 250, 20, 200, 40, "")
SetGadgetFont(#mfResolution0, FontID(font))
Gadget = TextGadget(#PB_Any, 10, 70, 150, 40, "ExamineDesktop()")
SetGadgetFont(Gadget, FontID(font))
TextGadget(#mfResolution1, 250, 70, 200, 40, "")
SetGadgetFont(#mfResolution1, FontID(font))
ButtonGadget(#mfExit, 0, 20, 100, 40, "Exit")
SetGadgetFont(#mfExit, FontID(font))
onChangeOrientation()
!navigator.vibrate(1000);
BindGadgetEvent(#mfExit, @Exit())
BindEvent(#PB_Event_SizeWindow, @onChangeOrientation())
EndProcedure
Procedure onChangeOrientation()
Protected width, height
ExamineDesktops()
!v_width = screen.width * window.devicePixelRatio;
!v_height = screen.height * window.devicePixelRatio;
!document.body.style.zoom = 1 / window.devicePixelRatio * 100 + "%"
ResizeWindow(#mf, #PB_Ignore, #PB_Ignore, width, height)
ResizeGadget(#mfExit, WindowWidth(#mf) - 120, #PB_Ignore, #PB_Ignore, #PB_Ignore)
SetGadgetText(#mfResolution0, Str(width) + " / " + Str(height))
SetGadgetText(#mfResolution1, Str(DesktopWidth(0)) + " / " + Str(DesktopHeight(0)) )
EndProcedure
Procedure Exit()
!window.close();
EndProcedure
Re: Create Android App Fullscreen
Posted: Sun Jun 11, 2017 12:15 am
by IdeasVacuum
Resolution 540/960
Examine Desktop 360/640
.... Procedure Exit looks interesting too!
With Fullscreen set, I thought Android would resize the window and gadgets on orientation change. Oh well.