π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Update link settings UI
AmanRajSinghMourya4c31e2030d83
diff --git a/mobile/apps/photos/lib/ui/sharing/manage_links_widget.dart b/mobile/apps/photos/lib/ui/sharing/manage_links_widget.dartindex f9393acf46..156211cf3b 100644--- a/mobile/apps/photos/lib/ui/sharing/manage_links_widget.dart+++ b/mobile/apps/photos/lib/ui/sharing/manage_links_widget.dart@@ -1,15 +1,12 @@import 'dart:async';import 'dart:convert';-import 'package:collection/collection.dart';import 'package:ente_components/ente_components.dart';import 'package:ente_crypto/ente_crypto.dart';import 'package:ente_pure_utils/ente_pure_utils.dart';-import 'package:ente_qr_ui/ente_qr_ui.dart';import "package:ente_strings/ente_strings.dart";import 'package:ente_ui/components/date_time_picker.dart';import 'package:flutter/material.dart';-import "package:flutter/services.dart";import 'package:hugeicons/hugeicons.dart';import 'package:photos/core/constants.dart';import "package:photos/core/errors.dart";@@ -23,15 +20,15 @@ import 'package:photos/ui/components/models/button_type.dart';import 'package:photos/ui/notification/toast.dart';import 'package:photos/ui/payment/subscription.dart';import 'package:photos/ui/sharing/pickers/layout_picker_page.dart';+import 'package:photos/ui/sharing/public_link_enabled_actions_widget.dart';import 'package:photos/ui/sharing/share_components.dart';import 'package:photos/utils/dialog_util.dart';import 'package:photos/utils/public_link_layout_util.dart';-import "package:photos/utils/share_util.dart";class ManageSharedLinkWidget extends StatefulWidget {- final Collection? collection;+ final Collection collection;- const ManageSharedLinkWidget({super.key, this.collection});+ const ManageSharedLinkWidget({super.key, required this.collection});@overrideState<ManageSharedLinkWidget> createState() => _ManageSharedLinkWidgetState();@@ -45,59 +42,28 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {);final GlobalKey sendLinkButtonKey = GlobalKey();- String _getLayoutDisplayName(String? layout, BuildContext context) {- final normalizedLayout = normalizePublicLinkLayout(layout);- switch (normalizedLayout) {- case 'masonry':- return context.strings.layoutMasonry;- case 'trip':- return context.strings.layoutTrip;- case 'grouped':- return context.strings.layoutGrouped;- default:- return context.strings.layoutMasonry;- }- }-@overrideWidget build(BuildContext context) {- final collection = widget.collection!;- final isCollectEnabled =- collection.publicURLs.firstOrNull?.enableCollect ?? false;- final isDownloadEnabled =- collection.publicURLs.firstOrNull?.enableDownload ?? true;- final isPasswordEnabled =- collection.publicURLs.firstOrNull?.passwordEnabled ?? false;- final isJoinEnabled = collection.publicURLs.firstOrNull?.enableJoin ?? true;- final enableComment =- collection.publicURLs.firstOrNull?.enableComment ?? false;- final PublicURL url = collection.publicURLs.firstOrNull!;- final String urlValue = CollectionsService.instance.getPublicUrl(- collection,- );- final colors = context.componentColors;+ final collection = widget.collection;+ final url = collection.publicURLs.first;+ final isQuickLink = collection.isQuickLinkCollection();return ShareScaffold(- title: context.strings.manageLink,+ title: context.strings.linkSettings,children: [ShareMenuGroup(items: [ShareMenuItem(title: context.strings.albumLayout,subtitle: _getLayoutDisplayName(- collection.pubMagicMetadata.layout ?? "masonry",+ collection.pubMagicMetadata.layout,context,),- icon: HugeIcons.strokeRoundedLayoutTable01,+ icon: HugeIcons.strokeRoundedGridView,showChevron: true,onTap: () async {- unawaited(- routeToPage(context, LayoutPickerPage(collection)).then((- value,- ) {- setState(() {});- }),- );+ await routeToPage(context, LayoutPickerPage(collection));+ if (mounted) setState(() {});},),],@@ -106,11 +72,11 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {ShareMenuGroup(items: [ShareMenuItem(- key: ValueKey("Allow collect $isCollectEnabled"),+ key: ValueKey("Allow collect ${url.enableCollect}"),title: context.strings.allowAddingPhotos,icon: HugeIcons.strokeRoundedImageAdd01,trailing: ToggleSwitchComponent(- selected: isCollectEnabled,+ selected: url.enableCollect,onChanged: (selected) async {await _updateUrlSettings(context, {'enableCollect': selected,@@ -119,11 +85,11 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {),),ShareMenuItem(- key: ValueKey("Enable comment $enableComment"),- title: context.strings.enableComment,- icon: HugeIcons.strokeRoundedComment01,+ key: ValueKey("Enable comment ${url.enableComment}"),+ title: context.strings.commentAndReact,+ icon: HugeIcons.strokeRoundedMessage01,trailing: ToggleSwitchComponent(- selected: enableComment,+ selected: url.enableComment,onChanged: (selected) async {await _updateUrlSettings(context, {'enableComment': selected,@@ -171,7 +137,7 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {ShareMenuItem(title: context.strings.linkDeviceLimit,subtitle: url.deviceLimit == 0- ? context.strings.noDeviceLimit+ ? context.strings.noLimit: "${url.deviceLimit}",icon: HugeIcons.strokeRoundedLaptop,showChevron: true,@@ -180,11 +146,11 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {},),ShareMenuItem(- key: ValueKey("Allow downloads $isDownloadEnabled"),- title: context.strings.allowDownloads,+ key: ValueKey("Allow downloads ${url.enableDownload}"),+ title: context.strings.downloadPhotos,icon: HugeIcons.strokeRoundedDownload04,trailing: ToggleSwitchComponent(- selected: isDownloadEnabled,+ selected: url.enableDownload,onChanged: (selected) async {await _updateUrlSettings(context, {'enableDownload': selected,@@ -203,22 +169,26 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {),),ShareMenuItem(- key: ValueKey("Allow join $isJoinEnabled"),- title: context.strings.allowJoiningAlbum,- icon: HugeIcons.strokeRoundedUserMultiple,+ key: ValueKey("Allow join ${url.enableJoin}"),+ title: context.strings.allowJoining,+ subtitle: url.enableDownload+ ? context.strings.allowJoiningDescription+ : context.strings.enableDownloadsToAllowJoining,+ icon: HugeIcons.strokeRoundedUserAdd01,trailing: ToggleSwitchComponent(- selected: isJoinEnabled,- onChanged: (selected) async {- await _updateUrlSettings(context, {'enableJoin': selected});- },+ selected: url.enableJoin,+ onChanged: url.enableDownload+ ? (selected) =>+ _updateUrlSettings(context, {'enableJoin': selected})+ : null,),),ShareMenuItem(- key: ValueKey("Password lock $isPasswordEnabled"),- title: context.strings.passwordLock,- icon: HugeIcons.strokeRoundedLockPassword,+ key: ValueKey("Password lock ${url.passwordEnabled}"),+ title: context.strings.password,+ icon: HugeIcons.strokeRoundedSquareLock01,trailing: ToggleSwitchComponent(- selected: isPasswordEnabled,+ selected: url.passwordEnabled,onChanged: (selected) async {if (selected) {unawaited(@@ -255,25 +225,39 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {],),const SizedBox(height: Spacing.sm),- ShareMenuGroup(items: _linkActionItems(context, url, urlValue)),+ PublicLinkEnabledActionsWidget(+ collection: collection,+ sendLinkButtonKey: sendLinkButtonKey,+ showEmbedHtml: true,+ showShareActions: isQuickLink,+ ),+ if (!url.isExpired)+ Padding(+ padding: const EdgeInsets.only(top: Spacing.sm),+ child: Text(+ context.strings.publicLinkAccessDescription,+ style: TextStyles.mini.copyWith(+ color: context.componentColors.textLight,+ ),+ ),+ ),const SizedBox(height: Spacing.sm),ShareMenuGroup(items: [ShareMenuItem(title: context.strings.removeLink,- leading: Icon(Icons.remove_circle_outline, color: colors.warning),+ icon: HugeIcons.strokeRoundedMinusSignCircle,isDestructive: true,onTap: () async {final bool result = await sharingActions.disableUrl(context,collection,);- if (result && mounted) {- if (!context.mounted) return;- Navigator.of(context).pop();+ if (result && context.mounted) {+ final navigator = Navigator.of(context);+ navigator.pop();if (collection.isQuickLinkCollection()) {- if (!context.mounted) return;- Navigator.of(context).pop();+ navigator.pop();}}},@@ -285,85 +269,12 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {);}- List<Widget> _linkActionItems(- BuildContext context,- PublicURL url,- String urlValue,- ) {- if (url.isExpired) {- return [- ShareMenuItem(- title: context.strings.linkHasExpired,- leading: const Icon(Icons.error_outline_rounded),- isDestructive: true,- isDisabled: true,- ),- ];- }-- return [- ShareMenuItem(- title: context.strings.copyLink,- icon: HugeIcons.strokeRoundedCopy01,- showOnlyLoadingState: true,- onTap: () async {- await Clipboard.setData(ClipboardData(text: urlValue));- if (!context.mounted) return;- showShortToast(context, context.strings.linkCopiedToClipboard);- },- ),- ShareMenuItem(- title: context.strings.copyEmbedHtml,- leading: const Icon(Icons.code_rounded),- onTap: () async {- final embedHtml = CollectionsService.instance.getEmbedHtml(- widget.collection!,- );- await Clipboard.setData(ClipboardData(text: embedHtml));- if (!context.mounted) return;- showShortToast(context, context.strings.linkCopiedToClipboard);- },- ),- ShareMenuItem(- key: sendLinkButtonKey,- title: context.strings.sendLink,- icon: HugeIcons.strokeRoundedSent,- onTap: () async {- await shareAlbumLink(- context,- urlValue,- sendLinkButtonKey,- albumName: widget.collection!.displayName,- albumDescription: widget.collection!.displayDescription,- );- },- ),- ShareMenuItem(- title: context.strings.sendQrCode,- icon: HugeIcons.strokeRoundedQrCode,- onTap: () async {- await showDialog<void>(- context: context,- builder: (BuildContext dialogContext) {- return QrCodeDialog(- data: urlValue,- title: widget.collection!.displayName,- accentColor: const Color(0xFF08C225),- shareFileName: 'ente_qr_${widget.collection!.displayName}.png',- shareText:- 'Scan this QR code to view my ${widget.collection!.displayName} album on ente',- dialogTitle: context.strings.qrCode,- shareButtonText: context.strings.share,- logoAssetPath: 'assets/qr_logo.png',- branding: const QrSvgBranding(- assetPath: 'assets/ente-branding.svg',- ),- );- },- );- },- ),- ];+ String _getLayoutDisplayName(String? layout, BuildContext context) {+ return switch (normalizePublicLinkLayout(layout)) {+ 'trip' => context.strings.layoutTrip,+ 'grouped' => context.strings.layoutGrouped,+ _ => context.strings.layoutMasonry,+ };}Future<void> _showLinkExpirySheet(BuildContext context, PublicURL url) async {@@ -424,9 +335,12 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {final newValidTill = _validTillForExpiryOption(expiryOption.expireAfterInMicroseconds,);- await _updateShareUrlFromPicker(context, {- 'validTill': newValidTill,- });+ await _updateUrlSettings(+ context,+ {'validTill': newValidTill},+ showProgressDialog: false,+ showToast: false,+ );if (sheetContext.mounted) {Navigator.of(sheetContext).pop();}@@ -451,9 +365,12 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {}if (!context.mounted) return;- await _updateShareUrlFromPicker(context, {- 'validTill': timeInMicrosecondsFromEpoch,- });+ await _updateUrlSettings(+ context,+ {'validTill': timeInMicrosecondsFromEpoch},+ showProgressDialog: false,+ showToast: false,+ );}int _validTillForExpiryOption(int expireAfterInMicroseconds) {@@ -508,15 +425,18 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {for (final deviceLimit in deviceLimits)MenuComponent(key: ValueKey(deviceLimit),- title: deviceLimit == 0 ? l10n.noDeviceLimit : "$deviceLimit",+ title: deviceLimit == 0 ? l10n.noLimit : "$deviceLimit",trailing: currentDeviceLimit == deviceLimit? shareCheck(sheetContext): null,showOnlyLoadingState: true,onTap: () async {- await _updateShareUrlFromPicker(context, {- 'deviceLimit': deviceLimit,- });+ await _updateUrlSettings(+ context,+ {'deviceLimit': deviceLimit},+ showProgressDialog: false,+ showToast: false,+ );if (sheetContext.mounted) {Navigator.of(sheetContext).pop();}@@ -528,32 +448,6 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {);}- Future<void> _updateShareUrlFromPicker(- BuildContext context,- Map<String, dynamic> prop,- ) async {- try {- await CollectionsService.instance.updateShareUrl(- widget.collection!,- prop,- );- if (mounted) {- setState(() {});- }- } catch (e) {- if (e is LinkEditNotAllowedError) {- if (context.mounted) {- await _showLinkEditNotAllowedDialog(context);- }- } else {- if (context.mounted) {- await showGenericErrorDialog(context: context, error: e);- }- }- rethrow;- }- }-Future<Map<String, dynamic>> _getEncryptedPassword(String pass) async {final kekSalt = CryptoUtil.getSaltToDeriveKey();final result = await CryptoUtil.deriveInteractiveKey(@@ -572,19 +466,17 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {BuildContext context,Map<String, dynamic> prop, {bool showProgressDialog = true,+ bool showToast = true,}) async {final dialog = showProgressDialog? createProgressDialog(context, context.strings.pleaseWait): null;await dialog?.show();try {- await CollectionsService.instance.updateShareUrl(- widget.collection!,- prop,- );+ await CollectionsService.instance.updateShareUrl(widget.collection, prop);await dialog?.hide();if (context.mounted) {- showShortToast(context, context.strings.albumUpdated);+ if (showToast) showShortToast(context, context.strings.albumUpdated);setState(() {});}} catch (e) {diff --git a/mobile/apps/photos/lib/ui/sharing/public_link_enabled_actions_widget.dart b/mobile/apps/photos/lib/ui/sharing/public_link_enabled_actions_widget.dartindex abab5e9687..7a76d80af4 100644--- a/mobile/apps/photos/lib/ui/sharing/public_link_enabled_actions_widget.dart+++ b/mobile/apps/photos/lib/ui/sharing/public_link_enabled_actions_widget.dart@@ -14,12 +14,16 @@ class PublicLinkEnabledActionsWidget extends StatelessWidget {final Collection collection;final GlobalKey? sendLinkButtonKey;final List<Widget> additionalItems;+ final bool showEmbedHtml;+ final bool showShareActions;const PublicLinkEnabledActionsWidget({super.key,required this.collection,this.sendLinkButtonKey,this.additionalItems = const [],+ this.showEmbedHtml = false,+ this.showShareActions = true,});@override@@ -55,45 +59,60 @@ class PublicLinkEnabledActionsWidget extends StatelessWidget {showShortToast(context, context.strings.linkCopiedToClipboard);},),- ShareMenuItem(- key: effectiveKey,- title: context.strings.sendLink,- icon: HugeIcons.strokeRoundedSent,- onTap: () async {- await shareAlbumLink(- context,- url,- effectiveKey,- albumName: collection.displayName,- albumDescription: collection.displayDescription,- );- },- ),- ShareMenuItem(- title: context.strings.sendQrCode,- icon: HugeIcons.strokeRoundedQrCode,- onTap: () async {- await showDialog<void>(- context: context,- builder: (BuildContext dialogContext) {- return QrCodeDialog(- data: url,- title: collection.displayName,- accentColor: const Color(0xFF08C225),- shareFileName: 'ente_qr_${collection.displayName}.png',- shareText:- 'Scan this QR code to view my ${collection.displayName} album on ente',- dialogTitle: context.strings.qrCode,- shareButtonText: context.strings.share,- logoAssetPath: 'assets/qr_logo.png',- branding: const QrSvgBranding(- assetPath: 'assets/ente-branding.svg',- ),- );- },- );- },- ),+ if (showEmbedHtml)+ ShareMenuItem(+ title: context.strings.copyEmbedHtml,+ leading: const Icon(Icons.code_rounded),+ onTap: () async {+ final embedHtml = CollectionsService.instance.getEmbedHtml(+ collection,+ );+ await Clipboard.setData(ClipboardData(text: embedHtml));+ if (!context.mounted) return;+ showShortToast(context, context.strings.linkCopiedToClipboard);+ },+ ),+ if (showShareActions) ...[+ ShareMenuItem(+ key: effectiveKey,+ title: context.strings.sendLink,+ icon: HugeIcons.strokeRoundedSent,+ onTap: () async {+ await shareAlbumLink(+ context,+ url,+ effectiveKey,+ albumName: collection.displayName,+ albumDescription: collection.displayDescription,+ );+ },+ ),+ ShareMenuItem(+ title: context.strings.sendQrCode,+ icon: HugeIcons.strokeRoundedQrCode,+ onTap: () async {+ await showDialog<void>(+ context: context,+ builder: (BuildContext dialogContext) {+ return QrCodeDialog(+ data: url,+ title: collection.displayName,+ accentColor: const Color(0xFF08C225),+ shareFileName: 'ente_qr_${collection.displayName}.png',+ shareText:+ 'Scan this QR code to view my ${collection.displayName} album on ente',+ dialogTitle: context.strings.qrCode,+ shareButtonText: context.strings.share,+ logoAssetPath: 'assets/qr_logo.png',+ branding: const QrSvgBranding(+ assetPath: 'assets/ente-branding.svg',+ ),+ );+ },+ );+ },+ ),+ ],]);}diff --git a/mobile/apps/photos/lib/ui/sharing/share_collection_page.dart b/mobile/apps/photos/lib/ui/sharing/share_collection_page.dartindex 9f6f41e510..ec98e8ca4f 100644--- a/mobile/apps/photos/lib/ui/sharing/share_collection_page.dart+++ b/mobile/apps/photos/lib/ui/sharing/share_collection_page.dart@@ -110,7 +110,7 @@ class _ShareCollectionPageState extends State<ShareCollectionPage> {sendLinkButtonKey: sendLinkButtonKey,additionalItems: [ShareMenuItem(- title: context.strings.manageLink,+ title: context.strings.linkSettings,icon: HugeIcons.strokeRoundedSetting07,showChevron: true,onTap: () async {diff --git a/mobile/packages/strings/lib/l10n/arb/strings_en.arb b/mobile/packages/strings/lib/l10n/arb/strings_en.arbindex b3c8e7f57e..1dfb32a756 100644--- a/mobile/packages/strings/lib/l10n/arb/strings_en.arb+++ b/mobile/packages/strings/lib/l10n/arb/strings_en.arb@@ -225,7 +225,9 @@},"allowAppToOpenSharedAlbumLinks": "Allow app to open shared album links","allowDownloads": "Allow downloads",+ "allowJoining": "Allow joining","allowJoiningAlbum": "Allow joining album",+ "allowJoiningDescription": "Viewers with an Ente account can join your album and stay updated","allowPermBody": "Please allow access to your photos from Settings so Ente can display and backup your library.","allowPermTitle": "Allow access to photos","allPersonGroupingWillReset": "All groupings for this person will be reset, and you will lose all suggestions made for this person",@@ -643,6 +645,7 @@"collectPhotos": "Collect photos","color": "Color","colorfulMarkets": "Vibrant markets",+ "commentAndReact": "Comment and react","commentedOnAPhoto": "commented on a photo","@commentedOnAPhoto": {"description": "Social notification action text shown after a person's name, for example 'John commented on a photo'. Make sure the translation reads naturally with a name before it, and do not capitalize the first letter."@@ -1118,6 +1121,7 @@}}},+ "downloadPhotos": "Download photos","downloadSkippedAlreadyAvailableOnDevice": "{fileName} is already available in the {albumName} album on your device","@downloadSkippedAlreadyAvailableOnDevice": {"description": "Toast shown in single-file download flow when the file already exists locally",@@ -1299,6 +1303,7 @@"enableAutomaticBackups": "Automatic backups","enableBackupsIosInstruction": "To enable backups on iOS, choose a folder in Files (for example \"On My iPhone\").","enableComment": "Comments and reactions",+ "enableDownloadsToAllowJoining": "Enable downloads to allow joining.","enabled": "Enabled","enableMaps": "Enable maps","encrypted": "Encrypted",@@ -2372,6 +2377,7 @@"linkLabel": "Link","linkNeverExpires": "Never","linkRequestLimitExceeded": "This album has been viewed on too many devices",+ "linkSettings": "Link settings","links": "Links","list": "List","livePhotos": "Live Photos",@@ -3193,6 +3199,7 @@"folderName": {}}},+ "publicLinkAccessDescription": "Anyone with the link can open the album without an Ente account.","publicLinkEnabled": "Public link enabled","qr": "QR","qrCode": "QR code",