From b3cadf8cd70a7512e790317552551c695d7affdb Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 24 Feb 2022 13:18:30 +0100 Subject: [PATCH] MOBILE-3833 qr: Set color-scheme to normal when open QR scanner For some reason leaving this value to 'light dark' displays a black screen in Android --- src/core/services/utils/utils.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/core/services/utils/utils.ts b/src/core/services/utils/utils.ts index 4808ccca5..81f37d7b1 100644 --- a/src/core/services/utils/utils.ts +++ b/src/core/services/utils/utils.ts @@ -49,6 +49,7 @@ export class CoreUtilsProvider { protected iabInstance?: InAppBrowserObject; protected uniqueIds: {[name: string]: number} = {}; protected qrScanData?: {deferred: PromiseDefer; observable: Subscription}; + protected initialColorSchemeContent = 'light dark'; constructor() { this.logger = CoreLogger.getInstance('CoreUtilsProvider'); @@ -1646,6 +1647,13 @@ export class CoreUtilsProvider { document.body.classList.add('core-scanning-qr'); + // Set color-scheme to 'normal', otherwise the camera isn't seen in Android. + const colorSchemeMeta = document.querySelector('meta[name="color-scheme"]'); + if (colorSchemeMeta) { + this.initialColorSchemeContent = colorSchemeMeta.getAttribute('content') || this.initialColorSchemeContent; + colorSchemeMeta.setAttribute('content', 'normal'); + } + return this.qrScanData.deferred.promise; } catch (e) { this.stopScanQR(e, true); @@ -1674,6 +1682,10 @@ export class CoreUtilsProvider { // Hide camera preview. document.body.classList.remove('core-scanning-qr'); + + // Set color-scheme to the initial value. + document.querySelector('meta[name="color-scheme"]')?.setAttribute('content', this.initialColorSchemeContent); + QRScanner.hide(); QRScanner.destroy();