Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance QRScannerWidget with flashlight and gallery options #426

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/l10n/app_cs.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"patchNotesNewFeatures": "Nové funkce",
"patchNotesImprovements": "Improvements",
"patchNotesBugFixes": "Opravy chyb",
"patchNotesV4_4_2NewFeatures1": "Žetony lze nyní vkládat pomocí kopírování a vkládání.",
"patchNotesV4_4_2NewFeatures2": "Přidána podpora galerie pro skenování QR kódů.",
"patchNotesV4_4_2Improvement1": "Přidána podpora svítilny pro skenování QR kódů.",
"patchNotesV4_4_0NewFeatures1": "Nyní je možné exportovat tokeny, u kterých lze zajistit, že se nejedná o tokeny privacyIDEA. V současné době nelze vyloučit, že tokeny přidané prostřednictvím čtečky QR kódů pocházejí z aplikace privacyIDEA. Rozlišování bude v budoucích verzích vylepšeno.",
"patchNotesV4_4_0NewFeatures2": "Přidána podpora pro \"require presence\" aplikace privacyIDEA.",
"patchNotesV4_4_0Improvement1": "Byly přidány další dovozní zdroje.",
Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"patchNotesNewFeatures": "Neue Funktionen",
"patchNotesImprovements": "Verbesserungen",
"patchNotesBugFixes": "Fehlerbehebungen",
"patchNotesV4_4_2NewFeatures1": "Token können jetzt per Copy & Paste eingefügt werden.",
"patchNotesV4_4_2NewFeatures2": "Galerie-Unterstützung für das Scannen von QR-Codes hinzugefügt.",
"patchNotesV4_4_2Improvement1": "Taschenlampenunterstützung für das Scannen von QR-Codes wurde zugefügt.",
"patchNotesV4_4_0NewFeatures1": "Es ist nun möglich, Token zu exportieren, bei denen sichergestellt werden kann, dass es sich nicht um privacyIDEA Token handelt. Derzeit kann nicht ausgeschlossen werden, dass über den QR-Code-Scanner hinzugefügte Token von privacyIDEA stammen. Die Differenzierung wird in zukünftigen Versionen verbessert.",
"patchNotesV4_4_0NewFeatures2": "Unterstützung für privacyIDEA's \"require presence\" hinzugefügt.",
"patchNotesV4_4_0Improvement1": "Es wurden weitere Importquellen hinzugefügt.",
Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"patchNotesNewFeatures": "New features",
"patchNotesImprovements": "Improvements",
"patchNotesBugFixes": "Bug fixes",
"patchNotesV4_4_2NewFeatures1": "Tokens can now be inserted using copy & paste.",
"patchNotesV4_4_2NewFeatures2": "Added gallery support for QR code scanning.",
"patchNotesV4_4_2Improvement1": "Added flashlight support for QR code scanning.",
"patchNotesV4_4_0NewFeatures1": "It is now possible to export tokens where it can be ensured that they are not privacyIDEA tokens. Currently, it cannot be ruled out that tokens added via the QR code scanner originate from privacyIDEA. The differentiation will be improved in future versions.",
"patchNotesV4_4_0NewFeatures2": "Added support for privacyIDEA's \"require presence\"",
"patchNotesV4_4_0Improvement1": "Further import sources have been added.",
Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"patchNotesNewFeatures": "Nuevas características",
"patchNotesImprovements": "Mejoras",
"patchNotesBugFixes": "Corrección de errores",
"patchNotesV4_4_2NewFeatures1": "Ahora es posible insertar tokens copiando y pegando.",
"patchNotesV4_4_2NewFeatures2": "Añadido soporte de galería para el escaneo de códigos QR.",
"patchNotesV4_4_2Improvement1": "Añadido soporte linterna para el escaneo de códigos QR.",
"patchNotesV4_4_0NewFeatures1": "Ahora es posible exportar tokens cuando se puede garantizar que no son tokens de privacyIDEA. Actualmente, no se puede descartar que los tokens añadidos a través del escáner de código QR procedan de privacyIDEA. La diferenciación se mejorará en futuras versiones.",
"patchNotesV4_4_0NewFeatures2": "Añadido soporte para privacyIDEA's \"require presence\".",
"patchNotesV4_4_0Improvement1": "Se han añadido más fuentes de importación.",
Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"patchNotesNewFeatures": "Nouvelles caractéristiques",
"patchNotesImprovements": "Améliorations",
"patchNotesBugFixes": "Bug fixes",
"patchNotesV4_4_2NewFeatures1": "Les jetons peuvent désormais être insérés par copier-coller.",
"patchNotesV4_4_2NewFeatures2": "Ajout de la prise en charge de la galerie pour la lecture des codes QR.",
"patchNotesV4_4_2Improvement1": "Ajout de la prise en charge de la lampe de poche pour la lecture des codes QR.",
"patchNotesV4_4_0NewFeatures1": "Il est désormais possible d'exporter des jetons dont on peut s'assurer qu'il ne s'agit pas de jetons privacyIDEA. Actuellement, il n'est pas possible d'exclure que des jetons ajoutés via le lecteur de code QR proviennent de privacyIDEA. La différenciation sera améliorée dans les versions futures.",
"patchNotesV4_4_0NewFeatures2": "Ajout du support pour privacyIDEA's \"require presence\".",
"patchNotesV4_4_0Improvement1": "D'autres sources d'importation ont été ajoutées.",
Expand Down
18 changes: 18 additions & 0 deletions lib/l10n/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,24 @@ abstract class AppLocalizations {
/// **'Bug fixes'**
String get patchNotesBugFixes;

/// No description provided for @patchNotesV4_4_2NewFeatures1.
///
/// In en, this message translates to:
/// **'Tokens can now be inserted using copy & paste.'**
String get patchNotesV4_4_2NewFeatures1;

/// No description provided for @patchNotesV4_4_2NewFeatures2.
///
/// In en, this message translates to:
/// **'Added gallery support for QR code scanning.'**
String get patchNotesV4_4_2NewFeatures2;

/// No description provided for @patchNotesV4_4_2Improvement1.
///
/// In en, this message translates to:
/// **'Added flashlight support for QR code scanning.'**
String get patchNotesV4_4_2Improvement1;

/// No description provided for @patchNotesV4_4_0NewFeatures1.
///
/// In en, this message translates to:
Expand Down
9 changes: 9 additions & 0 deletions lib/l10n/app_localizations_cs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ class AppLocalizationsCs extends AppLocalizations {
@override
String get patchNotesBugFixes => 'Opravy chyb';

@override
String get patchNotesV4_4_2NewFeatures1 => 'Žetony lze nyní vkládat pomocí kopírování a vkládání.';

@override
String get patchNotesV4_4_2NewFeatures2 => 'Přidána podpora galerie pro skenování QR kódů.';

@override
String get patchNotesV4_4_2Improvement1 => 'Přidána podpora svítilny pro skenování QR kódů.';

@override
String get patchNotesV4_4_0NewFeatures1 => 'Nyní je možné exportovat tokeny, u kterých lze zajistit, že se nejedná o tokeny privacyIDEA. V současné době nelze vyloučit, že tokeny přidané prostřednictvím čtečky QR kódů pocházejí z aplikace privacyIDEA. Rozlišování bude v budoucích verzích vylepšeno.';

Expand Down
9 changes: 9 additions & 0 deletions lib/l10n/app_localizations_de.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ class AppLocalizationsDe extends AppLocalizations {
@override
String get patchNotesBugFixes => 'Fehlerbehebungen';

@override
String get patchNotesV4_4_2NewFeatures1 => 'Token können jetzt per Copy & Paste eingefügt werden.';

@override
String get patchNotesV4_4_2NewFeatures2 => 'Galerie-Unterstützung für das Scannen von QR-Codes hinzugefügt.';

@override
String get patchNotesV4_4_2Improvement1 => 'Taschenlampenunterstützung für das Scannen von QR-Codes wurde zugefügt.';

@override
String get patchNotesV4_4_0NewFeatures1 => 'Es ist nun möglich, Token zu exportieren, bei denen sichergestellt werden kann, dass es sich nicht um privacyIDEA Token handelt. Derzeit kann nicht ausgeschlossen werden, dass über den QR-Code-Scanner hinzugefügte Token von privacyIDEA stammen. Die Differenzierung wird in zukünftigen Versionen verbessert.';

Expand Down
9 changes: 9 additions & 0 deletions lib/l10n/app_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get patchNotesBugFixes => 'Bug fixes';

@override
String get patchNotesV4_4_2NewFeatures1 => 'Tokens can now be inserted using copy & paste.';

@override
String get patchNotesV4_4_2NewFeatures2 => 'Added gallery support for QR code scanning.';

@override
String get patchNotesV4_4_2Improvement1 => 'Added flashlight support for QR code scanning.';

@override
String get patchNotesV4_4_0NewFeatures1 => 'It is now possible to export tokens where it can be ensured that they are not privacyIDEA tokens. Currently, it cannot be ruled out that tokens added via the QR code scanner originate from privacyIDEA. The differentiation will be improved in future versions.';

Expand Down
9 changes: 9 additions & 0 deletions lib/l10n/app_localizations_es.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ class AppLocalizationsEs extends AppLocalizations {
@override
String get patchNotesBugFixes => 'Corrección de errores';

@override
String get patchNotesV4_4_2NewFeatures1 => 'Ahora es posible insertar tokens copiando y pegando.';

@override
String get patchNotesV4_4_2NewFeatures2 => 'Añadido soporte de galería para el escaneo de códigos QR.';

@override
String get patchNotesV4_4_2Improvement1 => 'Añadido soporte linterna para el escaneo de códigos QR.';

@override
String get patchNotesV4_4_0NewFeatures1 => 'Ahora es posible exportar tokens cuando se puede garantizar que no son tokens de privacyIDEA. Actualmente, no se puede descartar que los tokens añadidos a través del escáner de código QR procedan de privacyIDEA. La diferenciación se mejorará en futuras versiones.';

Expand Down
9 changes: 9 additions & 0 deletions lib/l10n/app_localizations_fr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ class AppLocalizationsFr extends AppLocalizations {
@override
String get patchNotesBugFixes => 'Bug fixes';

@override
String get patchNotesV4_4_2NewFeatures1 => 'Les jetons peuvent désormais être insérés par copier-coller.';

@override
String get patchNotesV4_4_2NewFeatures2 => 'Ajout de la prise en charge de la galerie pour la lecture des codes QR.';

@override
String get patchNotesV4_4_2Improvement1 => 'Ajout de la prise en charge de la lampe de poche pour la lecture des codes QR.';

@override
String get patchNotesV4_4_0NewFeatures1 => 'Il est désormais possible d\'exporter des jetons dont on peut s\'assurer qu\'il ne s\'agit pas de jetons privacyIDEA. Actuellement, il n\'est pas possible d\'exclure que des jetons ajoutés via le lecteur de code QR proviennent de privacyIDEA. La différenciation sera améliorée dans les versions futures.';

Expand Down
9 changes: 9 additions & 0 deletions lib/l10n/app_localizations_nl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ class AppLocalizationsNl extends AppLocalizations {
@override
String get patchNotesBugFixes => 'Bugfixes';

@override
String get patchNotesV4_4_2NewFeatures1 => 'Tokens kunnen nu worden ingevoegd met kopiëren en plakken.';

@override
String get patchNotesV4_4_2NewFeatures2 => 'Galerijondersteuning toegevoegd voor QR-code scannen.';

@override
String get patchNotesV4_4_2Improvement1 => 'Zaklampondersteuning toegevoegd voor QR-code scannen.';

@override
String get patchNotesV4_4_0NewFeatures1 => 'Het is nu mogelijk om tokens te exporteren waarvan kan worden gegarandeerd dat het geen privacyIDEA tokens zijn. Op dit moment kan niet worden uitgesloten dat tokens die zijn toegevoegd via de QR-code scanner afkomstig zijn van privacyIDEA. De differentiatie zal in toekomstige versies worden verbeterd.';

Expand Down
9 changes: 9 additions & 0 deletions lib/l10n/app_localizations_pl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ class AppLocalizationsPl extends AppLocalizations {
@override
String get patchNotesBugFixes => 'Poprawki błędów';

@override
String get patchNotesV4_4_2NewFeatures1 => 'Tokeny można teraz wstawiać za pomocą funkcji kopiuj i wklej.';

@override
String get patchNotesV4_4_2NewFeatures2 => 'Dodano obsługę galerii dla skanowania kodów QR.';

@override
String get patchNotesV4_4_2Improvement1 => 'Dodano obsługę latarki dla skanowania kodów QR.';

@override
String get patchNotesV4_4_0NewFeatures1 => 'Możliwe jest teraz eksportowanie tokenów, w przypadku których można upewnić się, że nie są to tokeny privacyIDEA. Obecnie nie można wykluczyć, że tokeny dodane za pomocą skanera kodów QR pochodzą z privacyIDEA. Rozróżnienie to zostanie poprawione w przyszłych wersjach';

Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_nl.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"patchNotesNewFeatures": "Nieuwe functies",
"patchNotesImprovements": "Verbeteringen",
"patchNotesBugFixes": "Bugfixes",
"patchNotesV4_4_2NewFeatures1": "Tokens kunnen nu worden ingevoegd met kopiëren en plakken.",
"patchNotesV4_4_2NewFeatures2": "Galerijondersteuning toegevoegd voor QR-code scannen.",
"patchNotesV4_4_2Improvement1": "Zaklampondersteuning toegevoegd voor QR-code scannen.",
"patchNotesV4_4_0NewFeatures1": "Het is nu mogelijk om tokens te exporteren waarvan kan worden gegarandeerd dat het geen privacyIDEA tokens zijn. Op dit moment kan niet worden uitgesloten dat tokens die zijn toegevoegd via de QR-code scanner afkomstig zijn van privacyIDEA. De differentiatie zal in toekomstige versies worden verbeterd.",
"patchNotesV4_4_0NewFeatures2": "Ondersteuning toegevoegd voor privacyIDEA's \"require presence\".",
"patchNotesV4_4_0Improvement1": "Er zijn meer invoerbronnen toegevoegd.",
Expand Down
3 changes: 3 additions & 0 deletions lib/l10n/app_pl.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"patchNotesNewFeatures": "Nowe funkcje",
"patchNotesImprovements": "Ulepszenia",
"patchNotesBugFixes": "Poprawki błędów",
"patchNotesV4_4_2NewFeatures1": "Tokeny można teraz wstawiać za pomocą funkcji kopiuj i wklej.",
"patchNotesV4_4_2NewFeatures2": "Dodano obsługę galerii dla skanowania kodów QR.",
"patchNotesV4_4_2Improvement1": "Dodano obsługę latarki dla skanowania kodów QR.",
"patchNotesV4_4_0NewFeatures1": "Możliwe jest teraz eksportowanie tokenów, w przypadku których można upewnić się, że nie są to tokeny privacyIDEA. Obecnie nie można wykluczyć, że tokeny dodane za pomocą skanera kodów QR pochodzą z privacyIDEA. Rozróżnienie to zostanie poprawione w przyszłych wersjach",
"patchNotesV4_4_0NewFeatures2": "Dodano obsługę funkcji privacyIDEA \"require presence\".",
"patchNotesV4_4_0Improvement1": "Dodano kolejne źródła importu.",
Expand Down
35 changes: 22 additions & 13 deletions lib/utils/globals.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,13 @@ import '../model/enums/patch_note_type.dart';
import '../model/version.dart';

Map<Version, Map<PatchNoteType, List<String>>> getLocalizedPatchNotes(AppLocalizations localizations) => {
const Version(4, 3, 0): {
const Version(4, 4, 2): {
PatchNoteType.newFeature: [
localizations.patchNotesV4_3_0NewFeatures1,
localizations.patchNotesV4_3_0NewFeatures2,
localizations.patchNotesV4_3_0NewFeatures3,
localizations.patchNotesV4_3_0NewFeatures4,
localizations.patchNotesV4_3_0NewFeatures5,
localizations.patchNotesV4_3_0NewFeatures6,
],
},
const Version(4, 3, 1): {
PatchNoteType.bugFix: [
localizations.patchNotesV4_3_1BugFix1,
localizations.patchNotesV4_4_2NewFeatures1,
localizations.patchNotesV4_4_2NewFeatures2,
],
PatchNoteType.improvement: [
localizations.patchNotesV4_3_1Improvement1,
localizations.patchNotesV4_4_2Improvement1,
]
},
const Version(4, 4, 0): {
Expand All @@ -55,6 +46,24 @@ Map<Version, Map<PatchNoteType, List<String>>> getLocalizedPatchNotes(AppLocaliz
localizations.patchNotesV4_4_0Improvement2,
]
},
const Version(4, 3, 1): {
PatchNoteType.bugFix: [
localizations.patchNotesV4_3_1BugFix1,
],
PatchNoteType.improvement: [
localizations.patchNotesV4_3_1Improvement1,
]
},
const Version(4, 3, 0): {
PatchNoteType.newFeature: [
localizations.patchNotesV4_3_0NewFeatures1,
localizations.patchNotesV4_3_0NewFeatures2,
localizations.patchNotesV4_3_0NewFeatures3,
localizations.patchNotesV4_3_0NewFeatures4,
localizations.patchNotesV4_3_0NewFeatures5,
localizations.patchNotesV4_3_0NewFeatures6,
],
},
};

final globalSnackbarKey = GlobalKey<ScaffoldMessengerState>();
Expand Down
93 changes: 42 additions & 51 deletions lib/views/qr_scanner_view/qr_scanner_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Authors: Timo Sturm <[email protected]>
Frank Merkel <[email protected]>
Copyright (c) 2017-2023 NetKnights GmbH
Copyright (c) 2017-2024 NetKnights GmbH

Licensed under the Apache License, Version 2.0 (the 'License');
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -58,58 +58,49 @@ class _QRScannerViewState extends State<QRScannerView> {
PermissionStatus? _cameraPermission;

@override
Widget build(BuildContext context) {
return FutureBuilder<PermissionStatus>(
future: Future<PermissionStatus>(() async => _cameraPermission ?? await _requestCameraPermission()),
builder: (context, isGranted) {
if (isGranted.connectionState != ConnectionState.done) return const Center(child: CircularProgressIndicator());
if (isGranted.data == PermissionStatus.permanentlyDenied) {
return DefaultDialog(
title: Text(AppLocalizations.of(context)!.grantCameraPermissionDialogTitle),
content: Text(AppLocalizations.of(context)!.grantCameraPermissionDialogPermanentlyDenied),
);
}
if (isGranted.data != PermissionStatus.granted) {
return DefaultDialog(
title: Text(AppLocalizations.of(context)!.grantCameraPermissionDialogTitle),
content: Text(AppLocalizations.of(context)!.grantCameraPermissionDialogContent),
actions: [
DefaultDialogButton(
child: Text(AppLocalizations.of(context)!.grantCameraPermissionDialogButton),
onPressed: () async {
//Trigger the permission to request it
final cameraPermission = await _requestCameraPermission();
setState(() => _cameraPermission = cameraPermission);
},
Widget build(BuildContext context) => FutureBuilder<PermissionStatus>(
future: Future<PermissionStatus>(() async => _cameraPermission ?? await _requestCameraPermission()),
builder: (context, isGranted) {
if (isGranted.connectionState != ConnectionState.done) return const Center(child: CircularProgressIndicator());
return switch (isGranted.data) {
PermissionStatus.permanentlyDenied => DefaultDialog(
title: Text(AppLocalizations.of(context)!.grantCameraPermissionDialogTitle),
content: Text(AppLocalizations.of(context)!.grantCameraPermissionDialogPermanentlyDenied),
),
DefaultDialogButton(
child: Text(AppLocalizations.of(context)!.cancel),
onPressed: () {
Navigator.pop(context, null);
},
),
],
);
}
return SafeArea(
child: Stack(
children: [
const QRScannerWidget(),
Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent,
appBar: AppBar(
PermissionStatus.granted => SafeArea(
child: Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent,
foregroundColor: Colors.white,
elevation: 0,
appBar: AppBar(
backgroundColor: Colors.transparent,
foregroundColor: Colors.white,
elevation: 0,
),
extendBodyBehindAppBar: true,
body: const QRScannerWidget(),
),
extendBodyBehindAppBar: true,
body: const SizedBox(),
),
],
),
);
},
);
}
_ => DefaultDialog(
title: Text(AppLocalizations.of(context)!.grantCameraPermissionDialogTitle),
content: Text(AppLocalizations.of(context)!.grantCameraPermissionDialogContent),
actions: [
DefaultDialogButton(
child: Text(AppLocalizations.of(context)!.grantCameraPermissionDialogButton),
onPressed: () async {
//Trigger the permission to request it
final cameraPermission = await _requestCameraPermission();
setState(() => _cameraPermission = cameraPermission);
},
),
DefaultDialogButton(
child: Text(AppLocalizations.of(context)!.cancel),
onPressed: () {
Navigator.pop(context, null);
},
),
],
),
};
},
);
}
Loading
Loading