Skip to content

Commit

Permalink
[mob][photos] Implemeted Applock to set custom pin/password (#2130)
Browse files Browse the repository at this point in the history
This PR add the following features
1. **Device Lock:** If the user's device has a screen lock (PIN,
fingerprint, etc.), it will be used for initial authentication.
2. **Custom PIN/Passwprd**: Users can set a custom PIN/Password for app
access, independent of the device lock.

<br/>
<img width="300"
src="https://github.com/ente-io/ente/assets/146618155/54b044d1-d361-4ed8-a138-87b4838d75fc">
<img align="left" width="300"
src="https://github.com/ente-io/ente/assets/146618155/9bb90ab7-2d97-472e-90da-945a3a043533">

<br/>

<img width="300"
src="https://github.com/ente-io/ente/assets/146618155/8207605f-3495-4f62-bc34-b5a8ec64ab0a">
<img align="left" width="300"
src="https://github.com/ente-io/ente/assets/146618155/9f5fb83f-37a1-4214-b27e-4433b40a8773">
  • Loading branch information
AmanRajSinghMourya authored Jul 4, 2024
2 parents 5b7dcdd + cb94d95 commit 8c79aed
Show file tree
Hide file tree
Showing 48 changed files with 2,550 additions and 161 deletions.
Binary file added mobile/assets/2.0x/lock_screen_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile/assets/3.0x/lock_screen_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mobile/assets/lock_screen_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 13 additions & 8 deletions mobile/lib/core/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import 'package:photos/services/search_service.dart';
import 'package:photos/services/sync_service.dart';
import 'package:photos/utils/crypto_util.dart';
import 'package:photos/utils/file_uploader.dart';
import "package:photos/utils/lock_screen_settings.dart";
import 'package:photos/utils/validator_util.dart';
import "package:photos/utils/wakelock_util.dart";
import 'package:shared_preferences/shared_preferences.dart';
Expand All @@ -59,7 +60,7 @@ class Configuration {
// keyShouldKeepDeviceAwake is used to determine whether the device screen
// should be kept on while the app is in foreground.
static const keyShouldKeepDeviceAwake = "should_keep_device_awake";
static const keyShouldShowLockScreen = "should_show_lock_screen";
static const keyShowSystemLockScreen = "should_show_lock_screen";
static const keyHasSelectedAnyBackupFolder =
"has_selected_any_folder_for_backup";
static const lastTempFolderClearTimeKey = "last_temp_folder_clear_time";
Expand All @@ -72,7 +73,6 @@ class Configuration {
"has_selected_all_folders_for_backup";
static const anonymousUserIDKey = "anonymous_user_id";
static const endPointKey = "endpoint";

static final _logger = Logger("Configuration");

String? _cachedToken;
Expand All @@ -83,7 +83,6 @@ class Configuration {
late FlutterSecureStorage _secureStorage;
late String _tempDocumentsDirPath;
late String _thumbnailCacheDirectory;

// 6th July 22: Remove this after 3 months. Hopefully, active users
// will migrate to newer version of the app, where shared media is stored
// on appSupport directory which OS won't clean up automatically
Expand Down Expand Up @@ -621,16 +620,22 @@ class Configuration {
}
}

bool shouldShowLockScreen() {
if (_preferences.containsKey(keyShouldShowLockScreen)) {
return _preferences.getBool(keyShouldShowLockScreen)!;
Future<bool> shouldShowLockScreen() async {
final bool isPin = await LockScreenSettings.instance.isPinSet();
final bool isPass = await LockScreenSettings.instance.isPasswordSet();
return isPin || isPass || shouldShowSystemLockScreen();
}

bool shouldShowSystemLockScreen() {
if (_preferences.containsKey(keyShowSystemLockScreen)) {
return _preferences.getBool(keyShowSystemLockScreen)!;
} else {
return false;
}
}

Future<void> setShouldShowLockScreen(bool value) {
return _preferences.setBool(keyShouldShowLockScreen, value);
Future<void> setSystemLockScreen(bool value) {
return _preferences.setBool(keyShowSystemLockScreen, value);
}

void setVolatilePassword(String volatilePassword) {
Expand Down
20 changes: 20 additions & 0 deletions mobile/lib/generated/intl/messages_cs.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 20 additions & 1 deletion mobile/lib/generated/intl/messages_de.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions mobile/lib/generated/intl/messages_en.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8c79aed

Please sign in to comment.