fix(app): keyboards learn nothing of a password, a code or the phrase

The fields for a password, a code and the recovery phrase's words already
turned suggestions and corrections off; keyboards (Gboard, SwiftKey) still
learnt what was typed into them unless told not to. They now are
(enableIMEPersonalizedLearning: false), and the two sheets taking the
whole phrase share one PhraseField.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
Tizian 「ティツィアーン」 2026-10-21 14:48:43 +02:00
commit c9904de31d
Signed by: raisondetredev
GPG key ID: 07F6FCF405488B64
2 changed files with 106 additions and 31 deletions

View file

@ -38,8 +38,7 @@ void main() {
AppScope(
dependencies: TestAppDependencies(gateway: FakeAuthGateway()),
child: MaterialApp(
localizationsDelegates:
HalkyonAppLocalizations.localizationsDelegates,
localizationsDelegates: testLocalizationsDelegates,
supportedLocales: HalkyonAppLocalizations.supportedLocales,
home: Scaffold(body: SingleChildScrollView(child: view)),
),

View file

@ -0,0 +1,60 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:halkyon_app/halkyon_app.dart';
import 'package:halkyon_app/testing.dart';
import 'package:material_ui/material_ui.dart';
void main() {
/// Pumps [field] alone.
Future<void> pump(WidgetTester tester, Widget field) => tester.pumpWidget(
MaterialApp(
localizationsDelegates: testLocalizationsDelegates,
supportedLocales: HalkyonAppLocalizations.supportedLocales,
home: Scaffold(body: SingleChildScrollView(child: field)),
),
);
/// Whether every text field shown keeps what is typed from the keyboard:
/// no suggestions, no corrections, nothing learnt.
void expectNothingLearnt(WidgetTester tester, String what) {
final fields = tester.widgetList<TextField>(find.byType(TextField));
expect(fields, isNotEmpty, reason: what);
for (final field in fields) {
expect(field.enableIMEPersonalizedLearning, isFalse, reason: what);
expect(field.autocorrect, isFalse, reason: what);
expect(field.enableSuggestions, isFalse, reason: what);
}
}
testWidgets('a keyboard learns nothing of a password, a code or the '
'recovery phrase', (tester) async {
final controller = TextEditingController();
addTearDown(controller.dispose);
await pump(tester, PasswordField(controller: controller, label: 'P'));
expectNothingLearnt(tester, 'a password');
await pump(
tester,
CodeField(controller: controller, kind: CodeKind.totp),
);
expectNothingLearnt(tester, 'a code');
await pump(
tester,
CodeField(controller: controller, kind: CodeKind.recovery),
);
expectNothingLearnt(tester, 'a recovery code');
await pump(tester, PhraseField(controller: controller));
expectNothingLearnt(tester, 'the phrase');
await pump(
tester,
PhraseCheckFields(
positions: const [0, 5],
controllers: [controller, controller],
),
);
expectNothingLearnt(tester, "the phrase's words");
});
}