Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

[mob][photos] Autolock time delay implemented

Aman Raj Singh Mourya508972150749
diff --git a/mobile/lib/ui/settings/lock_screen/lock_screen_auto_lock.dart b/mobile/lib/ui/settings/lock_screen/lock_screen_auto_lock.dart
index 65950043bc..1a26ab5736 100644
--- a/mobile/lib/ui/settings/lock_screen/lock_screen_auto_lock.dart
+++ b/mobile/lib/ui/settings/lock_screen/lock_screen_auto_lock.dart
@@ -67,23 +67,15 @@ class AutoLockItems extends StatefulWidget {
}
class _AutoLockItemsState extends State<AutoLockItems> {
- final List<Duration> autoLockDurations = const [
- Duration(seconds: 0),
- Duration(seconds: 30),
- Duration(minutes: 1),
- Duration(minutes: 5),
- Duration(minutes: 15),
- Duration(minutes: 30),
- Duration(hours: 1),
- ];
+ final autoLockDurations = LockScreenSettings.instance.autoLockDurations;
List<Widget> items = [];
late Duration currentAutoLockTime;
@override
void initState() {
- for (int i = 0; i < autoLockDurations.length; i++) {
- if (autoLockDurations[i].inMilliseconds ==
+ for (Duration autoLockDuration in autoLockDurations) {
+ if (autoLockDuration.inMilliseconds ==
LockScreenSettings.instance.getAutoLockTime()) {
- currentAutoLockTime = autoLockDurations[i];
+ currentAutoLockTime = autoLockDuration;
break;
}
}
diff --git a/mobile/lib/ui/tools/app_lock.dart b/mobile/lib/ui/tools/app_lock.dart
index c9af24f711..30662c9197 100644
--- a/mobile/lib/ui/tools/app_lock.dart
+++ b/mobile/lib/ui/tools/app_lock.dart
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import "package:photos/generated/l10n.dart";
import "package:photos/l10n/l10n.dart";
+import "package:photos/utils/lock_screen_settings.dart";
/// A widget which handles app lifecycle events for showing and hiding a lock screen.
/// This should wrap around a `MyApp` widget (or equivalent).
@@ -84,8 +85,10 @@ class _AppLockState extends State<AppLock> with WidgetsBindingObserver {
if (state == AppLifecycleState.paused &&
(!this._isLocked && this._didUnlockForAppLaunch)) {
- this._backgroundLockLatencyTimer =
- Timer(this.widget.backgroundLockLatency, () => this.showLockScreen());
+ this._backgroundLockLatencyTimer = Timer(
+ Duration(milliseconds: LockScreenSettings.instance.getAutoLockTime()),
+ () => this.showLockScreen(),
+ );
}
if (state == AppLifecycleState.resumed) {
diff --git a/mobile/lib/utils/lock_screen_settings.dart b/mobile/lib/utils/lock_screen_settings.dart
index e710cb55a5..29a9ff1bf7 100644
--- a/mobile/lib/utils/lock_screen_settings.dart
+++ b/mobile/lib/utils/lock_screen_settings.dart
@@ -19,7 +19,15 @@ class LockScreenSettings {
static const autoLockTime = "ls_auto_lock_time";
late FlutterSecureStorage _secureStorage;
late SharedPreferences _preferences;
-
+ final List<Duration> autoLockDurations = const [
+ Duration(seconds: 0),
+ Duration(seconds: 30),
+ Duration(minutes: 1),
+ Duration(minutes: 5),
+ Duration(minutes: 15),
+ Duration(minutes: 30),
+ Duration(hours: 1),
+ ];
void init(SharedPreferences prefs) async {
_secureStorage = const FlutterSecureStorage();
_preferences = prefs;