Skip to content

Commit b31a872

Browse files
committed
MOBILE-4796 screen: Watch full screen to hide statusbars
1 parent 9fa7906 commit b31a872

File tree

5 files changed

+36
-6
lines changed

5 files changed

+36
-6
lines changed

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
@@ -83,7 +83,7 @@
8383
"@moodlehq/cordova-plugin-ionic-webview": "5.0.0-moodle.5",
8484
"@moodlehq/cordova-plugin-media-capture": "5.0.0-moodle.1",
8585
"@moodlehq/cordova-plugin-qrscanner": "3.0.1-moodle.5",
86-
"@moodlehq/cordova-plugin-statusbar": "4.0.0-moodle.4",
86+
"@moodlehq/cordova-plugin-statusbar": "4.0.0-moodle.5",
8787
"@moodlehq/cordova-plugin-zip": "3.1.0-moodle.1",
8888
"@moodlehq/phonegap-plugin-push": "4.0.0-moodle.12",
8989
"@ngx-translate/core": "^16.0.4",

src/core/initializers/watch-screen-status.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ export default function(): void {
2222
CoreScreen.watchViewport();
2323

2424
CoreScreen.watchOrientation();
25+
26+
CoreScreen.watchFullscreen();
2527
}

src/core/services/screen.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { Injectable } from '@angular/core';
1616
import { BehaviorSubject, Observable } from 'rxjs';
1717
import { distinctUntilChanged, map } from 'rxjs/operators';
1818

19-
import { makeSingleton } from '@singletons';
19+
import { makeSingleton, StatusBar } from '@singletons';
2020
import { CoreEvents } from '@singletons/events';
2121
import { CorePlatform } from '@services/platform';
2222

@@ -128,6 +128,27 @@ export class CoreScreenService {
128128
});
129129
}
130130

131+
/**
132+
* Watch fullscreen changes.
133+
*/
134+
async watchFullscreen(): Promise<void> {
135+
await CorePlatform.ready();
136+
137+
// During video playback, Android 11 and previous versions show the status bar on the first click.
138+
// We're not hiding the status bar in this case to avoid this issue.
139+
if (CorePlatform.isAndroid() && CorePlatform.getPlatformMajorVersion() < 12) {
140+
return;
141+
}
142+
143+
document.addEventListener('fullscreenchange', () => {
144+
if (document.fullscreenElement) {
145+
StatusBar.hide();
146+
} else {
147+
StatusBar.show();
148+
}
149+
});
150+
}
151+
131152
/**
132153
* Watch viewport changes.
133154
*/

src/theme/theme.base.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,13 @@ video::-webkit-media-text-track-display {
515515
white-space: normal !important;
516516
}
517517

518+
*:fullscreen {
519+
padding-top: var(--root-safe-area-top);
520+
padding-left: var(--root-safe-area-left);
521+
padding-bottom: var(--root-safe-area-bottom);
522+
padding-right: var(--root-safe-area-right);
523+
}
524+
518525
/**
519526
* https://github.com/ionic-team/ionic-framework/blob/6ffbdbb3b2b69290cf25753d535bc7483bd7c6e8/BREAKING.md#css-utilities
520527
*/

0 commit comments

Comments
 (0)