Browse Source

translate lockscren (#1110)

Neeraj Gupta 2 năm trước cách đây
mục cha
commit
64d8b2b832

+ 23 - 0
lib/generated/intl/messages_en.dart

@@ -243,8 +243,25 @@ class MessageLookup extends MessageLookupByLibrary {
             MessageLookupByLibrary.simpleMessage("Allow downloads"),
         "allowPeopleToAddPhotos":
             MessageLookupByLibrary.simpleMessage("Allow people to add photos"),
+        "androidBiometricHint":
+            MessageLookupByLibrary.simpleMessage("Verify identity"),
+        "androidBiometricNotRecognized":
+            MessageLookupByLibrary.simpleMessage("Not recognized. Try again."),
+        "androidBiometricRequiredTitle":
+            MessageLookupByLibrary.simpleMessage("Biometric required"),
+        "androidBiometricSuccess":
+            MessageLookupByLibrary.simpleMessage("Success"),
+        "androidCancelButton": MessageLookupByLibrary.simpleMessage("Cancel"),
+        "androidDeviceCredentialsRequiredTitle":
+            MessageLookupByLibrary.simpleMessage("Device credentials required"),
+        "androidDeviceCredentialsSetupDescription":
+            MessageLookupByLibrary.simpleMessage("Device credentials required"),
+        "androidGoToSettingsDescription": MessageLookupByLibrary.simpleMessage(
+            "Biometric authentication is not set up on your device. Go to \'Settings > Security\' to add biometric authentication."),
         "androidIosWebDesktop":
             MessageLookupByLibrary.simpleMessage("Android, iOS, Web, Desktop"),
+        "androidSignInTitle":
+            MessageLookupByLibrary.simpleMessage("Authentication required"),
         "appVersion": m46,
         "appleId": MessageLookupByLibrary.simpleMessage("Apple ID"),
         "apply": MessageLookupByLibrary.simpleMessage("Apply"),
@@ -628,6 +645,7 @@ class MessageLookup extends MessageLookupByLibrary {
         "general": MessageLookupByLibrary.simpleMessage("General"),
         "generatingEncryptionKeys": MessageLookupByLibrary.simpleMessage(
             "Generating encryption keys..."),
+        "goToSettings": MessageLookupByLibrary.simpleMessage("Go to settings"),
         "googlePlayId": MessageLookupByLibrary.simpleMessage("Google Play ID"),
         "grantPermission":
             MessageLookupByLibrary.simpleMessage("Grant permission"),
@@ -638,6 +656,11 @@ class MessageLookup extends MessageLookupByLibrary {
         "howItWorks": MessageLookupByLibrary.simpleMessage("How it works"),
         "howToViewShareeVerificationID": MessageLookupByLibrary.simpleMessage(
             "Please ask them to long-press their email address on the settings screen, and verify that the IDs on both devices match."),
+        "iOSGoToSettingsDescription": MessageLookupByLibrary.simpleMessage(
+            "Biometric authentication is not set up on your device. Please either enable Touch ID or Face ID on your phone."),
+        "iOSLockOut": MessageLookupByLibrary.simpleMessage(
+            "Biometric authentication is disabled. Please lock and unlock your screen to enable it."),
+        "iOSOkButton": MessageLookupByLibrary.simpleMessage("OK"),
         "ignoredFolderUploadReason": MessageLookupByLibrary.simpleMessage(
             "Some files in this album are ignored from upload because they had previously been deleted from ente."),
         "importing": MessageLookupByLibrary.simpleMessage("Importing...."),

+ 4 - 0
lib/generated/intl/messages_nl.dart

@@ -183,6 +183,9 @@ class MessageLookup extends MessageLookupByLibrary {
 
   static String m37(email) => "Dit is de verificatie-ID van ${email}";
 
+  static String m62(count) =>
+      "${Intl.plural(count, zero: '', one: '1 dag', other: '${count} dagen')}";
+
   static String m38(email) => "Verifieer ${email}";
 
   static String m39(email) =>
@@ -1196,6 +1199,7 @@ class MessageLookup extends MessageLookupByLibrary {
         "total": MessageLookupByLibrary.simpleMessage("totaal"),
         "totalSize": MessageLookupByLibrary.simpleMessage("Totale grootte"),
         "trash": MessageLookupByLibrary.simpleMessage("Prullenbak"),
+        "trashDaysLeft": m62,
         "tryAgain": MessageLookupByLibrary.simpleMessage("Probeer opnieuw"),
         "turnOnBackupForAutoUpload": MessageLookupByLibrary.simpleMessage(
             "Schakel back-up in om bestanden die toegevoegd zijn aan deze map op dit apparaat automatisch te uploaden."),

+ 143 - 0
lib/generated/l10n.dart

@@ -6979,6 +6979,149 @@ class S {
       args: [],
     );
   }
+
+  /// `Verify identity`
+  String get androidBiometricHint {
+    return Intl.message(
+      'Verify identity',
+      name: 'androidBiometricHint',
+      desc:
+          'Hint message advising the user how to authenticate with biometrics. It is used on Android side. Maximum 60 characters.',
+      args: [],
+    );
+  }
+
+  /// `Not recognized. Try again.`
+  String get androidBiometricNotRecognized {
+    return Intl.message(
+      'Not recognized. Try again.',
+      name: 'androidBiometricNotRecognized',
+      desc:
+          'Message to let the user know that authentication was failed. It is used on Android side. Maximum 60 characters.',
+      args: [],
+    );
+  }
+
+  /// `Success`
+  String get androidBiometricSuccess {
+    return Intl.message(
+      'Success',
+      name: 'androidBiometricSuccess',
+      desc:
+          'Message to let the user know that authentication was successful. It is used on Android side. Maximum 60 characters.',
+      args: [],
+    );
+  }
+
+  /// `Cancel`
+  String get androidCancelButton {
+    return Intl.message(
+      'Cancel',
+      name: 'androidCancelButton',
+      desc:
+          'Message showed on a button that the user can click to leave the current dialog. It is used on Android side. Maximum 30 characters.',
+      args: [],
+    );
+  }
+
+  /// `Authentication required`
+  String get androidSignInTitle {
+    return Intl.message(
+      'Authentication required',
+      name: 'androidSignInTitle',
+      desc:
+          'Message showed as a title in a dialog which indicates the user that they need to scan biometric to continue. It is used on Android side. Maximum 60 characters.',
+      args: [],
+    );
+  }
+
+  /// `Biometric required`
+  String get androidBiometricRequiredTitle {
+    return Intl.message(
+      'Biometric required',
+      name: 'androidBiometricRequiredTitle',
+      desc:
+          'Message showed as a title in a dialog which indicates the user has not set up biometric authentication on their device. It is used on Android side. Maximum 60 characters.',
+      args: [],
+    );
+  }
+
+  /// `Device credentials required`
+  String get androidDeviceCredentialsRequiredTitle {
+    return Intl.message(
+      'Device credentials required',
+      name: 'androidDeviceCredentialsRequiredTitle',
+      desc:
+          'Message showed as a title in a dialog which indicates the user has not set up credentials authentication on their device. It is used on Android side. Maximum 60 characters.',
+      args: [],
+    );
+  }
+
+  /// `Device credentials required`
+  String get androidDeviceCredentialsSetupDescription {
+    return Intl.message(
+      'Device credentials required',
+      name: 'androidDeviceCredentialsSetupDescription',
+      desc:
+          'Message advising the user to go to the settings and configure device credentials on their device. It shows in a dialog on Android side.',
+      args: [],
+    );
+  }
+
+  /// `Go to settings`
+  String get goToSettings {
+    return Intl.message(
+      'Go to settings',
+      name: 'goToSettings',
+      desc:
+          'Message showed on a button that the user can click to go to settings pages from the current dialog. It is used on both Android and iOS side. Maximum 30 characters.',
+      args: [],
+    );
+  }
+
+  /// `Biometric authentication is not set up on your device. Go to 'Settings > Security' to add biometric authentication.`
+  String get androidGoToSettingsDescription {
+    return Intl.message(
+      'Biometric authentication is not set up on your device. Go to \'Settings > Security\' to add biometric authentication.',
+      name: 'androidGoToSettingsDescription',
+      desc:
+          'Message advising the user to go to the settings and configure biometric on their device. It shows in a dialog on Android side.',
+      args: [],
+    );
+  }
+
+  /// `Biometric authentication is disabled. Please lock and unlock your screen to enable it.`
+  String get iOSLockOut {
+    return Intl.message(
+      'Biometric authentication is disabled. Please lock and unlock your screen to enable it.',
+      name: 'iOSLockOut',
+      desc:
+          'Message advising the user to re-enable biometrics on their device. It shows in a dialog on iOS side.',
+      args: [],
+    );
+  }
+
+  /// `Biometric authentication is not set up on your device. Please either enable Touch ID or Face ID on your phone.`
+  String get iOSGoToSettingsDescription {
+    return Intl.message(
+      'Biometric authentication is not set up on your device. Please either enable Touch ID or Face ID on your phone.',
+      name: 'iOSGoToSettingsDescription',
+      desc:
+          'Message advising the user to go to the settings and configure Biometrics for their device. It shows in a dialog on iOS side.',
+      args: [],
+    );
+  }
+
+  /// `OK`
+  String get iOSOkButton {
+    return Intl.message(
+      'OK',
+      name: 'iOSOkButton',
+      desc:
+          'Message showed on a button that the user can click to leave the current dialog. It is used on iOS side. Maximum 30 characters.',
+      args: [],
+    );
+  }
 }
 
 class AppLocalizationDelegate extends LocalizationsDelegate<S> {

+ 54 - 1
lib/l10n/intl_en.arb

@@ -983,5 +983,58 @@
   },
   "setRadius": "Set radius",
   "familyPlanPortalTitle": "Family",
-  "familyPlanOverview": "Add 5 family members to your existing plan without paying extra.\n\nEach member gets their own private space, and cannot see each other's files unless they're shared.\n\nFamily plans are available to customers who have a paid ente subscription.\n\nSubscribe now to get started!"
+  "familyPlanOverview": "Add 5 family members to your existing plan without paying extra.\n\nEach member gets their own private space, and cannot see each other's files unless they're shared.\n\nFamily plans are available to customers who have a paid ente subscription.\n\nSubscribe now to get started!",
+  "androidBiometricHint": "Verify identity",
+  "@androidBiometricHint": {
+    "description": "Hint message advising the user how to authenticate with biometrics. It is used on Android side. Maximum 60 characters."
+  },
+  "androidBiometricNotRecognized": "Not recognized. Try again.",
+  "@androidBiometricNotRecognized": {
+    "description": "Message to let the user know that authentication was failed. It is used on Android side. Maximum 60 characters."
+  },
+  "androidBiometricSuccess": "Success",
+  "@androidBiometricSuccess": {
+    "description": "Message to let the user know that authentication was successful. It is used on Android side. Maximum 60 characters."
+  },
+  "androidCancelButton": "Cancel",
+  "@androidCancelButton": {
+    "description": "Message showed on a button that the user can click to leave the current dialog. It is used on Android side. Maximum 30 characters."
+  },
+  "androidSignInTitle": "Authentication required",
+  "@androidSignInTitle": {
+    "description": "Message showed as a title in a dialog which indicates the user that they need to scan biometric to continue. It is used on Android side. Maximum 60 characters."
+  },
+  "androidBiometricRequiredTitle": "Biometric required",
+  "@androidBiometricRequiredTitle": {
+    "description": "Message showed as a title in a dialog which indicates the user has not set up biometric authentication on their device. It is used on Android side. Maximum 60 characters."
+  },
+  "androidDeviceCredentialsRequiredTitle": "Device credentials required",
+  "@androidDeviceCredentialsRequiredTitle": {
+    "description": "Message showed as a title in a dialog which indicates the user has not set up credentials authentication on their device. It is used on Android side. Maximum 60 characters."
+  },
+  "androidDeviceCredentialsSetupDescription": "Device credentials required",
+  "@androidDeviceCredentialsSetupDescription": {
+    "description": "Message advising the user to go to the settings and configure device credentials on their device. It shows in a dialog on Android side."
+  },
+  "goToSettings": "Go to settings",
+  "@goToSettings": {
+    "description": "Message showed on a button that the user can click to go to settings pages from the current dialog. It is used on both Android and iOS side. Maximum 30 characters."
+  },
+  "androidGoToSettingsDescription": "Biometric authentication is not set up on your device. Go to 'Settings > Security' to add biometric authentication.",
+  "@androidGoToSettingsDescription": {
+    "description": "Message advising the user to go to the settings and configure biometric on their device. It shows in a dialog on Android side."
+  },
+  "iOSLockOut": "Biometric authentication is disabled. Please lock and unlock your screen to enable it.",
+  "@iOSLockOut": {
+    "description": "Message advising the user to re-enable biometrics on their device. It shows in a dialog on iOS side."
+  },
+  "iOSGoToSettingsDescription": "Biometric authentication is not set up on your device. Please either enable Touch ID or Face ID on your phone.",
+  "@iOSGoToSettingsDescription": {
+    "description": "Message advising the user to go to the settings and configure Biometrics for their device. It shows in a dialog on iOS side."
+  },
+  "iOSOkButton": "OK",
+  "@iOSOkButton": {
+    "description": "Message showed on a button that the user can click to leave the current dialog. It is used on iOS side. Maximum 30 characters."
+  }
 }
+

+ 2 - 1
lib/services/local_authentication_service.dart

@@ -17,7 +17,7 @@ class LocalAuthenticationService {
   ) async {
     if (await _isLocalAuthSupportedOnDevice()) {
       AppLock.of(context)!.setEnabled(false);
-      final result = await requestAuthentication(infoMessage);
+      final result = await requestAuthentication(context, infoMessage);
       AppLock.of(context)!.setEnabled(
         Configuration.instance.shouldShowLockScreen(),
       );
@@ -41,6 +41,7 @@ class LocalAuthenticationService {
     if (await _isLocalAuthSupportedOnDevice()) {
       AppLock.of(context)!.disable();
       final result = await requestAuthentication(
+        context,
         infoMessage,
       );
       if (result) {

+ 1 - 0
lib/ui/tools/lock_screen.dart

@@ -95,6 +95,7 @@ class _LockScreenState extends State<LockScreen> with WidgetsBindingObserver {
     try {
       _isShowingLockScreen = true;
       final result = await requestAuthentication(
+        context,
         S.of(context).authToViewYourMemories,
       );
       _isShowingLockScreen = false;

+ 29 - 1
lib/utils/auth_util.dart

@@ -1,10 +1,38 @@
+import "package:flutter/widgets.dart";
 import 'package:local_auth/local_auth.dart';
+import 'package:local_auth_android/local_auth_android.dart';
+import 'package:local_auth_ios/local_auth_ios.dart';
 import 'package:logging/logging.dart';
+import "package:photos/generated/l10n.dart";
 
-Future<bool> requestAuthentication(String reason) async {
+Future<bool> requestAuthentication(BuildContext context, String reason) async {
   Logger("AuthUtil").info("Requesting authentication");
   await LocalAuthentication().stopAuthentication();
+
   return await LocalAuthentication().authenticate(
     localizedReason: reason,
+    authMessages: [
+      AndroidAuthMessages(
+        biometricHint: S.of(context).androidBiometricHint,
+        biometricNotRecognized: S.of(context).androidBiometricNotRecognized,
+        biometricRequiredTitle: S.of(context).androidBiometricRequiredTitle,
+        biometricSuccess: S.of(context).androidBiometricSuccess,
+        cancelButton: S.of(context).androidCancelButton,
+        deviceCredentialsRequiredTitle:
+            S.of(context).androidDeviceCredentialsRequiredTitle,
+        deviceCredentialsSetupDescription:
+            S.of(context).androidDeviceCredentialsSetupDescription,
+        goToSettingsButton: S.of(context).goToSettings,
+        goToSettingsDescription: S.of(context).androidGoToSettingsDescription,
+        signInTitle: S.of(context).androidSignInTitle,
+      ),
+      IOSAuthMessages(
+        goToSettingsButton: S.of(context).goToSettings,
+        goToSettingsDescription: S.of(context).goToSettings,
+        lockOut: S.of(context).iOSLockOut,
+        // cancelButton default value is "Ok"
+        cancelButton: S.of(context).iOSOkButton,
+      ),
+    ],
   );
 }