Skip to content

Commit

Permalink
Improves detection for tablets (#7689)
Browse files Browse the repository at this point in the history
* Improves detection for tablets
* Change from U+0421 to U+0043
* Adds detection for bq Fnac 10" 3G
  • Loading branch information
liviuconcioiu authored May 27, 2024
1 parent 27075fe commit 9208a48
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 44 deletions.
2 changes: 1 addition & 1 deletion DeviceDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ protected function getOsAttribute(string $attr): string
*/
protected function hasAndroidTableFragment(): bool
{
$regex = 'Android( [\.0-9]+)?; Tablet;|.*\-tablet$';
$regex = 'Android( [\.0-9]+)?; Tablet;|Tablet(?! PC)|.*\-tablet$';

return !!$this->matchUserAgent($regex);
}
Expand Down
18 changes: 0 additions & 18 deletions Tests/fixtures/desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -676,24 +676,6 @@
model: ""
os_family: GNU/Linux
browser_family: Unknown
-
user_agent: Mozilla/5.0 (X11; U; Linux armv7l; en-GB; rv:1.9.2a1pre) Gecko/20090514 Firefox/3.0 Tablet browser 0.9.7 RX-34
os:
name: GNU/Linux
version: ""
platform: ARM
client:
type: browser
name: MicroB
version: 0.9.7
engine: Gecko
engine_version: 1.9.2
device:
type: desktop
brand: ""
model: ""
os_family: GNU/Linux
browser_family: Firefox
-
user_agent: Mozilla/5.0 (X11; Linux) AppleWebKit/535.22 (KHTML, like Gecko) Chrome/18.0.1025.133 Safari/535.22 Midori/0.5
os:
Expand Down
2 changes: 1 addition & 1 deletion Tests/fixtures/smartphone-4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5751,7 +5751,7 @@
device:
type: smartphone
brand: Fly
model: Сhamp
model: Champ
os_family: Android
browser_family: Chrome
-
Expand Down
4 changes: 2 additions & 2 deletions Tests/fixtures/tablet-1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2262,7 +2262,7 @@
device:
type: tablet
brand: bq
model: Сharm
model: Charm
os_family: Android
browser_family: Chrome
-
Expand All @@ -2280,7 +2280,7 @@
device:
type: tablet
brand: bq
model: Сharm Plus
model: Charm Plus
os_family: Android
browser_family: Chrome
-
Expand Down
18 changes: 18 additions & 0 deletions Tests/fixtures/tablet-11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5597,3 +5597,21 @@
model: P40HD
os_family: Android
browser_family: Unknown
-
user_agent: Mozilla/5.0 (Linux; U; Android 4.0.4; es-es; tablet Fnac 10 3G Build/1.1.11-1015 20130125-16:17) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30
os:
name: Android
version: 4.0.4
platform: ""
client:
type: browser
name: Android Browser
version: ""
engine: WebKit
engine_version: "534.30"
device:
type: tablet
brand: bq
model: Fnac 10" 3G
os_family: Android
browser_family: Android Browser
52 changes: 34 additions & 18 deletions Tests/fixtures/unknown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1681,24 +1681,6 @@
model: ""
os_family: Android
browser_family: Android Browser
-
user_agent: Mozilla/5.0 (Linux; U; Android 4.0.4; es-es; tablet Fnac 10 3G Build/1.1.11-1015 20130125-16:17) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30
os:
name: Android
version: 4.0.4
platform: ""
client:
type: browser
name: Android Browser
version: ""
engine: WebKit
engine_version: "534.30"
device:
type: ""
brand: ""
model: ""
os_family: Android
browser_family: Android Browser
-
user_agent: Mozilla/5.0 (Linux; U; Android 4.0.4; es-us; f7 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
os:
Expand Down Expand Up @@ -3395,3 +3377,37 @@
model: ""
os_family: iOS
browser_family: Unknown
-
user_agent: Mozilla/5.0 (X11; U; Linux armv7l; en-GB; rv:1.9.2a1pre) Gecko/20090514 Firefox/3.0 Tablet browser 0.9.7 RX-34
os:
name: GNU/Linux
version: ""
platform: ARM
client:
type: browser
name: MicroB
version: 0.9.7
engine: Gecko
engine_version: 1.9.2
device:
type: tablet
brand: ""
model: ""
os_family: GNU/Linux
browser_family: Firefox
-
user_agent: Pinterest for Android Tablet/11.42.2 (trona; 9)
os:
name: Android
version: "9"
platform: ""
client:
type: mobile app
name: Pinterest
version: 11.42.2
device:
type: tablet
brand: ""
model: ""
os_family: Android
browser_family: Unknown
11 changes: 7 additions & 4 deletions regexes/device/mobiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5236,7 +5236,7 @@ Bmobile:

# bq
bq:
regex: 'Aquaris|bq [^/;]+ Build|BQS[-_]([0-9]{4})|(BQ(ru)?[_ -][0-9]{3,4})|BQ5059|BQ1008G|BQru_BQru-|Edison 3|Smart_TV_BQ'
regex: 'Aquaris|bq [^/;]+ Build|BQS[-_]([0-9]{4})|(BQ(ru)?[_ -][0-9]{3,4})|BQ5059|BQ1008G|BQru_BQru-|Edison 3|Smart_TV_BQ|Fnac 10 3G'
device: 'smartphone'
models:
- regex: 'BQ(?:ru)?-(?:5209L|5044)(?:[);/ ]|$)'
Expand Down Expand Up @@ -5299,6 +5299,9 @@ bq:
- regex: 'BQ-7022(G)?'
model: 'Canion'
device: 'tablet'
- regex: 'Fnac 10 3G'
model: 'Fnac 10" 3G'
device: 'tablet'
- regex: 'BQ-7021G'
model: 'Hit'
device: 'tablet'
Expand Down Expand Up @@ -5637,10 +5640,10 @@ bq:
model: 'Malta'
device: 'tablet'
- regex: 'BQ-7000G(?:[);/ ]|$)'
model: 'Сharm'
model: 'Charm'
device: 'tablet'
- regex: 'BQ-7040G(?:[);/ ]|$)'
model: 'Сharm Plus'
model: 'Charm Plus'
device: 'tablet'
- regex: 'BQ-7038G(?:[);/ ]|$)'
model: 'Light Plus'
Expand Down Expand Up @@ -28321,7 +28324,7 @@ Fly:
- regex: 'FS528'
model: 'Memory Plus'
- regex: 'FS529'
model: 'Сhamp'
model: 'Champ'
- regex: 'FS530'
model: 'Power Plus XXL'
- regex: 'FS454'
Expand Down

0 comments on commit 9208a48

Please sign in to comment.