Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob][photos] Add Copy embed HTML feature for internal users

Neeraj Gupta1e5d1e6a7d3e
diff --git a/mobile/apps/photos/lib/l10n/intl_en.arb b/mobile/apps/photos/lib/l10n/intl_en.arb
index 65a217b474..4801fec290 100644
--- a/mobile/apps/photos/lib/l10n/intl_en.arb
+++ b/mobile/apps/photos/lib/l10n/intl_en.arb
@@ -244,6 +244,7 @@
"sendLink": "Send link",
"sendQrCode": "Send QR code",
"copyLink": "Copy link",
+ "copyEmbedHtml": "Copy embed HTML",
"linkHasExpired": "Link has expired",
"publicLinkEnabled": "Public link enabled",
"shareALink": "Share a link",
diff --git a/mobile/apps/photos/lib/services/collections_service.dart b/mobile/apps/photos/lib/services/collections_service.dart
index 1f8bd4fc6f..13f33e1330 100644
--- a/mobile/apps/photos/lib/services/collections_service.dart
+++ b/mobile/apps/photos/lib/services/collections_service.dart
@@ -844,6 +844,40 @@ class CollectionsService {
return "$finalUrl#$collectionKey";
}
+ String getEmbedHtml(Collection c) {
+ final PublicURL url = c.publicURLs.firstOrNull!;
+ Uri publicUrl = Uri.parse(url.url);
+
+ // Replace with embed URL if configured
+ final String embedUrl = flagService.embedUrl;
+ if (embedUrl.isNotEmpty) {
+ final Uri embedUri = Uri.parse(embedUrl);
+ publicUrl = publicUrl.replace(
+ host: embedUri.host,
+ scheme: embedUri.scheme,
+ port: embedUri.hasPort ? embedUri.port : (embedUri.scheme == 'https' ? 443 : 80),
+ );
+ }
+
+ // Get the collection key for the URL fragment
+ final String collectionKey = Base58Encode(
+ CollectionsService.instance.getCollectionKey(c.id),
+ );
+
+ // Build the final URL
+ String finalUrl = publicUrl.toString();
+
+ // Handle IDN domains - if the host was percent-encoded by Uri.replace,
+ // decode it for user-friendly display
+ if (embedUrl.isNotEmpty && publicUrl.host.contains('%')) {
+ final decodedHost = Uri.decodeComponent(publicUrl.host);
+ finalUrl = finalUrl.replaceFirst(publicUrl.host, decodedHost);
+ }
+
+ final String embedHtmlUrl = "$finalUrl#$collectionKey";
+ return '<iframe src="$embedHtmlUrl" width="800" height="600" frameborder="0" allowfullscreen></iframe>';
+ }
+
Uint8List _getAndCacheDecryptedKey(
Collection collection, {
String source = "",
diff --git a/mobile/apps/photos/lib/ui/sharing/manage_links_widget.dart b/mobile/apps/photos/lib/ui/sharing/manage_links_widget.dart
index 387b99581d..d2bbdc8887 100644
--- a/mobile/apps/photos/lib/ui/sharing/manage_links_widget.dart
+++ b/mobile/apps/photos/lib/ui/sharing/manage_links_widget.dart
@@ -338,6 +338,36 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
dividerType: DividerType.menu,
bgColor: getEnteColorScheme(context).fillFaint,
),
+ if (!url.isExpired && flagService.internalUser)
+ MenuItemWidget(
+ captionedTextWidget: CaptionedTextWidget(
+ title:
+ AppLocalizations.of(context).copyEmbedHtml + " (i)",
+ makeTextBold: true,
+ ),
+ leadingIcon: Icons.code,
+ menuItemColor: getEnteColorScheme(context).fillFaint,
+ showOnlyLoadingState: false,
+ surfaceExecutionStates: false,
+ onTap: () async {
+ final embedHtml = CollectionsService.instance
+ .getEmbedHtml(widget.collection!);
+ await Clipboard.setData(
+ ClipboardData(text: embedHtml),
+ );
+ showShortToast(
+ context,
+ AppLocalizations.of(context).linkCopiedToClipboard,
+ );
+ },
+ isTopBorderRadiusRemoved: true,
+ isBottomBorderRadiusRemoved: true,
+ ),
+ if (!url.isExpired && flagService.internalUser)
+ DividerWidget(
+ dividerType: DividerType.menu,
+ bgColor: getEnteColorScheme(context).fillFaint,
+ ),
if (!url.isExpired)
MenuItemWidget(
key: sendLinkButtonKey,
diff --git a/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart b/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart
index 8c613d4560..3922e4fdb8 100644
--- a/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart
+++ b/mobile/apps/photos/plugins/ente_feature_flag/lib/src/service.dart
@@ -64,6 +64,8 @@ class FlagService {
String get customDomain => flags.customDomain;
+ String get embedUrl => flags.embedUrl;
+
bool get textDetection => internalUser && Platform.isIOS;
bool get addToAlbumFeature => internalUser;
diff --git a/mobile/apps/photos/scripts/internal_changes.txt b/mobile/apps/photos/scripts/internal_changes.txt
index 4336b54b9b..38d92a8b37 100644
--- a/mobile/apps/photos/scripts/internal_changes.txt
+++ b/mobile/apps/photos/scripts/internal_changes.txt
@@ -1,3 +1,4 @@
+- Neeraj: (i) Copy embed link option
- Prateek: Fix background uploads on Android 15 by skipping permission request in background mode
- Prateek: Fix CronetException during background sync by disabling NativeAdapter on Android
- Laurens: Change similar images labels copy