π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Seed anonymous avatars from anonymous identities
Neeraj Gupta55de9a57afc7
diff --git a/mobile/apps/photos/lib/ui/sharing/user_avator_widget.dart b/mobile/apps/photos/lib/ui/sharing/user_avator_widget.dartindex 52170f79cb..1a7c4dd21d 100644--- a/mobile/apps/photos/lib/ui/sharing/user_avator_widget.dart+++ b/mobile/apps/photos/lib/ui/sharing/user_avator_widget.dart@@ -32,6 +32,13 @@ AvatarIdentity getUserAvatarIdentity(User user) {);}+AvatarIdentity getAnonymousUserAvatarIdentity(User user, String anonymousID) {+ return AvatarIdentity.anonymous(+ label: resolveDisplayName(user),+ anonymousID: anonymousID,+ );+}+class UserAvatarWidget extends StatefulWidget {final User user;final AvatarType type;diff --git a/mobile/apps/photos/lib/ui/social/comment_likes_bottom_sheet.dart b/mobile/apps/photos/lib/ui/social/comment_likes_bottom_sheet.dartindex 611c165905..2e8c9fb184 100644--- a/mobile/apps/photos/lib/ui/social/comment_likes_bottom_sheet.dart+++ b/mobile/apps/photos/lib/ui/social/comment_likes_bottom_sheet.dart@@ -11,6 +11,7 @@ import "package:photos/ui/components/buttons/icon_button_widget.dart";import "package:photos/ui/sharing/user_avator_widget.dart";import "package:photos/ui/social/social_actor_contact_navigation.dart";import "package:photos/ui/social/widgets/resolved_social_user_name.dart";+import "package:photos/utils/avatar_util.dart";const _shrinkWrapThreshold = 30;@@ -169,6 +170,12 @@ class _CommentLikesBottomSheetState extends State<CommentLikesBottomSheet> {final user = _getUserForReaction(reaction);return _CommentLikeListItem(user: user,+ fallbackIdentity: reaction.anonUserID == null+ ? null+ : getAnonymousUserAvatarIdentity(+ user,+ reaction.anonUserID!,+ ),currentUserID: widget.currentUserID,youLabel: l10n.you,onTap: () => openSocialActorContactDestination(@@ -191,12 +198,14 @@ class _CommentLikesBottomSheetState extends State<CommentLikesBottomSheet> {class _CommentLikeListItem extends StatelessWidget {final User user;+ final AvatarIdentity? fallbackIdentity;final int currentUserID;final String youLabel;final VoidCallback? onTap;const _CommentLikeListItem({required this.user,+ required this.fallbackIdentity,required this.currentUserID,required this.youLabel,this.onTap,@@ -215,6 +224,7 @@ class _CommentLikeListItem extends StatelessWidget {currentUserID: currentUserID,type: AvatarType.regular,addStroke: false,+ fallbackIdentity: fallbackIdentity,),const SizedBox(width: 12),Expanded(diff --git a/mobile/apps/photos/lib/ui/social/likes_bottom_sheet.dart b/mobile/apps/photos/lib/ui/social/likes_bottom_sheet.dartindex 325347eb95..1df5f0f5b8 100644--- a/mobile/apps/photos/lib/ui/social/likes_bottom_sheet.dart+++ b/mobile/apps/photos/lib/ui/social/likes_bottom_sheet.dart@@ -18,6 +18,7 @@ import "package:photos/ui/sharing/user_avator_widget.dart";import "package:photos/ui/social/social_actor_contact_navigation.dart";import "package:photos/ui/social/widgets/collection_selector_widget.dart";import "package:photos/ui/social/widgets/resolved_social_user_name.dart";+import "package:photos/utils/avatar_util.dart";const _shrinkWrapThreshold = 30;@@ -412,6 +413,9 @@ class _LikesList extends StatelessWidget {final user = _getUserForReaction(reaction);return _LikeListItem(user: user,+ fallbackIdentity: reaction.anonUserID == null+ ? null+ : getAnonymousUserAvatarIdentity(user, reaction.anonUserID!),currentUserID: currentUserID,youLabel: l10n.you,onTap: () => onUserTap(user),@@ -423,12 +427,14 @@ class _LikesList extends StatelessWidget {class _LikeListItem extends StatelessWidget {final User user;+ final AvatarIdentity? fallbackIdentity;final int currentUserID;final String youLabel;final VoidCallback? onTap;const _LikeListItem({required this.user,+ required this.fallbackIdentity,required this.currentUserID,required this.youLabel,this.onTap,@@ -447,6 +453,7 @@ class _LikeListItem extends StatelessWidget {currentUserID: currentUserID,type: AvatarType.regular,addStroke: false,+ fallbackIdentity: fallbackIdentity,),const SizedBox(width: 12),Expanded(diff --git a/mobile/apps/photos/lib/ui/social/widgets/comment_bubble_widget.dart b/mobile/apps/photos/lib/ui/social/widgets/comment_bubble_widget.dartindex 25903527be..e76876313f 100644--- a/mobile/apps/photos/lib/ui/social/widgets/comment_bubble_widget.dart+++ b/mobile/apps/photos/lib/ui/social/widgets/comment_bubble_widget.dart@@ -21,6 +21,7 @@ import "package:photos/ui/social/widgets/comment_actions_popup.dart";import "package:photos/ui/social/widgets/comment_like_count_capsule.dart";import "package:photos/ui/social/widgets/delete_comment_confirmation_dialog.dart";import "package:photos/ui/social/widgets/resolved_social_user_name.dart";+import "package:photos/utils/avatar_util.dart";import "package:photos/utils/social/relative_time_formatter.dart";final _logger = Logger("CommentBubbleWidget");@@ -519,6 +520,12 @@ class _CommentBubbleWidgetState extends State<CommentBubbleWidget>child: _Header(isOwnComment: widget.isOwnComment,user: widget.user,+ fallbackIdentity: widget.comment.anonUserID == null+ ? null+ : getAnonymousUserAvatarIdentity(+ widget.user,+ widget.comment.anonUserID!,+ ),createdAt: widget.comment.createdAt,currentUserID: widget.currentUserID,onAuthorTap: widget.onAuthorTap,@@ -818,6 +825,7 @@ class _CommentBubble extends StatelessWidget {class _Header extends StatelessWidget {final bool isOwnComment;final User user;+ final AvatarIdentity? fallbackIdentity;final int createdAt;final int currentUserID;final VoidCallback? onAuthorTap;@@ -825,6 +833,7 @@ class _Header extends StatelessWidget {const _Header({required this.isOwnComment,required this.user,+ required this.fallbackIdentity,required this.createdAt,required this.currentUserID,this.onAuthorTap,@@ -909,6 +918,7 @@ class _Header extends StatelessWidget {type: AvatarType.regular,thumbnailView: true,addStroke: false,+ fallbackIdentity: fallbackIdentity,),const SizedBox(width: 10),Flexible(child: headerText),@@ -921,6 +931,7 @@ class _Header extends StatelessWidget {type: AvatarType.regular,thumbnailView: true,addStroke: false,+ fallbackIdentity: fallbackIdentity,),],],diff --git a/mobile/apps/photos/lib/ui/social/widgets/feed_item_widget.dart b/mobile/apps/photos/lib/ui/social/widgets/feed_item_widget.dartindex 8f173f197c..a5a24131e2 100644--- a/mobile/apps/photos/lib/ui/social/widgets/feed_item_widget.dart+++ b/mobile/apps/photos/lib/ui/social/widgets/feed_item_widget.dart@@ -13,6 +13,9 @@ import "package:photos/ui/sharing/user_avator_widget.dart";import "package:photos/ui/social/widgets/resolved_social_user_name.dart";import "package:photos/ui/social/widgets/shared_photos_grid.dart";import "package:photos/ui/viewer/file/thumbnail_widget.dart";+import "package:photos/utils/avatar_util.dart";++typedef _AvatarActor = ({User user, AvatarIdentity? fallbackIdentity});/// Widget that displays a single feed item.class FeedItemWidget extends StatelessWidget {@@ -381,7 +384,7 @@ class _StackedAvatars extends StatelessWidget {if (displayCount == 1) {return _wrapActorTap(_buildSingleAvatar(actors.first, colorScheme),- actors.first,+ actors.first.user,);}@@ -405,10 +408,11 @@ class _StackedAvatars extends StatelessWidget {),),child: UserAvatarWidget(- actors.first,+ actors.first.user,type: AvatarType.regular,currentUserID: currentUserID,addStroke: false,+ fallbackIdentity: actors.first.fallbackIdentity,),),),@@ -424,31 +428,33 @@ class _StackedAvatars extends StatelessWidget {),),child: UserAvatarWidget(- actors[1],+ actors[1].user,type: AvatarType.regular,currentUserID: currentUserID,addStroke: false,+ fallbackIdentity: actors[1].fallbackIdentity,),),),],),),- actors.first,+ actors.first.user,);}- Widget _buildSingleAvatar(User user, EnteColorScheme colorScheme) {+ Widget _buildSingleAvatar(_AvatarActor actor, EnteColorScheme colorScheme) {return Container(decoration: BoxDecoration(shape: BoxShape.circle,border: Border.all(color: colorScheme.backgroundColour, width: 1.167),),child: UserAvatarWidget(- user,+ actor.user,type: AvatarType.regular,currentUserID: currentUserID,addStroke: false,+ fallbackIdentity: actor.fallbackIdentity,),);}@@ -465,8 +471,8 @@ class _StackedAvatars extends StatelessWidget {);}- List<User> _getActors() {- final users = <User>[];+ List<_AvatarActor> _getActors() {+ final actors = <_AvatarActor>[];final maxActors = feedItem.actorCount.clamp(1, 2);for (int i = 0; i < maxActors; i++) {@@ -476,20 +482,26 @@ class _StackedAvatars extends StatelessWidget {if (userID <= 0 && anonID != null) {// Anonymous user - use decrypted display name if availablefinal displayName = anonDisplayNames[anonID] ?? anonID;- users.add(- User(id: userID, email: "[email protected]", name: displayName),+ final user = User(+ id: userID,+ email: "[email protected]",+ name: displayName,);+ actors.add((+ user: user,+ fallbackIdentity: getAnonymousUserAvatarIdentity(user, anonID),+ ));} else {// Get user from collections servicefinal user = CollectionsService.instance.getFileOwner(userID,feedItem.collectionID,);- users.add(user);+ actors.add((user: user, fallbackIdentity: null));}}- return users;+ return actors;}}