π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Hide content when app is in background using secure_app_switcher
Aman Raj Singh Mourya5b3b3b577b01
diff --git a/mobile/lib/app.dart b/mobile/lib/app.dartindex e7e299ed94..414c0f8fa5 100644--- a/mobile/lib/app.dart+++ b/mobile/lib/app.dart@@ -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:secure_app_switcher/secure_app_switcher.dart";class EnteApp extends StatefulWidget {final Future<void> Function(String) runBackgroundTask;@@ -109,8 +110,14 @@ class _EnteAppState extends State<EnteApp> with WidgetsBindingObserver {darkTheme: dartTheme,home: AppLifecycleService.instance.mediaExtensionAction.action ==IntentAction.view- ? const FileViewer()- : const HomeWidget(),+ ? const SecureAppSwitcherPage(+ style: SecureMaskStyle.blurDark,+ child: FileViewer(),+ )+ : const SecureAppSwitcherPage(+ style: SecureMaskStyle.blurDark,+ child: HomeWidget(),+ ),debugShowCheckedModeBanner: false,builder: EasyLoading.init(),locale: locale,@@ -129,7 +136,10 @@ class _EnteAppState extends State<EnteApp> with WidgetsBindingObserver {themeMode: ThemeMode.system,theme: lightThemeData,darkTheme: darkThemeData,- home: const HomeWidget(),+ home: const SecureAppSwitcherPage(+ style: SecureMaskStyle.blurDark,+ child: HomeWidget(),+ ),debugShowCheckedModeBanner: false,builder: EasyLoading.init(),locale: locale,diff --git a/mobile/lib/ui/settings/lock_screen/lock_screen_options.dart b/mobile/lib/ui/settings/lock_screen/lock_screen_options.dartindex be57aae3e5..78fc8099f8 100644--- a/mobile/lib/ui/settings/lock_screen/lock_screen_options.dart+++ b/mobile/lib/ui/settings/lock_screen/lock_screen_options.dart@@ -12,6 +12,7 @@ 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});@@ -26,10 +27,11 @@ class _LockScreenOptionsState extends State<LockScreenOptions> {late bool appLock;bool isPinEnabled = false;bool isPasswordEnabled = false;-+ late bool showAppContent;@overridevoid initState() {super.initState();+ showAppContent = _lockscreenSetting.getShowAppContent();_initializeSettings();appLock = isPinEnabled ||isPasswordEnabled ||@@ -96,6 +98,16 @@ class _LockScreenOptionsState extends State<LockScreenOptions> {});}+ Future<void> _tapShowContent() async {+ setState(() {+ showAppContent = !showAppContent;+ });+ showAppContent ? SecureAppSwitcher.off() : SecureAppSwitcher.on();+ await _lockscreenSetting.shouldShowAppContent(+ showAppContent,+ );+ }+@overrideWidget build(BuildContext context) {final colorTheme = getEnteColorScheme(context);@@ -204,6 +216,46 @@ class _LockScreenOptionsState extends State<LockScreenOptions> {trailingIconColor: colorTheme.tabIcon,onTap: () => _passwordLock(),),+ const SizedBox(+ height: 24,+ ),+ MenuItemWidget(+ captionedTextWidget: CaptionedTextWidget(+ title: "App content in Task switcher",+ textStyle: textTheme.small.copyWith(+ color: colorTheme.textMuted,+ ),+ ),+ alignCaptionedTextToLeft: true,+ isBottomBorderRadiusRemoved: true,+ menuItemColor: colorTheme.fillFaint,+ ),+ MenuItemWidget(+ captionedTextWidget:+ const CaptionedTextWidget(+ title: "Show content",+ ),+ alignCaptionedTextToLeft: true,+ isTopBorderRadiusRemoved: true,+ menuItemColor: colorTheme.fillFaint,+ trailingWidget: ToggleSwitchWidget(+ value: () => showAppContent,+ onChanged: () => _tapShowContent(),+ ),+ trailingIconColor: colorTheme.tabIcon,+ ),+ Padding(+ padding: const EdgeInsets.only(+ top: 14,+ left: 14,+ right: 12,+ ),+ child: Text(+ 'If disabled app content will be displayed in the task switcher',+ style: textTheme.miniFaint,+ textAlign: TextAlign.left,+ ),+ ),],): Container(),diff --git a/mobile/lib/utils/lock_screen_settings.dart b/mobile/lib/utils/lock_screen_settings.dartindex 13772d5224..3cf962e2f8 100644--- a/mobile/lib/utils/lock_screen_settings.dart+++ b/mobile/lib/utils/lock_screen_settings.dart@@ -16,6 +16,7 @@ class LockScreenSettings {static const saltKey = "ls_salt";static const keyInvalidAttempts = "ls_invalid_attempts";static const lastInvalidAttemptTime = "ls_last_invalid_attempt_time";+ static const keyShowAppContent = "ls_show_app_content";late FlutterSecureStorage _secureStorage;late SharedPreferences _preferences;@@ -24,6 +25,14 @@ class LockScreenSettings {_preferences = prefs;}+ Future<void> shouldShowAppContent(bool show) async {+ await _preferences.setBool(keyShowAppContent, show);+ }++ bool getShowAppContent() {+ return _preferences.getBool(keyShowAppContent) ?? true;+ }+Future<void> setLastInvalidAttemptTime(int time) async {await _preferences.setInt(lastInvalidAttemptTime, time);}diff --git a/mobile/pubspec.lock b/mobile/pubspec.lockindex 138d9890fe..e6e17fa21f 100644--- a/mobile/pubspec.lock+++ b/mobile/pubspec.lock@@ -2047,6 +2047,14 @@ packages:url: "https://pub.dev"source: hostedversion: "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:diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yamlindex d1d6b238c1..1d5513c9e4 100644--- a/mobile/pubspec.yaml+++ b/mobile/pubspec.yaml@@ -148,6 +148,7 @@ dependencies:receive_sharing_intent: ^1.7.0screenshot: ^3.0.0scrollable_positioned_list: ^0.3.5+ secure_app_switcher: ^0.1.0+1sentry: ^7.9.0sentry_flutter: ^7.9.0share_plus: ^9.0.0