Skip to content

armgit / ente

Public Imported from GitHub
0

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

Remove unused Locker code and dependencies

AmanRajSinghMourya26d07967ed48
diff --git a/mobile/apps/locker/lib/core/constants.dart b/mobile/apps/locker/lib/core/constants.dart
index 0a18f833de..4311e05b91 100644
--- a/mobile/apps/locker/lib/core/constants.dart
+++ b/mobile/apps/locker/lib/core/constants.dart
@@ -1,7 +1,6 @@
import 'package:flutter/foundation.dart';
const int microSecondsInDay = 86400000000;
-const int android11SDKINT = 30;
// 256 bit key maps to 24 words
// https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki#Generating_the_mnemonic
diff --git a/mobile/apps/locker/lib/models/file_type.dart b/mobile/apps/locker/lib/models/file_type.dart
index 5979b649e1..bbc9da9732 100644
--- a/mobile/apps/locker/lib/models/file_type.dart
+++ b/mobile/apps/locker/lib/models/file_type.dart
@@ -31,18 +31,3 @@ FileType getFileType(int fileType) {
return FileType.other;
}
}
-
-String getHumanReadableString(FileType fileType) {
- switch (fileType) {
- case FileType.image:
- return 'Images';
- case FileType.video:
- return 'Videos';
- case FileType.livePhoto:
- return 'Live Photos';
- case FileType.other:
- return 'Other Files';
- case FileType.info:
- return 'Information';
- }
-}
diff --git a/mobile/apps/locker/lib/models/info/info_item.dart b/mobile/apps/locker/lib/models/info/info_item.dart
index f022074eb5..0f6af47958 100644
--- a/mobile/apps/locker/lib/models/info/info_item.dart
+++ b/mobile/apps/locker/lib/models/info/info_item.dart
@@ -1,5 +1,3 @@
-import 'dart:convert';
-
enum InfoType { note, physicalRecord, accountCredential, emergencyContact }
// Locker file metadata currently uses the enum's camelCase name on the wire.
@@ -197,12 +195,6 @@ class InfoItem {
};
}
- String toJsonString() => jsonEncode(toJson());
-
- static InfoItem fromJsonString(String jsonString) {
- return InfoItem.fromJson(jsonDecode(jsonString));
- }
-
InfoItem copyWith({
InfoType? type,
InfoData? data,
diff --git a/mobile/apps/locker/lib/models/selected_collections.dart b/mobile/apps/locker/lib/models/selected_collections.dart
index d53ae6dd10..4d5cac7471 100644
--- a/mobile/apps/locker/lib/models/selected_collections.dart
+++ b/mobile/apps/locker/lib/models/selected_collections.dart
@@ -22,18 +22,6 @@ class SelectedCollections extends ChangeNotifier {
notifyListeners();
}
- void unSelect(
- Set<Collection> collectionsToUnselect, {
- bool skipNotify = false,
- }) {
- collections.removeWhere(
- (collection) => collectionsToUnselect.contains(collection),
- );
- if (!skipNotify) {
- notifyListeners();
- }
- }
-
bool isCollectionSelected(Collection collection) {
return collections.any((element) => element.id == collection.id);
}
diff --git a/mobile/apps/locker/lib/models/selected_files.dart b/mobile/apps/locker/lib/models/selected_files.dart
index 2dc57ddd24..7ec9207215 100644
--- a/mobile/apps/locker/lib/models/selected_files.dart
+++ b/mobile/apps/locker/lib/models/selected_files.dart
@@ -22,13 +22,6 @@ class SelectedFiles extends ChangeNotifier {
notifyListeners();
}
- void unSelectAll(Set<EnteFile> filesToUnselect, {bool skipNotify = false}) {
- files.removeWhere((file) => filesToUnselect.contains(file));
- if (!skipNotify) {
- notifyListeners();
- }
- }
-
bool isFileSelected(EnteFile file) {
final EnteFile? alreadySelected = files.firstWhereOrNull(
(element) => _isMatch(file, element),
diff --git a/mobile/apps/locker/lib/services/collections/collections_service.dart b/mobile/apps/locker/lib/services/collections/collections_service.dart
index f44ca4c36c..7a860b280b 100644
--- a/mobile/apps/locker/lib/services/collections/collections_service.dart
+++ b/mobile/apps/locker/lib/services/collections/collections_service.dart
@@ -1,5 +1,4 @@
import 'dart:async';
-import "dart:math";
import 'dart:typed_data';
import "package:ente_accounts/services/user_service.dart";
@@ -34,19 +33,6 @@ class CollectionService {
static final CollectionService instance =
CollectionService._privateConstructor();
- static const Set<String> _suggestedCollectionNames = {
- 'Personal',
- 'Work',
- 'Travel',
- 'Family',
- 'Projects',
- 'School',
- 'Music',
- 'Books',
- 'Events',
- 'Holidays',
- };
-
final _logger = Logger("CollectionService");
late CollectionApiClient _apiClient;
@@ -741,35 +727,6 @@ class CollectionService {
return createCollection("Documents", type: CollectionType.folder);
}
- Future<String> getRandomUnusedCollectionName() async {
- try {
- final existingCollections = await getCollections();
- final existingNames = existingCollections
- .map((collection) => collection.name?.toLowerCase())
- .where((name) => name != null)
- .toSet();
-
- final availableNames = _suggestedCollectionNames
- .where((name) => !existingNames.contains(name.toLowerCase()))
- .toList();
-
- if (availableNames.isEmpty) {
- _logger.info(
- "All suggested collection names are used, returning 'Documents'",
- );
- return "Documents";
- }
-
- final random = Random();
- final randomName = availableNames[random.nextInt(availableNames.length)];
- _logger.info("Selected random unused collection name");
- return randomName;
- } catch (e) {
- _logger.severe("Failed to get random unused collection name: $e");
- return "Documents";
- }
- }
-
Future<Collection> getCollection(int collectionID) async {
if (_collectionIDToCollections.containsKey(collectionID)) {
return _collectionIDToCollections[collectionID]!;
diff --git a/mobile/apps/locker/lib/services/feature_flag_service.dart b/mobile/apps/locker/lib/services/feature_flag_service.dart
index 5e305b2978..0f4659397a 100644
--- a/mobile/apps/locker/lib/services/feature_flag_service.dart
+++ b/mobile/apps/locker/lib/services/feature_flag_service.dart
@@ -16,7 +16,6 @@ class FeatureFlagService {
late FlagService _flagService;
bool get internalUser => _flagService.internalUser;
- bool get documentScanner => true;
bool get isInternalUserDisabled =>
_preferences.getBool(_internalUserDisabled) ?? false;
diff --git a/mobile/apps/locker/lib/services/files/upload/file_upload_service.dart b/mobile/apps/locker/lib/services/files/upload/file_upload_service.dart
index 409b04acaf..8372199ceb 100644
--- a/mobile/apps/locker/lib/services/files/upload/file_upload_service.dart
+++ b/mobile/apps/locker/lib/services/files/upload/file_upload_service.dart
@@ -30,11 +30,8 @@ import "package:uuid/uuid.dart";
class FileUploader {
static const kMaximumConcurrentUploads = 4;
- static const kMaximumConcurrentVideoUploads = 2;
- static const kMaximumThumbnailCompressionAttempts = 2;
static const kMaximumUploadAttempts = 4;
static const kMaxFileSize10Gib = 10737418240;
- static const kBlockedUploadsPollFrequency = Duration(seconds: 2);
static const kFileUploadTimeout = Duration(minutes: 50);
static const k20MBStorageBuffer = 20 * 1024 * 1024;
static const _lastStaleFileCleanupTime = "lastStaleFileCleanupTime";
@@ -46,13 +43,9 @@ class FileUploader {
LinkedHashMap<String, FileUploadItem>();
final LinkedHashMap<String, BackupItem> _allBackups =
LinkedHashMap<String, BackupItem>();
- final kSafeBufferForLockExpiry = const Duration(hours: 4).inMicroseconds;
- final kBGTaskDeathTimeout = const Duration(seconds: 5).inMicroseconds;
LinkedHashMap<String, BackupItem> get allBackups => _allBackups;
- int _totalCountInUploadSession = 0;
-
int _uploadCounter = 0;
late SharedPreferences _prefs;
@@ -77,7 +70,6 @@ class FileUploader {
Collection collection, {
String? fileName,
}) {
- _totalCountInUploadSession++;
final String path = file.path;
final completer = Completer<EnteFile>();
_queue[path] = FileUploadItem(
@@ -156,10 +148,6 @@ class FileUploader {
}
}
- int getCurrentSessionUploadCount() {
- return _totalCountInUploadSession;
- }
-
void clearQueue(final Error reason) {
final List<String> uploadsToBeRemoved = [];
_queue.entries
@@ -175,35 +163,10 @@ class FileUploader {
);
Bus.instance.fire(BackupUpdatedEvent(_allBackups));
}
- _totalCountInUploadSession = 0;
- }
-
- void removeFromQueueWhere(final bool Function(File) fn, final Error reason) {
- final List<String> uploadsToBeRemoved = [];
- _queue.entries
- .where((entry) => entry.value.status == UploadStatus.notStarted)
- .forEach((pendingUpload) {
- if (fn(pendingUpload.value.file)) {
- uploadsToBeRemoved.add(pendingUpload.key);
- }
- });
- for (final id in uploadsToBeRemoved) {
- _queue.remove(id)?.completer.completeError(reason);
- _allBackups[id] = _allBackups[id]!.copyWith(
- status: BackupItemStatus.retry,
- error: reason,
- );
- Bus.instance.fire(BackupUpdatedEvent(_allBackups));
- }
- _logger.info(
- 'number of enteries removed from queue ${uploadsToBeRemoved.length}',
- );
- _totalCountInUploadSession -= uploadsToBeRemoved.length;
}
void _pollQueue() {
if (_queue.isEmpty) {
- _totalCountInUploadSession = 0;
return;
}
if (_uploadCounter < kMaximumConcurrentUploads) {
@@ -840,6 +803,4 @@ class FileUploadItem {
});
}
-enum UploadStatus { notStarted, inProgress, inBackground, completed }
-
-enum ProcessType { background, foreground }
+enum UploadStatus { notStarted, inProgress }
diff --git a/mobile/apps/locker/lib/services/files/upload/models/backup_item_status.dart b/mobile/apps/locker/lib/services/files/upload/models/backup_item_status.dart
index 597153e7c8..b26ec3af66 100644
--- a/mobile/apps/locker/lib/services/files/upload/models/backup_item_status.dart
+++ b/mobile/apps/locker/lib/services/files/upload/models/backup_item_status.dart
@@ -1 +1 @@
-enum BackupItemStatus { uploading, inQueue, retry, inBackground, uploaded }
+enum BackupItemStatus { uploading, inQueue, retry, uploaded }
diff --git a/mobile/apps/locker/lib/services/scanner/scanner_models.dart b/mobile/apps/locker/lib/services/scanner/scanner_models.dart
index fa07f21406..96375953eb 100644
--- a/mobile/apps/locker/lib/services/scanner/scanner_models.dart
+++ b/mobile/apps/locker/lib/services/scanner/scanner_models.dart
@@ -150,23 +150,6 @@ class ScanQuad {
aligned;
}
- ScanQuad rotatedClockwise(int degrees) {
- if (degrees % 90 != 0) {
- throw ArgumentError.value(degrees, 'degrees', 'Expected quarter turns');
- }
- var result = this;
- for (var turn = 0; turn < (degrees ~/ 90) % 4; turn++) {
- result = ScanQuad._([
- for (var i = 0; i < 4; i++)
- Offset(
- 1 - result.corners[(i + 3) % 4].dy,
- result.corners[(i + 3) % 4].dx,
- ),
- ]);
- }
- return result;
- }
-
static void _validateSize(Size size) {
if (!size.width.isFinite || !size.height.isFinite || size.isEmpty) {
throw ArgumentError.value(size, 'sourceSize');
diff --git a/mobile/apps/locker/lib/services/update_service.dart b/mobile/apps/locker/lib/services/update_service.dart
index ebe7df62ba..c8f283ee62 100644
--- a/mobile/apps/locker/lib/services/update_service.dart
+++ b/mobile/apps/locker/lib/services/update_service.dart
@@ -129,11 +129,6 @@ class UpdateService {
await _prefs!.setInt(kChangeLogShownVersionKey, currentChangeLogVersion);
}
- Future<void> resetChangeLogShown() async {
- if (!_isInitialized) return;
- await _prefs!.remove(kChangeLogShownVersionKey);
- }
-
bool isIndependent() {
if (!_isInitialized) {
return false;
diff --git a/mobile/apps/locker/lib/ui/mixins/search_mixin.dart b/mobile/apps/locker/lib/ui/mixins/search_mixin.dart
index 795b083259..d4ce503421 100644
--- a/mobile/apps/locker/lib/ui/mixins/search_mixin.dart
+++ b/mobile/apps/locker/lib/ui/mixins/search_mixin.dart
@@ -22,7 +22,6 @@ class CollectionSearchResult {
mixin SearchMixin<T extends StatefulWidget> on State<T> {
String _searchQuery = '';
bool _isSearchActive = false;
- bool _isSearching = false;
Timer? _searchDebounceTimer;
final TextEditingController _searchController = TextEditingController();
final FocusNode _searchFocusNode = FocusNode();
@@ -94,10 +93,6 @@ mixin SearchMixin<T extends StatefulWidget> on State<T> {
Future<void> _performSearch(String query) async {
if (!mounted) return;
- setState(() {
- _isSearching = true;
- });
-
try {
final normalizedQuery = query.trim();
if (normalizedQuery.isEmpty) {
@@ -147,12 +142,6 @@ mixin SearchMixin<T extends StatefulWidget> on State<T> {
if (mounted) {
onSearchResultsChanged(allCollections, allFiles);
}
- } finally {
- if (mounted) {
- setState(() {
- _isSearching = false;
- });
- }
}
}
@@ -235,7 +224,6 @@ mixin SearchMixin<T extends StatefulWidget> on State<T> {
String get searchQuery => _searchQuery;
bool get isSearchActive => _isSearchActive;
- bool get isSearching => _isSearching;
TextEditingController get searchController => _searchController;
FocusNode get searchFocusNode => _searchFocusNode;
diff --git a/mobile/apps/locker/lib/ui/pages/home_page.dart b/mobile/apps/locker/lib/ui/pages/home_page.dart
index 88cd6e9ce8..9f98ca7d99 100644
--- a/mobile/apps/locker/lib/ui/pages/home_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/home_page.dart
@@ -20,7 +20,6 @@ import 'package:locker/models/selected_files.dart';
import 'package:locker/services/collections/collections_service.dart';
import 'package:locker/services/collections/models/collection.dart';
import 'package:locker/services/configuration.dart';
-import 'package:locker/services/feature_flag_service.dart';
import 'package:locker/services/files/sync/models/file.dart';
import 'package:locker/services/local_settings.dart';
import "package:locker/states/user_details_state.dart";
@@ -715,12 +714,8 @@ class _HomePageState extends UploaderPageState<HomePage>
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
- if (FeatureFlagService
- .instance
- .documentScanner) ...[
- _buildScannerFab(colors),
- const SizedBox(height: 14),
- ],
+ _buildScannerFab(colors),
+ const SizedBox(height: 14),
FloatingActionButton(
tooltip: 'Add item',
onPressed: () =>
diff --git a/mobile/apps/locker/lib/ui/pages/save_page.dart b/mobile/apps/locker/lib/ui/pages/save_page.dart
index 9cba0ad46b..20880f0b54 100644
--- a/mobile/apps/locker/lib/ui/pages/save_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/save_page.dart
@@ -6,7 +6,6 @@ import 'package:ente_strings/ente_strings.dart';
import 'package:ente_ui/utils/toast_util.dart';
import 'package:flutter/material.dart';
import 'package:hugeicons/hugeicons.dart';
-import 'package:locker/services/feature_flag_service.dart';
import 'package:locker/ui/pages/account_credentials_page.dart';
import 'package:locker/ui/pages/personal_note_page.dart';
import 'package:locker/ui/pages/physical_records_page.dart';
@@ -34,7 +33,7 @@ List<SaveOption> saveOptions(
}) {
final l10n = context.strings;
return [
- if (includeScanner && FeatureFlagService.instance.documentScanner)
+ if (includeScanner)
SaveOption(
type: SaveOptionType.scanDocument,
icon: HugeIcons.strokeRoundedFileScan,
diff --git a/mobile/apps/locker/lib/ui/sharing/add_email_bottom_sheet.dart b/mobile/apps/locker/lib/ui/sharing/add_email_bottom_sheet.dart
index 17d50949ce..1bf969f072 100644
--- a/mobile/apps/locker/lib/ui/sharing/add_email_bottom_sheet.dart
+++ b/mobile/apps/locker/lib/ui/sharing/add_email_bottom_sheet.dart
@@ -1,7 +1,7 @@
-import "package:email_validator/email_validator.dart";
import "package:ente_accounts/services/user_service.dart";
import "package:ente_components/ente_components.dart";
import 'package:ente_contacts/contacts.dart';
+import "package:ente_pure_utils/ente_pure_utils.dart";
import "package:ente_sharing/extensions/user_extension.dart";
import "package:ente_sharing/models/user.dart";
import "package:ente_sharing/user_avator_widget.dart";
@@ -113,7 +113,7 @@ class _AddEmailSheetState extends State<AddEmailSheet> {
shouldUnfocusOnClearOrSubmit: true,
onChanged: (value) {
_email = value.trim();
- _emailIsValid = _isValidEmail(_email);
+ _emailIsValid = isValidEmail(_email);
setState(() {});
},
);
@@ -392,10 +392,6 @@ class _AddEmailSheetState extends State<AddEmailSheet> {
return suggestedUsers;
}
- bool _isValidEmail(String email) {
- return EmailValidator.validate(email);
- }
-
bool _isScheduledDateTimeValid() {
if (_scheduledDate == null || _scheduledTime == null) {
return false;
diff --git a/mobile/apps/locker/lib/utils/file_actions.dart b/mobile/apps/locker/lib/utils/file_actions.dart
index f68711c0ab..1e96151a2c 100644
--- a/mobile/apps/locker/lib/utils/file_actions.dart
+++ b/mobile/apps/locker/lib/utils/file_actions.dart
@@ -11,7 +11,6 @@ import "package:locker/services/files/sync/metadata_updater_service.dart";
import "package:locker/services/files/sync/models/file.dart";
import "package:locker/services/info_file_service.dart";
import "package:locker/services/trash/models/trash_file.dart";
-import "package:locker/services/trash/trash_service.dart";
import "package:locker/ui/components/delete_confirmation_sheet.dart";
import "package:locker/ui/components/file_edit_sheet.dart";
import "package:locker/ui/components/locker_progress_dialog.dart";
@@ -317,68 +316,6 @@ class FileActions {
}
}
- static Future<void> deleteMultipleFiles(
- BuildContext context,
- List<EnteFile> files, {
- VoidCallback? onSuccess,
- }) async {
- if (files.isEmpty) {
- return;
- }
-
- final confirmation = await showDeleteConfirmationSheet(
- context,
- title: context.strings.moveToTrashQuestion,
- body: context.strings.itemsWillBeDeletedFromAllCollections(
- count: files.length,
- ),
- deleteButtonLabel: context.strings.deleteItemCount(count: files.length),
- illustration: LockerBottomSheetIllustration.fileDelete,
- );
-
- if (confirmation == null) {
- return;
- }
-
- final dialog = context.mounted
- ? await showLockerProgressDialog(context, context.strings.deletingFile)
- : null;
-
- try {
- for (final file in files) {
- final collections = await CollectionService.instance
- .getCollectionsForFile(file);
-
- if (collections.isNotEmpty) {
- await CollectionService.instance.trashFile(
- file,
- collections.first,
- runSync: false,
- );
- }
- }
-
- await CollectionService.instance.sync();
- await TrashService.instance.syncTrash();
-
- await dialog?.hide();
-
- if (context.mounted) {
- showToast(context, context.strings.fileDeletedSuccessfully);
- }
-
- onSuccess?.call();
- } catch (e, stackTrace) {
- await dialog?.hide();
-
- _logger.severe('Failed to delete files: $e', e, stackTrace);
- if (!context.mounted) {
- return;
- }
- await showLockerErrorSheet(context, e);
- }
- }
-
static bool isImportant(EnteFile file) {
return FavoritesService.instance.isFavoriteCache(file);
}
diff --git a/mobile/apps/locker/pubspec.yaml b/mobile/apps/locker/pubspec.yaml
index 4b609bbc03..c3f8ef50c7 100644
--- a/mobile/apps/locker/pubspec.yaml
+++ b/mobile/apps/locker/pubspec.yaml
@@ -16,7 +16,6 @@ dependencies:
dio: 5.9.2
dots_indicator: 4.0.1
dotted_border: 3.1.0
- email_validator: 3.0.0
ente_account_deletion:
path: ../../packages/account_deletion
ente_accounts:
diff --git a/mobile/packages/ente_components/fonts/Inter-Light.ttf b/mobile/packages/ente_components/fonts/Inter-Light.ttf
deleted file mode 100644
index ebaa005740..0000000000
Binary files a/mobile/packages/ente_components/fonts/Inter-Light.ttf and /dev/null differ
diff --git a/mobile/packages/ente_components/pubspec.yaml b/mobile/packages/ente_components/pubspec.yaml
index 7e0ee83ffd..2d0ccfe420 100644
--- a/mobile/packages/ente_components/pubspec.yaml
+++ b/mobile/packages/ente_components/pubspec.yaml
@@ -28,8 +28,6 @@ flutter:
- asset: fonts/Inter-Regular.ttf
- asset: fonts/Inter-Medium.ttf
weight: 500
- - asset: fonts/Inter-Light.ttf
- weight: 300
- asset: fonts/Inter-SemiBold.ttf
weight: 600
- asset: fonts/Inter-Bold.ttf