Skip to content

armgit / ente

Public Imported from GitHub
0

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

[mob] Add confirmation while adding trusted contact

Neeraj Gupta9da5f6c99d80
diff --git a/mobile/lib/emergency/emergency_page.dart b/mobile/lib/emergency/emergency_page.dart
index 535a78b366..252971a821 100644
--- a/mobile/lib/emergency/emergency_page.dart
+++ b/mobile/lib/emergency/emergency_page.dart
@@ -228,6 +228,7 @@ class _EmergencyPageState extends State<EmergencyPage> {
await routeToPage(
context,
AddContactPage(info!),
+ forceCustomPageRoute: true,
);
unawaited(_fetchData());
},
@@ -249,6 +250,7 @@ class _EmergencyPageState extends State<EmergencyPage> {
await routeToPage(
context,
AddContactPage(info!),
+ forceCustomPageRoute: true,
);
unawaited(_fetchData());
},
diff --git a/mobile/lib/emergency/select_contact_page.dart b/mobile/lib/emergency/select_contact_page.dart
index 3e33d96d4e..993b777e77 100644
--- a/mobile/lib/emergency/select_contact_page.dart
+++ b/mobile/lib/emergency/select_contact_page.dart
@@ -6,6 +6,7 @@ import "package:photos/emergency/emergency_service.dart";
import "package:photos/emergency/model.dart";
import "package:photos/generated/l10n.dart";
import "package:photos/models/api/collection/user.dart";
+import "package:photos/models/button_result.dart";
import 'package:photos/services/collections_service.dart';
import "package:photos/services/user_service.dart";
import 'package:photos/theme/ente_theme.dart';
@@ -19,6 +20,7 @@ import 'package:photos/ui/components/menu_section_title.dart';
import 'package:photos/ui/components/models/button_type.dart';
import 'package:photos/ui/sharing/user_avator_widget.dart';
import "package:photos/ui/sharing/verify_identity_dialog.dart";
+import "package:photos/ui/tabs/nav_bar.dart";
import "package:photos/utils/dialog_util.dart";
class AddContactPage extends StatefulWidget {
@@ -186,20 +188,32 @@ class _AddContactPage extends State<AddContactPage> {
: () async {
final emailToAdd =
selectedEmail == '' ? _email : selectedEmail;
- try {
- final result = await EmergencyContactService
- .instance
- .addContact(context, emailToAdd);
- if (result && mounted) {
- Navigator.of(context).pop(true);
+ final choiceResult = await showChoiceActionSheet(
+ context,
+ title: S.of(context).warning,
+ body: S.of(context).confirmAddingTrustedContact(
+ emailToAdd,
+ 30,
+ ),
+ firstButtonLabel: S.of(context).proceed,
+ isCritical: true,
+ );
+ if (choiceResult != null &&
+ choiceResult.action == ButtonAction.first) {
+ try {
+ final r = await EmergencyContactService.instance
+ .addContact(context, emailToAdd);
+ if (r && mounted) {
+ Navigator.of(context).pop(true);
+ }
+ } catch (e) {
+ _logger.severe('Failed to add contact', e);
+ await showErrorDialog(
+ context,
+ S.of(context).error,
+ S.of(context).somethingWentWrong,
+ );
}
- } catch (e) {
- _logger.severe('Failed to add contact', e);
- await showErrorDialog(
- context,
- S.of(context).error,
- S.of(context).somethingWentWrong,
- );
}
},
),
diff --git a/mobile/lib/generated/intl/messages_en.dart b/mobile/lib/generated/intl/messages_en.dart
index 6d2aa31a8f..37dbea3924 100644
--- a/mobile/lib/generated/intl/messages_en.dart
+++ b/mobile/lib/generated/intl/messages_en.dart
@@ -62,6 +62,9 @@ class MessageLookup extends MessageLookupByLibrary {
static String m82(count) =>
"${Intl.plural(count, zero: 'Added 0 collaborator', one: 'Added 1 collaborator', other: 'Added ${count} collaborators')}";
+ static String m83(email, numOfDays) =>
+ "You are about to add ${email} as a trusted contact. They will be able to recover your account if you are absent for ${numOfDays} days.";
+
static String m19(familyAdminEmail) =>
"Please contact <green>${familyAdminEmail}</green> to manage your subscription";
@@ -157,13 +160,13 @@ class MessageLookup extends MessageLookupByLibrary {
static String m52(storeName) => "Rate us on ${storeName}";
- static String m83(days, email) =>
+ static String m84(days, email) =>
"You can access the account after ${days} days. A notification will be sent to ${email}.";
- static String m84(email) =>
+ static String m85(email) =>
"You can now recover ${email}\'s account by setting a new password.";
- static String m85(email) => "${email} is trying to recover your account.";
+ static String m86(email) => "${email} is trying to recover your account.";
static String m53(storageInGB) =>
"3. Both of you get ${storageInGB} GB* free";
@@ -232,7 +235,7 @@ class MessageLookup extends MessageLookupByLibrary {
static String m73(count) =>
"${Intl.plural(count, zero: 'Soon', one: '1 day', other: '${count} days')}";
- static String m86(email) =>
+ static String m87(email) =>
"You have been invited to be a legacy contact by ${email}.";
static String m74(galleryType) =>
@@ -575,6 +578,7 @@ class MessageLookup extends MessageLookupByLibrary {
"Are you sure you want to disable two-factor authentication?"),
"confirmAccountDeletion":
MessageLookupByLibrary.simpleMessage("Confirm Account Deletion"),
+ "confirmAddingTrustedContact": m83,
"confirmDeletePrompt": MessageLookupByLibrary.simpleMessage(
"Yes, I want to permanently delete this account and its data across all apps."),
"confirmPassword":
@@ -1347,6 +1351,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Private backups"),
"privateSharing":
MessageLookupByLibrary.simpleMessage("Private sharing"),
+ "proceed": MessageLookupByLibrary.simpleMessage("Proceed"),
"processingImport": m51,
"publicLinkCreated":
MessageLookupByLibrary.simpleMessage("Public link created"),
@@ -1366,7 +1371,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Recover account"),
"recoveryInitiated":
MessageLookupByLibrary.simpleMessage("Recovery initiated"),
- "recoveryInitiatedDesc": m83,
+ "recoveryInitiatedDesc": m84,
"recoveryKey": MessageLookupByLibrary.simpleMessage("Recovery key"),
"recoveryKeyCopiedToClipboard": MessageLookupByLibrary.simpleMessage(
"Recovery key copied to clipboard"),
@@ -1380,12 +1385,12 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Recovery key verified"),
"recoveryKeyVerifyReason": MessageLookupByLibrary.simpleMessage(
"Your recovery key is the only way to recover your photos if you forget your password. You can find your recovery key in Settings > Account.\n\nPlease enter your recovery key here to verify that you have saved it correctly."),
- "recoveryReady": m84,
+ "recoveryReady": m85,
"recoverySuccessful":
MessageLookupByLibrary.simpleMessage("Recovery successful!"),
"recoveryWarning": MessageLookupByLibrary.simpleMessage(
"A trusted contact is trying to access your account"),
- "recoveryWarningBody": m85,
+ "recoveryWarningBody": m86,
"recreatePasswordBody": MessageLookupByLibrary.simpleMessage(
"The current device is not powerful enough to verify your password, but we can regenerate in a way that works with all devices.\n\nPlease login using your recovery key and regenerate your password (you can use the same one again if you wish)."),
"recreatePasswordTitle":
@@ -1772,7 +1777,7 @@ class MessageLookup extends MessageLookupByLibrary {
"trim": MessageLookupByLibrary.simpleMessage("Trim"),
"trustedContacts":
MessageLookupByLibrary.simpleMessage("Trusted contacts"),
- "trustedInviteBody": m86,
+ "trustedInviteBody": m87,
"tryAgain": MessageLookupByLibrary.simpleMessage("Try again"),
"turnOnBackupForAutoUpload": MessageLookupByLibrary.simpleMessage(
"Turn on backup to automatically upload files added to this device folder to Ente."),
@@ -1871,6 +1876,7 @@ class MessageLookup extends MessageLookupByLibrary {
MessageLookupByLibrary.simpleMessage("Waiting for verification..."),
"waitingForWifi":
MessageLookupByLibrary.simpleMessage("Waiting for WiFi..."),
+ "warning": MessageLookupByLibrary.simpleMessage("Warning"),
"weAreOpenSource":
MessageLookupByLibrary.simpleMessage("We are open source!"),
"weDontSupportEditingPhotosAndAlbumsThatYouDont":
diff --git a/mobile/lib/generated/l10n.dart b/mobile/lib/generated/l10n.dart
index ff00c23a90..13cadaf84a 100644
--- a/mobile/lib/generated/l10n.dart
+++ b/mobile/lib/generated/l10n.dart
@@ -10728,6 +10728,36 @@ class S {
args: [email],
);
}
+
+ /// `Warning`
+ String get warning {
+ return Intl.message(
+ 'Warning',
+ name: 'warning',
+ desc: '',
+ args: [],
+ );
+ }
+
+ /// `Proceed`
+ String get proceed {
+ return Intl.message(
+ 'Proceed',
+ name: 'proceed',
+ desc: '',
+ args: [],
+ );
+ }
+
+ /// `You are about to add {email} as a trusted contact. They will be able to recover your account if you are absent for {numOfDays} days.`
+ String confirmAddingTrustedContact(String email, int numOfDays) {
+ return Intl.message(
+ 'You are about to add $email as a trusted contact. They will be able to recover your account if you are absent for $numOfDays days.',
+ name: 'confirmAddingTrustedContact',
+ desc: '',
+ args: [email, numOfDays],
+ );
+ }
}
class AppLocalizationDelegate extends LocalizationsDelegate<S> {
diff --git a/mobile/lib/l10n/intl_en.arb b/mobile/lib/l10n/intl_en.arb
index 8066c5a092..01df2f3d5d 100644
--- a/mobile/lib/l10n/intl_en.arb
+++ b/mobile/lib/l10n/intl_en.arb
@@ -1558,5 +1558,20 @@
}
},
"recoveryWarningBody": "{email} is trying to recover your account.",
- "trustedInviteBody": "You have been invited to be a legacy contact by {email}."
+ "trustedInviteBody": "You have been invited to be a legacy contact by {email}.",
+ "warning": "Warning",
+ "proceed": "Proceed",
+ "confirmAddingTrustedContact": "You are about to add {email} as a trusted contact. They will be able to recover your account if you are absent for {numOfDays} days.",
+ "@confirmAddingTrustedContact": {
+ "placeholders": {
+ "email": {
+ "type": "String",
+ "example": "[email protected]"
+ },
+ "numOfDays": {
+ "type": "int",
+ "example": "30"
+ }
+ }
+ }
}
\ No newline at end of file