diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist
index 3cdbf996d1719fac3def4171dfb449e9aba9907d..6372f1850365fe969c6fa82c5f3d150e19f24f60 100644
--- a/ios/Runner/Info.plist
+++ b/ios/Runner/Info.plist
@@ -62,5 +62,7 @@
Please allow auth to lock itself with FaceID or TouchID
NSPhotoLibraryUsageDescription
Please allow auth to pick a file to import data from
-
+ UIApplicationSupportsIndirectInputEvents
+
+
diff --git a/lib/app/view/app.dart b/lib/app/view/app.dart
index 069ce5fb1eb1a7c3e1c7e30b5b6582824914f684..f4a0a6c5e0191bb5323fa0fdf466b826ad2e4673 100644
--- a/lib/app/view/app.dart
+++ b/lib/app/view/app.dart
@@ -19,7 +19,8 @@ import "package:flutter/material.dart";
import 'package:flutter_localizations/flutter_localizations.dart';
class App extends StatefulWidget {
- const App({Key key});
+ final Locale locale;
+ const App({Key key, this.locale = const Locale("en")}) : super(key: key);
@override
State createState() => _AppState();
@@ -79,6 +80,7 @@ class _AppState extends State {
theme: lightTheme,
darkTheme: dartTheme,
debugShowCheckedModeBanner: false,
+ locale: widget.locale,
supportedLocales: appSupportedLocales,
localeListResolutionCallback: localResolutionCallBack,
localizationsDelegates: const [
@@ -97,6 +99,7 @@ class _AppState extends State {
theme: lightThemeData,
darkTheme: darkThemeData,
debugShowCheckedModeBanner: false,
+ locale: widget.locale,
supportedLocales: appSupportedLocales,
localeListResolutionCallback: localResolutionCallBack,
localizationsDelegates: const [
diff --git a/lib/locale.dart b/lib/locale.dart
index f80090cfc2f1fefd0628aedd30a4ea781bfa05c4..215631e652d94e6b7f88497f5393eef2784ecfcf 100644
--- a/lib/locale.dart
+++ b/lib/locale.dart
@@ -1,13 +1,18 @@
-import 'dart:ui';
+import 'package:flutter/cupertino.dart';
+import 'package:shared_preferences/shared_preferences.dart';
// list of locales which are enabled for auth app.
// Add more language to the list only when at least 90% of the strings are
// translated in the corresponding language.
const List appSupportedLocales = [
Locale('en'),
+ Locale('de'),
+ Locale('fr'),
+ Locale('fi'),
];
Locale localResolutionCallBack(locales, supportedLocales) {
+ // print call stacktrace to identify caller
for (Locale locale in locales) {
if (appSupportedLocales.contains(locale)) {
return locale;
@@ -16,3 +21,17 @@ Locale localResolutionCallBack(locales, supportedLocales) {
// if device language is not supported by the app, use en as default
return const Locale('en');
}
+
+Future getLocale() async {
+ final String? savedLocale =
+ (await SharedPreferences.getInstance()).getString('locale');
+ if (savedLocale != null) {
+ return Locale(savedLocale);
+ }
+ return const Locale('en');
+}
+
+Future setLocale(Locale locale) async {
+ await (await SharedPreferences.getInstance())
+ .setString('locale', locale.languageCode);
+}
diff --git a/lib/main.dart b/lib/main.dart
index de3ce54723fc930fdf156442c098e3cb1d79e09a..f1a8c382a61672ac46606d319c3e0fc3d1c3d90e 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -5,6 +5,7 @@ import 'package:ente_auth/core/constants.dart';
import 'package:ente_auth/core/logging/super_logging.dart';
import 'package:ente_auth/core/network.dart';
import 'package:ente_auth/ente_theme_data.dart';
+import 'package:ente_auth/locale.dart';
import 'package:ente_auth/services/authenticator_service.dart';
import 'package:ente_auth/services/billing_service.dart';
import 'package:ente_auth/services/notification_service.dart';
@@ -31,12 +32,14 @@ Future _runInForeground() async {
return await _runWithLogs(() async {
_logger.info("Starting app in foreground");
await _init(false, via: 'mainMethod');
+ final Locale locale = await getLocale();
UpdateService.instance.showUpdateNotification();
runApp(
AppLock(
- builder: (args) => const App(),
+ builder: (args) => App(locale: locale),
lockScreen: const LockScreen(),
enabled: Configuration.instance.shouldShowLockScreen(),
+ locale: locale,
lightTheme: lightThemeData,
darkTheme: darkThemeData,
),
diff --git a/lib/ui/tools/app_lock.dart b/lib/ui/tools/app_lock.dart
index ebafdb106846a50dce10708787e6cb7e43275ed8..3e427e93d780884d36744f386c6275c83bad2930 100644
--- a/lib/ui/tools/app_lock.dart
+++ b/lib/ui/tools/app_lock.dart
@@ -36,6 +36,7 @@ class AppLock extends StatefulWidget {
final Duration backgroundLockLatency;
final ThemeData darkTheme;
final ThemeData lightTheme;
+ final Locale locale;
const AppLock({
Key key,
@@ -45,6 +46,7 @@ class AppLock extends StatefulWidget {
this.backgroundLockLatency = const Duration(seconds: 0),
this.darkTheme,
this.lightTheme,
+ this.locale,
}) : super(key: key);
static _AppLockState of(BuildContext context) =>
@@ -110,6 +112,7 @@ class _AppLockState extends State with WidgetsBindingObserver {
themeMode: ThemeMode.system,
theme: widget.lightTheme,
darkTheme: widget.darkTheme,
+ locale: widget.locale,
supportedLocales: appSupportedLocales,
localeListResolutionCallback: localResolutionCallBack,
localizationsDelegates: const [
diff --git a/test/app/view/app_test.dart b/test/app/view/app_test.dart
index 89eda5bb6dd7a449e33877c70e093c91755fd9f1..b80fa4f5387cdd122b8683c74fdb9c81a21a1bc6 100644
--- a/test/app/view/app_test.dart
+++ b/test/app/view/app_test.dart
@@ -1,10 +1,12 @@
+import "dart:ui";
+
import "package:ente_auth/app/app.dart";
import "package:flutter_test/flutter_test.dart";
void main() {
group("App", () {
testWidgets("renders CounterPage", (tester) async {
- await tester.pumpWidget(const App());
+ await tester.pumpWidget(const App(Locale("en")));
// expect(find.byType(CounterPage), findsOneWidget);
});
});