[mob][photos] Show lockscreen when guestview is enabled and app is killed

This commit is contained in:
Aman Raj Singh Mourya
2024-09-04 20:44:47 +05:30
parent e58c48aa70
commit b3c6c0fc9b
6 changed files with 17 additions and 1 deletions

View File

@@ -71,6 +71,7 @@ class Configuration {
"has_selected_all_folders_for_backup";
static const anonymousUserIDKey = "anonymous_user_id";
static const endPointKey = "endpoint";
static const guestViewKey = "key_guest_view";
static final _logger = Logger("Configuration");
String? _cachedToken;
@@ -633,6 +634,14 @@ class Configuration {
return _preferences.setBool(keyShowSystemLockScreen, value);
}
Future<void> setGuestView(bool value) {
return _preferences.setBool(guestViewKey, value);
}
bool getGuestView() {
return _preferences.getBool(guestViewKey) ?? false;
}
void setVolatilePassword(String volatilePassword) {
_volatilePassword = volatilePassword;
}

View File

@@ -112,7 +112,8 @@ Future<void> _runInForeground(AdaptiveThemeMode? savedThemeMode) async {
builder: (args) =>
EnteApp(_runBackgroundTask, _killBGTask, locale, savedThemeMode),
lockScreen: const LockScreen(),
enabled: await Configuration.instance.shouldShowLockScreen(),
enabled: await Configuration.instance.shouldShowLockScreen() ||
Configuration.instance.getGuestView(),
locale: locale,
lightTheme: lightThemeData,
darkTheme: darkThemeData,

View File

@@ -345,6 +345,7 @@ class _LockScreenState extends State<LockScreen>
lockedTimeInSeconds = 15;
isTimerRunning = false;
});
await Configuration.instance.setGuestView(false);
} else {
if (!_hasPlacedAppInBackground) {
if (_lockscreenSetting.getInvalidAttemptCount() > 4 &&

View File

@@ -581,6 +581,7 @@ class _FileSelectionActionsWidgetState
"guest_view",
),
);
await Configuration.instance.setGuestView(true);
routeToPage(context, page, forceCustomPageRoute: true).ignore();
WidgetsBinding.instance.addPostFrameCallback((_) {
Bus.instance.fire(GuestViewEvent(true, false));

View File

@@ -156,6 +156,7 @@ class _DetailPageState extends State<DetailPage> {
final authenticated = await _requestAuthentication();
if (authenticated) {
Bus.instance.fire(GuestViewEvent(false, false));
await Configuration.instance.setGuestView(false);
}
}
},

View File

@@ -6,6 +6,7 @@ import "package:flutter_svg/flutter_svg.dart";
import "package:local_auth/local_auth.dart";
import 'package:logging/logging.dart';
import 'package:media_extension/media_extension.dart';
import "package:photos/core/configuration.dart";
import "package:photos/core/event_bus.dart";
import "package:photos/events/guest_view_event.dart";
import "package:photos/generated/l10n.dart";
@@ -475,6 +476,7 @@ class FileAppBarState extends State<FileAppBar> {
Future<void> _onTapGuestView() async {
if (await LocalAuthentication().isDeviceSupported()) {
Bus.instance.fire(GuestViewEvent(true, true));
await Configuration.instance.setGuestView(true);
} else {
await showErrorDialog(
context,
@@ -492,6 +494,7 @@ class FileAppBarState extends State<FileAppBar> {
);
if (hasAuthenticated) {
Bus.instance.fire(GuestViewEvent(false, false));
await Configuration.instance.setGuestView(false);
}
}
}