NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: John Fligg 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]
-
>> 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
-
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
-
>> 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
-
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
-
that field in the template is an expression, so you can definitely use a variable there - primed from a setting or whatever....