π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] UX changes regarding pinning persons (#8276)
Laurens Priem260157d8641e
diff --git a/mobile/apps/photos/lib/l10n/intl_en.arb b/mobile/apps/photos/lib/l10n/intl_en.arbindex 2bba08ec82..3a42067ee1 100644--- a/mobile/apps/photos/lib/l10n/intl_en.arb+++ b/mobile/apps/photos/lib/l10n/intl_en.arb@@ -1206,10 +1206,13 @@"unpinAlbum": "Unpin album","pinAlbum": "Pin album","pin": "Pin",+ "pinPerson": "Pin person","pinToTop": "Pin to top","unpin": "Unpin",+ "unpinPerson": "Unpin person","visibility": "Visibility","hideFromMemories": "Hide from memories",+ "showInMemories": "Show in memories","create": "Create","viewAll": "View all","nothingSharedWithYouYet": "Nothing shared with you yet",diff --git a/mobile/apps/photos/lib/services/wrapped/wrapped_engine.dart b/mobile/apps/photos/lib/services/wrapped/wrapped_engine.dartindex bbe80a1f28..17626a1e55 100644--- a/mobile/apps/photos/lib/services/wrapped/wrapped_engine.dart+++ b/mobile/apps/photos/lib/services/wrapped/wrapped_engine.dart@@ -246,10 +246,11 @@ class WrappedEngine {if (isMe) {selfPersonID = person.remoteID;}+ final bool isHidden = data.isHidden || data.hideFromMemories;personEntries[person.remoteID] = WrappedPersonEntry(personID: person.remoteID,displayName: data.name,- isHidden: data.isHidden,+ isHidden: isHidden,clusterFaceCounts: clusterFaceCounts,isMe: isMe,);diff --git a/mobile/apps/photos/lib/ui/activity/rituals_section.dart b/mobile/apps/photos/lib/ui/activity/rituals_section.dartindex 20cd0899a4..7f43345ef7 100644--- a/mobile/apps/photos/lib/ui/activity/rituals_section.dart+++ b/mobile/apps/photos/lib/ui/activity/rituals_section.dart@@ -599,7 +599,7 @@ Future<void> _showRitualEditor(BuildContext context, {Ritual? ritual}) async {Expanded(child: TextFormField(controller: controller,- autofocus: true,+ autofocus: false,textCapitalization:TextCapitalization.sentences,onChanged: (_) => setState(() {}),diff --git a/mobile/apps/photos/lib/ui/viewer/actions/people_selection_action_widget.dart b/mobile/apps/photos/lib/ui/viewer/actions/people_selection_action_widget.dartindex 9a6e65c23c..1a6bee97f0 100644--- a/mobile/apps/photos/lib/ui/viewer/actions/people_selection_action_widget.dart+++ b/mobile/apps/photos/lib/ui/viewer/actions/people_selection_action_widget.dart@@ -3,6 +3,7 @@ import "package:logging/logging.dart";import "package:photos/core/event_bus.dart";import "package:photos/events/people_changed_event.dart";import "package:photos/generated/l10n.dart";+import "package:photos/l10n/l10n.dart";import "package:photos/models/ml/face/person.dart";import "package:photos/models/selected_people.dart";import "package:photos/services/machine_learning/face_ml/feedback/cluster_feedback.dart";@@ -86,25 +87,58 @@ class _PeopleSelectionActionWidgetStateselectedPersonIds.isNotEmpty && selectedClusterIds.isEmpty;final onePersonAndClusters =selectedPersonIds.length == 1 && selectedClusterIds.isNotEmpty;- final anythingSelected =- selectedPersonIds.isNotEmpty || selectedClusterIds.isNotEmpty;+ final bool namedPersonsSelected = selectedPersonIds.isNotEmpty &&+ selectedPersonIds.every(+ (id) => (personMap[id]?.data.name ?? "").isNotEmpty,+ );+ final bool showEditAction = onlyOnePerson;+ final bool showReviewAction = onlyOnePerson;+ final bool showMergeAction = onePersonAndClusters;+ final bool showResetAction = onlyOnePerson;+ final bool showAutoAddAction = onlyPersonSelected;final bool showPinAction = onlyPersonSelected &&- selectedPersonIds.isNotEmpty &&+ namedPersonsSelected &&selectedPersonIds.every((id) => !(personMap[id]?.data.isPinned ?? false),);final bool showUnpinAction = onlyPersonSelected &&- selectedPersonIds.isNotEmpty &&+ namedPersonsSelected &&selectedPersonIds.every((id) => personMap[id]?.data.isPinned ?? false,);+ final bool showHideFromMemoriesAction = onlyPersonSelected &&+ namedPersonsSelected &&+ selectedPersonIds.every(+ (id) => !(personMap[id]?.data.hideFromMemories ?? false),+ );+ final bool showShowInMemoriesAction = onlyPersonSelected &&+ namedPersonsSelected &&+ selectedPersonIds.every(+ (id) => personMap[id]?.data.hideFromMemories ?? false,+ );+ final bool showIgnoreAction =+ selectedClusterIds.isNotEmpty && selectedPersonIds.isEmpty;+ final bool hasVisibleAction = showEditAction ||+ showReviewAction ||+ showIgnoreAction ||+ showMergeAction ||+ showResetAction ||+ showPinAction ||+ showUnpinAction ||+ showHideFromMemoriesAction ||+ showShowInMemoriesAction ||+ showAutoAddAction;++ if (!hasVisibleAction) {+ return const SizedBox.shrink();+ }items.add(SelectionActionButton(labelText: AppLocalizations.of(context).edit,icon: Icons.edit_outlined,onTap: _onEditPerson,- shouldShow: onlyOnePerson,+ shouldShow: showEditAction,),);items.add(@@ -112,7 +146,7 @@ class _PeopleSelectionActionWidgetStatelabelText: AppLocalizations.of(context).review,icon: Icons.search_outlined,onTap: _onReviewSuggestion,- shouldShow: onlyOnePerson,+ shouldShow: showReviewAction,),);items.add(@@ -120,7 +154,7 @@ class _PeopleSelectionActionWidgetStatelabelText: AppLocalizations.of(context).ignore,icon: Icons.hide_image_outlined,onTap: _onIgnore,- shouldShow: anythingSelected,+ shouldShow: showIgnoreAction,),);items.add(@@ -128,7 +162,7 @@ class _PeopleSelectionActionWidgetStatelabelText: AppLocalizations.of(context).merge,icon: Icons.merge_outlined,onTap: _onMerge,- shouldShow: onePersonAndClusters,+ shouldShow: showMergeAction,),);items.add(@@ -136,7 +170,7 @@ class _PeopleSelectionActionWidgetStatelabelText: AppLocalizations.of(context).reset,icon: Icons.remove_outlined,onTap: _onResetPerson,- shouldShow: onlyOnePerson,+ shouldShow: showResetAction,),);items.add(@@ -155,6 +189,22 @@ class _PeopleSelectionActionWidgetStateshouldShow: showUnpinAction,),);+ items.add(+ SelectionActionButton(+ labelText: AppLocalizations.of(context).hideFromMemories,+ icon: Icons.visibility_off_outlined,+ onTap: () => _updateHideFromMemoriesState(true),+ shouldShow: showHideFromMemoriesAction,+ ),+ );+ items.add(+ SelectionActionButton(+ labelText: context.l10n.showInMemories,+ icon: Icons.visibility_outlined,+ onTap: () => _updateHideFromMemoriesState(false),+ shouldShow: showShowInMemoriesAction,+ ),+ );items.add(SelectionActionButton(labelText: AppLocalizations.of(context).autoAddToAlbum,@@ -165,7 +215,7 @@ class _PeopleSelectionActionWidgetStatecolor: EnteTheme.isDark(context) ? Colors.white : Colors.black,),onTap: _autoAddToAlbum,- shouldShow: onlyPersonSelected,+ shouldShow: showAutoAddAction,),);@@ -267,6 +317,28 @@ class _PeopleSelectionActionWidgetState}}+ Future<void> _updateHideFromMemoriesState(bool shouldHide) async {+ final selectedPersonIds = _getSelectedPersonIds();+ if (selectedPersonIds.isEmpty) return;+ try {+ final personMap = await personEntitiesMapFuture;+ for (final personID in selectedPersonIds) {+ final person = personMap[personID];+ if (person == null || person.data.name.isEmpty) continue;+ if (person.data.hideFromMemories == shouldHide) continue;+ await PersonService.instance.updateAttributes(+ person.remoteID,+ hideFromMemories: shouldHide,+ );+ }+ Bus.instance.fire(PeopleChangedEvent());+ } catch (e, s) {+ _logger.severe('Failed to update hide from memories state', e, s);+ } finally {+ widget.selectedPeople.clearAll();+ }+ }+Future<void> _onResetPerson() async {final selectedPersonIds = _getSelectedPersonIds();if (selectedPersonIds.length != 1) return;diff --git a/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dart b/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dartindex 5117087eed..0ad89028e7 100644--- a/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dart+++ b/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dart@@ -56,6 +56,8 @@ class PeopleAppBar extends StatefulWidget {enum PeoplePopupAction {rename,setCover,+ pinPerson,+ hideFromMemories,removeLabel,reviewSuggestions,unignore,@@ -211,6 +213,10 @@ class _AppBarWidgetState extends State<PeopleAppBar> {List<Widget> _getDefaultActions(BuildContext context) {final textTheme = getEnteTextTheme(context);+ final currentPerson = person;+ final bool isIgnored = currentPerson.data.isIgnored;+ final bool isPinned = currentPerson.data.isPinned;+ final bool hideFromMemories = currentPerson.data.hideFromMemories;final List<Widget> actions = <Widget>[];// If the user has selected files, don't show any actionsif (widget.selectedFiles.files.isNotEmpty ||@@ -241,7 +247,7 @@ class _AppBarWidgetState extends State<PeopleAppBar> {);}- if (!widget.isIgnored) {+ if (!isIgnored) {items.addAll([PopupMenuItem(@@ -289,8 +295,44 @@ class _AppBarWidgetState extends State<PeopleAppBar> {],),),- if (widget.person.data.email != null &&- (widget.person.data.email == Configuration.instance.getEmail()))+ PopupMenuItem(+ value: PeoplePopupAction.pinPerson,+ child: Row(+ children: [+ Icon(isPinned ? Icons.push_pin : Icons.push_pin_outlined),+ const Padding(+ padding: EdgeInsets.all(8),+ ),+ Text(+ isPinned ? context.l10n.unpinPerson : context.l10n.pinPerson,+ style: textTheme.bodyBold,+ ),+ ],+ ),+ ),+ PopupMenuItem(+ value: PeoplePopupAction.hideFromMemories,+ child: Row(+ children: [+ Icon(+ hideFromMemories+ ? Icons.visibility_outlined+ : Icons.visibility_off_outlined,+ ),+ const Padding(+ padding: EdgeInsets.all(8),+ ),+ Text(+ hideFromMemories+ ? context.l10n.showInMemories+ : context.l10n.hideFromMemories,+ style: textTheme.bodyBold,+ ),+ ],+ ),+ ),+ if (currentPerson.data.email != null &&+ (currentPerson.data.email == Configuration.instance.getEmail()))PopupMenuItem(value: PeoplePopupAction.reassignMe,child: Row(@@ -367,6 +409,10 @@ class _AppBarWidgetState extends State<PeopleAppBar> {await _editPerson(context);} else if (value == PeoplePopupAction.setCover) {await setCoverPhoto(context);+ } else if (value == PeoplePopupAction.pinPerson) {+ await _togglePinState();+ } else if (value == PeoplePopupAction.hideFromMemories) {+ await _toggleHideFromMemories();} else if (value == PeoplePopupAction.unignore) {await _showPerson(context);} else if (value == PeoplePopupAction.removeLabel) {@@ -382,6 +428,50 @@ class _AppBarWidgetState extends State<PeopleAppBar> {return actions;}+ Future<void> _togglePinState() async {+ final shouldPin = !person.data.isPinned;+ try {+ final updatedPerson = await PersonService.instance.updateAttributes(+ person.remoteID,+ isPinned: shouldPin,+ );+ setState(() {+ person = updatedPerson;+ });+ Bus.instance.fire(+ PeopleChangedEvent(+ type: PeopleEventType.saveOrEditPerson,+ source: "_AppBarWidgetState._togglePinState",+ person: updatedPerson,+ ),+ );+ } catch (e, s) {+ _logger.severe('Failed to update pin state', e, s);+ }+ }++ Future<void> _toggleHideFromMemories() async {+ final shouldHideFromMemories = !person.data.hideFromMemories;+ try {+ final updatedPerson = await PersonService.instance.updateAttributes(+ person.remoteID,+ hideFromMemories: shouldHideFromMemories,+ );+ setState(() {+ person = updatedPerson;+ });+ Bus.instance.fire(+ PeopleChangedEvent(+ type: PeopleEventType.saveOrEditPerson,+ source: "_AppBarWidgetState._toggleHideFromMemories",+ person: updatedPerson,+ ),+ );+ } catch (e, s) {+ _logger.severe('Failed to update hide from memories state', e, s);+ }+ }+Future<void> _resetPerson(BuildContext context) async {await showChoiceDialog(context,diff --git a/mobile/apps/photos/lib/ui/viewer/people/save_or_edit_person.dart b/mobile/apps/photos/lib/ui/viewer/people/save_or_edit_person.dartindex dad7fefbd8..60450000fd 100644--- a/mobile/apps/photos/lib/ui/viewer/people/save_or_edit_person.dart+++ b/mobile/apps/photos/lib/ui/viewer/people/save_or_edit_person.dart@@ -14,7 +14,6 @@ import "package:photos/l10n/l10n.dart";import "package:photos/models/api/collection/user.dart";import "package:photos/models/file/file.dart";import "package:photos/models/ml/face/person.dart";-import "package:photos/service_locator.dart";import "package:photos/services/account/user_service.dart";import "package:photos/services/machine_learning/face_ml/feedback/cluster_feedback.dart";import "package:photos/services/machine_learning/face_ml/person/person_service.dart";@@ -24,11 +23,7 @@ import "package:photos/ui/common/date_input.dart";import "package:photos/ui/common/loading_widget.dart";import "package:photos/ui/components/action_sheet_widget.dart";import "package:photos/ui/components/buttons/button_widget.dart";-import "package:photos/ui/components/captioned_text_widget.dart";-import "package:photos/ui/components/expandable_menu_item_widget.dart";-import "package:photos/ui/components/menu_item_widget/menu_item_widget.dart";import "package:photos/ui/components/models/button_type.dart";-import "package:photos/ui/components/toggle_switch_widget.dart";import "package:photos/ui/notification/toast.dart";import "package:photos/ui/sharing/album_share_info_widget.dart";import "package:photos/ui/sharing/user_avator_widget.dart";@@ -307,8 +302,6 @@ class _SaveOrEditPersonState extends State<SaveOrEditPerson> {child: _EmailSection(_email, person?.remoteID),),const SizedBox(height: 24),- _buildVisibilitySection(context),- const SizedBox(height: 24),ButtonWidget(buttonType: ButtonType.primary,labelText: context.l10n.save,@@ -365,51 +358,6 @@ class _SaveOrEditPersonState extends State<SaveOrEditPerson> {);}- Widget _buildVisibilitySection(BuildContext context) {- return ExpandableMenuItemWidget(- title: context.l10n.visibility,- leadingIcon: Icons.visibility_outlined,- selectionOptionsWidget: Column(- children: [- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.l10n.pinToTop,- ),- trailingWidget: ToggleSwitchWidget(- value: () => _isPinned,- onChanged: () async {- if (!mounted) return;- setState(() {- _isPinned = !_isPinned;- });- },- ),- singleBorderRadius: 8,- isGestureDetectorDisabled: true,- ),- const SizedBox(height: 12),- MenuItemWidget(- captionedTextWidget: CaptionedTextWidget(- title: context.l10n.hideFromMemories,- ),- trailingWidget: ToggleSwitchWidget(- value: () => _hideFromMemories,- onChanged: () async {- if (!mounted) return;- setState(() {- _hideFromMemories = !_hideFromMemories;- });- memoriesCacheService.queueUpdateCache();- },- ),- singleBorderRadius: 8,- isGestureDetectorDisabled: true,- ),- ],- ),- );- }-Future<dynamic> _saveChangesPrompt(BuildContext context) async {PersonEntity? updatedPersonEntity;return await showActionSheet(