diff --git a/lib/src/localization/app_de.arb b/lib/src/localization/app_de.arb index d953863..fd3a2c0 100644 --- a/lib/src/localization/app_de.arb +++ b/lib/src/localization/app_de.arb @@ -462,5 +462,7 @@ "verifiedPublicKey": "Der öffentliche Schlüssel von {username} wurde überprüft und ist gültig.", "memoriesAYearAgo": "Vor einem Jahr", "memoriesXYearsAgo": "Vor {years} Jahren", - "migrationOfMemories": "Migration von Mediendateien: {open} noch offen." + "migrationOfMemories": "Migration von Mediendateien: {open} noch offen.", + "autoStoreAllSendUnlimitedMediaFiles": "Alle gesendeten Medien speichern", + "autoStoreAllSendUnlimitedMediaFilesSubtitle": "Wenn du diese Option aktivierst, werden alle Bilder, die du sendest, gespeichert, sofern sie mit einem unendlichen Countdown und nicht im twonly-Modus gesendet wurden." } \ No newline at end of file diff --git a/lib/src/localization/app_en.arb b/lib/src/localization/app_en.arb index 25571df..4bb71e3 100644 --- a/lib/src/localization/app_en.arb +++ b/lib/src/localization/app_en.arb @@ -492,5 +492,7 @@ "verifiedPublicKey": "The public key of {username} has been verified and is valid.", "memoriesAYearAgo": "One year ago", "memoriesXYearsAgo": "{years} years ago", - "migrationOfMemories": "Migration of media files: {open} still to be processed." + "migrationOfMemories": "Migration of media files: {open} still to be processed.", + "autoStoreAllSendUnlimitedMediaFiles": "Save all sent media", + "autoStoreAllSendUnlimitedMediaFilesSubtitle": "If you enable this option, all images you send will be saved as long as they were sent with an infinite countdown and not in twonly mode." } \ No newline at end of file diff --git a/lib/src/localization/generated/app_localizations.dart b/lib/src/localization/generated/app_localizations.dart index 695f6d2..60ae99d 100644 --- a/lib/src/localization/generated/app_localizations.dart +++ b/lib/src/localization/generated/app_localizations.dart @@ -2875,6 +2875,18 @@ abstract class AppLocalizations { /// In en, this message translates to: /// **'Migration of media files: {open} still to be processed.'** String migrationOfMemories(Object open); + + /// No description provided for @autoStoreAllSendUnlimitedMediaFiles. + /// + /// In en, this message translates to: + /// **'Save all sent media'** + String get autoStoreAllSendUnlimitedMediaFiles; + + /// No description provided for @autoStoreAllSendUnlimitedMediaFilesSubtitle. + /// + /// In en, this message translates to: + /// **'If you enable this option, all images you send will be saved as long as they were sent with an infinite countdown and not in twonly mode.'** + String get autoStoreAllSendUnlimitedMediaFilesSubtitle; } class _AppLocalizationsDelegate diff --git a/lib/src/localization/generated/app_localizations_de.dart b/lib/src/localization/generated/app_localizations_de.dart index a9a569a..f86be36 100644 --- a/lib/src/localization/generated/app_localizations_de.dart +++ b/lib/src/localization/generated/app_localizations_de.dart @@ -1595,4 +1595,12 @@ class AppLocalizationsDe extends AppLocalizations { String migrationOfMemories(Object open) { return 'Migration von Mediendateien: $open noch offen.'; } + + @override + String get autoStoreAllSendUnlimitedMediaFiles => + 'Alle gesendeten Medien speichern'; + + @override + String get autoStoreAllSendUnlimitedMediaFilesSubtitle => + 'Wenn du diese Option aktivierst, werden alle Bilder, die du sendest, gespeichert, sofern sie mit einem unendlichen Countdown und nicht im twonly-Modus gesendet wurden.'; } diff --git a/lib/src/localization/generated/app_localizations_en.dart b/lib/src/localization/generated/app_localizations_en.dart index a45eab5..94642e2 100644 --- a/lib/src/localization/generated/app_localizations_en.dart +++ b/lib/src/localization/generated/app_localizations_en.dart @@ -1585,4 +1585,11 @@ class AppLocalizationsEn extends AppLocalizations { String migrationOfMemories(Object open) { return 'Migration of media files: $open still to be processed.'; } + + @override + String get autoStoreAllSendUnlimitedMediaFiles => 'Save all sent media'; + + @override + String get autoStoreAllSendUnlimitedMediaFilesSubtitle => + 'If you enable this option, all images you send will be saved as long as they were sent with an infinite countdown and not in twonly mode.'; } diff --git a/lib/src/model/json/userdata.dart b/lib/src/model/json/userdata.dart index fc5c4cd..eb26ef3 100644 --- a/lib/src/model/json/userdata.dart +++ b/lib/src/model/json/userdata.dart @@ -72,6 +72,9 @@ class UserData { @JsonKey(defaultValue: false) bool storeMediaFilesInGallery = false; + @JsonKey(defaultValue: false) + bool autoStoreAllSendUnlimitedMediaFiles = false; + String? lastPlanBallance; String? additionalUserInvites; diff --git a/lib/src/model/json/userdata.g.dart b/lib/src/model/json/userdata.g.dart index 8e2103d..a478117 100644 --- a/lib/src/model/json/userdata.g.dart +++ b/lib/src/model/json/userdata.g.dart @@ -33,7 +33,7 @@ UserData _$UserDataFromJson(Map json) => UserData( json['requestedAudioPermission'] as bool? ?? false ..showFeedbackShortcut = json['showFeedbackShortcut'] as bool? ?? true ..showShowImagePreviewWhenSending = - json['showShowImagePreviewWhenSending'] as bool? ?? true + json['showShowImagePreviewWhenSending'] as bool? ?? false ..startWithCameraOpen = json['startWithCameraOpen'] as bool? ?? true ..preSelectedEmojies = (json['preSelectedEmojies'] as List?) ?.map((e) => e as String) @@ -45,6 +45,8 @@ UserData _$UserDataFromJson(Map json) => UserData( ) ..storeMediaFilesInGallery = json['storeMediaFilesInGallery'] as bool? ?? false + ..autoStoreAllSendUnlimitedMediaFiles = + json['autoStoreAllSendUnlimitedMediaFiles'] as bool? ?? false ..lastPlanBallance = json['lastPlanBallance'] as String? ..additionalUserInvites = json['additionalUserInvites'] as String? ..tutorialDisplayed = (json['tutorialDisplayed'] as List?) @@ -102,6 +104,8 @@ Map _$UserDataToJson(UserData instance) => { 'preSelectedEmojies': instance.preSelectedEmojies, 'autoDownloadOptions': instance.autoDownloadOptions, 'storeMediaFilesInGallery': instance.storeMediaFilesInGallery, + 'autoStoreAllSendUnlimitedMediaFiles': + instance.autoStoreAllSendUnlimitedMediaFiles, 'lastPlanBallance': instance.lastPlanBallance, 'additionalUserInvites': instance.additionalUserInvites, 'tutorialDisplayed': instance.tutorialDisplayed, diff --git a/lib/src/services/api/mediafiles/upload.service.dart b/lib/src/services/api/mediafiles/upload.service.dart index 0c2e930..ee5e08d 100644 --- a/lib/src/services/api/mediafiles/upload.service.dart +++ b/lib/src/services/api/mediafiles/upload.service.dart @@ -132,6 +132,15 @@ Future startBackgroundMediaUpload(MediaFileService mediaService) async { } } + // if the user has enabled auto storing and the file + // was send with unlimited counter not in twonly-Mode then store the file + if (gUser.autoStoreAllSendUnlimitedMediaFiles && + !mediaService.mediaFile.requiresAuthentication && + !mediaService.storedPath.existsSync() && + mediaService.mediaFile.displayLimitInMilliseconds == null) { + await mediaService.storeMediaFile(); + } + if (!mediaService.encryptedPath.existsSync()) { await _encryptMediaFiles(mediaService); if (!mediaService.encryptedPath.existsSync()) { diff --git a/lib/src/views/settings/data_and_storage.view.dart b/lib/src/views/settings/data_and_storage.view.dart index 52cd299..5ff3161 100644 --- a/lib/src/views/settings/data_and_storage.view.dart +++ b/lib/src/views/settings/data_and_storage.view.dart @@ -46,6 +46,15 @@ class _DataAndStorageViewState extends State { setState(() {}); } + Future toggleAutoStoreMediaFiles() async { + await updateUserdata((u) { + u.autoStoreAllSendUnlimitedMediaFiles = + !u.autoStoreAllSendUnlimitedMediaFiles; + return u; + }); + setState(() {}); + } + @override Widget build(BuildContext context) { final autoDownloadOptions = @@ -65,6 +74,18 @@ class _DataAndStorageViewState extends State { onChanged: (a) => toggleStoreInGallery(), ), ), + ListTile( + title: Text(context.lang.autoStoreAllSendUnlimitedMediaFiles), + subtitle: Text( + context.lang.autoStoreAllSendUnlimitedMediaFilesSubtitle, + style: const TextStyle(fontSize: 9), + ), + onTap: toggleAutoStoreMediaFiles, + trailing: Switch( + value: gUser.autoStoreAllSendUnlimitedMediaFiles, + onChanged: (a) => toggleAutoStoreMediaFiles(), + ), + ), if (Platform.isAndroid) ListTile( title: Text( diff --git a/lib/src/views/settings/profile/modify_avatar.view.dart b/lib/src/views/settings/profile/modify_avatar.view.dart index 219daa4..fd95b5c 100644 --- a/lib/src/views/settings/profile/modify_avatar.view.dart +++ b/lib/src/views/settings/profile/modify_avatar.view.dart @@ -3,7 +3,6 @@ import 'package:avatar_maker/avatar_maker.dart'; import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:twonly/globals.dart'; -import 'package:twonly/src/services/api/messages.dart'; import 'package:twonly/src/utils/misc.dart'; import 'package:twonly/src/utils/storage.dart'; diff --git a/lib/src/views/settings/profile/profile.view.dart b/lib/src/views/settings/profile/profile.view.dart index dbe028c..0e404a9 100644 --- a/lib/src/views/settings/profile/profile.view.dart +++ b/lib/src/views/settings/profile/profile.view.dart @@ -5,7 +5,6 @@ import 'package:flutter/services.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:twonly/globals.dart'; import 'package:twonly/src/model/protobuf/api/websocket/error.pb.dart'; -import 'package:twonly/src/services/api/messages.dart'; import 'package:twonly/src/services/twonly_safe/common.twonly_safe.dart'; import 'package:twonly/src/services/twonly_safe/create_backup.twonly_safe.dart'; import 'package:twonly/src/utils/misc.dart';