Skip to content

Commit 9be16e9

Browse files
committed
MOBILE-4475 ios: Enable native full screen in iOS 17+
1 parent 7f1c6b1 commit 9be16e9

File tree

5 files changed

+14
-10
lines changed

5 files changed

+14
-10
lines changed

config.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<preference name="iosPersistentFileLocation" value="Compatibility" />
4747
<preference name="iosScheme" value="moodleappfs" />
4848
<preference name="WKWebViewOnly" value="true" />
49-
<preference name="WKFullScreenEnabled" value="false" />
49+
<preference name="WKFullScreenEnabled" value="true" />
5050
<preference name="AndroidXEnabled" value="true" />
5151
<preference name="GradlePluginGoogleServicesEnabled" value="true" />
5252
<preference name="GradlePluginGoogleServicesVersion" value="4.3.15" />

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"@moodlehq/cordova-plugin-file-transfer": "2.0.0-moodle.2",
8181
"@moodlehq/cordova-plugin-inappbrowser": "5.0.0-moodle.3",
8282
"@moodlehq/cordova-plugin-intent": "2.2.0-moodle.3",
83-
"@moodlehq/cordova-plugin-ionic-webview": "5.0.0-moodle.3",
83+
"@moodlehq/cordova-plugin-ionic-webview": "5.0.0-moodle.4",
8484
"@moodlehq/cordova-plugin-local-notification": "0.9.0-moodle.12",
8585
"@moodlehq/cordova-plugin-qrscanner": "3.0.1-moodle.5",
8686
"@moodlehq/cordova-plugin-statusbar": "4.0.0-moodle.3",

src/core/features/h5p/assets/js/h5p.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ function isIOS() {
2727
|| (navigator.userAgent.includes("Mac") && "ontouchend" in document);
2828
}
2929

30+
let useFakeFullScreen = false;
31+
3032
// Detect if we support fullscreen, and what prefix to use.
3133
if (document.documentElement.requestFullscreen) {
3234
/**
@@ -57,6 +59,7 @@ else if (document.documentElement.msRequestFullscreen) {
5759
// This code has been added to allow a "fake" full screen in Moodle app.
5860
H5P.fullScreenBrowserPrefix = 'webkit';
5961
H5P.safariBrowser = 0;
62+
useFakeFullScreen = true;
6063
}
6164

6265
/**
@@ -174,7 +177,7 @@ H5P.init = function (target) {
174177
})
175178
;
176179

177-
if (isIOS()) {
180+
if (useFakeFullScreen) {
178181
// Register message listener to enter fullscreen.
179182
window.addEventListener('message', function receiveMessage(event) {
180183
if (event.data == 'enterFullScreen') {
@@ -699,7 +702,7 @@ H5P.fullScreen = function ($element, instance, exitCallback, body, forceSemiFull
699702
var method = (H5P.fullScreenBrowserPrefix === 'ms' ? 'msRequestFullscreen' : H5P.fullScreenBrowserPrefix + 'RequestFullScreen');
700703
var params = (H5P.fullScreenBrowserPrefix === 'webkit' && H5P.safariBrowser === 0 ? Element.ALLOW_KEYBOARD_INPUT : undefined);
701704

702-
if (isIOS()) {
705+
if (useFakeFullScreen) {
703706
before('h5p-fullscreen-ios');
704707
window.parent.postMessage('enterFullScreen', '*');
705708
} else {
@@ -718,7 +721,7 @@ H5P.fullScreen = function ($element, instance, exitCallback, body, forceSemiFull
718721
else {
719722
done('h5p-fullscreen');
720723
document[H5P.fullScreenBrowserPrefix + 'ExitFullscreen'] && document[H5P.fullScreenBrowserPrefix + 'ExitFullscreen']();
721-
if (isIOS()) {
724+
if (useFakeFullScreen) {
722725
done('h5p-fullscreen-ios');
723726
window.parent.postMessage('exitFullScreen', '*');
724727
}
@@ -727,7 +730,7 @@ H5P.fullScreen = function ($element, instance, exitCallback, body, forceSemiFull
727730
}
728731
};
729732

730-
if (isIOS()) {
733+
if (useFakeFullScreen) {
731734
// Pass fullscreen messages to child iframes.
732735
window.addEventListener('message', function receiveMessage(event) {
733736
if (event.data === 'enterFullScreen' || event.data === 'exitFullScreen') {

src/core/features/h5p/assets/readme_moodle.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ Changes:
77
2. The h5p.js file has been modified to simulate a fake full screen in iOS. The H5P file now sends post messages to the app, and also listens to messages sent by the app to enter/exit full screen.
88
3. The embed.js file has been modified to remove optional chaining because it isn't supported in some old devices.
99
4. The h5p.js has been modified to include a call to contentUserDataAjax (this change was done in LMS too).
10+
5. The h5p.js has been modified so the fake sull screen (point 2) is only used if native full screen is not available (iOS 16 or older).

0 commit comments

Comments
 (0)