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
main
Dani Palou 2022-02-24 13:18:30 +01:00
parent 56a3287aff
commit b3cadf8cd7
1 changed files with 12 additions and 0 deletions

View File

@ -49,6 +49,7 @@ export class CoreUtilsProvider {
protected iabInstance?: InAppBrowserObject; protected iabInstance?: InAppBrowserObject;
protected uniqueIds: {[name: string]: number} = {}; protected uniqueIds: {[name: string]: number} = {};
protected qrScanData?: {deferred: PromiseDefer<string>; observable: Subscription}; protected qrScanData?: {deferred: PromiseDefer<string>; observable: Subscription};
protected initialColorSchemeContent = 'light dark';
constructor() { constructor() {
this.logger = CoreLogger.getInstance('CoreUtilsProvider'); this.logger = CoreLogger.getInstance('CoreUtilsProvider');
@ -1646,6 +1647,13 @@ export class CoreUtilsProvider {
document.body.classList.add('core-scanning-qr'); 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; return this.qrScanData.deferred.promise;
} catch (e) { } catch (e) {
this.stopScanQR(e, true); this.stopScanQR(e, true);
@ -1674,6 +1682,10 @@ export class CoreUtilsProvider {
// Hide camera preview. // Hide camera preview.
document.body.classList.remove('core-scanning-qr'); 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.hide();
QRScanner.destroy(); QRScanner.destroy();