diff --git a/packages/mobile/src/Lib/Interface.ts b/packages/mobile/src/Lib/Interface.ts index b89a24e0b..a4e4b6c2f 100644 --- a/packages/mobile/src/Lib/Interface.ts +++ b/packages/mobile/src/Lib/Interface.ts @@ -220,10 +220,12 @@ export class MobileDevice implements MobileDeviceInterface { hideMobileInterfaceFromScreenshots(): void { hide() + this.setAndroidScreenshotPrivacy(true) } stopHidingMobileInterfaceFromScreenshots(): void { show() + this.setAndroidScreenshotPrivacy(false) } async getAllRawStorageKeyValues() { diff --git a/packages/web/src/javascripts/Application/Application.ts b/packages/web/src/javascripts/Application/Application.ts index 6efbf0490..f2940d158 100644 --- a/packages/web/src/javascripts/Application/Application.ts +++ b/packages/web/src/javascripts/Application/Application.ts @@ -261,6 +261,14 @@ export class WebApplication extends SNApplication implements WebApplicationInter setViewportHeightWithFallback() } + handleInitialMobileScreenshotPrivacy(): void { + if (this.protections.getMobileScreenshotPrivacyEnabled()) { + this.mobileDevice().hideMobileInterfaceFromScreenshots() + } else { + this.mobileDevice().stopHidingMobileInterfaceFromScreenshots() + } + } + async handleMobileLosingFocusEvent(): Promise { if (this.protections.getMobileScreenshotPrivacyEnabled()) { this.mobileDevice().stopHidingMobileInterfaceFromScreenshots() diff --git a/packages/web/src/javascripts/Controllers/ViewControllerManager.ts b/packages/web/src/javascripts/Controllers/ViewControllerManager.ts index b7381bad0..6544f850b 100644 --- a/packages/web/src/javascripts/Controllers/ViewControllerManager.ts +++ b/packages/web/src/javascripts/Controllers/ViewControllerManager.ts @@ -150,6 +150,7 @@ export class ViewControllerManager implements InternalEventHandlerInterface { this.toastService = new ToastService() this.applicationEventObserver = new ApplicationEventObserver( + application, application.routeService, this.purchaseFlowController, this.accountMenuController, diff --git a/packages/web/src/javascripts/Event/ApplicationEventObserver.spec.ts b/packages/web/src/javascripts/Event/ApplicationEventObserver.spec.ts index a61d31e09..bc723cf3f 100644 --- a/packages/web/src/javascripts/Event/ApplicationEventObserver.spec.ts +++ b/packages/web/src/javascripts/Event/ApplicationEventObserver.spec.ts @@ -26,8 +26,10 @@ import { SyncStatusController } from '@/Controllers/SyncStatusController' import { AccountMenuPane } from '@/Components/AccountMenu/AccountMenuPane' import { ApplicationEventObserver } from './ApplicationEventObserver' +import { WebApplication } from '@/Application/Application' describe('ApplicationEventObserver', () => { + let application: WebApplication let routeService: RouteServiceInterface let purchaseFlowController: PurchaseFlowController let accountMenuController: AccountMenuController @@ -40,6 +42,7 @@ describe('ApplicationEventObserver', () => { const createObserver = () => new ApplicationEventObserver( + application, routeService, purchaseFlowController, accountMenuController, @@ -52,6 +55,8 @@ describe('ApplicationEventObserver', () => { ) beforeEach(() => { + application = {} as jest.Mocked + routeService = {} as jest.Mocked routeService.getRoute = jest.fn().mockReturnValue({ type: RouteType.None, @@ -223,4 +228,15 @@ describe('ApplicationEventObserver', () => { expect(syncStatusController.update).toHaveBeenCalled() }) }) + + describe('Upon Database Loaded', () => { + it('should handle mobile screenshot privacy setting', async () => { + application.isNativeMobileWeb = jest.fn().mockReturnValue(true) + application.handleInitialMobileScreenshotPrivacy = jest.fn() + + await createObserver().handle(ApplicationEvent.LocalDataLoaded) + + expect(application.handleInitialMobileScreenshotPrivacy).toHaveBeenCalled() + }) + }) }) diff --git a/packages/web/src/javascripts/Event/ApplicationEventObserver.ts b/packages/web/src/javascripts/Event/ApplicationEventObserver.ts index 5a2172071..667ccd530 100644 --- a/packages/web/src/javascripts/Event/ApplicationEventObserver.ts +++ b/packages/web/src/javascripts/Event/ApplicationEventObserver.ts @@ -20,9 +20,11 @@ import { SyncStatusController } from '@/Controllers/SyncStatusController' import { AccountMenuPane } from '@/Components/AccountMenu/AccountMenuPane' import { EventObserverInterface } from './EventObserverInterface' +import { WebApplication } from '@/Application/Application' export class ApplicationEventObserver implements EventObserverInterface { constructor( + private application: WebApplication, private routeService: RouteServiceInterface, private purchaseFlowController: PurchaseFlowController, private accountMenuController: AccountMenuController, @@ -89,6 +91,11 @@ export class ApplicationEventObserver implements EventObserverInterface { case ApplicationEvent.SyncStatusChanged: this.syncStatusController.update(this.syncClient.getSyncStatus()) break + case ApplicationEvent.LocalDataLoaded: + if (this.application.isNativeMobileWeb()) { + this.application.handleInitialMobileScreenshotPrivacy() + } + break } }