Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions mobile/apps/locker/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,83 @@
}
}
},
"saveOffline": "Save offline",
"unsave": "Unsave",
"savingOffline": "Saving offline...",
"savingOfflineProgress": "Saving offline... {percentage}%",
"@savingOfflineProgress": {
"description": "Offline save progress message",
"placeholders": {
"percentage": {
"type": "int",
"example": "75"
}
}
},
"filesAvailableOffline": "{count, plural, =1{1 file saved offline} other{{count} files saved offline}}",
"@filesAvailableOffline": {
"description": "Success message when files are saved offline",
"placeholders": {
"count": {
"type": "int",
"example": "3"
}
}
},
"filesAvailableOfflinePartial": "{successCount} files saved offline, {failureCount} failed",
"@filesAvailableOfflinePartial": {
"description": "Partial success message for offline save",
"placeholders": {
"successCount": {
"type": "int",
"example": "2"
},
"failureCount": {
"type": "int",
"example": "1"
}
}
},
"failedToSaveFilesOffline": "{count, plural, =1{Failed to save 1 file offline} other{Failed to save {count} files offline}}",
"@failedToSaveFilesOffline": {
"description": "Failure message when files could not be saved offline",
"placeholders": {
"count": {
"type": "int",
"example": "2"
}
}
},
"failedToSaveFilesOfflineNetwork": "{count, plural, =1{No internet connection. Failed to save 1 file offline} other{No internet connection. Failed to save {count} files offline}}",
"@failedToSaveFilesOfflineNetwork": {
"description": "Failure message when files could not be saved offline because the device was offline",
"placeholders": {
"count": {
"type": "int",
"example": "2"
}
}
},
"failedToSaveFilesOfflineStorage": "{count, plural, =1{Failed to save 1 file offline. Check device storage} other{Failed to save {count} files offline. Check device storage}}",
"@failedToSaveFilesOfflineStorage": {
"description": "Failure message when files could not be saved offline because local storage failed",
"placeholders": {
"count": {
"type": "int",
"example": "2"
}
}
},
"filesRemovedFromOffline": "{count, plural, =1{1 file removed from offline} other{{count} files removed from offline}}",
"@filesRemovedFromOffline": {
"description": "Success message when offline copies are removed",
"placeholders": {
"count": {
"type": "int",
"example": "2"
}
}
},
"downloadFailed": "Download failed",
"failedToDownloadOrDecrypt": "Failed to download item",
"errorOpeningFile": "Error opening item",
Expand Down
66 changes: 63 additions & 3 deletions mobile/apps/locker/lib/l10n/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,66 @@ abstract class AppLocalizations {
/// **'Downloading... {percentage}%'**
String downloadingProgress(int percentage);

/// No description provided for @saveOffline.
///
/// In en, this message translates to:
/// **'Save offline'**
String get saveOffline;

/// No description provided for @unsave.
///
/// In en, this message translates to:
/// **'Unsave'**
String get unsave;

/// No description provided for @savingOffline.
///
/// In en, this message translates to:
/// **'Saving offline...'**
String get savingOffline;

/// Offline save progress message
///
/// In en, this message translates to:
/// **'Saving offline... {percentage}%'**
String savingOfflineProgress(int percentage);

/// Success message when files are saved offline
///
/// In en, this message translates to:
/// **'{count, plural, =1{1 file saved offline} other{{count} files saved offline}}'**
String filesAvailableOffline(int count);

/// Partial success message for offline save
///
/// In en, this message translates to:
/// **'{successCount} files saved offline, {failureCount} failed'**
String filesAvailableOfflinePartial(int successCount, int failureCount);

/// Failure message when files could not be saved offline
///
/// In en, this message translates to:
/// **'{count, plural, =1{Failed to save 1 file offline} other{Failed to save {count} files offline}}'**
String failedToSaveFilesOffline(int count);

/// Failure message when files could not be saved offline because the device was offline
///
/// In en, this message translates to:
/// **'{count, plural, =1{No internet connection. Failed to save 1 file offline} other{No internet connection. Failed to save {count} files offline}}'**
String failedToSaveFilesOfflineNetwork(int count);

/// Failure message when files could not be saved offline because local storage failed
///
/// In en, this message translates to:
/// **'{count, plural, =1{Failed to save 1 file offline. Check device storage} other{Failed to save {count} files offline. Check device storage}}'**
String failedToSaveFilesOfflineStorage(int count);

/// Success message when offline copies are removed
///
/// In en, this message translates to:
/// **'{count, plural, =1{1 file removed from offline} other{{count} files removed from offline}}'**
String filesRemovedFromOffline(int count);

/// No description provided for @downloadFailed.
///
/// In en, this message translates to:
Expand Down Expand Up @@ -1947,7 +2007,7 @@ abstract class AppLocalizations {
/// No description provided for @shareTextRecommendUsingEnte.
///
/// In en, this message translates to:
/// **'Download Ente\n\nhttps://ente.io'**
/// **'Download Ente\n\nhttps://ente.com'**
String get shareTextRecommendUsingEnte;

/// No description provided for @thisIsYourVerificationId.
Expand Down Expand Up @@ -1995,13 +2055,13 @@ abstract class AppLocalizations {
/// No description provided for @shareMyVerificationID.
///
/// In en, this message translates to:
/// **'Here\'s my verification ID: {verificationID} for ente.io.'**
/// **'Here\'s my verification ID: {verificationID} for ente.com.'**
String shareMyVerificationID(Object verificationID);

/// No description provided for @shareTextConfirmOthersVerificationID.
///
/// In en, this message translates to:
/// **'Hey, can you confirm that this is your ente.io verification ID: {verificationID}'**
/// **'Hey, can you confirm that this is your ente.com verification ID: {verificationID}'**
String shareTextConfirmOthersVerificationID(Object verificationID);

/// No description provided for @passwordLock.
Expand Down
80 changes: 77 additions & 3 deletions mobile/apps/locker/lib/l10n/app_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,80 @@ class AppLocalizationsEn extends AppLocalizations {
return 'Downloading... $percentage%';
}

@override
String get saveOffline => 'Save offline';

@override
String get unsave => 'Unsave';

@override
String get savingOffline => 'Saving offline...';

@override
String savingOfflineProgress(int percentage) {
return 'Saving offline... $percentage%';
}

@override
String filesAvailableOffline(int count) {
String _temp0 = intl.Intl.pluralLogic(
count,
locale: localeName,
other: '$count files saved offline',
one: '1 file saved offline',
);
return '$_temp0';
}

@override
String filesAvailableOfflinePartial(int successCount, int failureCount) {
return '$successCount files saved offline, $failureCount failed';
}

@override
String failedToSaveFilesOffline(int count) {
String _temp0 = intl.Intl.pluralLogic(
count,
locale: localeName,
other: 'Failed to save $count files offline',
one: 'Failed to save 1 file offline',
);
return '$_temp0';
}

@override
String failedToSaveFilesOfflineNetwork(int count) {
String _temp0 = intl.Intl.pluralLogic(
count,
locale: localeName,
other: 'No internet connection. Failed to save $count files offline',
one: 'No internet connection. Failed to save 1 file offline',
);
return '$_temp0';
}

@override
String failedToSaveFilesOfflineStorage(int count) {
String _temp0 = intl.Intl.pluralLogic(
count,
locale: localeName,
other: 'Failed to save $count files offline. Check device storage',
one: 'Failed to save 1 file offline. Check device storage',
);
return '$_temp0';
}

@override
String filesRemovedFromOffline(int count) {
String _temp0 = intl.Intl.pluralLogic(
count,
locale: localeName,
other: '$count files removed from offline',
one: '1 file removed from offline',
);
return '$_temp0';
}

@override
String get downloadFailed => 'Download failed';

Expand Down Expand Up @@ -1042,7 +1116,7 @@ class AppLocalizationsEn extends AppLocalizations {
String get sendInvite => 'Send invite';

@override
String get shareTextRecommendUsingEnte => 'Download Ente\n\nhttps://ente.io';
String get shareTextRecommendUsingEnte => 'Download Ente\n\nhttps://ente.com';

@override
String get thisIsYourVerificationId => 'This is your Verification ID';
Expand Down Expand Up @@ -1075,12 +1149,12 @@ class AppLocalizationsEn extends AppLocalizations {

@override
String shareMyVerificationID(Object verificationID) {
return 'Here\'s my verification ID: $verificationID for ente.io.';
return 'Here\'s my verification ID: $verificationID for ente.com.';
}

@override
String shareTextConfirmOthersVerificationID(Object verificationID) {
return 'Hey, can you confirm that this is your ente.io verification ID: $verificationID';
return 'Hey, can you confirm that this is your ente.com verification ID: $verificationID';
}

@override
Expand Down
10 changes: 6 additions & 4 deletions mobile/apps/locker/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ import 'package:locker/l10n/app_localizations.dart';
import 'package:locker/services/collections/collections_api_client.dart';
import 'package:locker/services/collections/collections_service.dart';
import 'package:locker/services/configuration.dart';
import "package:locker/services/db/locker_db.dart";
import 'package:locker/services/db/locker_db.dart';
import 'package:locker/services/favorites_service.dart';
import 'package:locker/services/files/download/service_locator.dart';
import "package:locker/services/files/links/links_client.dart";
import "package:locker/services/files/links/links_service.dart";
import 'package:locker/services/files/links/links_client.dart';
import 'package:locker/services/files/links/links_service.dart';
import 'package:locker/services/files/offline/offline_files_service.dart';
import 'package:locker/services/trash/trash_service.dart';
import "package:locker/services/update_service.dart";
import 'package:locker/services/update_service.dart';
import 'package:locker/ui/pages/home_page.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider/path_provider.dart';
Expand Down Expand Up @@ -179,6 +180,7 @@ Future<void> _init(bool bool, {String? via}) async {
await CollectionApiClient.instance.init();
await CollectionService.instance.init(preferences);
await FavoritesService.instance.init();
await OfflineFilesService.instance.init();
await LinksClient.instance.init();
await LinksService.instance.init();
await ServiceLocator.instance.init(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import "package:locker/services/collections/models/files_split.dart";
import "package:locker/services/collections/models/public_url.dart";
import 'package:locker/services/configuration.dart';
import "package:locker/services/db/locker_db.dart";
import 'package:locker/services/files/offline/offline_files_service.dart';
import 'package:locker/services/files/sync/models/file.dart';
import 'package:locker/services/trash/models/trash_item_request.dart';
import "package:locker/services/trash/trash_service.dart";
Expand Down Expand Up @@ -347,6 +348,10 @@ class CollectionService {
requests.add(TrashRequest(file.uploadedFileID!, collection.id));
await _apiClient.trash(requests);

await OfflineFilesService.instance.unmarkFilesOfflineLocally(
[file],
removeWorkingCopies: false,
);
await _db.deleteFilesFromCollection(collection, [file]);

if (runSync) {
Expand Down Expand Up @@ -436,11 +441,6 @@ class CollectionService {
try {
await _apiClient.removeFromCollection(collectionId, files);

final collection = await getCollectionByID(collectionId);
if (collection != null) {
await _db.deleteFilesFromCollection(collection, files);
}

Bus.instance.fire(CollectionsUpdatedEvent('files_removed'));

await sync();
Expand Down Expand Up @@ -469,17 +469,15 @@ class CollectionService {
// Call API to move files on server
await _apiClient.move(files, from, to);

// Update local database for all files
// Remove from source collection
await _db.deleteFilesFromCollection(from, files);

// Update collectionID for all files
for (final file in files) {
file.collectionID = to.id;
}

// Add to target collection
// Write the destination row first so local key material and offline state
// stay attached to the moved file before the source mapping is removed.
await _db.addFilesToCollection(to, files);
await _db.deleteFilesFromCollection(from, files);

// Let sync update the local state to ensure consistency
if (runSync) {
Expand Down
2 changes: 2 additions & 0 deletions mobile/apps/locker/lib/services/configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:io';
import 'package:ente_configuration/base_configuration.dart';
import 'package:locker/services/collections/collections_service.dart';
import 'package:locker/services/favorites_service.dart';
import 'package:locker/services/files/offline/offline_file_storage.dart';
import 'package:logging/logging.dart';

class Configuration extends BaseConfiguration {
Expand All @@ -25,6 +26,7 @@ class Configuration extends BaseConfiguration {

await super.logout(autoLogout: autoLogout);
await _clearCachedFiles();
await clearAllOfflineFileCopies();
}

Future<void> _clearCachedFiles() async {
Expand Down
Loading
Loading