From bcaa8d121a4592f371ac7f441a5ab60b434c0f98 Mon Sep 17 00:00:00 2001 From: Thomas Kemmer Date: Sun, 7 Jan 2024 19:13:04 +0100 Subject: [PATCH] Fix Android fullscreen mode based on screen orientation. --- src/app/app.component.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 8dd4774..a6dddf0 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -40,12 +40,13 @@ export class AppComponent implements AfterViewInit, OnInit, OnDestroy { private translate: TranslateService, private updates: SwUpdate) { - // enable/disable fullscreen mode based on screen orientation, *not* WebView orientation - window.addEventListener("orientationchange", () => { - app.enableFullScreen(window.screen.orientation.type.startsWith('landscape')); - }); - if (window.screen.orientation && window.screen.orientation.type) { - app.enableFullScreen(window.screen.orientation.type.startsWith('landscape')); + if (window.screen) { + window.screen.orientation.addEventListener('change', () => { + app.enableFullScreen(window.screen.orientation.type.startsWith('landscape')); + }); + if (window.screen.orientation && window.screen.orientation.type) { + app.enableFullScreen(window.screen.orientation.type.startsWith('landscape')); + } } app.keepAwake(true); translate.setDefaultLang('en');