Skip to content
Snippets Groups Projects
Commit 0281a1d7 authored by Pierre Paridans's avatar Pierre Paridans
Browse files

[FIX] web: backport mobile OS detection support


This commit backports the mobile OS detection support, and specifically
Android & iOS one to allow more specific targeting of edge cases (i.e.
disabling native date picker in the mobile iOS app only).

opw-2613810

closes odoo/odoo#75536

X-original-commit: be9effaae8fe9dee2166abe7f79a73a119b78a92
Related: odoo/enterprise#20434
Signed-off-by: default avatarAdrien Dieudonné (adr) <adr@odoo.com>
Signed-off-by: default avatarPierre Paridans <pparidans@users.noreply.github.com>
parent c9f5a502
Branches
Tags
No related merge requests found
......@@ -10,6 +10,11 @@ odoo.define('web.config', function () {
* this file someday.
*/
const maxTouchPoints = navigator.maxTouchPoints || 1;
const isAndroid = /Android/i.test(navigator.userAgent);
const isIOS = /(iPad|iPhone|iPod)/i.test(navigator.userAgent) || (navigator.platform === 'MacIntel' && maxTouchPoints > 1);
const isOtherMobileDevice = /(webOS|BlackBerry|Windows Phone)/i.test(navigator.userAgent);
var config = {
device: {
/**
......@@ -26,6 +31,20 @@ var config = {
* @type Number
*/
size_class: null,
/**
* Mobile OS (Android) device detection using userAgent.
* This flag doesn't depend on the size/resolution of the screen.
*
* @return Boolean
*/
isAndroid: isAndroid,
/**
* Mobile OS (iOS) device detection using userAgent.
* This flag doesn't depend on the size/resolution of the screen.
*
* @return Boolean
*/
isIOS: isIOS,
/**
* A frequent use case is to have a different render in 'mobile' mode,
* meaning when the screen is small. This flag (boolean) is true when
......@@ -34,6 +53,14 @@ var config = {
* @type Boolean
*/
isMobile: null,
/**
* Mobile device detection using userAgent.
* This flag doesn't depend on the size/resolution of the screen.
* It targets mobile devices which suggests that there is a virtual keyboard.
*
* @return {boolean}
*/
isMobileDevice: isAndroid || isIOS || isOtherMobileDevice,
/**
* Mapping between the numbers 0,1,2,3,4,5,6 and some descriptions
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment