mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 07:28:26 +00:00
[mob][photos] Refractor code
This commit is contained in:
parent
b3c6c0fc9b
commit
3e136baee2
@ -71,7 +71,6 @@ 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;
|
||||
@ -634,14 +633,6 @@ 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;
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ Future<void> _runInForeground(AdaptiveThemeMode? savedThemeMode) async {
|
||||
EnteApp(_runBackgroundTask, _killBGTask, locale, savedThemeMode),
|
||||
lockScreen: const LockScreen(),
|
||||
enabled: await Configuration.instance.shouldShowLockScreen() ||
|
||||
Configuration.instance.getGuestView(),
|
||||
localSettings.isOnGuestView(),
|
||||
locale: locale,
|
||||
lightTheme: lightThemeData,
|
||||
darkTheme: darkThemeData,
|
||||
|
@ -9,6 +9,7 @@ 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/user_service.dart";
|
||||
import "package:photos/theme/ente_theme.dart";
|
||||
import "package:photos/ui/components/buttons/icon_button_widget.dart";
|
||||
@ -345,7 +346,7 @@ class _LockScreenState extends State<LockScreen>
|
||||
lockedTimeInSeconds = 15;
|
||||
isTimerRunning = false;
|
||||
});
|
||||
await Configuration.instance.setGuestView(false);
|
||||
await localSettings.setOnGuestView(false);
|
||||
} else {
|
||||
if (!_hasPlacedAppInBackground) {
|
||||
if (_lockscreenSetting.getInvalidAttemptCount() > 4 &&
|
||||
|
@ -21,6 +21,7 @@ import 'package:photos/models/gallery_type.dart';
|
||||
import "package:photos/models/metadata/common_keys.dart";
|
||||
import "package:photos/models/ml/face/person.dart";
|
||||
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/machine_learning/face_ml/feedback/cluster_feedback.dart';
|
||||
@ -581,7 +582,7 @@ class _FileSelectionActionsWidgetState
|
||||
"guest_view",
|
||||
),
|
||||
);
|
||||
await Configuration.instance.setGuestView(true);
|
||||
await localSettings.setOnGuestView(true);
|
||||
routeToPage(context, page, forceCustomPageRoute: true).ignore();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
Bus.instance.fire(GuestViewEvent(true, false));
|
||||
|
@ -15,6 +15,7 @@ import "package:photos/generated/l10n.dart";
|
||||
import "package:photos/models/file/extensions/file_props.dart";
|
||||
import 'package:photos/models/file/file.dart';
|
||||
import "package:photos/models/file/file_type.dart";
|
||||
import "package:photos/service_locator.dart";
|
||||
import "package:photos/services/local_authentication_service.dart";
|
||||
import "package:photos/ui/common/fast_scroll_physics.dart";
|
||||
import 'package:photos/ui/tools/editor/image_editor_page.dart';
|
||||
@ -156,7 +157,7 @@ class _DetailPageState extends State<DetailPage> {
|
||||
final authenticated = await _requestAuthentication();
|
||||
if (authenticated) {
|
||||
Bus.instance.fire(GuestViewEvent(false, false));
|
||||
await Configuration.instance.setGuestView(false);
|
||||
await localSettings.setOnGuestView(false);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -6,7 +6,6 @@ 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";
|
||||
@ -476,7 +475,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);
|
||||
await localSettings.setOnGuestView(true);
|
||||
} else {
|
||||
await showErrorDialog(
|
||||
context,
|
||||
@ -494,7 +493,7 @@ class FileAppBarState extends State<FileAppBar> {
|
||||
);
|
||||
if (hasAuthenticated) {
|
||||
Bus.instance.fire(GuestViewEvent(false, false));
|
||||
await Configuration.instance.setGuestView(false);
|
||||
await localSettings.setOnGuestView(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ class LocalSettings {
|
||||
static const kEnableMultiplePart = "ls.enable_multiple_part";
|
||||
static const kRateUsPromptThreshold = 2;
|
||||
static const shouldLoopVideoKey = "video.should_loop";
|
||||
static const onGuestViewKey = "on_guest_view";
|
||||
|
||||
final SharedPreferences _prefs;
|
||||
|
||||
@ -91,4 +92,12 @@ class LocalSettings {
|
||||
bool shouldLoopVideo() {
|
||||
return _prefs.getBool(shouldLoopVideoKey) ?? true;
|
||||
}
|
||||
|
||||
Future<void> setOnGuestView(bool value) {
|
||||
return _prefs.setBool(onGuestViewKey, value);
|
||||
}
|
||||
|
||||
bool isOnGuestView() {
|
||||
return _prefs.getBool(onGuestViewKey) ?? false;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user