NetTalk Central

Author Topic: ScreenWidth and Height - not working?  (Read 4037 times)

John Fligg

  • Sr. Member
  • ****
  • Posts: 361
    • View Profile
    • Ambrit Software
    • Email
ScreenWidth and Height - not working?
« on: February 26, 2012, 02:29:12 AM »
I am trying to implement a change in the value of _mobile_ for An Android running on a  tablet. Currently NT6 assumes Android means mobile = 1.

In NetWeb.clw there are 2 new methods one of which is SetMobileBasedOnSize. In that code is a trace statement:

self._trace('sw=' & sw & 'sh=' & sh & ' self.site.mobile.phonemax=' & self.site.mobile.phonemax)

where sw and sh are derived from:

sw = self.GSV('_screenWidth_')
sh = self.GSV('_screenHeight_')

However when I uncomment that trace statement and examine the values of sw and sh they are 0 as shown attached.

Does this mean that _screenwidth/height_ is not working? I need it to be in order to examine those and override the default settings.

I know that Bruce has allowed us to change the mobile width in the templates but that only works for second and subsequent screens and would really like to force an Android running on a table into full screen mode and override the default mobile detection.

Thanks

John



[attachment deleted by admin]

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: ScreenWidth and Height - not working?
« Reply #1 on: February 26, 2012, 11:27:46 PM »
>> However when I uncomment that trace statement and examine the values of sw and sh they are 0 as shown attached.

correct, they are set by;

  sw = self.GSV('_screenWidth_')
  sh = self.GSV('_screenHeight_')

which means they are 0 until set - which means in your log they have not been set yet.

>> but that only works for second and subsequent screens

yes, because when requesting the first page, the browser does not send through the screen size. In the reply to the first page is a note to the browser to report the screen size, which it then does (you'll see it in the log) and so subsequent requests will take that into account.

>> I would really like to force an Android running on a table into full screen mode

ok, then use the User-Agent to make a determination of whether it is mobile or not. ie add code to the SetMobileBasedOnAgent method. the UserAgent (property p_web._UserAgent) is all you have on the first request to base your decision on.

cheers
Bruce



John Fligg

  • Sr. Member
  • ****
  • Posts: 361
    • View Profile
    • Ambrit Software
    • Email
Re: ScreenWidth and Height - not working?
« Reply #2 on: February 27, 2012, 12:09:26 AM »
Thanks Bruce but not really the anser to the Android solution.

With Android you need a mixture of the 2 methods.

i.e. If Android then check the screen size as it may be a smartphone or a tablet. This I am sure will become even more of an issue when other tablets use an OS used on  a smartphone in the future. Also screen resolutions are changing (see private post).

So I guess what I really need to know Bruce is how do I check for Android AND screensize? SetMobileBasedOnAgent or SetMobileBasedOnSize?

I am happy for the change to take place on the 2nd screen as the login screen is not a problem.

Many thanks

John

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: ScreenWidth and Height - not working?
« Reply #3 on: February 27, 2012, 12:17:49 AM »
>> I am happy for the change to take place on the 2nd screen

ok, so in what way is the default behavior not working for you?

cheers
Bruce

John Fligg

  • Sr. Member
  • ****
  • Posts: 361
    • View Profile
    • Ambrit Software
    • Email
Re: ScreenWidth and Height - not working?
« Reply #4 on: February 27, 2012, 12:40:46 AM »
By that I guess you mean setting it to 600? I am not sure because I do not have an Adroid tablet (yet).

The thing is, whilst this is just one specific case I suspect this could become an issue in the future and whilst 600 may work now that might not always be the case.

So let's turn it around a bit - is there a way I can set that 600 in a preferences file? Then In theory I could read that immediatley after Login (so I cna get the correct preferences file for the specific user) and have them change the preference. Then next time it would be set correctly.

From what I was reading this weekend, 480 was the average smartphone resolution so 600 would work. However some are now at about 750 I think so 600 is not going to work. So it really needs to be customisable using Preferences or getting the code to detect OS and size as a combination.

Thanks

John

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: ScreenWidth and Height - not working?
« Reply #5 on: February 27, 2012, 02:26:04 AM »
that field in the template is an expression, so you can definitely use a variable there - primed from a setting or whatever....