From 1a654fe7484c3e09aba6e35fb858a0e482b1f74b Mon Sep 17 00:00:00 2001 From: Muhammed Ayimen Abdul Latheef Date: Wed, 6 Dec 2023 17:20:36 +0900 Subject: [PATCH] Added: When the app is in the background, hided te contents of the app (#387) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Added: Hide the contents of the app, when is it in the background - Both android and ios In android, it shows a blank white/black background, when in background In iOS, it shows the launch icon, when in background ![photo_2023-12-06_12-53-02](https://github.com/ente-io/auth/assets/54765537/4f787e6a-984c-4eae-9028-303a32009838) Android Physical Device ![photo_2023-12-06_12-52-55](https://github.com/ente-io/auth/assets/54765537/b8802cf5-0db0-473e-8be8-8cf3bf7b29a5) Android stimulator Also, compared the bitwarden apps in android, the flow is same iOS Device: Need to verify @ua741 @vishnukvmd Could you run on iOS devices and verify it? Closes #47 ## Type of Change - [ ] ๐Ÿ–ผ๏ธ New icon - [x] โœจ New feature (non-breaking change which adds functionality) - [ ] ๐Ÿ› ๏ธ Bug fix (non-breaking change which fixes an issue) - [ ] โŒ Breaking change (fix or feature that would cause existing functionality to change) - [ ] ๐Ÿงน Code refactor - [ ] โœ… Build configuration change - [ ] ๐Ÿ“ Documentation - [ ] ๐Ÿ—‘๏ธ Chore --- lib/main.dart | 17 +++++++++++++++++ pubspec.lock | 8 ++++++++ pubspec.yaml | 1 + 3 files changed, 26 insertions(+) diff --git a/lib/main.dart b/lib/main.dart index 4f82fffe34..e5c81304a7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -24,6 +24,7 @@ import "package:flutter/material.dart"; import 'package:flutter_displaymode/flutter_displaymode.dart'; import 'package:logging/logging.dart'; import 'package:path_provider/path_provider.dart'; +import 'package:privacy_screen/privacy_screen.dart'; final _logger = Logger("main"); @@ -31,6 +32,22 @@ void main() async { WidgetsFlutterBinding.ensureInitialized(); final savedThemeMode = await AdaptiveTheme.getThemeMode(); await _runInForeground(savedThemeMode); + await PrivacyScreen.instance.enable( + iosOptions: const PrivacyIosOptions( + enablePrivacy: true, + privacyImageName: "LaunchImage", + lockTrigger: IosLockTrigger.didEnterBackground, + ), + androidOptions: const PrivacyAndroidOptions( + enableSecure: true, + ), + backgroundColor: savedThemeMode == AdaptiveThemeMode.dark + ? Colors.black + : Colors.white, + blurEffect: savedThemeMode == AdaptiveThemeMode.dark + ? PrivacyBlurEffect.dark + : PrivacyBlurEffect.extraLight, + ); FlutterDisplayMode.setHighRefreshRate(); } diff --git a/pubspec.lock b/pubspec.lock index be8b19c1dc..10c1a4093b 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1047,6 +1047,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.1" + privacy_screen: + dependency: "direct main" + description: + name: privacy_screen + sha256: b80297d2726d96e8a8341149e81a415302755f02d3af7c05c820d9e191bbfbee + url: "https://pub.dev" + source: hosted + version: "0.0.6" process: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 5409ff39b5..cb8eda5d76 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -67,6 +67,7 @@ dependencies: path_provider: ^2.0.11 pinput: ^1.2.2 pointycastle: ^3.7.3 + privacy_screen: ^0.0.6 protobuf: ^3.0.0 qr_code_scanner: ^1.0.1 qr_flutter: 4.0.0