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