Skip to content

armgit / ente

Public Imported from GitHub
0

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

Move photos to ente_lock_screen

Manav Rathi1a2d75cc0ebb
diff --git a/mobile/apps/photos/lib/core/configuration.dart b/mobile/apps/photos/lib/core/configuration.dart
index 6079bb3740..327fd976b1 100644
--- a/mobile/apps/photos/lib/core/configuration.dart
+++ b/mobile/apps/photos/lib/core/configuration.dart
@@ -6,6 +6,7 @@ import 'package:backup_exclusion/backup_exclusion.dart';
import 'package:bip39/bip39.dart' as bip39;
import 'package:ente_contacts/contacts.dart';
import "package:ente_crypto/ente_crypto.dart";
+import 'package:ente_lock_screen/lock_screen_host.dart';
import "package:flutter/services.dart";
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:logging/logging.dart';
@@ -49,7 +50,7 @@ import 'package:shared_preferences/shared_preferences.dart';
import "package:tuple/tuple.dart";
import 'package:uuid/uuid.dart';
-class Configuration {
+class Configuration implements LockScreenHost {
Configuration._privateConstructor();
static final Configuration instance = Configuration._privateConstructor();
@@ -186,6 +187,7 @@ class Configuration {
}
}
+ @override
Future<void> logout({bool autoLogout = false}) async {
_logger.info("Logging out, autoLogout: $autoLogout");
if (!autoLogout) {
@@ -516,6 +518,7 @@ class Configuration {
return _cachedToken;
}
+ @override
bool isLoggedIn() {
return getToken() != null;
}
diff --git a/mobile/apps/photos/lib/main.dart b/mobile/apps/photos/lib/main.dart
index ab109d1444..819d05cea7 100644
--- a/mobile/apps/photos/lib/main.dart
+++ b/mobile/apps/photos/lib/main.dart
@@ -5,8 +5,13 @@ import "package:adaptive_theme/adaptive_theme.dart";
import "package:computer/computer.dart";
import "package:ente_components/ente_components.dart" as components;
import 'package:ente_crypto/ente_crypto.dart';
+import "package:ente_crypto_api/ente_crypto_api.dart" show registerCryptoApi;
+import "package:ente_lock_screen/lock_screen_settings.dart";
+import "package:ente_lock_screen/ui/app_lock.dart";
+import "package:ente_lock_screen/ui/lock_screen.dart";
import "package:ente_pure_utils/ente_pure_utils.dart";
import "package:ente_rust/ente_rust.dart";
+import "package:ente_strings/l10n/strings_localizations.dart";
import "package:ffmpeg_kit_flutter/ffmpeg_kit_config.dart";
import 'package:flutter/foundation.dart';
import "package:flutter/gestures.dart";
@@ -29,6 +34,7 @@ import 'package:photos/core/network/network.dart';
import 'package:photos/db/files_db.dart';
import "package:photos/db/ml/db.dart";
import 'package:photos/ente_theme_data.dart';
+import "package:photos/generated/l10n.dart";
import "package:photos/l10n/l10n.dart";
import "package:photos/service_locator.dart";
import "package:photos/services/account/user_service.dart";
@@ -52,14 +58,12 @@ import 'package:photos/services/sync/remote_sync_service.dart';
import "package:photos/services/sync/sync_service.dart";
import "package:photos/services/video_preview_service.dart";
import "package:photos/services/wake_lock_service.dart";
-import "package:photos/settings/lock_screen_settings.dart";
import "package:photos/src/rust/frb_generated.dart";
-import 'package:photos/ui/tools/app_lock.dart';
-import 'package:photos/ui/tools/lock_screen.dart';
import "package:photos/utils/device_info.dart";
import "package:photos/utils/email_util.dart";
import 'package:photos/utils/file_uploader.dart';
import "package:photos/utils/intent_util.dart";
+import "package:photos/utils/photos_crypto_api_adapter.dart";
import 'package:rive/rive.dart' as rive;
import 'package:shared_preferences/shared_preferences.dart';
@@ -144,11 +148,18 @@ Future<void> _runInForeground(
savedThemeMode,
initialMediaExtensionAction: initialMediaExtensionAction,
),
- lockScreen: const LockScreen(),
+ lockScreen: LockScreen(Configuration.instance),
enabled:
await LockScreenSettings.instance.shouldShowLockScreen() ||
localSettings.isOnGuestView(),
+ onUnlock: () => unawaited(localSettings.setOnGuestView(false)),
locale: locale,
+ supportedLocales: appSupportedLocales,
+ localizationsDelegates: const [
+ ...StringsLocalizations.localizationsDelegates,
+ ...AppLocalizations.localizationsDelegates,
+ ],
+ localeListResolutionCallback: localResolutionCallBack,
lightTheme: lightThemeData,
darkTheme: darkThemeData,
savedThemeMode: _themeMode(savedThemeMode),
@@ -408,7 +419,11 @@ Future<void> _init(
);
_logger.info("Lockscreen init $tlog");
- LockScreenSettings.instance.init(preferences);
+ registerCryptoApi(const PhotosCryptoApiAdapter());
+ await LockScreenSettings.instance.init(
+ Configuration.instance,
+ useLegacyHashFallback: true,
+ );
_logger.info("Configuration init $tlog");
await Configuration.instance.init(preferences);
diff --git a/mobile/apps/photos/lib/services/local_authentication_service.dart b/mobile/apps/photos/lib/services/local_authentication_service.dart
deleted file mode 100644
index 9d6449f8c4..0000000000
--- a/mobile/apps/photos/lib/services/local_authentication_service.dart
+++ /dev/null
@@ -1,117 +0,0 @@
-import "dart:async";
-
-import 'package:flutter/material.dart';
-import 'package:local_auth/local_auth.dart';
-import "package:photos/settings/lock_screen_settings.dart";
-import 'package:photos/ui/notification/toast.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/auth_util.dart';
-import 'package:photos/utils/dialog_util.dart';
-
-class LocalAuthenticationService {
- LocalAuthenticationService._privateConstructor();
- static final LocalAuthenticationService instance =
- LocalAuthenticationService._privateConstructor();
-
- Future<bool> requestLocalAuthentication(
- BuildContext context,
- String infoMessage,
- ) async {
- if (await _isLocalAuthSupportedOnDevice()) {
- AppLock.of(context)!.setEnabled(false);
- final result = await requestAuthentication(
- context,
- infoMessage,
- isAuthenticatingForInAppChange: true,
- );
- AppLock.of(
- context,
- )!.setEnabled(await LockScreenSettings.instance.shouldShowLockScreen());
- if (!result) {
- showToast(context, infoMessage);
- return false;
- } else {
- return true;
- }
- }
- return true;
- }
-
- Future<bool> requestEnteAuthForLockScreen(
- BuildContext context,
- String? savedPin,
- String? savedPassword, {
- bool isAuthenticatingOnAppLaunch = false,
- bool isAuthenticatingForInAppChange = false,
- }) async {
- if (savedPassword != null) {
- final result = await Navigator.of(context).push(
- MaterialPageRoute(
- builder: (BuildContext context) {
- return LockScreenPassword(
- isChangingLockScreenSettings: true,
- isAuthenticatingForInAppChange: isAuthenticatingForInAppChange,
- isAuthenticatingOnAppLaunch: isAuthenticatingOnAppLaunch,
- authPass: savedPassword,
- );
- },
- ),
- );
- if (result == true) {
- return true;
- }
- }
- if (savedPin != null) {
- final result = await Navigator.of(context).push(
- MaterialPageRoute(
- builder: (BuildContext context) {
- return LockScreenPin(
- isChangingLockScreenSettings: true,
- isAuthenticatingForInAppChange: isAuthenticatingForInAppChange,
- isAuthenticatingOnAppLaunch: isAuthenticatingOnAppLaunch,
- authPin: savedPin,
- );
- },
- ),
- );
- if (result == true) {
- return true;
- }
- }
- return false;
- }
-
- Future<bool> requestLocalAuthForLockScreen(
- BuildContext context,
- bool shouldEnableLockScreen,
- String infoMessage,
- String errorDialogContent, [
- String errorDialogTitle = "",
- ]) async {
- if (await _isLocalAuthSupportedOnDevice()) {
- AppLock.of(context)!.disable();
- final result = await requestAuthentication(context, infoMessage);
- if (result) {
- AppLock.of(context)!.setEnabled(shouldEnableLockScreen);
-
- await LockScreenSettings.instance.setSystemLockScreen(
- shouldEnableLockScreen,
- );
- return true;
- } else {
- AppLock.of(
- context,
- )!.setEnabled(await LockScreenSettings.instance.shouldShowLockScreen());
- }
- } else {
- unawaited(showErrorDialog(context, errorDialogTitle, errorDialogContent));
- }
- return false;
- }
-
- Future<bool> _isLocalAuthSupportedOnDevice() async {
- return LocalAuthentication().isDeviceSupported();
- }
-}
diff --git a/mobile/apps/photos/lib/settings/lock_screen_settings.dart b/mobile/apps/photos/lib/settings/lock_screen_settings.dart
deleted file mode 100644
index c4a6564753..0000000000
--- a/mobile/apps/photos/lib/settings/lock_screen_settings.dart
+++ /dev/null
@@ -1,187 +0,0 @@
-import "dart:async";
-import "dart:convert";
-
-import "package:ente_crypto/ente_crypto.dart";
-import "package:flutter/foundation.dart";
-import "package:flutter_secure_storage/flutter_secure_storage.dart";
-import "package:flutter_sodium/flutter_sodium.dart";
-import "package:logging/logging.dart";
-import "package:privacy_screen/privacy_screen.dart";
-import "package:shared_preferences/shared_preferences.dart";
-
-class LockScreenSettings {
- LockScreenSettings._privateConstructor();
-
- static final LockScreenSettings instance =
- LockScreenSettings._privateConstructor();
- static const password = "ls_password";
- static const pin = "ls_pin";
- static const saltKey = "ls_salt";
- static const keyInvalidAttempts = "ls_invalid_attempts";
- static const lastInvalidAttemptTime = "ls_last_invalid_attempt_time";
- static const keyHideAppContent = "ls_hide_app_content";
- static const autoLockTime = "ls_auto_lock_time";
- static const keyShowSystemLockScreen = "should_show_lock_screen";
- static const _keyAppLockEnabled = "ls.app_lock_enabled";
- static final _logger = Logger("LockScreenSettings");
- late FlutterSecureStorage _secureStorage;
- late SharedPreferences _preferences;
- static const List<Duration> autoLockDurations = [
- Duration(milliseconds: 650),
- Duration(seconds: 5),
- Duration(seconds: 15),
- Duration(minutes: 1),
- Duration(minutes: 5),
- Duration(minutes: 30),
- ];
- void init(SharedPreferences prefs) {
- _secureStorage = const FlutterSecureStorage();
- _preferences = prefs;
- unawaited(_restorePrivacyScreenPreference());
- }
-
- Future<void> _restorePrivacyScreenPreference() async {
- await Future<void>.delayed(const Duration(milliseconds: 500));
- try {
- if (getShouldHideAppContent()) {
- await setHideAppContent(true);
- }
- } catch (error, stackTrace) {
- _logger.severe("Error enabling PrivacyScreen", error, stackTrace);
- }
- }
-
- Future<void> setHideAppContent(bool hideContent) async {
- !hideContent
- ? 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(keyHideAppContent, hideContent);
- }
-
- bool getShouldHideAppContent() {
- return _preferences.getBool(keyHideAppContent) ?? 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);
- }
-
- int getlastInvalidAttemptTime() {
- return _preferences.getInt(lastInvalidAttemptTime) ?? 0;
- }
-
- int getInvalidAttemptCount() {
- return _preferences.getInt(keyInvalidAttempts) ?? 0;
- }
-
- Future<void> setInvalidAttemptCount(int count) async {
- await _preferences.setInt(keyInvalidAttempts, count);
- }
-
- bool get appLockEnabledCached =>
- _preferences.getBool(_keyAppLockEnabled) ?? false;
-
- Future<void> setAppLockEnabledCached(bool value) {
- return _preferences.setBool(_keyAppLockEnabled, value);
- }
-
- Future<bool> shouldShowLockScreen() async {
- return shouldShowSystemLockScreen() ||
- await isPinSet() ||
- await isPasswordSet();
- }
-
- bool shouldShowSystemLockScreen() {
- return _preferences.getBool(keyShowSystemLockScreen) ?? false;
- }
-
- Future<void> setSystemLockScreen(bool value) {
- return _preferences.setBool(keyShowSystemLockScreen, value);
- }
-
- static Uint8List _generateSalt() {
- return Sodium.randombytesBuf(Sodium.cryptoPwhashSaltbytes);
- }
-
- Future<void> setPin(String userPin) async {
- await _secureStorage.delete(key: saltKey);
-
- final salt = _generateSalt();
- final hash = cryptoPwHash({
- "password": utf8.encode(userPin),
- "salt": salt,
- "opsLimit": Sodium.cryptoPwhashOpslimitInteractive,
- "memLimit": Sodium.cryptoPwhashMemlimitInteractive,
- });
-
- final String saltPin = base64Encode(salt);
- final String hashedPin = base64Encode(hash);
-
- await _secureStorage.write(key: saltKey, value: saltPin);
- await _secureStorage.write(key: pin, value: hashedPin);
- await _secureStorage.delete(key: password);
-
- return;
- }
-
- Future<Uint8List?> getSalt() async {
- final String? salt = await _secureStorage.read(key: saltKey);
- if (salt == null) return null;
- return base64Decode(salt);
- }
-
- Future<String?> getPin() async {
- return _secureStorage.read(key: pin);
- }
-
- Future<void> setPassword(String pass) async {
- await _secureStorage.delete(key: saltKey);
-
- final salt = _generateSalt();
- final hash = cryptoPwHash({
- "password": utf8.encode(pass),
- "salt": salt,
- "opsLimit": Sodium.cryptoPwhashOpslimitInteractive,
- "memLimit": Sodium.cryptoPwhashMemlimitInteractive,
- });
-
- await _secureStorage.write(key: saltKey, value: base64Encode(salt));
- await _secureStorage.write(key: password, value: base64Encode(hash));
- await _secureStorage.delete(key: pin);
-
- return;
- }
-
- Future<String?> getPassword() async {
- return _secureStorage.read(key: password);
- }
-
- Future<void> removePinAndPassword() async {
- await _secureStorage.delete(key: saltKey);
- await _secureStorage.delete(key: pin);
- await _secureStorage.delete(key: password);
- }
-
- Future<bool> isPinSet() async {
- return await _secureStorage.containsKey(key: pin);
- }
-
- Future<bool> isPasswordSet() async {
- return await _secureStorage.containsKey(key: password);
- }
-}
diff --git a/mobile/apps/photos/lib/ui/account/verify_recovery_page.dart b/mobile/apps/photos/lib/ui/account/verify_recovery_page.dart
index d45db56517..d3b7e71d76 100644
--- a/mobile/apps/photos/lib/ui/account/verify_recovery_page.dart
+++ b/mobile/apps/photos/lib/ui/account/verify_recovery_page.dart
@@ -2,6 +2,7 @@ import 'package:bip39/bip39.dart' as bip39;
import 'package:dio/dio.dart';
import "package:ente_components/ente_components.dart";
import 'package:ente_crypto/ente_crypto.dart';
+import 'package:ente_lock_screen/local_authentication_service.dart';
import 'package:ente_pure_utils/ente_pure_utils.dart';
import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
@@ -10,7 +11,6 @@ import 'package:photos/events/notification_event.dart';
import "package:photos/generated/l10n.dart";
import "package:photos/service_locator.dart";
import 'package:photos/services/account/user_service.dart';
-import 'package:photos/services/local_authentication_service.dart';
import 'package:photos/ui/account/recovery_key_page.dart';
import "package:photos/ui/components/alert_bottom_sheet.dart";
import 'package:photos/ui/components/buttons/button_widget.dart';
diff --git a/mobile/apps/photos/lib/ui/rituals/ritual_privacy.dart b/mobile/apps/photos/lib/ui/rituals/ritual_privacy.dart
index 8826d50d65..df220ff30b 100644
--- a/mobile/apps/photos/lib/ui/rituals/ritual_privacy.dart
+++ b/mobile/apps/photos/lib/ui/rituals/ritual_privacy.dart
@@ -1,9 +1,9 @@
+import "package:ente_lock_screen/local_authentication_service.dart";
import "package:flutter/material.dart";
import "package:photos/l10n/l10n.dart";
import "package:photos/models/rituals/ritual_models.dart";
import "package:photos/service_locator.dart";
import "package:photos/services/collections_service.dart";
-import "package:photos/services/local_authentication_service.dart";
bool isRitualAlbumHidden(Ritual ritual) {
final albumId = ritual.albumId;
diff --git a/mobile/apps/photos/lib/ui/settings/account/account_settings_page.dart b/mobile/apps/photos/lib/ui/settings/account/account_settings_page.dart
index d8ad959205..6e754e74a7 100644
--- a/mobile/apps/photos/lib/ui/settings/account/account_settings_page.dart
+++ b/mobile/apps/photos/lib/ui/settings/account/account_settings_page.dart
@@ -1,12 +1,12 @@
import "dart:async";
import "package:ente_crypto/ente_crypto.dart";
+import "package:ente_lock_screen/local_authentication_service.dart";
import "package:flutter/material.dart";
import "package:hugeicons/hugeicons.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/service_locator.dart";
import "package:photos/services/account/user_service.dart";
-import "package:photos/services/local_authentication_service.dart";
import "package:photos/ui/account/change_email_dialog.dart";
import "package:photos/ui/account/delete_account_page.dart";
import "package:photos/ui/account/password_entry_page.dart";
diff --git a/mobile/apps/photos/lib/ui/settings/lock_screen/custom_pin_keypad.dart b/mobile/apps/photos/lib/ui/settings/lock_screen/custom_pin_keypad.dart
deleted file mode 100644
index 6b3596a465..0000000000
--- a/mobile/apps/photos/lib/ui/settings/lock_screen/custom_pin_keypad.dart
+++ /dev/null
@@ -1,222 +0,0 @@
-import "package:flutter/material.dart";
-import "package:photos/theme/ente_theme.dart";
-
-class CustomPinKeypad extends StatelessWidget {
- final TextEditingController controller;
- const CustomPinKeypad({required this.controller, super.key});
-
- @override
- Widget build(BuildContext context) {
- return SafeArea(
- child: Container(
- padding: const EdgeInsets.all(2),
- color: getEnteColorScheme(context).strokeFainter,
- child: Column(
- children: [
- Row(
- children: [
- _Button(
- text: '',
- number: '1',
- onTap: () {
- _onKeyTap('1');
- },
- ),
- _Button(
- text: "ABC",
- number: '2',
- onTap: () {
- _onKeyTap('2');
- },
- ),
- _Button(
- text: "DEF",
- number: '3',
- onTap: () {
- _onKeyTap('3');
- },
- ),
- ],
- ),
- Row(
- children: [
- _Button(
- number: '4',
- text: "GHI",
- onTap: () {
- _onKeyTap('4');
- },
- ),
- _Button(
- number: '5',
- text: 'JKL',
- onTap: () {
- _onKeyTap('5');
- },
- ),
- _Button(
- number: '6',
- text: 'MNO',
- onTap: () {
- _onKeyTap('6');
- },
- ),
- ],
- ),
- Row(
- children: [
- _Button(
- number: '7',
- text: 'PQRS',
- onTap: () {
- _onKeyTap('7');
- },
- ),
- _Button(
- number: '8',
- text: 'TUV',
- onTap: () {
- _onKeyTap('8');
- },
- ),
- _Button(
- number: '9',
- text: 'WXYZ',
- onTap: () {
- _onKeyTap('9');
- },
- ),
- ],
- ),
- Row(
- children: [
- const _Button(
- number: '',
- text: '',
- muteButton: true,
- onTap: null,
- ),
- _Button(
- number: '0',
- text: '',
- onTap: () {
- _onKeyTap('0');
- },
- ),
- _Button(
- number: '',
- text: '',
- icon: const Icon(Icons.backspace_outlined),
- onTap: () {
- _onBackspace();
- },
- ),
- ],
- ),
- ],
- ),
- ),
- );
- }
-
- void _onKeyTap(String number) {
- controller.text += number;
- return;
- }
-
- void _onBackspace() {
- if (controller.text.isNotEmpty) {
- controller.text = controller.text.substring(
- 0,
- controller.text.length - 1,
- );
- }
- return;
- }
-}
-
-class _Button extends StatefulWidget {
- final String number;
- final String text;
- final VoidCallback? onTap;
- final bool muteButton;
- final Widget? icon;
-
- const _Button({
- required this.number,
- required this.text,
- this.muteButton = false,
- required this.onTap,
- this.icon,
- });
-
- @override
- State<_Button> createState() => _ButtonState();
-}
-
-class _ButtonState extends State<_Button> {
- bool isPressed = false;
-
- void _onTapDown(TapDownDetails details) {
- setState(() {
- isPressed = true;
- });
- }
-
- void _onTapUp(TapUpDetails details) async {
- setState(() {
- isPressed = false;
- });
- }
-
- @override
- Widget build(BuildContext context) {
- final colorScheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
- return Expanded(
- child: GestureDetector(
- onTapDown: _onTapDown,
- onTapUp: _onTapUp,
- onTap: widget.onTap,
- child: AnimatedContainer(
- duration: const Duration(milliseconds: 100),
- curve: Curves.easeOut,
- margin: const EdgeInsets.all(4),
- decoration: BoxDecoration(
- shape: BoxShape.rectangle,
- borderRadius: BorderRadius.circular(6),
- color: isPressed
- ? colorScheme.backgroundElevated
- : widget.muteButton
- ? colorScheme.fillFaintPressed
- : widget.icon == null
- ? colorScheme.backgroundElevated2
- : null,
- ),
- child: Center(
- child: widget.muteButton
- ? const SizedBox.shrink()
- : widget.icon != null
- ? Container(
- padding: const EdgeInsets.symmetric(
- horizontal: 4,
- vertical: 10,
- ),
- child: widget.icon,
- )
- : Container(
- padding: const EdgeInsets.all(4),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Text(widget.number, style: textTheme.h3),
- Text(widget.text, style: textTheme.tinyBold),
- ],
- ),
- ),
- ),
- ),
- ),
- );
- }
-}
diff --git a/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_auto_lock.dart b/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_auto_lock.dart
deleted file mode 100644
index 715b4bccad..0000000000
--- a/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_auto_lock.dart
+++ /dev/null
@@ -1,95 +0,0 @@
-import "package:ente_components/ente_components.dart";
-import "package:flutter/material.dart";
-import "package:hugeicons/hugeicons.dart";
-import "package:photos/generated/l10n.dart";
-import "package:photos/settings/lock_screen_settings.dart";
-import "package:photos/ui/settings/components/settings_page_scaffold.dart";
-
-class LockScreenAutoLock extends StatefulWidget {
- const LockScreenAutoLock({super.key});
-
- @override
- State<LockScreenAutoLock> createState() => _LockScreenAutoLockState();
-}
-
-class _LockScreenAutoLockState extends State<LockScreenAutoLock> {
- @override
- Widget build(BuildContext context) {
- return SettingsPageScaffold(
- title: AppLocalizations.of(context).autoLock,
- children: const [AutoLockItems()],
- );
- }
-}
-
-class AutoLockItems extends StatefulWidget {
- const AutoLockItems({super.key});
-
- @override
- State<AutoLockItems> createState() => _AutoLockItemsState();
-}
-
-class _AutoLockItemsState extends State<AutoLockItems> {
- final autoLockDurations = LockScreenSettings.autoLockDurations;
- final autoLockTimeInMilliseconds = LockScreenSettings.instance
- .getAutoLockTime();
- late Duration currentAutoLockTime;
-
- @override
- void initState() {
- super.initState();
- for (Duration autoLockDuration in autoLockDurations) {
- if (autoLockDuration.inMilliseconds == autoLockTimeInMilliseconds) {
- currentAutoLockTime = autoLockDuration;
- break;
- }
- }
- }
-
- @override
- Widget build(BuildContext context) {
- return MenuGroupComponent(
- items: [
- for (final autoLockDuration in autoLockDurations)
- _menuItemForPicker(autoLockDuration),
- ],
- );
- }
-
- MenuComponent _menuItemForPicker(Duration autoLockTime) {
- final colors = context.componentColors;
- return MenuComponent(
- key: ValueKey(autoLockTime),
- title: _formatTime(autoLockTime),
- trailing: currentAutoLockTime == autoLockTime
- ? HugeIcon(
- icon: HugeIcons.strokeRoundedTick02,
- color: colors.primary,
- size: IconSizes.medium,
- )
- : null,
- showOnlyLoadingState: true,
- onTap: () async {
- await LockScreenSettings.instance.setAutoLockTime(autoLockTime);
- if (!mounted) {
- return;
- }
- setState(() {
- currentAutoLockTime = autoLockTime;
- });
- },
- );
- }
-
- String _formatTime(Duration duration) {
- if (duration.inHours != 0) {
- return "${duration.inHours}hr";
- } else if (duration.inMinutes != 0) {
- return "${duration.inMinutes}m";
- } else if (duration.inSeconds != 0) {
- return "${duration.inSeconds}s";
- } else {
- return "Immediately";
- }
- }
-}
diff --git a/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_confirm_password.dart b/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_confirm_password.dart
deleted file mode 100644
index 5139c13c93..0000000000
--- a/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_confirm_password.dart
+++ /dev/null
@@ -1,177 +0,0 @@
-import "package:flutter/material.dart";
-import "package:flutter/services.dart";
-import "package:photos/generated/l10n.dart";
-import "package:photos/settings/lock_screen_settings.dart";
-import "package:photos/theme/ente_theme.dart";
-import "package:photos/ui/components/buttons/button_widget_v2.dart";
-import "package:photos/ui/components/buttons/icon_button_widget.dart";
-import "package:photos/ui/components/text_input_widget.dart";
-
-class LockScreenConfirmPassword extends StatefulWidget {
- const LockScreenConfirmPassword({super.key, required this.password});
- final String password;
-
- @override
- State<LockScreenConfirmPassword> createState() =>
- _LockScreenConfirmPasswordState();
-}
-
-class _LockScreenConfirmPasswordState extends State<LockScreenConfirmPassword> {
- /// _confirmPasswordController is disposed by the [TextInputWidget]
- final _confirmPasswordController = TextEditingController(text: null);
-
- final LockScreenSettings _lockscreenSetting = LockScreenSettings.instance;
- final _focusNode = FocusNode();
- final _isFormValid = ValueNotifier<bool>(false);
- final _submitNotifier = ValueNotifier(false);
- @override
- void initState() {
- super.initState();
- WidgetsBinding.instance.addPostFrameCallback((_) async {
- _focusNode.requestFocus();
- });
- }
-
- @override
- void dispose() {
- _submitNotifier.dispose();
- _focusNode.dispose();
- _isFormValid.dispose();
- super.dispose();
- }
-
- Future<void> _confirmPasswordMatch() async {
- if (widget.password == _confirmPasswordController.text) {
- await _lockscreenSetting.setPassword(_confirmPasswordController.text);
-
- Navigator.of(context).pop(true);
- Navigator.of(context).pop(true);
- return;
- }
- await HapticFeedback.vibrate();
- throw Exception("Incorrect password");
- }
-
- @override
- Widget build(BuildContext context) {
- final colorTheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
- return Scaffold(
- resizeToAvoidBottomInset: true,
- appBar: AppBar(
- elevation: 0,
- leading: IconButton(
- onPressed: () {
- FocusScope.of(context).unfocus();
- Navigator.of(context).pop();
- },
- icon: Icon(Icons.arrow_back, color: colorTheme.tabIcon),
- ),
- ),
- floatingActionButton: ValueListenableBuilder<bool>(
- valueListenable: _isFormValid,
- builder: (context, isFormValid, child) {
- return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: ButtonWidgetV2(
- buttonType: ButtonTypeV2.primary,
- labelText: AppLocalizations.of(context).confirm,
- isDisabled: !isFormValid,
- onTap: isFormValid
- ? () async {
- _submitNotifier.value = !_submitNotifier.value;
- }
- : null,
- ),
- );
- },
- ),
- floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
- body: SingleChildScrollView(
- child: Center(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- SizedBox(
- height: 120,
- width: 120,
- child: Stack(
- alignment: Alignment.center,
- children: [
- Container(
- width: 82,
- height: 82,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- gradient: LinearGradient(
- colors: [
- Colors.grey.shade500.withValues(alpha: 0.2),
- Colors.grey.shade50.withValues(alpha: 0.1),
- Colors.grey.shade400.withValues(alpha: 0.2),
- Colors.grey.shade300.withValues(alpha: 0.4),
- ],
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- ),
- ),
- child: Padding(
- padding: const EdgeInsets.all(1.0),
- child: Container(
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: colorTheme.backgroundColour,
- ),
- ),
- ),
- ),
- SizedBox(
- height: 75,
- width: 75,
- child: CircularProgressIndicator(
- color: colorTheme.fillFaintPressed,
- value: 1,
- strokeWidth: 1.5,
- ),
- ),
- IconButtonWidget(
- size: 30,
- icon: Icons.lock,
- iconButtonType: IconButtonType.primary,
- iconColor: colorTheme.tabIcon,
- ),
- ],
- ),
- ),
- Text(
- AppLocalizations.of(context).reenterPassword,
- style: textTheme.bodyBold,
- ),
- const Padding(padding: EdgeInsets.all(12)),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: TextInputWidget(
- hintText: AppLocalizations.of(context).confirmPassword,
- focusNode: _focusNode,
- enableFillColor: false,
- textCapitalization: TextCapitalization.none,
- textEditingController: _confirmPasswordController,
- isPasswordInput: true,
- shouldSurfaceExecutionStates: false,
- onChange: (p0) {
- _isFormValid.value =
- _confirmPasswordController.text.isNotEmpty;
- },
- onSubmit: (p0) {
- return _confirmPasswordMatch();
- },
- submitNotifier: _submitNotifier,
- ),
- ),
- const Padding(padding: EdgeInsets.all(12)),
- ],
- ),
- ),
- ),
- );
- }
-}
diff --git a/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_confirm_pin.dart b/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_confirm_pin.dart
deleted file mode 100644
index a765d64728..0000000000
--- a/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_confirm_pin.dart
+++ /dev/null
@@ -1,206 +0,0 @@
-import "package:flutter/material.dart";
-import "package:flutter/services.dart";
-import "package:photos/generated/l10n.dart";
-import "package:photos/settings/lock_screen_settings.dart";
-import "package:photos/theme/colors.dart";
-import "package:photos/theme/ente_theme.dart";
-import "package:photos/theme/text_style.dart";
-import "package:photos/ui/components/buttons/icon_button_widget.dart";
-import "package:photos/ui/settings/lock_screen/custom_pin_keypad.dart";
-import "package:pinput/pinput.dart";
-
-class LockScreenConfirmPin extends StatefulWidget {
- const LockScreenConfirmPin({super.key, required this.pin});
- final String pin;
- @override
- State<LockScreenConfirmPin> createState() => _LockScreenConfirmPinState();
-}
-
-class _LockScreenConfirmPinState extends State<LockScreenConfirmPin> {
- final _confirmPinController = TextEditingController(text: null);
- bool isConfirmPinValid = false;
-
- final LockScreenSettings _lockscreenSetting = LockScreenSettings.instance;
- final _pinPutDecoration = PinTheme(
- height: 48,
- width: 48,
- padding: const EdgeInsets.only(top: 6.0),
- decoration: BoxDecoration(
- border: Border.all(color: const Color.fromRGBO(45, 194, 98, 1.0)),
- borderRadius: BorderRadius.circular(15.0),
- ),
- );
-
- @override
- void dispose() {
- super.dispose();
- _confirmPinController.dispose();
- }
-
- Future<void> _confirmPinMatch() async {
- if (widget.pin == _confirmPinController.text) {
- await _lockscreenSetting.setPin(_confirmPinController.text);
-
- Navigator.of(context).pop(true);
- Navigator.of(context).pop(true);
- return;
- }
- setState(() {
- isConfirmPinValid = true;
- });
- await HapticFeedback.vibrate();
- await Future.delayed(const Duration(milliseconds: 75));
- _confirmPinController.clear();
- setState(() {
- isConfirmPinValid = false;
- });
- }
-
- @override
- Widget build(BuildContext context) {
- final colorTheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
- return Scaffold(
- appBar: AppBar(
- elevation: 0,
- leading: IconButton(
- onPressed: () {
- Navigator.of(context).pop(false);
- },
- icon: Icon(Icons.arrow_back, color: colorTheme.tabIcon),
- ),
- ),
- body: OrientationBuilder(
- builder: (context, orientation) {
- return orientation == Orientation.portrait
- ? _getBody(colorTheme, textTheme, isPortrait: true)
- : SingleChildScrollView(
- child: _getBody(colorTheme, textTheme, isPortrait: false),
- );
- },
- ),
- );
- }
-
- Widget _getBody(
- EnteColorScheme colorTheme,
- EnteTextTheme textTheme, {
- required bool isPortrait,
- }) {
- return Center(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- SizedBox(
- height: 120,
- width: 120,
- child: Stack(
- alignment: Alignment.center,
- children: [
- Container(
- width: 82,
- height: 82,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- gradient: LinearGradient(
- colors: [
- Colors.grey.shade500.withValues(alpha: 0.2),
- Colors.grey.shade50.withValues(alpha: 0.1),
- Colors.grey.shade400.withValues(alpha: 0.2),
- Colors.grey.shade300.withValues(alpha: 0.4),
- ],
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- ),
- ),
- child: Padding(
- padding: const EdgeInsets.all(1.0),
- child: Container(
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: colorTheme.backgroundColour,
- ),
- ),
- ),
- ),
- SizedBox(
- height: 75,
- width: 75,
- child: ValueListenableBuilder(
- valueListenable: _confirmPinController,
- builder: (context, value, child) {
- return TweenAnimationBuilder<double>(
- tween: Tween<double>(
- begin: 0,
- end: _confirmPinController.text.length / 4,
- ),
- curve: Curves.ease,
- duration: const Duration(milliseconds: 250),
- builder: (context, value, _) =>
- CircularProgressIndicator(
- backgroundColor: colorTheme.fillFaintPressed,
- value: value,
- color: colorTheme.primary400,
- strokeWidth: 1.5,
- ),
- );
- },
- ),
- ),
- IconButtonWidget(
- size: 30,
- icon: Icons.lock,
- iconButtonType: IconButtonType.primary,
- iconColor: colorTheme.tabIcon,
- ),
- ],
- ),
- ),
- Text(
- AppLocalizations.of(context).reenterPin,
- style: textTheme.bodyBold,
- ),
- const Padding(padding: EdgeInsets.all(12)),
- Pinput(
- length: 4,
- showCursor: false,
- useNativeKeyboard: false,
- controller: _confirmPinController,
- defaultPinTheme: _pinPutDecoration,
- submittedPinTheme: _pinPutDecoration.copyWith(
- textStyle: textTheme.h3Bold,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(10.0),
- border: Border.all(color: colorTheme.fillBase),
- ),
- ),
- followingPinTheme: _pinPutDecoration.copyWith(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(10.0),
- border: Border.all(color: colorTheme.fillMuted),
- ),
- ),
- focusedPinTheme: _pinPutDecoration,
- errorPinTheme: _pinPutDecoration.copyWith(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(10.0),
- border: Border.all(color: colorTheme.warning400),
- ),
- ),
- errorText: '',
- obscureText: true,
- obscuringCharacter: '*',
- forceErrorState: isConfirmPinValid,
- onCompleted: (value) async {
- await _confirmPinMatch();
- },
- ),
- isPortrait
- ? const Spacer()
- : const Padding(padding: EdgeInsets.all(12)),
- CustomPinKeypad(controller: _confirmPinController),
- ],
- ),
- );
- }
-}
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.dart
deleted file mode 100644
index d63f6aadad..0000000000
--- a/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_options.dart
+++ /dev/null
@@ -1,253 +0,0 @@
-import "dart:io";
-
-import "package:ente_components/ente_components.dart";
-import "package:ente_pure_utils/ente_pure_utils.dart";
-import "package:flutter/material.dart";
-import "package:hugeicons/hugeicons.dart";
-import "package:photos/generated/l10n.dart";
-import "package:photos/settings/lock_screen_settings.dart";
-import "package:photos/ui/settings/components/settings_item.dart";
-import "package:photos/ui/settings/components/settings_page_scaffold.dart";
-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";
-
-class LockScreenOptions extends StatefulWidget {
- const LockScreenOptions({super.key});
-
- @override
- State<LockScreenOptions> createState() => _LockScreenOptionsState();
-}
-
-enum LockType { device, pin, password }
-
-class _LockScreenOptionsState extends State<LockScreenOptions> {
- final LockScreenSettings _lockscreenSetting = LockScreenSettings.instance;
- late bool appLock;
- late bool hideAppContent;
- LockType _currentLockType = LockType.device;
- bool _isInitialized = false;
-
- @override
- void initState() {
- super.initState();
- hideAppContent = _lockscreenSetting.getShouldHideAppContent();
- appLock = _lockscreenSetting.appLockEnabledCached;
- _initializeSettings();
- }
-
- Future<void> _initializeSettings() async {
- final bool passwordEnabled = await _lockscreenSetting.isPasswordSet();
- final bool pinEnabled = await _lockscreenSetting.isPinSet();
- final bool shouldShowAppContent = _lockscreenSetting
- .getShouldHideAppContent();
-
- LockType lockType = LockType.device;
- if (pinEnabled) {
- lockType = LockType.pin;
- } else if (passwordEnabled) {
- lockType = LockType.password;
- }
-
- final bool isAppLockEnabled =
- pinEnabled ||
- passwordEnabled ||
- _lockscreenSetting.shouldShowSystemLockScreen();
-
- setState(() {
- hideAppContent = shouldShowAppContent;
- _currentLockType = lockType;
- appLock = isAppLockEnabled;
- _isInitialized = true;
- });
- await _lockscreenSetting.setAppLockEnabledCached(isAppLockEnabled);
- }
-
- Future<void> _onToggleSwitch() async {
- if (appLock) {
- // Turning off app lock
- AppLock.of(context)!.setEnabled(false);
- await _lockscreenSetting.setSystemLockScreen(false);
- await _lockscreenSetting.removePinAndPassword();
- setState(() {
- appLock = false;
- _currentLockType = LockType.device;
- });
- } else {
- // Turning on app lock - default to device lock
- AppLock.of(context)!.setEnabled(true);
- await _lockscreenSetting.setSystemLockScreen(true);
- setState(() {
- appLock = true;
- _currentLockType = LockType.device;
- });
- }
- await _initializeSettings();
- }
-
- Future<void> _onSelectDeviceLock() async {
- // Remove any existing PIN/password and use device lock
- await _lockscreenSetting.removePinAndPassword();
- await _lockscreenSetting.setSystemLockScreen(true);
- AppLock.of(context)!.setEnabled(true);
- setState(() {
- _currentLockType = LockType.device;
- });
- await _initializeSettings();
- }
-
- Future<void> _onSelectPinLock() async {
- final result = await routeToPage(context, const LockScreenPin());
- if (result == true) {
- await _lockscreenSetting.setSystemLockScreen(false);
- setState(() {
- _currentLockType = LockType.pin;
- });
- }
- await _initializeSettings();
- }
-
- Future<void> _onSelectPasswordLock() async {
- final result = await routeToPage(context, const LockScreenPassword());
- if (result == true) {
- await _lockscreenSetting.setSystemLockScreen(false);
- setState(() {
- _currentLockType = LockType.password;
- });
- }
- await _initializeSettings();
- }
-
- Future<void> _onAutoLockTap() async {
- await routeToPage(context, const LockScreenAutoLock());
- setState(() {});
- }
-
- Future<void> _tapHideContent() async {
- setState(() {
- hideAppContent = !hideAppContent;
- });
- await _lockscreenSetting.setHideAppContent(hideAppContent);
- }
-
- String _formatAutoLockTime(int milliseconds) {
- final duration = Duration(milliseconds: milliseconds);
- if (duration.inMinutes >= 1) {
- return "${duration.inMinutes}m";
- } else if (duration.inSeconds >= 1) {
- return "${duration.inSeconds}s";
- } else {
- return AppLocalizations.of(context).immediately;
- }
- }
-
- @override
- Widget build(BuildContext context) {
- final l10n = AppLocalizations.of(context);
- final colors = context.componentColors;
-
- return SettingsPageScaffold(
- title: l10n.appLock,
- children: [
- SettingsItem(
- title: l10n.appLock,
- trailing: ToggleSwitchComponent.async(
- value: () => appLock,
- onChanged: _onToggleSwitch,
- ),
- ),
- _description(l10n.appLockDescriptions),
- if (appLock && _isInitialized) ...[
- const SizedBox(height: Spacing.lg),
- MenuGroupComponent(
- items: [
- _lockTypeItem(
- title: l10n.deviceLock,
- lockType: LockType.device,
- onTap: _onSelectDeviceLock,
- ),
- _lockTypeItem(
- title: l10n.pinLock,
- lockType: LockType.pin,
- onTap: _onSelectPinLock,
- ),
- _lockTypeItem(
- title: l10n.passwordLock,
- lockType: LockType.password,
- onTap: _onSelectPasswordLock,
- ),
- ],
- ),
- const SizedBox(height: Spacing.lg),
- SettingsItem(
- title: l10n.autoLock,
- showOnlyLoadingState: true,
- trailing: Row(
- mainAxisSize: MainAxisSize.min,
- children: [
- Text(
- _formatAutoLockTime(_lockscreenSetting.getAutoLockTime()),
- style: TextStyles.body.copyWith(color: colors.textLight),
- ),
- const SizedBox(width: Spacing.xs),
- Icon(
- Icons.chevron_right_outlined,
- color: colors.textLight,
- size: IconSizes.medium,
- ),
- ],
- ),
- onTap: _onAutoLockTap,
- ),
- _description(l10n.autoLockFeatureDescription),
- ],
- const SizedBox(height: Spacing.lg),
- SettingsItem(
- title: l10n.hideContent,
- trailing: ToggleSwitchComponent.async(
- value: () => hideAppContent,
- onChanged: _tapHideContent,
- ),
- ),
- _description(
- Platform.isAndroid
- ? l10n.hideContentDescriptionAndroid
- : l10n.hideContentDescriptionIos,
- ),
- ],
- );
- }
-
- Widget _description(String text) {
- return Padding(
- padding: const EdgeInsets.only(top: Spacing.sm),
- child: Text(
- text,
- style: TextStyles.mini.copyWith(
- color: context.componentColors.textLight,
- ),
- ),
- );
- }
-
- MenuComponent _lockTypeItem({
- required String title,
- required LockType lockType,
- required Future<void> Function() onTap,
- }) {
- final isSelected = _currentLockType == lockType;
- return MenuComponent(
- title: title,
- trailing: isSelected
- ? HugeIcon(
- icon: HugeIcons.strokeRoundedTick02,
- color: context.componentColors.primary,
- size: IconSizes.medium,
- )
- : null,
- showOnlyLoadingState: true,
- onTap: onTap,
- );
- }
-}
diff --git a/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_password.dart b/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_password.dart
deleted file mode 100644
index ba218e87f8..0000000000
--- a/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_password.dart
+++ /dev/null
@@ -1,242 +0,0 @@
-import "dart:convert";
-
-import 'package:ente_crypto/ente_crypto.dart';
-import "package:flutter/material.dart";
-import "package:flutter/services.dart";
-import "package:flutter_sodium/flutter_sodium.dart";
-import "package:photos/generated/l10n.dart";
-import "package:photos/settings/lock_screen_settings.dart";
-import "package:photos/theme/ente_theme.dart";
-import "package:photos/ui/components/buttons/button_widget_v2.dart";
-import "package:photos/ui/components/buttons/icon_button_widget.dart";
-import "package:photos/ui/components/text_input_widget.dart";
-import "package:photos/ui/settings/lock_screen/lock_screen_confirm_password.dart";
-import "package:photos/ui/settings/lock_screen/lock_screen_options.dart";
-
-class LockScreenPassword extends StatefulWidget {
- const LockScreenPassword({
- super.key,
- this.isChangingLockScreenSettings = false,
- this.isAuthenticatingOnAppLaunch = false,
- this.isAuthenticatingForInAppChange = false,
- this.authPass,
- });
-
- /// [isChangingLockScreenSettings] Authentication required for changing lock screen settings.
- /// Set to true when the app requires the user to authenticate before allowing
- /// changes to the lock screen settings.
- final bool isChangingLockScreenSettings;
-
- /// [isAuthenticatingOnAppLaunch] Authentication required on app launch.
- /// Set to true when the app requires the user to authenticate immediately upon opening.
- final bool isAuthenticatingOnAppLaunch;
-
- /// [isAuthenticatingForInAppChange] Authentication required for in-app changes (e.g., email, password).
- /// Set to true when the app requires the to authenticate for sensitive actions like email, password changes.
- final bool isAuthenticatingForInAppChange;
- final String? authPass;
- @override
- State<LockScreenPassword> createState() => _LockScreenPasswordState();
-}
-
-class _LockScreenPasswordState extends State<LockScreenPassword> {
- /// _passwordController is disposed by the [TextInputWidget]
- final _passwordController = TextEditingController(text: null);
- final _focusNode = FocusNode();
- final _isFormValid = ValueNotifier<bool>(false);
- final _submitNotifier = ValueNotifier(false);
- int invalidAttemptsCount = 0;
-
- final _lockscreenSetting = LockScreenSettings.instance;
- @override
- void initState() {
- super.initState();
- invalidAttemptsCount = _lockscreenSetting.getInvalidAttemptCount();
- WidgetsBinding.instance.addPostFrameCallback((_) async {
- _focusNode.requestFocus();
- });
- }
-
- @override
- void dispose() {
- super.dispose();
- _submitNotifier.dispose();
- _focusNode.dispose();
- _isFormValid.dispose();
- }
-
- @override
- Widget build(BuildContext context) {
- final colorTheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
- return Scaffold(
- resizeToAvoidBottomInset: true,
- appBar: AppBar(
- elevation: 0,
- leading: IconButton(
- onPressed: () {
- FocusScope.of(context).unfocus();
- Navigator.of(context).pop(false);
- },
- icon: Icon(Icons.arrow_back, color: colorTheme.tabIcon),
- ),
- ),
- floatingActionButton: ValueListenableBuilder<bool>(
- valueListenable: _isFormValid,
- builder: (context, isFormValid, child) {
- return Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: ButtonWidgetV2(
- buttonType: ButtonTypeV2.primary,
- labelText: AppLocalizations.of(context).next,
- isDisabled: !isFormValid,
- onTap: isFormValid
- ? () async {
- _submitNotifier.value = !_submitNotifier.value;
- }
- : null,
- ),
- );
- },
- ),
- floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
- body: SingleChildScrollView(
- child: Center(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- SizedBox(
- height: 120,
- width: 120,
- child: Stack(
- alignment: Alignment.center,
- children: [
- Container(
- width: 82,
- height: 82,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- gradient: LinearGradient(
- colors: [
- Colors.grey.shade500.withValues(alpha: 0.2),
- Colors.grey.shade50.withValues(alpha: 0.1),
- Colors.grey.shade400.withValues(alpha: 0.2),
- Colors.grey.shade300.withValues(alpha: 0.4),
- ],
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- ),
- ),
- child: Padding(
- padding: const EdgeInsets.all(1.0),
- child: Container(
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: colorTheme.backgroundColour,
- ),
- ),
- ),
- ),
- SizedBox(
- height: 75,
- width: 75,
- child: CircularProgressIndicator(
- color: colorTheme.fillFaintPressed,
- value: 1,
- strokeWidth: 1.5,
- ),
- ),
- IconButtonWidget(
- size: 30,
- icon: Icons.lock,
- iconButtonType: IconButtonType.primary,
- iconColor: colorTheme.tabIcon,
- ),
- ],
- ),
- ),
- Text(
- widget.isChangingLockScreenSettings
- ? AppLocalizations.of(context).enterPassword
- : AppLocalizations.of(context).setNewPassword,
- textAlign: TextAlign.center,
- style: textTheme.bodyBold,
- ),
- const Padding(padding: EdgeInsets.all(12)),
- Padding(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: TextInputWidget(
- hintText: AppLocalizations.of(context).password,
- focusNode: _focusNode,
- enableFillColor: false,
- textCapitalization: TextCapitalization.none,
- textEditingController: _passwordController,
- isPasswordInput: true,
- shouldSurfaceExecutionStates: false,
- onChange: (p0) {
- _isFormValid.value = _passwordController.text.isNotEmpty;
- },
- onSubmit: (p0) {
- return _confirmPassword();
- },
- submitNotifier: _submitNotifier,
- ),
- ),
- const Padding(padding: EdgeInsets.all(12)),
- ],
- ),
- ),
- ),
- );
- }
-
- Future<bool> _confirmPasswordAuth(String inputtedPassword) async {
- final Uint8List? salt = await _lockscreenSetting.getSalt();
- final hash = cryptoPwHash({
- "password": utf8.encode(inputtedPassword),
- "salt": salt,
- "opsLimit": Sodium.cryptoPwhashOpslimitInteractive,
- "memLimit": Sodium.cryptoPwhashMemlimitInteractive,
- });
-
- if (widget.authPass == base64Encode(hash)) {
- await _lockscreenSetting.setInvalidAttemptCount(0);
-
- widget.isAuthenticatingOnAppLaunch ||
- widget.isAuthenticatingForInAppChange
- ? Navigator.of(context).pop(true)
- : Navigator.of(context).pushReplacement(
- MaterialPageRoute(
- builder: (context) => const LockScreenOptions(),
- ),
- );
- return true;
- } else {
- if (widget.isAuthenticatingOnAppLaunch) {
- invalidAttemptsCount++;
- await _lockscreenSetting.setInvalidAttemptCount(invalidAttemptsCount);
- if (invalidAttemptsCount > 4) {
- Navigator.of(context).pop(false);
- }
- }
-
- await HapticFeedback.vibrate();
- throw Exception("Incorrect password");
- }
- }
-
- Future<void> _confirmPassword() async {
- if (widget.isChangingLockScreenSettings) {
- await _confirmPasswordAuth(_passwordController.text);
- return;
- } else {
- await Navigator.of(context).push(
- MaterialPageRoute(
- builder: (BuildContext context) =>
- LockScreenConfirmPassword(password: _passwordController.text),
- ),
- );
- _passwordController.clear();
- }
- }
-}
diff --git a/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_pin.dart b/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_pin.dart
deleted file mode 100644
index c11ab04b8d..0000000000
--- a/mobile/apps/photos/lib/ui/settings/lock_screen/lock_screen_pin.dart
+++ /dev/null
@@ -1,279 +0,0 @@
-import "dart:convert";
-
-import 'package:ente_crypto/ente_crypto.dart';
-import "package:flutter/material.dart";
-import "package:flutter/services.dart";
-import "package:flutter_sodium/flutter_sodium.dart";
-import "package:photos/generated/l10n.dart";
-import "package:photos/settings/lock_screen_settings.dart";
-import "package:photos/theme/colors.dart";
-import "package:photos/theme/ente_theme.dart";
-import "package:photos/theme/text_style.dart";
-import "package:photos/ui/components/buttons/icon_button_widget.dart";
-import "package:photos/ui/settings/lock_screen/custom_pin_keypad.dart";
-import "package:photos/ui/settings/lock_screen/lock_screen_confirm_pin.dart";
-import "package:photos/ui/settings/lock_screen/lock_screen_options.dart";
-import 'package:pinput/pinput.dart';
-
-class LockScreenPin extends StatefulWidget {
- const LockScreenPin({
- super.key,
- this.isChangingLockScreenSettings = false,
- this.isAuthenticatingOnAppLaunch = false,
- this.isAuthenticatingForInAppChange = false,
- this.authPin,
- });
-
- /// [isChangingLockScreenSettings] Authentication required for changing lock screen settings.
- /// Set to true when the app requires the user to authenticate before allowing
- /// changes to the lock screen settings.
- final bool isChangingLockScreenSettings;
-
- /// [isAuthenticatingOnAppLaunch] Authentication required on app launch.
- /// Set to true when the app requires the user to authenticate immediately upon opening.
- final bool isAuthenticatingOnAppLaunch;
-
- /// [isAuthenticatingForInAppChange] Authentication required for in-app changes (e.g., email, password).
- /// Set to true when the app requires the to authenticate for sensitive actions like email, password changes.
- final bool isAuthenticatingForInAppChange;
- final String? authPin;
- @override
- State<LockScreenPin> createState() => _LockScreenPinState();
-}
-
-class _LockScreenPinState extends State<LockScreenPin> {
- final _pinController = TextEditingController(text: null);
-
- final LockScreenSettings _lockscreenSetting = LockScreenSettings.instance;
- bool isPinValid = false;
- int invalidAttemptsCount = 0;
-
- @override
- void initState() {
- super.initState();
- invalidAttemptsCount = _lockscreenSetting.getInvalidAttemptCount();
- }
-
- @override
- void dispose() {
- super.dispose();
- _pinController.dispose();
- }
-
- Future<bool> confirmPinAuth(String code) async {
- final Uint8List? salt = await _lockscreenSetting.getSalt();
- final hash = cryptoPwHash({
- "password": utf8.encode(code),
- "salt": salt,
- "opsLimit": Sodium.cryptoPwhashOpslimitInteractive,
- "memLimit": Sodium.cryptoPwhashMemlimitInteractive,
- });
-
- if (widget.authPin == base64Encode(hash)) {
- invalidAttemptsCount = 0;
- await _lockscreenSetting.setInvalidAttemptCount(0);
- widget.isAuthenticatingOnAppLaunch ||
- widget.isAuthenticatingForInAppChange
- ? Navigator.of(context).pop(true)
- : Navigator.of(context).pushReplacement(
- MaterialPageRoute(
- builder: (context) => const LockScreenOptions(),
- ),
- );
- return true;
- } else {
- setState(() {
- isPinValid = true;
- });
- await HapticFeedback.vibrate();
- await Future.delayed(const Duration(milliseconds: 75));
- _pinController.clear();
- setState(() {
- isPinValid = false;
- });
-
- if (widget.isAuthenticatingOnAppLaunch) {
- invalidAttemptsCount++;
- await _lockscreenSetting.setInvalidAttemptCount(invalidAttemptsCount);
- if (invalidAttemptsCount > 4) {
- Navigator.of(context).pop(false);
- }
- }
- return false;
- }
- }
-
- Future<void> _confirmPin(String code) async {
- if (widget.isChangingLockScreenSettings) {
- await confirmPinAuth(code);
- return;
- } else {
- await Navigator.of(context).push(
- MaterialPageRoute(
- builder: (BuildContext context) => LockScreenConfirmPin(pin: code),
- ),
- );
- _pinController.clear();
- }
- }
-
- final _pinPutDecoration = PinTheme(
- height: 48,
- width: 48,
- padding: const EdgeInsets.only(top: 6.0),
- decoration: BoxDecoration(
- border: Border.all(color: const Color.fromRGBO(45, 194, 98, 1.0)),
- borderRadius: BorderRadius.circular(15.0),
- ),
- );
-
- @override
- Widget build(BuildContext context) {
- final colorTheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
- return Scaffold(
- appBar: AppBar(
- elevation: 0,
- leading: IconButton(
- onPressed: () {
- Navigator.of(context).pop(false);
- },
- icon: Icon(Icons.arrow_back, color: colorTheme.tabIcon),
- ),
- ),
- body: OrientationBuilder(
- builder: (context, orientation) {
- return orientation == Orientation.portrait
- ? _getBody(colorTheme, textTheme, isPortrait: true)
- : SingleChildScrollView(
- child: _getBody(colorTheme, textTheme, isPortrait: false),
- );
- },
- ),
- );
- }
-
- Widget _getBody(
- EnteColorScheme colorTheme,
- EnteTextTheme textTheme, {
- required bool isPortrait,
- }) {
- return Center(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- SizedBox(
- height: 120,
- width: 120,
- child: Stack(
- alignment: Alignment.center,
- children: [
- Container(
- width: 82,
- height: 82,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- gradient: LinearGradient(
- colors: [
- Colors.grey.shade500.withValues(alpha: 0.2),
- Colors.grey.shade50.withValues(alpha: 0.1),
- Colors.grey.shade400.withValues(alpha: 0.2),
- Colors.grey.shade300.withValues(alpha: 0.4),
- ],
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- ),
- ),
- child: Padding(
- padding: const EdgeInsets.all(1.0),
- child: Container(
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: colorTheme.backgroundColour,
- ),
- ),
- ),
- ),
- SizedBox(
- height: 75,
- width: 75,
- child: ValueListenableBuilder(
- valueListenable: _pinController,
- builder: (context, value, child) {
- return TweenAnimationBuilder<double>(
- tween: Tween<double>(
- begin: 0,
- end: _pinController.text.length / 4,
- ),
- curve: Curves.ease,
- duration: const Duration(milliseconds: 250),
- builder: (context, value, _) =>
- CircularProgressIndicator(
- backgroundColor: colorTheme.fillFaintPressed,
- value: value,
- color: colorTheme.primary400,
- strokeWidth: 1.5,
- ),
- );
- },
- ),
- ),
- IconButtonWidget(
- size: 30,
- icon: Icons.lock,
- iconButtonType: IconButtonType.primary,
- iconColor: colorTheme.tabIcon,
- ),
- ],
- ),
- ),
- Text(
- widget.isChangingLockScreenSettings
- ? AppLocalizations.of(context).enterPin
- : AppLocalizations.of(context).setNewPin,
- style: textTheme.bodyBold,
- ),
- const Padding(padding: EdgeInsets.all(12)),
- Pinput(
- length: 4,
- showCursor: false,
- useNativeKeyboard: false,
- controller: _pinController,
- defaultPinTheme: _pinPutDecoration,
- submittedPinTheme: _pinPutDecoration.copyWith(
- textStyle: textTheme.h3Bold,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(10.0),
- border: Border.all(color: colorTheme.fillBase),
- ),
- ),
- followingPinTheme: _pinPutDecoration.copyWith(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(10.0),
- border: Border.all(color: colorTheme.fillMuted),
- ),
- ),
- focusedPinTheme: _pinPutDecoration,
- errorPinTheme: _pinPutDecoration.copyWith(
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(10.0),
- border: Border.all(color: colorTheme.warning400),
- ),
- ),
- forceErrorState: isPinValid,
- obscureText: true,
- obscuringCharacter: '*',
- errorText: '',
- onCompleted: (value) async {
- await _confirmPin(_pinController.text);
- },
- ),
- isPortrait
- ? const Spacer()
- : const Padding(padding: EdgeInsets.all(12)),
- CustomPinKeypad(controller: _pinController),
- ],
- ),
- );
- }
-}
diff --git a/mobile/apps/photos/lib/ui/settings/security/security_settings_page.dart b/mobile/apps/photos/lib/ui/settings/security/security_settings_page.dart
index 86768b6745..339ca0d507 100644
--- a/mobile/apps/photos/lib/ui/settings/security/security_settings_page.dart
+++ b/mobile/apps/photos/lib/ui/settings/security/security_settings_page.dart
@@ -3,6 +3,9 @@ import "dart:typed_data";
import "package:ente_components/ente_components.dart";
import "package:ente_crypto/ente_crypto.dart";
+import "package:ente_lock_screen/auth_util.dart";
+import "package:ente_lock_screen/local_authentication_service.dart";
+import "package:ente_lock_screen/ui/lock_screen_options.dart";
import "package:ente_pure_utils/ente_pure_utils.dart";
import "package:flutter/material.dart";
import "package:hugeicons/hugeicons.dart";
@@ -18,14 +21,11 @@ import "package:photos/models/user_details.dart";
import "package:photos/service_locator.dart";
import "package:photos/services/account/passkey_service.dart";
import "package:photos/services/account/user_service.dart";
-import "package:photos/services/local_authentication_service.dart";
import "package:photos/ui/account/request_pwd_verification_page.dart";
import "package:photos/ui/account/sessions_page.dart";
import "package:photos/ui/notification/toast.dart";
import "package:photos/ui/settings/components/settings_item.dart";
import "package:photos/ui/settings/components/settings_page_scaffold.dart";
-import "package:photos/ui/settings/lock_screen/lock_screen_options.dart";
-import "package:photos/utils/auth_util.dart";
import "package:photos/utils/dialog_util.dart";
class SecuritySettingsPage extends StatefulWidget {
@@ -260,6 +260,7 @@ class _SecuritySettingsPageState extends State<SecuritySettingsPage> {
final bool result = await requestAuthentication(
context,
AppLocalizations.of(context).authToChangeLockscreenSetting,
+ macOSReason: AppLocalizations.of(context).authToChangeLockscreenSetting,
);
if (result) {
await Navigator.of(context).push(
diff --git a/mobile/apps/photos/lib/ui/settings_page.dart b/mobile/apps/photos/lib/ui/settings_page.dart
index ea3c8785af..ac98512e94 100644
--- a/mobile/apps/photos/lib/ui/settings_page.dart
+++ b/mobile/apps/photos/lib/ui/settings_page.dart
@@ -1,4 +1,5 @@
import "package:ente_components/ente_components.dart";
+import "package:ente_lock_screen/local_authentication_service.dart";
import "package:ente_pure_utils/ente_pure_utils.dart";
import "package:flutter/foundation.dart";
import "package:flutter/material.dart";
@@ -10,7 +11,6 @@ import "package:photos/generated/l10n.dart";
import "package:photos/models/user_details.dart";
import "package:photos/service_locator.dart";
import "package:photos/services/account/user_service.dart";
-import "package:photos/services/local_authentication_service.dart";
import "package:photos/ui/account/email_entry_page.dart";
import "package:photos/ui/account/login_page.dart";
import "package:photos/ui/components/banners/offline_settings_banner.dart";
diff --git a/mobile/apps/photos/lib/ui/tabs/albums/albums_manage_sheet.dart b/mobile/apps/photos/lib/ui/tabs/albums/albums_manage_sheet.dart
index 7a39746468..5685f14e2d 100644
--- a/mobile/apps/photos/lib/ui/tabs/albums/albums_manage_sheet.dart
+++ b/mobile/apps/photos/lib/ui/tabs/albums/albums_manage_sheet.dart
@@ -2,6 +2,7 @@ import "dart:async";
import "package:collection/collection.dart";
import "package:ente_components/ente_components.dart";
+import "package:ente_lock_screen/local_authentication_service.dart";
import "package:ente_pure_utils/ente_pure_utils.dart";
import "package:flutter/material.dart";
import "package:hugeicons/hugeicons.dart";
@@ -9,7 +10,6 @@ import "package:photos/generated/l10n.dart";
import "package:photos/models/collection/collection.dart";
import "package:photos/services/collections_service.dart";
import "package:photos/services/hidden_service.dart";
-import "package:photos/services/local_authentication_service.dart";
import "package:photos/ui/tabs/shared/all_links_page.dart";
import "package:photos/ui/viewer/gallery/archive_page.dart";
import "package:photos/ui/viewer/gallery/hidden_page.dart";
diff --git a/mobile/apps/photos/lib/ui/tools/app_lock.dart b/mobile/apps/photos/lib/ui/tools/app_lock.dart
deleted file mode 100644
index 8e5ab3d55f..0000000000
--- a/mobile/apps/photos/lib/ui/tools/app_lock.dart
+++ /dev/null
@@ -1,206 +0,0 @@
-import 'dart:async';
-
-import 'package:flutter/material.dart';
-import "package:photos/generated/l10n.dart";
-import "package:photos/l10n/l10n.dart";
-import "package:photos/settings/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).
-///
-/// [lockScreen] is a [Widget] which should be a screen for handling login logic and
-/// calling `AppLock.of(context).didUnlock();` upon a successful login.
-///
-/// [builder] is a [Function] taking an [Object] as its argument and should return a
-/// [Widget]. The [Object] argument is provided by the [lockScreen] calling
-/// `AppLock.of(context).didUnlock();` with an argument. [Object] can then be injected
-/// in to your `MyApp` widget (or equivalent).
-///
-/// [enabled] determines wether or not the [lockScreen] should be shown on app launch
-/// and subsequent app pauses. This can be changed later on using `AppLock.of(context).enable();`,
-/// `AppLock.of(context).disable();` or the convenience method `AppLock.of(context).setEnabled(enabled);`
-/// using a bool argument.
-///
-/// [_backgroundLockLatencyTimer] determines how much time is allowed to pass when
-/// the app is in the background state before the [lockScreen] widget should be
-/// shown upon returning. It defaults to instantly.
-///
-
-// ignore_for_file: unnecessary_this, library_private_types_in_public_api
-class AppLock extends StatefulWidget {
- final Widget Function(Object?) builder;
- final Widget lockScreen;
- final bool enabled;
- final ThemeData? darkTheme;
- final ThemeData? lightTheme;
- final ThemeMode savedThemeMode;
- final Locale? locale;
-
- const AppLock({
- super.key,
- required this.builder,
- required this.lockScreen,
- required this.savedThemeMode,
- this.enabled = true,
- this.locale,
- this.darkTheme,
- this.lightTheme,
- });
-
- static _AppLockState? of(BuildContext context) =>
- context.findAncestorStateOfType<_AppLockState>();
-
- @override
- State<AppLock> createState() => _AppLockState();
-}
-
-class _AppLockState extends State<AppLock> with WidgetsBindingObserver {
- static final GlobalKey<NavigatorState> _navigatorKey = GlobalKey();
-
- late bool _didUnlockForAppLaunch;
- late bool _isLocked;
- late bool _enabled;
-
- Timer? _backgroundLockLatencyTimer;
-
- @override
- void initState() {
- WidgetsBinding.instance.addObserver(this);
-
- this._didUnlockForAppLaunch = !this.widget.enabled;
- this._isLocked = false;
- this._enabled = this.widget.enabled;
-
- super.initState();
- }
-
- @override
- void didChangeAppLifecycleState(AppLifecycleState state) {
- if (!this._enabled) {
- return;
- }
-
- if (state == AppLifecycleState.paused &&
- (!this._isLocked && this._didUnlockForAppLaunch)) {
- this._backgroundLockLatencyTimer = Timer(
- Duration(milliseconds: LockScreenSettings.instance.getAutoLockTime()),
- () => this.showLockScreen(),
- );
- }
-
- if (state == AppLifecycleState.resumed) {
- this._backgroundLockLatencyTimer?.cancel();
- }
-
- super.didChangeAppLifecycleState(state);
- }
-
- @override
- void dispose() {
- WidgetsBinding.instance.removeObserver(this);
-
- this._backgroundLockLatencyTimer?.cancel();
-
- super.dispose();
- }
-
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- home: this.widget.enabled ? this._lockScreen : this.widget.builder(null),
- navigatorKey: _navigatorKey,
- themeMode: widget.savedThemeMode,
- theme: widget.lightTheme,
- darkTheme: widget.darkTheme,
- locale: widget.locale,
- debugShowCheckedModeBanner: false,
- supportedLocales: appSupportedLocales,
- localeListResolutionCallback: localResolutionCallBack,
- localizationsDelegates: const [
- ...AppLocalizations.localizationsDelegates,
- ],
- onGenerateRoute: (settings) {
- // On Android disabling deep links doesn't work, so this function
- // also gets triggered like /?generatedId=xyz&mainKey=abcd
- // Related: https://github.com/flutter/flutter/issues/119938
-
- switch (settings.name) {
- case '/lock-screen':
- return PageRouteBuilder(pageBuilder: (_, _, _) => this._lockScreen);
- case '/unlocked':
- return PageRouteBuilder(
- pageBuilder: (_, _, _) => this.widget.builder(settings.arguments),
- );
- }
- return null;
- },
- );
- }
-
- Widget get _lockScreen {
- return PopScope(canPop: false, child: this.widget.lockScreen);
- }
-
- /// Causes `AppLock` to either pop the [lockScreen] if the app is already running
- /// or instantiates widget returned from the [builder] method if the app is cold
- /// launched.
- ///
- /// [args] is an optional argument which will get passed to the [builder] method
- /// when built. Use this when you want to inject objects created from the
- /// [lockScreen] in to the rest of your app so you can better guarantee that some
- /// objects, services or databases are already instantiated before using them.
- void didUnlock([Object? args]) {
- if (this._didUnlockForAppLaunch) {
- this._didUnlockOnAppPaused();
- } else {
- this._didUnlockOnAppLaunch(args);
- }
- }
-
- /// Makes sure that [AppLock] shows the [lockScreen] on subsequent app pauses if
- /// [enabled] is true of makes sure it isn't shown on subsequent app pauses if
- /// [enabled] is false.
- ///
- /// This is a convenience method for calling the [enable] or [disable] method based
- /// on [enabled].
- void setEnabled(bool enabled) {
- if (enabled) {
- this.enable();
- } else {
- this.disable();
- }
- }
-
- /// Makes sure that [AppLock] shows the [lockScreen] on subsequent app pauses.
- void enable() {
- setState(() {
- this._enabled = true;
- });
- }
-
- /// Makes sure that [AppLock] doesn't show the [lockScreen] on subsequent app pauses.
- void disable() {
- setState(() {
- this._enabled = false;
- });
- }
-
- /// Manually show the [lockScreen].
- Future<void> showLockScreen() {
- this._isLocked = true;
- return _navigatorKey.currentState!.pushNamed('/lock-screen');
- }
-
- void _didUnlockOnAppLaunch(Object? args) {
- this._didUnlockForAppLaunch = true;
- _navigatorKey.currentState!.pushReplacementNamed(
- '/unlocked',
- arguments: args,
- );
- }
-
- void _didUnlockOnAppPaused() {
- this._isLocked = false;
- _navigatorKey.currentState!.pop();
- }
-}
diff --git a/mobile/apps/photos/lib/ui/tools/lock_screen.dart b/mobile/apps/photos/lib/ui/tools/lock_screen.dart
deleted file mode 100644
index e6700fa1ca..0000000000
--- a/mobile/apps/photos/lib/ui/tools/lock_screen.dart
+++ /dev/null
@@ -1,383 +0,0 @@
-import "dart:async";
-import "dart:io";
-import "dart:math";
-
-import 'package:flutter/material.dart';
-import "package:flutter/scheduler.dart";
-import "package:flutter_animate/flutter_animate.dart";
-import 'package:logging/logging.dart';
-import "package:photos/core/configuration.dart";
-import "package:photos/generated/l10n.dart";
-import "package:photos/l10n/l10n.dart";
-import "package:photos/service_locator.dart";
-import "package:photos/services/account/user_service.dart";
-import "package:photos/settings/lock_screen_settings.dart";
-import "package:photos/theme/ente_theme.dart";
-import "package:photos/ui/components/buttons/icon_button_widget.dart";
-import 'package:photos/ui/tools/app_lock.dart';
-import 'package:photos/utils/auth_util.dart';
-import "package:photos/utils/dialog_util.dart";
-
-class LockScreen extends StatefulWidget {
- const LockScreen({super.key});
-
- @override
- State<LockScreen> createState() => _LockScreenState();
-}
-
-class _LockScreenState extends State<LockScreen>
- with WidgetsBindingObserver, TickerProviderStateMixin {
- final _logger = Logger("LockScreen");
- bool _isShowingLockScreen = false;
- bool _hasPlacedAppInBackground = false;
- bool _hasAuthenticationFailed = false;
- int? lastAuthenticatingTime;
- bool isTimerRunning = false;
- int lockedTimeInSeconds = 0;
- int invalidAttemptCount = 0;
- int remainingTimeInSeconds = 0;
- final _lockscreenSetting = LockScreenSettings.instance;
- late Brightness _platformBrightness;
-
- @override
- void initState() {
- _logger.info("initiatingState");
- super.initState();
- invalidAttemptCount = _lockscreenSetting.getInvalidAttemptCount();
- WidgetsBinding.instance.addObserver(this);
- WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
- if (isNonMobileIOSDevice()) {
- _logger.info('ignore init for non mobile iOS device');
- return;
- }
- _showLockScreen(source: "postFrameInit");
- });
-
- _platformBrightness =
- SchedulerBinding.instance.platformDispatcher.platformBrightness;
- }
-
- @override
- Widget build(BuildContext context) {
- final colorTheme = getEnteColorScheme(context);
- final textTheme = getEnteTextTheme(context);
- return Scaffold(
- appBar: AppBar(
- elevation: 0,
- leading: Configuration.instance.isLoggedIn()
- ? IconButton(
- icon: const Icon(Icons.logout_outlined),
- color: Theme.of(context).iconTheme.color,
- onPressed: () {
- _onLogoutTapped(context);
- },
- )
- : const SizedBox.shrink(),
- ),
- body: GestureDetector(
- onTap: () {
- isTimerRunning ? null : _showLockScreen(source: "tap");
- },
- child: Container(
- decoration: BoxDecoration(
- image: DecorationImage(
- opacity: _platformBrightness == Brightness.light ? 0.08 : 0.12,
- image: const ExactAssetImage('assets/lock_screen_background.png'),
- fit: BoxFit.cover,
- ),
- ),
- child: Center(
- child: Column(
- children: [
- const Spacer(),
- SizedBox(
- height: 120,
- width: 120,
- child: Stack(
- alignment: Alignment.center,
- children: [
- Container(
- width: 82,
- height: 82,
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- gradient: LinearGradient(
- colors: [
- Colors.grey.shade500.withValues(alpha: 0.2),
- Colors.grey.shade50.withValues(alpha: 0.1),
- Colors.grey.shade400.withValues(alpha: 0.2),
- Colors.grey.shade300.withValues(alpha: 0.4),
- ],
- begin: Alignment.topCenter,
- end: Alignment.bottomCenter,
- ),
- ),
- child: Padding(
- padding: const EdgeInsets.all(1.0),
- child: Container(
- decoration: BoxDecoration(
- shape: BoxShape.circle,
- color: colorTheme.backgroundColour,
- ),
- ),
- ),
- ),
- SizedBox(
- height: 75,
- width: 75,
- child: TweenAnimationBuilder<double>(
- tween: Tween<double>(
- begin: isTimerRunning ? 0 : 1,
- end: isTimerRunning
- ? _getFractionOfTimeElapsed()
- : 1,
- ),
- duration: const Duration(seconds: 1),
- builder: (context, value, _) =>
- CircularProgressIndicator(
- backgroundColor: colorTheme.fillFaintPressed,
- value: value,
- color: colorTheme.primary400,
- strokeWidth: 1.5,
- ),
- ),
- ),
- IconButtonWidget(
- size: 30,
- icon: Icons.lock,
- iconButtonType: IconButtonType.primary,
- iconColor: colorTheme.tabIcon,
- ),
- ],
- ),
- ),
- const Spacer(),
- isTimerRunning
- ? Stack(
- alignment: Alignment.center,
- children: [
- Text(
- AppLocalizations.of(
- context,
- ).tooManyIncorrectAttempts,
- style: textTheme.small,
- )
- .animate(
- delay: const Duration(milliseconds: 2000),
- )
- .fadeOut(
- duration: 400.ms,
- curve: Curves.easeInOutCirc,
- ),
- Text(
- _formatTime(remainingTimeInSeconds),
- style: textTheme.small,
- )
- .animate(
- delay: const Duration(milliseconds: 2250),
- )
- .fadeIn(
- duration: 400.ms,
- curve: Curves.easeInOutCirc,
- ),
- ],
- )
- : GestureDetector(
- onTap: () => _showLockScreen(source: "tap"),
- child: Text(
- AppLocalizations.of(context).tapToUnlock,
- style: textTheme.small,
- ),
- ),
- const Padding(padding: EdgeInsets.only(bottom: 24)),
- ],
- ),
- ),
- ),
- ),
- );
- }
-
- bool isNonMobileIOSDevice() {
- if (Platform.isAndroid) {
- return false;
- }
- final shortestSide = MediaQuery.sizeOf(context).shortestSide;
- return shortestSide > 600 ? true : false;
- }
-
- void _onLogoutTapped(BuildContext context) {
- showChoiceActionSheet(
- context,
- title: AppLocalizations.of(context).warning,
- body: AppLocalizations.of(context).areYouSureYouWantToLogout,
- illustration: Image.asset("assets/warning-grey.png"),
- firstButtonLabel: AppLocalizations.of(context).yes,
- isCritical: true,
- firstButtonOnTap: () async {
- await UserService.instance.logout(context);
- Process.killPid(pid, ProcessSignal.sigkill);
- },
- );
- }
-
- Future<void> _autoLogoutOnMaxInvalidAttempts() async {
- _logger.info("Auto logout on max invalid attempts");
- Navigator.of(context).popUntil((route) => route.isFirst);
- final dialog = createProgressDialog(
- context,
- AppLocalizations.of(context).loggingOut,
- );
- await dialog.show();
- await Configuration.instance.logout();
- await dialog.hide();
- }
-
- @override
- Future<void> didChangeAppLifecycleState(AppLifecycleState state) async {
- _logger.info(state.toString());
- if (state == AppLifecycleState.resumed && !_isShowingLockScreen) {
- _hasPlacedAppInBackground = false;
- final bool didAuthInLast5Seconds =
- lastAuthenticatingTime != null &&
- DateTime.now().millisecondsSinceEpoch - lastAuthenticatingTime! <
- 5000;
-
- if (!_hasAuthenticationFailed && !didAuthInLast5Seconds) {
- if (_lockscreenSetting.getlastInvalidAttemptTime() >
- DateTime.now().millisecondsSinceEpoch &&
- !_isShowingLockScreen) {
- final int time =
- (_lockscreenSetting.getlastInvalidAttemptTime() -
- DateTime.now().millisecondsSinceEpoch) ~/
- 1000;
-
- Future.delayed(Duration.zero, () {
- startLockTimer(time);
- _showLockScreen(source: "lifeCycle");
- });
- }
- } else {
- _hasAuthenticationFailed = false;
- }
- } else if (state == AppLifecycleState.paused ||
- state == AppLifecycleState.inactive) {
- if (!_isShowingLockScreen) {
- _hasPlacedAppInBackground = true;
- _hasAuthenticationFailed = false;
- }
- }
- }
-
- @override
- void dispose() {
- _logger.info('disposing');
- WidgetsBinding.instance.removeObserver(this);
- super.dispose();
- }
-
- Future<void> startLockTimer(int timeInSeconds) async {
- if (isTimerRunning) {
- return;
- }
-
- setState(() {
- isTimerRunning = true;
- remainingTimeInSeconds = timeInSeconds;
- });
-
- while (remainingTimeInSeconds > 0) {
- await Future.delayed(const Duration(seconds: 1));
- setState(() {
- remainingTimeInSeconds--;
- });
- }
-
- setState(() {
- isTimerRunning = false;
- });
- }
-
- double _getFractionOfTimeElapsed() {
- final int totalLockedTime = lockedTimeInSeconds =
- pow(2, invalidAttemptCount - 5).toInt() * 30;
- if (remainingTimeInSeconds == 0) return 1;
-
- return 1 - remainingTimeInSeconds / totalLockedTime;
- }
-
- String _formatTime(int seconds) {
- final int hours = seconds ~/ 3600;
- final int minutes = (seconds % 3600) ~/ 60;
- final int remainingSeconds = seconds % 60;
-
- if (hours > 0) {
- return "${hours}h ${minutes}m";
- } else if (minutes > 0) {
- return "${minutes}m ${remainingSeconds}s";
- } else {
- return "${remainingSeconds}s";
- }
- }
-
- Future<void> _showLockScreen({String source = ''}) async {
- final int currentTimestamp = DateTime.now().millisecondsSinceEpoch;
- _logger.info("Showing lock screen $source $currentTimestamp");
- try {
- if (currentTimestamp < _lockscreenSetting.getlastInvalidAttemptTime() &&
- !_isShowingLockScreen) {
- final int remainingTime =
- (_lockscreenSetting.getlastInvalidAttemptTime() -
- currentTimestamp) ~/
- 1000;
-
- await startLockTimer(remainingTime);
- }
- _isShowingLockScreen = true;
- final result = isTimerRunning
- ? false
- : await requestAuthentication(
- context,
- context.l10n.authToViewYourMemories,
- isOpeningApp: true,
- );
- _logger.info("LockScreen Result $result");
- _isShowingLockScreen = false;
- if (result) {
- lastAuthenticatingTime = DateTime.now().millisecondsSinceEpoch;
- AppLock.of(context)!.didUnlock();
- await _lockscreenSetting.setInvalidAttemptCount(0);
- setState(() {
- lockedTimeInSeconds = 15;
- isTimerRunning = false;
- });
- await localSettings.setOnGuestView(false);
- } else {
- if (!_hasPlacedAppInBackground) {
- if (_lockscreenSetting.getInvalidAttemptCount() > 4 &&
- invalidAttemptCount !=
- _lockscreenSetting.getInvalidAttemptCount()) {
- invalidAttemptCount = _lockscreenSetting.getInvalidAttemptCount();
-
- if (invalidAttemptCount > 9) {
- await _autoLogoutOnMaxInvalidAttempts();
- return;
- }
-
- lockedTimeInSeconds = pow(2, invalidAttemptCount - 5).toInt() * 30;
- await _lockscreenSetting.setLastInvalidAttemptTime(
- DateTime.now().millisecondsSinceEpoch +
- lockedTimeInSeconds * 1000,
- );
- await startLockTimer(lockedTimeInSeconds);
- }
- _hasAuthenticationFailed = true;
- _logger.info("Authentication failed");
- }
- }
- } catch (e, s) {
- _isShowingLockScreen = false;
- _logger.severe("Failed to show lock screen", e, s);
- }
- }
-}
diff --git a/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart b/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart
index fca42d9791..acc58f92c4 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/detail_page.dart
@@ -1,6 +1,7 @@
import "dart:async";
import "dart:math";
+import 'package:ente_lock_screen/local_authentication_service.dart';
import 'package:ente_pure_utils/ente_pure_utils.dart';
import 'package:extended_image/extended_image.dart';
import "package:flutter/foundation.dart";
@@ -19,7 +20,6 @@ import "package:photos/models/file/trash_file.dart";
import "package:photos/models/gallery_type.dart";
import "package:photos/service_locator.dart";
import "package:photos/services/collections_service.dart";
-import "package:photos/services/local_authentication_service.dart";
import "package:photos/states/detail_page_state.dart";
import "package:photos/ui/common/fast_scroll_physics.dart";
import 'package:photos/ui/notification/toast.dart';
diff --git a/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dart b/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dart
index 6ccb9d1383..be2bd0f141 100644
--- a/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dart
+++ b/mobile/apps/photos/lib/ui/viewer/file/file_app_bar.dart
@@ -2,6 +2,7 @@ import "dart:async";
import 'dart:io';
import "package:ente_components/ente_components.dart";
+import "package:ente_lock_screen/local_authentication_service.dart";
import 'package:flutter/material.dart';
import "package:flutter/services.dart";
import "package:hugeicons/hugeicons.dart";
@@ -23,7 +24,6 @@ import 'package:photos/models/selected_files.dart';
import "package:photos/service_locator.dart";
import 'package:photos/services/collections_service.dart';
import 'package:photos/services/hidden_service.dart';
-import "package:photos/services/local_authentication_service.dart";
import "package:photos/services/video_preview_service.dart";
import "package:photos/states/detail_page_state.dart";
import "package:photos/theme/colors.dart";
diff --git a/mobile/apps/photos/lib/utils/auth_util.dart b/mobile/apps/photos/lib/utils/auth_util.dart
deleted file mode 100644
index 00f4b2d24d..0000000000
--- a/mobile/apps/photos/lib/utils/auth_util.dart
+++ /dev/null
@@ -1,69 +0,0 @@
-import "package:flutter/widgets.dart";
-import 'package:local_auth/local_auth.dart';
-import 'package:local_auth_android/local_auth_android.dart';
-import 'package:local_auth_ios/local_auth_ios.dart';
-import 'package:logging/logging.dart';
-import "package:photos/generated/l10n.dart";
-import "package:photos/services/local_authentication_service.dart";
-import "package:photos/settings/lock_screen_settings.dart";
-
-Future<bool> requestAuthentication(
- BuildContext context,
- String reason, {
- bool isOpeningApp = false,
- bool isAuthenticatingForInAppChange = false,
-}) async {
- Logger("AuthUtil").info("Requesting authentication");
- await LocalAuthentication().stopAuthentication();
-
- final String? savedPin = await LockScreenSettings.instance.getPin();
- final String? savedPassword = await LockScreenSettings.instance.getPassword();
- if (savedPassword != null || savedPin != null) {
- return await LocalAuthenticationService.instance
- .requestEnteAuthForLockScreen(
- context,
- savedPin,
- savedPassword,
- isAuthenticatingOnAppLaunch: isOpeningApp,
- isAuthenticatingForInAppChange: isAuthenticatingForInAppChange,
- );
- } else {
- return await LocalAuthentication().authenticate(
- localizedReason: reason,
- authMessages: [
- AndroidAuthMessages(
- biometricHint: AppLocalizations.of(context).androidBiometricHint,
- biometricNotRecognized: AppLocalizations.of(
- context,
- ).androidBiometricNotRecognized,
- biometricRequiredTitle: AppLocalizations.of(
- context,
- ).androidBiometricRequiredTitle,
- biometricSuccess: AppLocalizations.of(
- context,
- ).androidBiometricSuccess,
- cancelButton: AppLocalizations.of(context).androidCancelButton,
- deviceCredentialsRequiredTitle: AppLocalizations.of(
- context,
- ).androidDeviceCredentialsRequiredTitle,
- deviceCredentialsSetupDescription: AppLocalizations.of(
- context,
- ).androidDeviceCredentialsSetupDescription,
- goToSettingsButton: AppLocalizations.of(context).goToSettings,
- goToSettingsDescription: AppLocalizations.of(
- context,
- ).androidGoToSettingsDescription,
- signInTitle: AppLocalizations.of(context).androidSignInTitle,
- ),
- IOSAuthMessages(
- localizedFallbackTitle: AppLocalizations.of(context).enterPassword,
- goToSettingsButton: AppLocalizations.of(context).goToSettings,
- goToSettingsDescription: AppLocalizations.of(context).goToSettings,
- lockOut: AppLocalizations.of(context).iOSLockOut,
- // cancelButton default value is "Ok"
- cancelButton: AppLocalizations.of(context).iOSOkButton,
- ),
- ],
- );
- }
-}
diff --git a/mobile/apps/photos/lib/utils/photos_crypto_api_adapter.dart b/mobile/apps/photos/lib/utils/photos_crypto_api_adapter.dart
new file mode 100644
index 0000000000..19f35a04c9
--- /dev/null
+++ b/mobile/apps/photos/lib/utils/photos_crypto_api_adapter.dart
@@ -0,0 +1,50 @@
+import "dart:typed_data";
+
+import "package:ente_crypto/ente_crypto.dart" as ente_crypto;
+import "package:ente_crypto_api/ente_crypto_api.dart";
+import "package:flutter_sodium/flutter_sodium.dart";
+
+/// A [CryptoApi] backed by photos' existing [ente_crypto] (flutter_sodium), so
+/// the lock screen reuses photos' libsodium instead of pulling in a second one.
+///
+/// Only the subset the lock screen calls is implemented; anything else throws.
+class PhotosCryptoApiAdapter implements CryptoApi {
+ const PhotosCryptoApiAdapter();
+
+ @override
+ Future<void> init() async {}
+
+ @override
+ Uint8List cryptoPwHash(
+ Uint8List password,
+ Uint8List salt,
+ int memLimit,
+ int opsLimit,
+ ) => ente_crypto.cryptoPwHash({
+ "password": password,
+ "salt": salt,
+ "memLimit": memLimit,
+ "opsLimit": opsLimit,
+ });
+
+ @override
+ Uint8List getSaltToDeriveKey() => ente_crypto.CryptoUtil.getSaltToDeriveKey();
+
+ @override
+ int get pwhashMemLimitInteractive => Sodium.cryptoPwhashMemlimitInteractive;
+
+ @override
+ int get pwhashMemLimitSensitive => Sodium.cryptoPwhashMemlimitSensitive;
+
+ @override
+ int get pwhashOpsLimitInteractive => Sodium.cryptoPwhashOpslimitInteractive;
+
+ @override
+ int get pwhashOpsLimitSensitive => Sodium.cryptoPwhashOpslimitSensitive;
+
+ @override
+ dynamic noSuchMethod(Invocation invocation) => throw UnimplementedError(
+ "PhotosCryptoApiAdapter implements only the lock-screen crypto subset; "
+ "${invocation.memberName} is not available.",
+ );
+}
diff --git a/mobile/apps/photos/pubspec.lock b/mobile/apps/photos/pubspec.lock
index c9aecb45c2..59bd57e472 100644
--- a/mobile/apps/photos/pubspec.lock
+++ b/mobile/apps/photos/pubspec.lock
@@ -587,6 +587,20 @@ packages:
url: "https://pub.dev"
source: hosted
version: "5.0.3"
+ ente_accounts:
+ dependency: "direct overridden"
+ description:
+ path: "../../packages/accounts"
+ relative: true
+ source: path
+ version: "1.0.0"
+ ente_base:
+ dependency: "direct overridden"
+ description:
+ path: "../../packages/base"
+ relative: true
+ source: path
+ version: "1.0.0"
ente_cast:
dependency: "direct main"
description:
@@ -601,6 +615,13 @@ packages:
relative: true
source: path
version: "0.1.0"
+ ente_configuration:
+ dependency: "direct overridden"
+ description:
+ path: "../../packages/configuration"
+ relative: true
+ source: path
+ version: "1.0.0"
ente_contacts:
dependency: "direct main"
description:
@@ -615,6 +636,20 @@ packages:
relative: true
source: path
version: "0.0.1"
+ ente_crypto_api:
+ dependency: "direct main"
+ description:
+ path: "../../packages/ente_crypto_api"
+ relative: true
+ source: path
+ version: "0.0.1"
+ ente_events:
+ dependency: "direct overridden"
+ description:
+ path: "../../packages/events"
+ relative: true
+ source: path
+ version: "1.0.0"
ente_feature_flag:
dependency: "direct main"
description:
@@ -629,6 +664,27 @@ packages:
relative: true
source: path
version: "1.0.0"
+ ente_lock_screen:
+ dependency: "direct main"
+ description:
+ path: "../../packages/lock_screen"
+ relative: true
+ source: path
+ version: "1.0.0"
+ ente_logging:
+ dependency: "direct overridden"
+ description:
+ path: "../../packages/logging"
+ relative: true
+ source: path
+ version: "1.0.0"
+ ente_network:
+ dependency: "direct overridden"
+ description:
+ path: "../../packages/network"
+ relative: true
+ source: path
+ version: "1.0.0"
ente_photos_rust:
dependency: "direct main"
description:
@@ -664,6 +720,34 @@ packages:
relative: true
source: path
version: "0.0.1"
+ ente_screen_cover:
+ dependency: "direct overridden"
+ description:
+ path: "../../packages/screen_cover"
+ relative: true
+ source: path
+ version: "0.0.1"
+ ente_strings:
+ dependency: "direct main"
+ description:
+ path: "../../packages/strings"
+ relative: true
+ source: path
+ version: "1.0.0"
+ ente_ui:
+ dependency: "direct overridden"
+ description:
+ path: "../../packages/ui"
+ relative: true
+ source: path
+ version: "1.0.0"
+ ente_utils:
+ dependency: "direct overridden"
+ description:
+ path: "../../packages/utils"
+ relative: true
+ source: path
+ version: "1.0.0"
equatable:
dependency: "direct main"
description:
@@ -1586,34 +1670,33 @@ packages:
dependency: "direct main"
description:
name: local_auth
- sha256: "434d854cf478f17f12ab29a76a02b3067f86a63a6d6c4eb8fbfdcfe4879c1b7b"
+ sha256: ae6f382f638108c6becd134318d7c3f0a93875383a54010f61d7c97ac05d5137
url: "https://pub.dev"
source: hosted
- version: "2.3.0"
+ version: "3.0.1"
local_auth_android:
dependency: "direct main"
description:
name: local_auth_android
- sha256: "63ad7ca6396290626dc0cb34725a939e4cfe965d80d36112f08d49cf13a8136e"
+ sha256: b201c006fa769c23386f89aa6837ec0eb8179fcfb212eadcf87b422b3f9a6a78
url: "https://pub.dev"
source: hosted
- version: "1.0.49"
+ version: "2.0.8"
local_auth_darwin:
- dependency: transitive
+ dependency: "direct main"
description:
name: local_auth_darwin
- sha256: "699873970067a40ef2f2c09b4c72eb1cfef64224ef041b3df9fdc5c4c1f91f49"
+ sha256: a8c3d4e17454111f7fd31ff72a31222359f6059f7fe956c2dcfe0f88f49826d4
url: "https://pub.dev"
source: hosted
- version: "1.6.1"
- local_auth_ios:
- dependency: "direct main"
+ version: "2.0.3"
+ local_auth_linux:
+ dependency: "direct overridden"
description:
- name: local_auth_ios
- sha256: "6dde47dc852bc0c8343cb58e66a46efb16b62eddf389ce103d4dacb0c6c40c71"
- url: "https://pub.dev"
- source: hosted
- version: "1.1.7"
+ path: "../../packages/local_auth_linux"
+ relative: true
+ source: path
+ version: "0.1.0"
local_auth_platform_interface:
dependency: transitive
description:
@@ -1626,10 +1709,10 @@ packages:
dependency: transitive
description:
name: local_auth_windows
- sha256: bc4e66a29b0fdf751aafbec923b5bed7ad6ed3614875d8151afe2578520b2ab5
+ sha256: be12c5b8ba5e64896983123655c5f67d2484ecfcc95e367952ad6e3bff94cb16
url: "https://pub.dev"
source: hosted
- version: "1.0.11"
+ version: "2.0.1"
log_viewer:
dependency: "direct main"
description:
@@ -2350,6 +2433,46 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.3"
+ screen_retriever:
+ dependency: transitive
+ description:
+ name: screen_retriever
+ sha256: "42cc3b402a0f67d2455a0d067553d0f13453f6a008d98eababf8b63958d506bd"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.2.1"
+ screen_retriever_linux:
+ dependency: transitive
+ description:
+ name: screen_retriever_linux
+ sha256: "2a476f1a5538065bc5badf376cfdc83d6ecf07d77eb2391b9c2bff5a76970048"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.2.1"
+ screen_retriever_macos:
+ dependency: transitive
+ description:
+ name: screen_retriever_macos
+ sha256: b5abb900fcb86614ff10b738b34e37b9e1d03b0447280668e2bc8a98bdc7bd59
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.2.1"
+ screen_retriever_platform_interface:
+ dependency: transitive
+ description:
+ name: screen_retriever_platform_interface
+ sha256: "3af22d926bedf20c2caa308eea376776451a3af125919ce072e56525fded8901"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.2.1"
+ screen_retriever_windows:
+ dependency: transitive
+ description:
+ name: screen_retriever_windows
+ sha256: c44b38a4c4bab34af259180a70a4eee1e29384e7b82e627c9faa68afcdab2e73
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.2.1"
scrollable_positioned_list:
dependency: "direct main"
description:
@@ -2823,10 +2946,10 @@ packages:
dependency: transitive
description:
name: url_launcher_ios
- sha256: "580fe5dfb51671ae38191d316e027f6b76272b026370708c2d898799750a02b0"
+ sha256: d80b3f567a617cb923546034cc94bfe44eb15f989fe670b37f26abdb9d939cb7
url: "https://pub.dev"
source: hosted
- version: "6.4.1"
+ version: "6.3.4"
url_launcher_linux:
dependency: transitive
description:
@@ -3085,6 +3208,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.0"
+ window_manager:
+ dependency: transitive
+ description:
+ name: window_manager
+ sha256: "7eb6d6c4164ec08e1bf978d6e733f3cebe792e2a23fb07cbca25c2872bfdbdcd"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.5.1"
wkt_parser:
dependency: transitive
description:
diff --git a/mobile/apps/photos/pubspec.yaml b/mobile/apps/photos/pubspec.yaml
index 8240581912..1e7099c4b3 100644
--- a/mobile/apps/photos/pubspec.yaml
+++ b/mobile/apps/photos/pubspec.yaml
@@ -62,10 +62,14 @@ dependencies:
path: ../../packages/contacts
ente_crypto:
path: plugins/ente_crypto
+ ente_crypto_api:
+ path: ../../packages/ente_crypto_api
ente_feature_flag:
path: plugins/ente_feature_flag
ente_icons:
path: ../../packages/ente_icons
+ ente_lock_screen:
+ path: ../../packages/lock_screen
ente_photos_rust:
path: rust_builder
ente_pure_utils:
@@ -76,6 +80,8 @@ dependencies:
path: ../../packages/qr
ente_rust:
path: ../../packages/rust
+ ente_strings:
+ path: ../../packages/strings
equatable: 2.0.7
event_bus: 2.0.1
exif_reader: 4.1.0
@@ -137,9 +143,9 @@ dependencies:
just_audio: 0.10.5
latlong2: 0.9.1
launcher_icon_switcher: 0.0.2
- local_auth: 2.3.0
- local_auth_android: 1.0.49
- local_auth_ios: 1.1.7
+ local_auth: 3.0.1
+ local_auth_android: 2.0.8
+ local_auth_darwin: 2.0.3
log_viewer:
path: ../../packages/log_viewer
logging: 1.3.0
diff --git a/mobile/apps/photos/pubspec_overrides.yaml b/mobile/apps/photos/pubspec_overrides.yaml
index fbbe468a57..2fd5107d1c 100644
--- a/mobile/apps/photos/pubspec_overrides.yaml
+++ b/mobile/apps/photos/pubspec_overrides.yaml
@@ -1,4 +1,4 @@
-# melos_managed_dependency_overrides: ente_cast,ente_crypto,ente_feature_flag,onnx_dart,ffi,flutter_sodium,intl,js,protobuf,video_player_avfoundation,watcher,win32,log_viewer,native_video_editor,ente_qr_ui,ente_icons,ente_rust,ente_pure_utils,backup_exclusion,ente_contacts,ente_qr
+# melos_managed_dependency_overrides: ente_cast,ente_crypto,ente_feature_flag,onnx_dart,ffi,flutter_sodium,intl,js,protobuf,video_player_avfoundation,watcher,win32,log_viewer,native_video_editor,ente_qr_ui,ente_icons,ente_rust,ente_pure_utils,backup_exclusion,ente_contacts,ente_qr,ente_accounts,ente_base,ente_configuration,ente_crypto_api,ente_events,ente_lock_screen,ente_logging,ente_network,ente_screen_cover,ente_strings,ente_ui,ente_utils,local_auth_linux
dependency_overrides:
ente_cast:
path: plugins/ente_cast
@@ -47,3 +47,29 @@ dependency_overrides:
path: ../../packages/ente_qr
ente_components:
path: ../../packages/ente_components
+ ente_accounts:
+ path: ../../packages/accounts
+ ente_base:
+ path: ../../packages/base
+ ente_configuration:
+ path: ../../packages/configuration
+ ente_crypto_api:
+ path: ../../packages/ente_crypto_api
+ ente_events:
+ path: ../../packages/events
+ ente_lock_screen:
+ path: ../../packages/lock_screen
+ ente_logging:
+ path: ../../packages/logging
+ ente_network:
+ path: ../../packages/network
+ ente_screen_cover:
+ path: ../../packages/screen_cover
+ ente_strings:
+ path: ../../packages/strings
+ ente_ui:
+ path: ../../packages/ui
+ ente_utils:
+ path: ../../packages/utils
+ local_auth_linux:
+ path: ../../packages/local_auth_linux