mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-23 18:22:39 +03:00
Merge PR #1373.
This commit is contained in:
commit
02a3bc3a57
@ -19,15 +19,14 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../android/app_methods.dart';
|
||||
import '../../android/qr_scanner/qr_scanner_provider.dart';
|
||||
import '../../android/state.dart';
|
||||
import '../../core/state.dart';
|
||||
import '../../exception/cancellation_exception.dart';
|
||||
import '../../fido/views/fingerprints_screen.dart';
|
||||
import '../../fido/views/passkeys_screen.dart';
|
||||
import '../../fido/views/webauthn_page.dart';
|
||||
import '../../management/views/management_screen.dart';
|
||||
import '../../oath/views/oath_screen.dart';
|
||||
import '../../oath/views/utils.dart';
|
||||
import '../../otp/views/otp_screen.dart';
|
||||
import '../../piv/views/piv_screen.dart';
|
||||
import '../../widgets/custom_icons.dart';
|
||||
@ -102,22 +101,7 @@ class MainPage extends ConsumerWidget {
|
||||
icon: const Icon(Icons.person_add_alt_1),
|
||||
tooltip: l10n.s_add_account,
|
||||
onPressed: () async {
|
||||
final withContext = ref.read(withContextProvider);
|
||||
final qrScanner = ref.read(qrScannerProvider);
|
||||
if (qrScanner != null) {
|
||||
try {
|
||||
final qrData = await qrScanner.scanQr();
|
||||
await AndroidQrScanner.handleScannedData(
|
||||
qrData, withContext, qrScanner, l10n);
|
||||
} on CancellationException catch (_) {
|
||||
// ignored - user cancelled
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// no QR scanner - enter data manually
|
||||
await AndroidQrScanner.showAccountManualEntryDialog(
|
||||
withContext, l10n);
|
||||
}
|
||||
await addOathAccount(context, ref);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
@ -207,6 +207,7 @@ extension on OathCredential {
|
||||
}
|
||||
|
||||
const String _steamCharTable = '23456789BCDFGHJKMNPQRTVWXY';
|
||||
|
||||
String _formatSteam(String response) {
|
||||
final offset = int.parse(response.substring(response.length - 1), radix: 16);
|
||||
var number =
|
||||
@ -225,6 +226,7 @@ class DesktopCredentialListNotifier extends OathCredentialListNotifier {
|
||||
final RpcNodeSession _session;
|
||||
final bool _locked;
|
||||
Timer? _timer;
|
||||
|
||||
DesktopCredentialListNotifier(this._withContext, this._session, this._locked)
|
||||
: super();
|
||||
|
||||
|
@ -18,18 +18,16 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../android/qr_scanner/qr_scanner_provider.dart';
|
||||
import '../../app/message.dart';
|
||||
import '../../app/models.dart';
|
||||
import '../../app/state.dart';
|
||||
import '../../app/views/action_list.dart';
|
||||
import '../../core/state.dart';
|
||||
import '../features.dart' as features;
|
||||
import '../icon_provider/icon_pack_dialog.dart';
|
||||
import '../keys.dart' as keys;
|
||||
import '../models.dart';
|
||||
import 'add_account_dialog.dart';
|
||||
import 'manage_password_dialog.dart';
|
||||
import 'utils.dart';
|
||||
|
||||
Widget oathBuildActions(
|
||||
BuildContext context,
|
||||
@ -58,25 +56,7 @@ Widget oathBuildActions(
|
||||
onTap: used != null && (capacity == null || capacity > used)
|
||||
? (context) async {
|
||||
Navigator.of(context).popUntil((route) => route.isFirst);
|
||||
if (isAndroid) {
|
||||
final withContext = ref.read(withContextProvider);
|
||||
final qrScanner = ref.read(qrScannerProvider);
|
||||
if (qrScanner != null) {
|
||||
final qrData = await qrScanner.scanQr();
|
||||
await AndroidQrScanner.handleScannedData(
|
||||
qrData, withContext, qrScanner, l10n);
|
||||
} else {
|
||||
// no QR scanner - enter data manually
|
||||
await AndroidQrScanner.showAccountManualEntryDialog(
|
||||
withContext, l10n);
|
||||
}
|
||||
} else {
|
||||
await showBlurDialog(
|
||||
context: context,
|
||||
builder: (context) =>
|
||||
AddAccountDialog(devicePath, oathState),
|
||||
);
|
||||
}
|
||||
await addOathAccount(context, ref, devicePath, oathState);
|
||||
}
|
||||
: null),
|
||||
]),
|
||||
|
@ -44,7 +44,6 @@ import 'account_dialog.dart';
|
||||
import 'account_helper.dart';
|
||||
import 'account_list.dart';
|
||||
import 'actions.dart';
|
||||
import 'add_account_dialog.dart';
|
||||
import 'key_actions.dart';
|
||||
import 'unlock_form.dart';
|
||||
import 'utils.dart';
|
||||
@ -164,12 +163,11 @@ class _UnlockedViewState extends ConsumerState<_UnlockedView> {
|
||||
ActionChip(
|
||||
label: Text(l10n.s_add_account),
|
||||
onPressed: () async {
|
||||
await showBlurDialog(
|
||||
context: context,
|
||||
builder: (context) => AddAccountDialog(
|
||||
await addOathAccount(
|
||||
context,
|
||||
ref,
|
||||
widget.devicePath,
|
||||
widget.oathState,
|
||||
),
|
||||
);
|
||||
},
|
||||
avatar: const Icon(Icons.person_add_alt_1_outlined),
|
||||
|
@ -20,14 +20,19 @@ import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
import '../../android/qr_scanner/qr_scanner_provider.dart';
|
||||
import '../../app/message.dart';
|
||||
import '../../app/models.dart';
|
||||
import '../../app/state.dart';
|
||||
import '../../core/state.dart';
|
||||
import '../../desktop/models.dart';
|
||||
import '../../exception/cancellation_exception.dart';
|
||||
import '../../widgets/utf8_utils.dart';
|
||||
import '../keys.dart';
|
||||
import '../models.dart';
|
||||
import 'add_account_dialog.dart';
|
||||
import 'add_account_page.dart';
|
||||
import 'add_multi_account_page.dart';
|
||||
|
||||
@ -146,3 +151,30 @@ Future<String?> handleQrFile(File file, BuildContext context,
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> addOathAccount(BuildContext context, WidgetRef ref,
|
||||
[DevicePath? devicePath, OathState? oathState]) async {
|
||||
if (isAndroid) {
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
final withContext = ref.read(withContextProvider);
|
||||
final qrScanner = ref.read(qrScannerProvider);
|
||||
if (qrScanner != null) {
|
||||
try {
|
||||
final qrData = await qrScanner.scanQr();
|
||||
await AndroidQrScanner.handleScannedData(
|
||||
qrData, withContext, qrScanner, l10n);
|
||||
} on CancellationException catch (_) {
|
||||
//ignored - user cancelled
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// no QR scanner - enter data manually
|
||||
await AndroidQrScanner.showAccountManualEntryDialog(withContext, l10n);
|
||||
}
|
||||
} else {
|
||||
await showBlurDialog(
|
||||
context: context,
|
||||
builder: (context) => AddAccountDialog(devicePath, oathState),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user