? ? Pending

User tests: Successful: Unsuccessful:

avatar photodude
photodude
11 Apr 2017

Pull Request for Issue mobile checks have multiple conditionals when one is sufficient

Summary of Changes

only check for resolution in user agent once to determine mobile
add common user agent strings that identify mobile
Fix mobile check to be separate from browser.

Testing Instructions

code review

(could apply patch and check on a mobile device or emulator that mobile is detected)

Expected result

mobile is easily and correctly detected.

Actual result

extraneous checks were in additional locations specific to certain browsers

Documentation Changes Required

none

avatar photodude photodude - open - 11 Apr 2017
avatar photodude photodude - change - 11 Apr 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 11 Apr 2017
Category Libraries
avatar photodude photodude - change - 11 Apr 2017
Labels Added: ?
avatar photodude photodude - change - 17 Apr 2017
The description was changed
avatar photodude photodude - edited - 17 Apr 2017
avatar photodude
photodude - comment - 22 Apr 2017

@rdeutz, @mbabker, @wilsonge
Any thoughts on these changes?

avatar wilsonge
wilsonge - comment - 22 Apr 2017

I think this is wrong. For example edge handsets will now just be recognised as mobile but not as edge. Because they will trigger in the first if that does the mobile check, but not in the part that does the

Ditto I assume iPhone's can be identified as Safari (or iOS Chrome by the user agent) and therefore shouldn't 'just' be a unknown browser mobile. But should trigger user agent checks so we know mobile and browser

avatar dgt41
dgt41 - comment - 22 Apr 2017

I've proposed this before, but I will do it again, let's use: https://github.com/serbanghita/Mobile-Detect

avatar photodude
photodude - comment - 22 Apr 2017

@wilsonge I believe mobile is a wholly separate property from browser. I also believe the two are checked and set separately (although in the same function).

avatar dgt41
dgt41 - comment - 22 Apr 2017

@brianteeman and this is one of those areas that Joomla should not try to innovate by having it's own well abandoned code. Check the highlighted part of their repo and compare it to the last update of the Joomla's shiny WebClient.php:
screen shot 2017-04-22 at 20 18 02

Use other people's code when it's an obvious win!

avatar mbabker
mbabker - comment - 22 Apr 2017

If someone does a PR that at least proxies the internals of either JBrowser or Joomla\Application\Web\WebClient (or both) to another library we could use it. We'd need that to help with the transition away from our own code.

avatar wilsonge
wilsonge - comment - 22 Apr 2017
avatar photodude
photodude - comment - 22 Apr 2017

@wilsonge that is technically a bug in the existing code too I overlooked the if elseif; I was thinking it was two different conditionals as it should be. Corrected, as mobile and browser are different properties.

avatar photodude
photodude - comment - 22 Apr 2017

@dgt41 I'm all for using an external solution. We will never be able to properly maintain every browser combination and properly check them.
See joomla-framework/application#59 where we have been discussing that for Joomla\Application\Web\WebClient

but as @mbabker noted, someone needs to proxy the internals of our existing solutions to whatever option we use. I'm leaning towards pulling in the browscap.ini and use the php native get_browser() although that requires setting another ini value at runtime with ini_set('browscap', '[thebrowscap.ini file location]'); and parsing the returned object. I'm leaning that direction since many other userland browscap libraries don't support the range of PHP versions that Joomla does.

avatar photodude
photodude - comment - 22 Apr 2017

@brianteeman Yes, there is a mobile detection in Joomla\Application\Web\WebClient. as there currently is here in JBrowser. There is work needed here; either fixing, or proxying to a 3rdparty library, or making JBrowser an alias of Joomla\Application\Web\WebClient

The focus in this PR is improving (and apparently fixing) the current JBrowser mobile detection.

avatar photodude
photodude - comment - 22 Apr 2017

@mbabker can you rerun the appveyor tests. There was an unrelated failure in one of the Cachelite tests. Thanks in advance.

avatar photodude photodude - change - 22 Apr 2017
The description was changed
avatar photodude photodude - edited - 22 Apr 2017
avatar photodude
photodude - comment - 29 Apr 2017

@wilsonge with the correction to the conditional, do you think this is good to go?

avatar infograf768
infograf768 - comment - 31 May 2017

Question:
Can we serve different contents depending on this detection?
For example, a different content depending if mobile or desktop.
And usable in a multilingual setting?

avatar photodude
photodude - comment - 31 May 2017

@infograf768 It might be possible. Although, I'm more of a fan of responsive design and let the css control the view depending on the viewport size. As for content, it seems reasonable that a module could be set to change content when JBrowser::mobile === true but I am unaware of any examples showing such a content switching based on the value of JBrowser::mobile.

I've done a few things in the past where a module would show if it was desktop and would hide and show a different module if it was mobile, that switch was all controlled by css classes.

avatar Quy
Quy - comment - 1 Jun 2017

I have tested this item successfully on 4328de0


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/15228.

avatar Quy Quy - test_item - 1 Jun 2017 - Tested successfully
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 2 Jun 2017

Have tested successfully using "Firefox > Responsive Design Mode" – ist this Test-Scenario enough for marking as successfully Test?

avatar photodude
photodude - comment - 2 Jun 2017

@franz-wohlkoenig Looking over the code JBrowser seems to only be used in JHtml::includeRelativeFiles and affects JHtml::stylesheet. Any general testing should be sufficient unless you can find a template that uses different files for different browsers and want to test with multiple browsers. Since that is a very unique situation, general use testing, Code review and the unit tests should be sufficient for now.

Likely need to look at depreciating JBrowser for 4.0 and just use the framework browser detection in the application library.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 2 Jun 2017

I have tested this item successfully on 4328de0


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/15228.

avatar franz-wohlkoenig franz-wohlkoenig - test_item - 2 Jun 2017 - Tested successfully
avatar franz-wohlkoenig franz-wohlkoenig - change - 2 Jun 2017
Status Pending Ready to Commit
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 2 Jun 2017

RTC after two successful tests.

avatar wilsonge wilsonge - change - 2 Jun 2017
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2017-06-02 18:50:00
Closed_By wilsonge
Labels Added: ?
avatar wilsonge wilsonge - close - 2 Jun 2017
avatar wilsonge wilsonge - merge - 2 Jun 2017
avatar wilsonge
wilsonge - comment - 2 Jun 2017

Thanks!

avatar infograf768
infograf768 - comment - 16 Jul 2017

@photodude
Please look at #17139 urgently

avatar photodude
photodude - comment - 16 Jul 2017

@infograf768 I have reviewed it.

Add a Comment

Login with GitHub to post a comment