π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob] Cache last state of app lock (#8901)
Neerajbb7522dace35
diff --git a/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_options.dart b/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_options.dartindex 40eafd452b..30f4773912 100644--- a/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_options.dart+++ b/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_options.dart@@ -4,6 +4,7 @@ import "package:ente_pure_utils/ente_pure_utils.dart";import "package:flutter/material.dart";import "package:photos/core/configuration.dart";import "package:photos/generated/l10n.dart";+import "package:photos/service_locator.dart";import "package:photos/theme/ente_theme.dart";import "package:photos/ui/components/menu_item_widget/menu_item_widget_new.dart";import "package:photos/ui/components/toggle_switch_widget.dart";@@ -11,6 +12,7 @@ import "package:photos/ui/settings/lock_screen/lock_screen_auto_lock.dart";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/local_settings.dart";import "package:photos/utils/lock_screen_settings.dart";class LockScreenOptions extends StatefulWidget {@@ -24,6 +26,7 @@ enum LockType { device, pin, password }class _LockScreenOptionsState extends State<LockScreenOptions> {final Configuration _configuration = Configuration.instance;+ final LocalSettings _localSettings = localSettings;final LockScreenSettings _lockscreenSetting = LockScreenSettings.instance;late bool appLock;late bool hideAppContent;@@ -34,7 +37,7 @@ class _LockScreenOptionsState extends State<LockScreenOptions> {void initState() {super.initState();hideAppContent = _lockscreenSetting.getShouldHideAppContent();- appLock = true; // Will be corrected by _initializeSettings()+ appLock = _localSettings.appLockEnabledCached;_initializeSettings();}@@ -51,14 +54,17 @@ class _LockScreenOptionsState extends State<LockScreenOptions> {lockType = LockType.password;}+ final bool isAppLockEnabled = pinEnabled ||+ passwordEnabled ||+ _configuration.shouldShowSystemLockScreen();+setState(() {hideAppContent = shouldShowAppContent;_currentLockType = lockType;- appLock = pinEnabled ||- passwordEnabled ||- _configuration.shouldShowSystemLockScreen();+ appLock = isAppLockEnabled;_isInitialized = true;});+ await _localSettings.setAppLockEnabledCached(isAppLockEnabled);}Future<void> _onToggleSwitch() async {@@ -80,6 +86,7 @@ class _LockScreenOptionsState extends State<LockScreenOptions> {_currentLockType = LockType.device;});}+ await _initializeSettings();}Future<void> _onSelectDeviceLock() async {@@ -90,6 +97,7 @@ class _LockScreenOptionsState extends State<LockScreenOptions> {setState(() {_currentLockType = LockType.device;});+ await _initializeSettings();}Future<void> _onSelectPinLock() async {diff --git a/mobile/apps/photos/lib/utils/local_settings.dart b/mobile/apps/photos/lib/utils/local_settings.dartindex dc2ad49a84..50be111039 100644--- a/mobile/apps/photos/lib/utils/local_settings.dart+++ b/mobile/apps/photos/lib/utils/local_settings.dart@@ -60,6 +60,7 @@ class LocalSettings {static const _kInternalUserDisabled = "ls.internal_user_disabled";static const _kWrapped2025ResumeIndex = "ls.wrapped_2025_resume_index";static const _kWrapped2025Complete = "ls.wrapped_2025_complete";+ static const _kAppLockEnabled = "ls.app_lock_enabled";static const _memoryLaneSeenKey = "faces_timeline_seen_person_ids";static const _kChristmasBannerEnabled = "ls.christmas_banner_enabled";static const _kAutoMergeThresholdOverride = "ml_debug.auto_merge_threshold";@@ -136,6 +137,12 @@ class LocalSettings {await _prefs.setBool(kPeopleSortSimilaritySelected, value);}+ bool get appLockEnabledCached => _prefs.getBool(_kAppLockEnabled) ?? false;++ Future<void> setAppLockEnabledCached(bool value) async {+ await _prefs.setBool(_kAppLockEnabled, value);+ }+GroupType getGalleryGroupType() {final groupTypeString = _prefs.getString(kGalleryGroupType);if (groupTypeString != null) {