[IMP] web: add isDisplayStandalone feature detection helper

This commit adds the isDisplayStandalone helper, allowing to detect whether
Odoo is running inside the Progressive Web App (in standalone mode) or not.

This feature detection is directly used in the linked enterprise

closes odoo/odoo#128969

Pr: https://github.com/odoo/enterprise/pull/43680.
Related: odoo/enterprise#43680
Signed-off-by: Pierre Paridans (app) <app@odoo.com>
This commit is contained in:
luvi
2023-07-20 08:57:13 +02:00
parent 9c5ae5432f
commit 563b6a8a39
2 changed files with 5 additions and 0 deletions
@@ -33,6 +33,7 @@ export const browser = {
cancelAnimationFrame: window.cancelAnimationFrame.bind(window),
console: window.console,
history: window.history,
matchMedia: window.matchMedia.bind(window),
navigator,
Notification: window.Notification,
open: window.open.bind(window),
@@ -48,6 +48,10 @@ export function isAndroidApp() {
return /OdooMobile.+Android/i.test(browser.navigator.userAgent);
}
export function isDisplayStandalone() {
return browser.matchMedia("(display-mode: standalone)").matches;
}
export function hasTouch() {
return browser.ontouchstart !== undefined;
}