π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Merge branch 'main' into show_app_content
Aman Raj Singh Mourya940c02bbbccd
diff --cc mobile/lib/ui/settings/lock_screen/lock_screen_options.dartindex 7a086ec8c1,7b9ba31ac5..18c6defb84--- a/mobile/lib/ui/settings/lock_screen/lock_screen_options.dart+++ b/mobile/lib/ui/settings/lock_screen/lock_screen_options.dart@@@ -28,11 -28,11 +30,14 @@@ class _LockScreenOptionsState extends Slate bool appLock;bool isPinEnabled = false;bool isPasswordEnabled = false;+ late int autoLockTimeInMilliseconds;+ late bool hideAppContent;++@overridevoid initState() {super.initState();+ hideAppContent = _lockscreenSetting.getShouldShowAppContent();+ autoLockTimeInMilliseconds = _lockscreenSetting.getAutoLockTime();_initializeSettings();appLock = isPinEnabled ||isPasswordEnabled ||@@@ -105,15 -110,18 +121,27 @@@});}+ Future<void> _tapHideContent() async {+ setState(() {+ hideAppContent = !hideAppContent;+ });+ await _lockscreenSetting.shouldShowAppContent(+ isContentVisible: hideAppContent,+ );+ }++ String _formatTime(Duration duration) {+ if (duration.inHours != 0) {+ return "in ${duration.inHours} hour${duration.inHours > 1 ? 's' : ''}";+ } else if (duration.inMinutes != 0) {+ return "in ${duration.inMinutes} minute${duration.inMinutes > 1 ? 's' : ''}";+ } else if (duration.inSeconds != 0) {+ return "in ${duration.inSeconds} second${duration.inSeconds > 1 ? 's' : ''}";+ } else {+ return S.of(context).immediately;+ }+ }+@overrideWidget build(BuildContext context) {final colorTheme = getEnteColorScheme(context);@@@ -224,36 -232,38 +252,69 @@@onTap: () => _passwordLock(),),const SizedBox(+ height: 24,+ ),+ MenuItemWidget(+ captionedTextWidget: CaptionedTextWidget(+ title: S.of(context).autoLock,+ subTitle: _formatTime(+ Duration(+ milliseconds:+ autoLockTimeInMilliseconds,+ ),+ ),+ ),+ trailingIcon: Icons.chevron_right_outlined,+ trailingIconIsMuted: true,+ alignCaptionedTextToLeft: true,+ singleBorderRadius: 8,+ menuItemColor: colorTheme.fillFaint,+ trailingIconColor: colorTheme.tabIcon,+ onTap: () => _onAutolock(),+ ),+ Padding(+ padding: const EdgeInsets.only(+ top: 14,+ left: 14,+ right: 12,+ ),+ child: Text(+ S.of(context).autoLockFeatureDescription,+ style: textTheme.miniFaint,+ textAlign: TextAlign.left,+ ),+ ),++ const SizedBox(+ height: 24,+ ),+ MenuItemWidget(+ captionedTextWidget:+ const CaptionedTextWidget(+ title: "Hide content",+ ),+ alignCaptionedTextToLeft: true,+ singleBorderRadius: 8,+ menuItemColor: colorTheme.fillFaint,+ trailingWidget: ToggleSwitchWidget(+ value: () => hideAppContent,+ onChanged: () => _tapHideContent(),+ ),+ trailingIconColor: colorTheme.tabIcon,+ ),+ Padding(+ padding: const EdgeInsets.only(+ top: 14,+ left: 14,+ right: 12,+ ),+ child: Text(+ Platform.isAndroid+ ? 'Hides app content in the app switcher and disables screenshots'+ : 'Hides app content in the app switcher',+ style: textTheme.miniFaint,+ textAlign: TextAlign.left,+ ),+ ),],): Container(),diff --cc mobile/lib/utils/lock_screen_settings.dartindex 88e36aa6f0,d8d5cc511f..3df6546f0a--- a/mobile/lib/utils/lock_screen_settings.dart+++ b/mobile/lib/utils/lock_screen_settings.dart@@@ -17,36 -16,31 +17,52 @@@ class LockScreenSettingsstatic 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";+ static const autoLockTime = "ls_auto_lock_time";-late FlutterSecureStorage _secureStorage;late SharedPreferences _preferences;-+ static const List<Duration> autoLockDurations = [+ Duration(seconds: 0),+ Duration(seconds: 5),+ Duration(seconds: 15),+ Duration(minutes: 1),+ Duration(minutes: 5),+ Duration(minutes: 30),+ ];void init(SharedPreferences prefs) async {_secureStorage = const FlutterSecureStorage();_preferences = prefs;+ await shouldShowAppContent(isContentVisible: getShouldShowAppContent());+ }++ Future<void> shouldShowAppContent({bool isContentVisible = true}) async {+ !isContentVisible+ ? await PrivacyScreen.instance.disable()+ : await PrivacyScreen.instance.enable(+ iosOptions: const PrivacyIosOptions(+ enablePrivacy: true,+ lockTrigger: IosLockTrigger.didEnterBackground,+ ),+ androidOptions: const PrivacyAndroidOptions(+ enableSecure: true,+ ),+ blurEffect: PrivacyBlurEffect.extraLight,+ );+ await _preferences.setBool(keyShowAppContent, isContentVisible);+ }++ bool getShouldShowAppContent() {+ return _preferences.getBool(keyShowAppContent) ?? false;}+ Future<void> setAutoLockTime(Duration duration) async {+ await _preferences.setInt(autoLockTime, duration.inMilliseconds);+ }++ int getAutoLockTime() {+ return _preferences.getInt(autoLockTime) ?? 5000;+ }+Future<void> setLastInvalidAttemptTime(int time) async {await _preferences.setInt(lastInvalidAttemptTime, time);}