mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 07:28:26 +00:00
[mob][photos] Used privacy_screen instead of secure_app_switcher to hide app content
This commit is contained in:
parent
5b3b3b577b
commit
1381cfc6e4
@ -20,6 +20,7 @@ import 'package:photos/services/sync_service.dart';
|
||||
import 'package:photos/ui/tabs/home_widget.dart';
|
||||
import "package:photos/ui/viewer/actions/file_viewer.dart";
|
||||
import "package:photos/utils/intent_util.dart";
|
||||
import "package:privacy_screen/privacy_screen.dart";
|
||||
import "package:secure_app_switcher/secure_app_switcher.dart";
|
||||
|
||||
class EnteApp extends StatefulWidget {
|
||||
@ -110,12 +111,10 @@ class _EnteAppState extends State<EnteApp> with WidgetsBindingObserver {
|
||||
darkTheme: dartTheme,
|
||||
home: AppLifecycleService.instance.mediaExtensionAction.action ==
|
||||
IntentAction.view
|
||||
? const SecureAppSwitcherPage(
|
||||
style: SecureMaskStyle.blurDark,
|
||||
? const PrivacyGate(
|
||||
child: FileViewer(),
|
||||
)
|
||||
: const SecureAppSwitcherPage(
|
||||
style: SecureMaskStyle.blurDark,
|
||||
: const PrivacyGate(
|
||||
child: HomeWidget(),
|
||||
),
|
||||
debugShowCheckedModeBanner: false,
|
||||
|
@ -12,7 +12,6 @@ import "package:photos/ui/settings/lock_screen/lock_screen_password.dart";
|
||||
import "package:photos/ui/settings/lock_screen/lock_screen_pin.dart";
|
||||
import "package:photos/ui/tools/app_lock.dart";
|
||||
import "package:photos/utils/lock_screen_settings.dart";
|
||||
import "package:secure_app_switcher/secure_app_switcher.dart";
|
||||
|
||||
class LockScreenOptions extends StatefulWidget {
|
||||
const LockScreenOptions({super.key});
|
||||
@ -31,7 +30,7 @@ class _LockScreenOptionsState extends State<LockScreenOptions> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
showAppContent = _lockscreenSetting.getShowAppContent();
|
||||
showAppContent = _lockscreenSetting.getShouldShowAppContent();
|
||||
_initializeSettings();
|
||||
appLock = isPinEnabled ||
|
||||
isPasswordEnabled ||
|
||||
@ -41,9 +40,12 @@ class _LockScreenOptionsState extends State<LockScreenOptions> {
|
||||
Future<void> _initializeSettings() async {
|
||||
final bool passwordEnabled = await _lockscreenSetting.isPasswordSet();
|
||||
final bool pinEnabled = await _lockscreenSetting.isPinSet();
|
||||
final bool shouldShowAppContent =
|
||||
_lockscreenSetting.getShouldShowAppContent();
|
||||
setState(() {
|
||||
isPasswordEnabled = passwordEnabled;
|
||||
isPinEnabled = pinEnabled;
|
||||
showAppContent = shouldShowAppContent;
|
||||
});
|
||||
}
|
||||
|
||||
@ -92,6 +94,9 @@ class _LockScreenOptionsState extends State<LockScreenOptions> {
|
||||
AppLock.of(context)!.setEnabled(!appLock);
|
||||
await _configuration.setSystemLockScreen(!appLock);
|
||||
await _lockscreenSetting.removePinAndPassword();
|
||||
if (appLock == true) {
|
||||
await _lockscreenSetting.shouldShowAppContent(isContentVisible: true);
|
||||
}
|
||||
setState(() {
|
||||
_initializeSettings();
|
||||
appLock = !appLock;
|
||||
@ -102,9 +107,8 @@ class _LockScreenOptionsState extends State<LockScreenOptions> {
|
||||
setState(() {
|
||||
showAppContent = !showAppContent;
|
||||
});
|
||||
showAppContent ? SecureAppSwitcher.off() : SecureAppSwitcher.on();
|
||||
await _lockscreenSetting.shouldShowAppContent(
|
||||
showAppContent,
|
||||
isContentVisible: showAppContent,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import "package:flutter/foundation.dart";
|
||||
import "package:flutter_secure_storage/flutter_secure_storage.dart";
|
||||
import "package:flutter_sodium/flutter_sodium.dart";
|
||||
import "package:photos/utils/crypto_util.dart";
|
||||
import "package:privacy_screen/privacy_screen.dart";
|
||||
import "package:shared_preferences/shared_preferences.dart";
|
||||
|
||||
class LockScreenSettings {
|
||||
@ -25,11 +26,22 @@ class LockScreenSettings {
|
||||
_preferences = prefs;
|
||||
}
|
||||
|
||||
Future<void> shouldShowAppContent(bool show) async {
|
||||
await _preferences.setBool(keyShowAppContent, show);
|
||||
Future<void> shouldShowAppContent({bool isContentVisible = true}) async {
|
||||
isContentVisible
|
||||
? await PrivacyScreen.instance.disable()
|
||||
: await PrivacyScreen.instance.enable(
|
||||
iosOptions: const PrivacyIosOptions(
|
||||
enablePrivacy: true,
|
||||
),
|
||||
androidOptions: const PrivacyAndroidOptions(
|
||||
enableSecure: true,
|
||||
),
|
||||
blurEffect: PrivacyBlurEffect.extraLight,
|
||||
);
|
||||
await _preferences.setBool(keyShowAppContent, isContentVisible);
|
||||
}
|
||||
|
||||
bool getShowAppContent() {
|
||||
bool getShouldShowAppContent() {
|
||||
return _preferences.getBool(keyShowAppContent) ?? true;
|
||||
}
|
||||
|
||||
|
@ -1903,6 +1903,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:
|
||||
@ -2047,14 +2055,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.3.8"
|
||||
secure_app_switcher:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: secure_app_switcher
|
||||
sha256: "6f8a1755d15358291e697d212a2a5a28a302cc14798c0849e8630c12b4df4efd"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.0+1"
|
||||
sentry:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -142,13 +142,13 @@ dependencies:
|
||||
pinput: ^5.0.0
|
||||
pointycastle: ^3.7.3
|
||||
pool: ^1.5.1
|
||||
privacy_screen: ^0.0.6
|
||||
protobuf: ^3.1.0
|
||||
provider: ^6.0.0
|
||||
quiver: ^3.0.1
|
||||
receive_sharing_intent: ^1.7.0
|
||||
screenshot: ^3.0.0
|
||||
scrollable_positioned_list: ^0.3.5
|
||||
secure_app_switcher: ^0.1.0+1
|
||||
sentry: ^7.9.0
|
||||
sentry_flutter: ^7.9.0
|
||||
share_plus: ^9.0.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user