Everything else that doesn't fall into one of the other categories.
falsam
 
Posts: 237
Joined: Mon May 05, 2014 9:49 pm
Location: France

Android: Test resolution screen

by falsam Mon Sep 18, 2017 6:31 pm

If you have a tablet or a smartphone with Android, you can create an apk with this code and tell me if the result is identical to this image.

Image

Each corner of the screen must have a green square.

This code does not work with a computer browser. Only Android.

Thanks.

Greetings

Code: Select all
; Date & Time Version 1
;
; SpiderBasic 2.2 JDK 1.1.8.0 144 (x86)
; Android Only

EnableExplicit

Enumeration
  #FontH1
  #FontH2
 
  #mf
  #mfDate
  #mfTime
 
  #TL ;Square Top Left
  #TR ;Square Top Right
  #BL ;Square Bottom Left
  #BR ;Square Bottom Right
 
  #Timer
EndEnumeration

Declare Start()
Declare onTimer()
Declare onChangeOrientation()

Start()

Procedure Start()
  Protected BackColor = RGB(105, 105, 105)
  Protected FrontColor = RGB(152, 251, 152)
  Protected Image, Gadget
 
  CloseDebugOutput()
 
  ;No Zoom
  !$('head').append('<meta name="viewport" content="width=device-width, maximum-scale=1.0, user-scalable=0">');
 
  LoadFont(#FontH1, "", 70)
  LoadFont(#FontH2, "", 50)
 
  OpenWindow(#mf, 0, 0, 0, 0, "Date & Time", #PB_Window_Background)
  SetWindowColor(#mf, BackColor)
 
  TextGadget(#mfDate, 0, 0, 400, 100, "", #PB_Text_Center)   
  SetGadgetFont(#mfDate, FontID(#FontH1))
  SetGadgetColor(#mfDate, #PB_Gadget_FrontColor, FrontColor)
 
  TextGadget(#mfTime, 0, 0, 400, 100, "00:00:00", #PB_Text_Center)   
  SetGadgetFont(#mfTime, FontID(#FontH2))
  SetGadgetColor(#mfTime, #PB_Gadget_FrontColor, FrontColor)
 
  ;Squares
  Image = CreateImage(#PB_Any, 40, 40, 0, FrontColor)
  StartDrawing(ImageOutput(Image))
  Box(0, 0, 40, 40, RGB(0, 0, 0))
  Box(5, 5, 30, 30, FrontColor)
  StopDrawing()
 
  For Gadget = #TL To #BR
    ImageGadget(Gadget, 0, 0, 40, 40, ImageID(Image))
  Next
   
  ;Init
  AddWindowTimer(#mf, #Timer, 1000)
  onTimer()
  onChangeOrientation()
 
  ;Triggers
  BindEvent(#PB_Event_Timer, @onTimer(), #mf, #Timer)
  BindEvent(#PB_Event_SizeWindow, @onChangeOrientation()) 
EndProcedure

Procedure onTimer()
  SetGadgetText(#mfDate, FormatDate("%yyyy-%mm-%dd", Date()))
  SetGadgetText(#mfTime, FormatDate("%hh:%ii:%ss", Date()))
EndProcedure

Procedure onChangeOrientation()
  Protected width, height
 
  !v_width = screen.width * window.devicePixelRatio;
  !v_height = screen.height * window.devicePixelRatio;
   
  !document.body.style.zoom = 1 / window.devicePixelRatio * 100 + "%"
 
  ResizeGadget(#mfDate, (width - GadgetWidth(#mfDate))/2, (height - GadgetHeight(#mfDate))/2, #PB_Ignore, #PB_Ignore)
  ResizeGadget(#mfTime, (width - GadgetWidth(#mfTime))/2, (height - GadgetHeight(#mfTime))/2 + 100, #PB_Ignore, #PB_Ignore)
 
  ResizeGadget(#TL, 0, 0, #PB_Ignore, #PB_Ignore)
  ResizeGadget(#TR, Width - 40, 0, #PB_Ignore, #PB_Ignore)
  ResizeGadget(#BL, 0, height - 40, #PB_Ignore, #PB_Ignore)
  ResizeGadget(#BR, Width - 40, height -40, #PB_Ignore, #PB_Ignore)
 
  ResizeWindow(#mf, #PB_Ignore, #PB_Ignore, width, height)
EndProcedure
If you can not compile for Android, I suggest the APK. DateTime.apk (1.8 Mo)

■ Parameter
- General option: Enabled unknown sources.
- Development options: Enabled USB debugging
➽ Windows 10 - JDK 1.8 - SB 2.20 - Android 5.5
Mood ☀️
http://falsam.com

Sorry for my poor english
mdp
 
Posts: 31
Joined: Fri Oct 06, 2017 10:37 am

Re: Android: Test resolution screen

by mdp Sun Oct 08, 2017 7:33 pm

I LOVE that trick to inhibit zoom. I needed that.
Saw your reply minutes ago, still reading the code...
User avatar
Peter
 
Posts: 447
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1

Re: Android: Test resolution screen

by Peter Wed Nov 01, 2017 11:07 am

falsam wrote:If you have a tablet or a smartphone with Android, you can create an apk with this code and tell me if the result is identical to this image.

I have just downloaded, installed and started your APK. Works as expected on my Nexus 5X. Thanks!

Greetings ... Peter
falsam
 
Posts: 237
Joined: Mon May 05, 2014 9:49 pm
Location: France

Re: Android: Test resolution screen

by falsam Wed Nov 01, 2017 11:20 am

Thanks for this test Peter :)
➽ Windows 10 - JDK 1.8 - SB 2.20 - Android 5.5
Mood ☀️
http://falsam.com

Sorry for my poor english
Return to General Discussion

Who is online

Users browsing this forum: No registered users and 4 guests