diff --git a/mobile/lib/generated/intl/messages_en.dart b/mobile/lib/generated/intl/messages_en.dart index c6dc0032ab..53d79d6ebe 100644 --- a/mobile/lib/generated/intl/messages_en.dart +++ b/mobile/lib/generated/intl/messages_en.dart @@ -1488,7 +1488,7 @@ class MessageLookup extends MessageLookupByLibrary { "subWillBeCancelledOn": m62, "subscribe": MessageLookupByLibrary.simpleMessage("Subscribe"), "subscribeToEnableSharing": MessageLookupByLibrary.simpleMessage( - "Looks like your subscription has expired. Please subscribe to enable sharing."), + "You need an active paid subscription to enable sharing."), "subscription": MessageLookupByLibrary.simpleMessage("Subscription"), "success": MessageLookupByLibrary.simpleMessage("Success"), "successfullyArchived": diff --git a/mobile/lib/generated/l10n.dart b/mobile/lib/generated/l10n.dart index d1ff4bdeb0..7172afe5bd 100644 --- a/mobile/lib/generated/l10n.dart +++ b/mobile/lib/generated/l10n.dart @@ -2452,10 +2452,10 @@ class S { ); } - /// `Looks like your subscription has expired. Please subscribe to enable sharing.` + /// `You need an active paid subscription to enable sharing.` String get subscribeToEnableSharing { return Intl.message( - 'Looks like your subscription has expired. Please subscribe to enable sharing.', + 'You need an active paid subscription to enable sharing.', name: 'subscribeToEnableSharing', desc: '', args: [], diff --git a/mobile/lib/l10n/intl_en.arb b/mobile/lib/l10n/intl_en.arb index c57c8b7e3a..88620e3c45 100644 --- a/mobile/lib/l10n/intl_en.arb +++ b/mobile/lib/l10n/intl_en.arb @@ -327,7 +327,7 @@ "removingFromFavorites": "Removing from favorites...", "sorryCouldNotAddToFavorites": "Sorry, could not add to favorites!", "sorryCouldNotRemoveFromFavorites": "Sorry, could not remove from favorites!", - "subscribeToEnableSharing": "Looks like your subscription has expired. Please subscribe to enable sharing.", + "subscribeToEnableSharing": "You need an active paid subscription to enable sharing.", "subscribe": "Subscribe", "canOnlyRemoveFilesOwnedByYou": "Can only remove files owned by you", "deleteSharedAlbum": "Delete shared album?", diff --git a/mobile/lib/ui/actions/collection/collection_sharing_actions.dart b/mobile/lib/ui/actions/collection/collection_sharing_actions.dart index c4f23df419..55bec3ad45 100644 --- a/mobile/lib/ui/actions/collection/collection_sharing_actions.dart +++ b/mobile/lib/ui/actions/collection/collection_sharing_actions.dart @@ -5,7 +5,6 @@ import 'package:logging/logging.dart'; import 'package:photos/core/configuration.dart'; import "package:photos/core/errors.dart"; import 'package:photos/db/files_db.dart'; -import 'package:photos/ente_theme_data.dart'; import "package:photos/generated/l10n.dart"; import 'package:photos/models/api/collection/create_request.dart'; import "package:photos/models/api/collection/user.dart"; @@ -51,7 +50,7 @@ class CollectionActions { return true; } catch (e) { if (e is SharingNotPermittedForFreeAccountsError) { - _showUnSupportedAlert(context); + await _showUnSupportedAlert(context); } else { logger.severe("Failed to update shareUrl collection", e); await showGenericErrorDialog(context: context, error: e); @@ -110,6 +109,7 @@ class CollectionActions { BuildContext context, List files, ) async { + late final Collection newCollection; try { // create album with emptyName, use collectionCreationTime on UI to // show name @@ -133,14 +133,29 @@ class CollectionActions { final collection = await collectionsService.createAndCacheCollection( req, ); + newCollection = collection; logger.finest("adding files to share to new album"); await collectionsService.addOrCopyToCollection(collection.id, files); logger.finest("creating public link for the newly created album"); - await CollectionsService.instance.createShareUrl(collection); + try { + await CollectionsService.instance.createShareUrl(collection); + } catch (e) { + if (e is SharingNotPermittedForFreeAccountsError) { + if (newCollection.isQuickLinkCollection() && + !newCollection.hasSharees) { + await trashCollectionKeepingPhotos(newCollection, context); + } + rethrow; + } + } return collection; } catch (e, s) { - await showGenericErrorDialog(context: context, error: e); - logger.severe("Failing to create link for selected files", e, s); + if (e is SharingNotPermittedForFreeAccountsError) { + await _showUnSupportedAlert(context); + } else { + logger.severe("Failing to create link for selected files", e, s); + await showGenericErrorDialog(context: context, error: e); + } } return null; } @@ -327,7 +342,7 @@ class CollectionActions { } catch (e) { await dialog?.hide(); if (e is SharingNotPermittedForFreeAccountsError) { - _showUnSupportedAlert(context); + await _showUnSupportedAlert(context); } else { logger.severe("failed to share collection", e); await showGenericErrorDialog(context: context, error: e); @@ -641,50 +656,50 @@ class CollectionActions { return true; } - void _showUnSupportedAlert(BuildContext context) { + Future _showUnSupportedAlert(BuildContext context) async { final AlertDialog alert = AlertDialog( title: Text(S.of(context).sorry), content: Text( S.of(context).subscribeToEnableSharing, ), actions: [ - TextButton( - child: Text( - S.of(context).subscribe, - style: TextStyle( - color: Theme.of(context).colorScheme.greenAlternative, - ), - ), - onPressed: () { - Navigator.of(context, rootNavigator: true).pop(); - Navigator.of(context).pushReplacement( + ButtonWidget( + buttonType: ButtonType.primary, + isInAlert: true, + shouldStickToDarkTheme: false, + buttonAction: ButtonAction.first, + shouldSurfaceExecutionStates: true, + labelText: S.of(context).subscribe, + onTap: () async { + // for quickLink collection, we need to trash the collection + Navigator.of(context).push( MaterialPageRoute( builder: (BuildContext context) { return getSubscriptionPage(); }, ), - ); + ).ignore(); }, ), - TextButton( - child: Text( - S.of(context).ok, - style: TextStyle( - color: Theme.of(context).colorScheme.onSurface, - ), + Padding( + padding: const EdgeInsets.only(top: 8.0), + child: ButtonWidget( + buttonType: ButtonType.secondary, + buttonAction: ButtonAction.cancel, + isInAlert: true, + shouldStickToDarkTheme: false, + labelText: S.of(context).ok, ), - onPressed: () { - Navigator.of(context, rootNavigator: true).pop(); - }, ), ], ); - showDialog( + return showDialog( context: context, builder: (BuildContext context) { return alert; }, + barrierDismissible: true, ); } } diff --git a/mobile/lib/ui/settings/backup/backup_section_widget.dart b/mobile/lib/ui/settings/backup/backup_section_widget.dart index 904f899d57..6fbdca287e 100644 --- a/mobile/lib/ui/settings/backup/backup_section_widget.dart +++ b/mobile/lib/ui/settings/backup/backup_section_widget.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import "package:photos/generated/l10n.dart"; -import "package:photos/service_locator.dart"; import 'package:photos/theme/ente_theme.dart'; import "package:photos/ui/components/captioned_text_widget.dart"; import 'package:photos/ui/components/expandable_menu_item_widget.dart'; @@ -48,22 +47,21 @@ class BackupSectionWidgetState extends State { ); }, ), - if (flagService.internalUser) sectionOptionSpacing, - if (flagService.internalUser) - MenuItemWidget( - captionedTextWidget: CaptionedTextWidget( - title: S.of(context).backupStatus, - ), - pressedColor: getEnteColorScheme(context).fillFaint, - trailingIcon: Icons.chevron_right_outlined, - trailingIconIsMuted: true, - onTap: () async { - await routeToPage( - context, - const BackupStatusScreen(), - ); - }, + sectionOptionSpacing, + MenuItemWidget( + captionedTextWidget: CaptionedTextWidget( + title: S.of(context).backupStatus, ), + pressedColor: getEnteColorScheme(context).fillFaint, + trailingIcon: Icons.chevron_right_outlined, + trailingIconIsMuted: true, + onTap: () async { + await routeToPage( + context, + const BackupStatusScreen(), + ); + }, + ), sectionOptionSpacing, MenuItemWidget( captionedTextWidget: CaptionedTextWidget( diff --git a/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart b/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart index d3ef8bc524..d6ec440bb6 100644 --- a/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart +++ b/mobile/lib/ui/viewer/actions/file_selection_actions_widget.dart @@ -680,6 +680,10 @@ class _FileSelectionActionsWidgetState _cachedCollectionForSharedLink ??= await collectionActions .createSharedCollectionLink(context, split.ownedByCurrentUser); + if (_cachedCollectionForSharedLink == null) { + await dialog.hide(); + return; + } final List ownedSelectedFiles = split.ownedByCurrentUser; placeholderBytes = await _createPlaceholder(ownedSelectedFiles); await dialog.hide(); diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yaml index 3542225522..199ff5a0de 100644 --- a/mobile/pubspec.yaml +++ b/mobile/pubspec.yaml @@ -12,7 +12,7 @@ description: ente photos application # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 0.9.37+937 +version: 0.9.38+938 publish_to: none environment: