Skip to content

armgit / ente

Public Imported from GitHub
0

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

Add join album feature for mobile

Anand Baburajan0d65cfb4ff29
diff --git a/mobile/apps/photos/ios/Podfile.lock b/mobile/apps/photos/ios/Podfile.lock
index 915b669376..7c321d3fb1 100644
--- a/mobile/apps/photos/ios/Podfile.lock
+++ b/mobile/apps/photos/ios/Podfile.lock
@@ -478,14 +478,14 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/workmanager_apple/ios"
SPEC CHECKSUMS:
- app_links: f3e17e4ee5e357b39d8b95290a9b2c299fca71c6
- audio_session: 19e9480dbdd4e5f6c4543826b2e8b0e4ab6145fe
- battery_info: b6c551049266af31556b93c9d9b9452cfec0219f
- connectivity_plus: 2a701ffec2c0ae28a48cf7540e279787e77c447d
- cupertino_http: 947a233f40cfea55167a49f2facc18434ea117ba
- dart_ui_isolate: d5bcda83ca4b04f129d70eb90110b7a567aece14
- device_info_plus: bf2e3232933866d73fe290f2942f2156cdd10342
- emoji_picker_flutter: fe2e6151c5b548e975d546e6eeb567daf0962a58
+ app_links: 76b66b60cc809390ca1ad69bfd66b998d2387ac7
+ audio_session: 9bb7f6c970f21241b19f5a3658097ae459681ba0
+ battery_info: 83f3aae7be2fccefab1d2bf06b8aa96f11c8bcdd
+ connectivity_plus: cb623214f4e1f6ef8fe7403d580fdad517d2f7dd
+ cupertino_http: 94ac07f5ff090b8effa6c5e2c47871d48ab7c86c
+ dart_ui_isolate: 46f6714abe6891313267153ef6f9748d8ecfcab1
+ device_info_plus: 21fcca2080fbcd348be798aa36c3e5ed849eefbe
+ emoji_picker_flutter: ed468d9746c21711e66b2788880519a9de5de211
ffmpeg_kit_custom: 682b4f2f1ff1f8abae5a92f6c3540f2441d5be99
ffmpeg_kit_flutter: 915b345acc97d4142e8a9a8549d177ff10f043f5
file_saver: 6cdbcddd690cb02b0c1a0c225b37cd805c2bf8b6
@@ -508,11 +508,11 @@ SPEC CHECKSUMS:
fluttertoast: 2c67e14dce98bbdb200df9e1acf610d7a6264ea1
GoogleDataTransport: aae35b7ea0c09004c3797d53c8c41f66f219d6a7
GoogleUtilities: 00c88b9a86066ef77f0da2fab05f65d7768ed8e1
- home_widget: 0434835a4c9a75704264feff6be17ea40e0f0d57
- in_app_purchase_storekit: a1ce04056e23eecc666b086040239da7619cd783
- integration_test: 252f60fa39af5e17c3aa9899d35d908a0721b573
- just_audio: a42c63806f16995daf5b219ae1d679deb76e6a79
- launcher_icon_switcher: 8e0ad2131a20c51c1dd939896ee32e70cd845b37
+ home_widget: f169fc41fd807b4d46ab6615dc44d62adbf9f64f
+ in_app_purchase_storekit: d1a48cb0f8b29dbf5f85f782f5dd79b21b90a5e6
+ integration_test: 4a889634ef21a45d28d50d622cf412dc6d9f586e
+ just_audio: 4e391f57b79cad2b0674030a00453ca5ce817eed
+ launcher_icon_switcher: 84c218d233505aa7d8655d8fa61a3ba802c022da
libwebp: 02b23773aedb6ff1fd38cec7a77b81414c6842a8
local_auth_ios: f7a1841beef3151d140a967c2e46f30637cdf451
Mantle: c5aa8794a29a022dfbbfc9799af95f477a69b62d
@@ -539,9 +539,9 @@ SPEC CHECKSUMS:
photo_manager: 1d80ae07a89a67dfbcae95953a1e5a24af7c3e62
privacy_screen: 3159a541f5d3a31bea916cfd4e58f9dc722b3fd4
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
- receive_sharing_intent: 79c848f5b045674ad60b9fea3bafea59962ad2c1
- rive_native: b9a36ed0644fc2ed1fd46f1d2b4e5501e5948235
- rust_lib_photos: 8813b31af48ff02ca75520cbc81a363a13d51a84
+ receive_sharing_intent: 222384f00ffe7e952bbfabaa9e3967cb87e5fe00
+ rive_native: a57df296c558867395bfe82fafe857ec67640f58
+ rust_lib_photos: 04d3901908d2972192944083310b65abf410774c
SDWebImage: 9f177d83116802728e122410fb25ad88f5c7608a
SDWebImageWebPCoder: e38c0a70396191361d60c092933e22c20d5b1380
Sentry: da60d980b197a46db0b35ea12cb8f39af48d8854
diff --git a/mobile/apps/photos/lib/ui/tabs/home_widget.dart b/mobile/apps/photos/lib/ui/tabs/home_widget.dart
index 03545827a6..ee121ad935 100644
--- a/mobile/apps/photos/lib/ui/tabs/home_widget.dart
+++ b/mobile/apps/photos/lib/ui/tabs/home_widget.dart
@@ -4,6 +4,7 @@ import "dart:io";
import "package:app_links/app_links.dart";
import "package:ente_crypto/ente_crypto.dart";
+import "package:flutter/foundation.dart";
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
@@ -243,10 +244,8 @@ class _HomeWidgetState extends State<HomeWidget> {
});
});
- // MediaExtension plugin handles the deeplink for android
- // [todo 4/Feb/2025]We need to validate if calling this method doesn't break
- // android deep linking
- Platform.isIOS ? _initDeepLinkSubscriptionForPublicAlbums() : null;
+ // Initialize deep link subscription for public albums on both iOS and Android
+ _initDeepLinkSubscriptionForPublicAlbums();
// For sharing images coming from outside the app
_initMediaShareSubscription();
@@ -298,6 +297,10 @@ class _HomeWidgetState extends State<HomeWidget> {
final Map<Uri, (bool, int)> _linkedPublicAlbums = {};
Future<void> _handlePublicAlbumLink(Uri uri, String via) async {
+ if (!mounted) {
+ _logger.warning("Cannot handle public album link - widget not mounted");
+ return;
+ }
try {
_logger.info("Handling public album link: via $via");
final int currentTime = DateTime.now().millisecondsSinceEpoch;
@@ -331,6 +334,10 @@ class _HomeWidgetState extends State<HomeWidget> {
return;
}
+ // Check for action=join parameter to show join dialog
+ final shouldShowJoinDialog = uri.queryParameters['action'] == 'join' &&
+ Configuration.instance.isLoggedIn();
+
// Check for trip layout and show in webview
if (collection.pubMagicMetadata.layout == "trip") {
await routeToPage(
@@ -396,11 +403,12 @@ class _HomeWidgetState extends State<HomeWidget> {
await routeToPage(
context,
SharedPublicCollectionPage(
- files: sharedFiles,
CollectionWithThumbnail(
collection,
null,
),
+ files: sharedFiles,
+ shouldShowJoinDialog: shouldShowJoinDialog,
),
);
}
@@ -423,16 +431,17 @@ class _HomeWidgetState extends State<HomeWidget> {
);
await dialog.hide();
- routeToPage(
+ await routeToPage(
context,
SharedPublicCollectionPage(
- files: sharedFiles,
CollectionWithThumbnail(
collection,
null,
),
+ files: sharedFiles,
+ shouldShowJoinDialog: shouldShowJoinDialog,
),
- ).ignore();
+ );
if (sharedFiles.length == 1) {
await routeToPage(
context,
@@ -518,7 +527,9 @@ class _HomeWidgetState extends State<HomeWidget> {
if (value.isEmpty) {
return;
}
- if (value[0].path.contains("albums.ente.io")) {
+ // Check if this is a public album link (ente:// scheme or albums.ente.io)
+ if (value[0].path.startsWith("ente://") ||
+ value[0].path.contains("albums.ente.io")) {
final uri = Uri.parse(value[0].path);
_handlePublicAlbumLink(uri, "sharedIntent.getMediaStream");
return;
@@ -585,7 +596,10 @@ class _HomeWidgetState extends State<HomeWidget> {
.getInitialMedia()
.then((List<SharedMediaFile> value) {
if (mounted) {
- if (value.isNotEmpty && value[0].path.contains("albums.ente.io")) {
+ // Check if this is a public album link (ente:// scheme or albums.ente.io)
+ if (value.isNotEmpty &&
+ (value[0].path.startsWith("ente://") ||
+ value[0].path.contains("albums.ente.io"))) {
final uri = Uri.parse(value[0].path);
_handlePublicAlbumLink(uri, "sharedIntent.getInitialMedia");
return;
@@ -616,10 +630,14 @@ class _HomeWidgetState extends State<HomeWidget> {
Future<void> _initDeepLinkSubscriptionForPublicAlbums() async {
final appLinks = AppLinks();
+
+ // Use AppLinks for public album deep links (works reliably on cold start)
+ // Note: MediaExtension is skipped for ente:// URLs as AppLinks handles them better
try {
final initialUri = await appLinks.getInitialLink();
if (initialUri != null) {
- if (initialUri.toString().contains("albums.ente.io")) {
+ if (initialUri.scheme == "ente" &&
+ _isPublicAlbumHost(initialUri.toString())) {
await _handlePublicAlbumLink(initialUri, "appLinks.getInitialLink");
} else {
_logger.info(
@@ -638,7 +656,7 @@ class _HomeWidgetState extends State<HomeWidget> {
_publicAlbumLinkSubscription = appLinks.uriLinkStream.listen(
(Uri? uri) {
if (uri != null) {
- if (uri.toString().contains("albums.ente.io")) {
+ if (uri.scheme == "ente" && _isPublicAlbumHost(uri.toString())) {
_handlePublicAlbumLink(uri, "appLinks.uriLinkStream");
} else {
_logger.info(
@@ -655,6 +673,12 @@ class _HomeWidgetState extends State<HomeWidget> {
);
}
+ bool _isPublicAlbumHost(String url) {
+ if (url.contains("albums.ente.io")) return true;
+ if (kDebugMode && url.contains("192.168.0.61:3002")) return true;
+ return false;
+ }
+
@override
Widget build(BuildContext context) {
_logger.info("Building home_Widget with tab $_selectedTabIndex");
diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/shared_public_collection_page.dart b/mobile/apps/photos/lib/ui/viewer/gallery/shared_public_collection_page.dart
index 3e9a21e625..517f5c44e0 100644
--- a/mobile/apps/photos/lib/ui/viewer/gallery/shared_public_collection_page.dart
+++ b/mobile/apps/photos/lib/ui/viewer/gallery/shared_public_collection_page.dart
@@ -1,3 +1,5 @@
+import "dart:async";
+
import "package:flutter/material.dart";
import "package:logging/logging.dart";
import "package:photos/core/configuration.dart";
@@ -33,12 +35,14 @@ class SharedPublicCollectionPage extends StatefulWidget {
final CollectionWithThumbnail c;
final String tagPrefix;
final List<EnteFile>? files;
+ final bool shouldShowJoinDialog;
const SharedPublicCollectionPage(
this.c, {
this.tagPrefix = "shared_public_collection",
super.key,
this.files,
+ this.shouldShowJoinDialog = false,
}) : assert(
!(files == null),
'sharedLinkFiles cannot be empty',
@@ -58,6 +62,46 @@ class _SharedPublicCollectionPageState
void initState() {
super.initState();
logger.info("Init SharedPublicCollectionPage");
+
+ // Show join dialog after the page is built if requested
+ if (widget.shouldShowJoinDialog) {
+ WidgetsBinding.instance.addPostFrameCallback((_) {
+ _showJoinDialog();
+ });
+ }
+ }
+
+ Future<void> _showJoinDialog() async {
+ final result = await showChoiceDialog(
+ context,
+ title: context.l10n.joinAlbum,
+ body: context.l10n.joinAlbumConfirmationDialogBody,
+ firstButtonLabel: context.l10n.join,
+ );
+ if (result != null && result.action == ButtonAction.first) {
+ final dialog = createProgressDialog(
+ context,
+ context.l10n.pleaseWait,
+ isDismissible: true,
+ );
+ await dialog.show();
+ try {
+ await RemoteSyncService.instance
+ .joinAndSyncCollection(context, widget.c.collection.id);
+ final c = CollectionsService.instance
+ .getCollectionByID(widget.c.collection.id);
+ await dialog.hide();
+ Navigator.of(context).pop();
+ await routeToPage(
+ context,
+ CollectionPage(CollectionWithThumbnail(c!, null)),
+ );
+ } catch (e, s) {
+ logger.severe("Failed to join public album", e, s);
+ await dialog.hide();
+ await showGenericErrorDialog(context: context, error: e);
+ }
+ }
}
@override
diff --git a/mobile/apps/photos/pubspec.lock b/mobile/apps/photos/pubspec.lock
index 3a79cf7cd2..07cf93cec9 100644
--- a/mobile/apps/photos/pubspec.lock
+++ b/mobile/apps/photos/pubspec.lock
@@ -1595,7 +1595,7 @@ packages:
description:
path: "."
ref: HEAD
- resolved-ref: "23a38887fa6b61330452555f8e686c3a3a1c91a2"
+ resolved-ref: "324f8fbdbc7ae6d326a6d541751b7a895a249089"
url: "https://github.com/ente-io/media_extension.git"
source: git
version: "1.0.2"