From a67d98c31ee2a846993a6d494fb1df1e7a95074c Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Wed, 21 Aug 2024 02:59:14 +0200 Subject: [PATCH 1/2] fix: Disable auto-zoom on iOS When using iOS and focussing an input element the view should not be zoomed. So if we set a maximum scale iOS will not auto-zoom but still allow users to zoom. But we can not do this by default as this will disable user zoom on Chrome. Signed-off-by: Ferdinand Thiessen --- core/templates/layout.base.php | 4 +++- core/templates/layout.guest.php | 4 +++- core/templates/layout.public.php | 4 +++- core/templates/layout.user.php | 4 +++- lib/private/TemplateLayout.php | 9 +++++++++ 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/core/templates/layout.base.php b/core/templates/layout.base.php index e74cd4b8cd2f2..4473117276075 100644 --- a/core/templates/layout.base.php +++ b/core/templates/layout.base.php @@ -12,7 +12,9 @@ <?php p($theme->getTitle()); ?> - + "> diff --git a/core/templates/layout.guest.php b/core/templates/layout.guest.php index 03682a24193fc..f006a6fda3818 100644 --- a/core/templates/layout.guest.php +++ b/core/templates/layout.guest.php @@ -20,7 +20,9 @@ ?> "> - + getiTunesAppId() !== '') { ?> diff --git a/core/templates/layout.public.php b/core/templates/layout.public.php index 90aefe0b8a8d8..10b64fcdef845 100644 --- a/core/templates/layout.public.php +++ b/core/templates/layout.public.php @@ -15,7 +15,9 @@ ?> "> - + getiTunesAppId() !== '') { ?> diff --git a/core/templates/layout.user.php b/core/templates/layout.user.php index 3293fc0acd706..a70fa6dcdbca0 100644 --- a/core/templates/layout.user.php +++ b/core/templates/layout.user.php @@ -30,7 +30,9 @@ ?> "> - + getiTunesAppId() !== '') { ?> diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index 7b33f88d4dba3..272557f51779f 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -8,6 +8,7 @@ namespace OC; use bantu\IniGetWrapper\IniGetWrapper; +use OC\AppFramework\Http\Request; use OC\Authentication\Token\IProvider; use OC\Files\FilenameValidator; use OC\Search\SearchQuery; @@ -20,6 +21,7 @@ use OCP\IConfig; use OCP\IInitialStateService; use OCP\INavigationManager; +use OCP\IRequest; use OCP\IURLGenerator; use OCP\IUserSession; use OCP\L10N\IFactory; @@ -286,6 +288,13 @@ public function __construct($renderAs, $appId = '') { } } + $request = \OCP\Server::get(IRequest::class); + if ($request->isUserAgent([Request::USER_AGENT_CLIENT_IOS, Request::USER_AGENT_SAFARI])) { + // Prevent auto zoom with iOS but still allow user zoom + // On chrome (and others) this does not work (will also disable user zoom) + $this->assign('viewport_maximum_scale', '1.0'); + } + $this->assign('initialStates', $this->initialState->getInitialStates()); $this->assign('id-app-content', $renderAs === TemplateResponse::RENDER_AS_USER ? '#app-content' : '#content'); From 655b318b23e9a670db2c9b788d1d32cd83a06aa4 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Wed, 21 Aug 2024 11:54:47 +0200 Subject: [PATCH 2/2] fix: Support Safari mobile Signed-off-by: Ferdinand Thiessen --- lib/private/AppFramework/Http/Request.php | 1 + lib/private/TemplateLayout.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/private/AppFramework/Http/Request.php b/lib/private/AppFramework/Http/Request.php index f790dae226cb4..c877304c92988 100644 --- a/lib/private/AppFramework/Http/Request.php +++ b/lib/private/AppFramework/Http/Request.php @@ -38,6 +38,7 @@ class Request implements \ArrayAccess, \Countable, IRequest { public const USER_AGENT_CHROME = '/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\)( Ubuntu Chromium\/[0-9.]+|) Chrome\/[0-9.]+ (Mobile Safari|Safari)\/[0-9.]+( (Vivaldi|Brave|OPR)\/[0-9.]+|)$/'; // Safari User Agent from http://www.useragentstring.com/pages/Safari/ public const USER_AGENT_SAFARI = '/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\) Version\/[0-9.]+ Safari\/[0-9.A-Z]+$/'; + public const USER_AGENT_SAFARI_MOBILE = '/^Mozilla\/5\.0 \([^)]+\) AppleWebKit\/[0-9.]+ \(KHTML, like Gecko\) Version\/[0-9.]+ (Mobile\/[0-9.A-Z]+) Safari\/[0-9.A-Z]+$/'; // Android Chrome user agent: https://developers.google.com/chrome/mobile/docs/user-agent public const USER_AGENT_ANDROID_MOBILE_CHROME = '#Android.*Chrome/[.0-9]*#'; public const USER_AGENT_FREEBOX = '#^Mozilla/5\.0$#'; diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index 272557f51779f..fd6b7b27a97fd 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -289,7 +289,7 @@ public function __construct($renderAs, $appId = '') { } $request = \OCP\Server::get(IRequest::class); - if ($request->isUserAgent([Request::USER_AGENT_CLIENT_IOS, Request::USER_AGENT_SAFARI])) { + if ($request->isUserAgent([Request::USER_AGENT_CLIENT_IOS, Request::USER_AGENT_SAFARI, Request::USER_AGENT_SAFARI_MOBILE])) { // Prevent auto zoom with iOS but still allow user zoom // On chrome (and others) this does not work (will also disable user zoom) $this->assign('viewport_maximum_scale', '1.0');