Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with Samsung Galaxy Tab 4 #5

Closed
toshsharma opened this issue Jun 4, 2014 · 14 comments
Closed

Not working with Samsung Galaxy Tab 4 #5

toshsharma opened this issue Jun 4, 2014 · 14 comments
Labels

Comments

@toshsharma
Copy link

The UA is:
Mozilla/5.0 (Linux; Android 4.4.2; en-us; SAMSUNG SM-T530NU Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Safari/537.36

Since the check for a phone is before that for a tablet, its being identified as a phone - mobielDetectRules for a phone contain the regex /Samsung/i. This causes the regex for a Samsung tablet /SAMSUNG.*Tablet/ to never be matched since the check for a phone is made before that for a tablet. Should the checking order be reversed (tablet, then phone)?

@hgoebl hgoebl added the bug label Jun 4, 2014
@hgoebl
Copy link
Owner

hgoebl commented Jun 4, 2014

This is a general problem not only for this special device. There are some regexps which are way too general and then many devices fall into the wrong category even if stronger regexps exist. I have to discuss this with @serbanghita and find a special treatment if necessary.

Just reversing the order of checks wouldn't really help - we only moved the problem to phones detected as tablet then.

@serbanghita
Copy link
Collaborator

@toshsharma thanks for reporting this!

@hgoebl I will research and update the Samsung tablet regex with the new tablet releases and get back asap.

Yes the phones regex is wider because it need to catch everything, the tablet regex works like a filter to that.

@toshsharma
Copy link
Author

Thanks. Although, even when I updated the tablet regex to include the model number for the Tab 4, it doesn't work because the UA for the Tab 4 contains the word "Samsung" (which is not present in earlier tablet models, I think), thereby causing it to be recognized as a phone (since prepareDetectionCache returns as soon as it finds a match). Perhaps prepareDetectionCache should check further if the UA also matches a tablet (even if a phone regex has been matched)?

@hgoebl
Copy link
Owner

hgoebl commented Jun 4, 2014

@toshsharma sounds like the solution is obvious:

phone = match(phone) && !tablet

The problem is that I don't have very reliable tests - many of them failed from the beginning. But maybe with such a change the number of failing tests decreases.

I hope I manage to release a new version before my holiday (on Saturday)...
To be honest repairing my MTB and downloading GPX tracks has more priority at the moment.

@hgoebl
Copy link
Owner

hgoebl commented Jun 4, 2014

@serbanghita thanks for the instant and constructive input!

@toshsharma
Copy link
Author

Thanks @hgoebl - I believe that'll work well.

I'll test with some devices and let you know if something breaks with this change - as you said, I expect things should be better with it.

There seem to be multiple variants of the Tab 4 - SM-T530, SM-T531, SM-T535 - I'm hoping you'll update the regex with all of them. Thanks again for a quick response! :)

@serbanghita
Copy link
Collaborator

@toshsharma I've released Mobile_Detect 2.8.1 that should contain the newest tablet releases from Samsung. All UnitTests passing.

@toshsharma
Copy link
Author

Thanks @serbanghita!

@hgoebl
Copy link
Owner

hgoebl commented Jun 5, 2014

@toshsharma no need to fork - I'm currently fixing the bug!

@toshsharma
Copy link
Author

Awesome - thanks for the quick resolution!

@toshsharma
Copy link
Author

Could you please update the regex to include "SM-T331" (Samsung Galaxy Tab 4 8" variant)?

@serbanghita
Copy link
Collaborator

@toshsharma absolutely. I'm adding it tonight with some other newly released tablets. Will get back to you!

@serbanghita
Copy link
Collaborator

Updated Mobile_Detect to 2.8.2

@toshsharma
Copy link
Author

Thanks @serbanghita. I'll pick the ne wlib once your changes are integrated into mobile-detect.js.

Do you think it'd be a good idea to report mobile() === true if the OS is Android or iOS, even if it can't be figured out whether the device is a phone or a tablet? This could be useful in the case of new mobile devices, where it'd still be meaningful to know that the device is a mobile (regardless of phone or tablet).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants