User tests: Successful: Unsuccessful:
Pull Request for Issue mobile checks have multiple conditionals when one is sufficient
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.
code review
(could apply patch and check on a mobile device or emulator that mobile is detected)
mobile is easily and correctly detected.
extraneous checks were in additional locations specific to certain browsers
none
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Labels |
Added:
?
|
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
I've proposed this before, but I will do it again, let's use: https://github.com/serbanghita/Mobile-Detect
Dont we have mobile detection already in https://github.com/joomla/joomla-cms/blob/staging/libraries/vendor/joomla/application/src/Web/WebClient.php
@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:
Use other people's code when it's an obvious win!
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.
@photodude if you match this if
https://github.com/photodude/joomla-cms/blob/f1a5b8df900c31d21e93291286dedd405ca5320c/libraries/joomla/environment/browser.php#L229-L242 then you're never going to reach the edge elseif
afterwards
@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.
@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.
@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.
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?
@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.
I have tested this item
Have tested successfully using "Firefox > Responsive Design Mode" – ist this Test-Scenario enough for marking as successfully Test?
@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.
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
RTC after two successful tests.
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:
?
|
Thanks!
@photodude
Please look at #17139 urgently
@infograf768 I have reviewed it.
@rdeutz, @mbabker, @wilsonge
Any thoughts on these changes?