mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-22 16:32:01 +03:00
Merge PR #1098.
This commit is contained in:
commit
23316ab7c0
@ -154,18 +154,17 @@ class MainActivity : FlutterFragmentActivity() {
|
|||||||
@SuppressLint("WrongConstant")
|
@SuppressLint("WrongConstant")
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
val receiverFlags = ContextCompat.RECEIVER_NOT_EXPORTED
|
|
||||||
ContextCompat.registerReceiver(
|
ContextCompat.registerReceiver(
|
||||||
this,
|
this,
|
||||||
qrScannerCameraClosedBR,
|
qrScannerCameraClosedBR,
|
||||||
QRScannerCameraClosedBR.intentFilter,
|
QRScannerCameraClosedBR.intentFilter,
|
||||||
receiverFlags
|
ContextCompat.RECEIVER_NOT_EXPORTED
|
||||||
)
|
)
|
||||||
ContextCompat.registerReceiver(
|
ContextCompat.registerReceiver(
|
||||||
this,
|
this,
|
||||||
nfcAdapterStateChangeBR,
|
nfcAdapterStateChangeBR,
|
||||||
NfcAdapterStateChangedBR.intentFilter,
|
NfcAdapterStateChangedBR.intentFilter,
|
||||||
receiverFlags
|
ContextCompat.RECEIVER_EXPORTED
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,11 +328,15 @@ class MainActivity : FlutterFragmentActivity() {
|
|||||||
* this receiver restarts the YubiKit NFC discovery when the QR Scanner camera is closed.
|
* this receiver restarts the YubiKit NFC discovery when the QR Scanner camera is closed.
|
||||||
*/
|
*/
|
||||||
class QRScannerCameraClosedBR : BroadcastReceiver() {
|
class QRScannerCameraClosedBR : BroadcastReceiver() {
|
||||||
|
|
||||||
|
private val logger = LoggerFactory.getLogger(QRScannerCameraClosedBR::class.java)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val intentFilter = IntentFilter("com.yubico.authenticator.QRScannerView.CameraClosed")
|
val intentFilter = IntentFilter("com.yubico.authenticator.QRScannerView.CameraClosed")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onReceive(context: Context?, intent: Intent?) {
|
override fun onReceive(context: Context?, intent: Intent?) {
|
||||||
|
logger.debug("Restarting nfc discovery after camera was closed.")
|
||||||
(context as? MainActivity)?.startNfcDiscovery()
|
(context as? MainActivity)?.startNfcDiscovery()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Yubico.
|
* Copyright (C) 2022-2023 Yubico.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -37,6 +37,7 @@ import '../../desktop/models.dart';
|
|||||||
import '../../management/models.dart';
|
import '../../management/models.dart';
|
||||||
import '../../widgets/choice_filter_chip.dart';
|
import '../../widgets/choice_filter_chip.dart';
|
||||||
import '../../widgets/file_drop_target.dart';
|
import '../../widgets/file_drop_target.dart';
|
||||||
|
import '../../widgets/focus_utils.dart';
|
||||||
import '../../widgets/responsive_dialog.dart';
|
import '../../widgets/responsive_dialog.dart';
|
||||||
import '../../widgets/utf8_utils.dart';
|
import '../../widgets/utf8_utils.dart';
|
||||||
import '../keys.dart' as keys;
|
import '../keys.dart' as keys;
|
||||||
@ -175,6 +176,9 @@ class _OathAddAccountPageState extends ConsumerState<OathAddAccountPage> {
|
|||||||
{DevicePath? devicePath, required Uri credUri}) async {
|
{DevicePath? devicePath, required Uri credUri}) async {
|
||||||
final l10n = AppLocalizations.of(context)!;
|
final l10n = AppLocalizations.of(context)!;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
FocusUtils.unfocus(context);
|
||||||
|
|
||||||
if (devicePath == null) {
|
if (devicePath == null) {
|
||||||
assert(isAndroid, 'devicePath is only optional for Android');
|
assert(isAndroid, 'devicePath is only optional for Android');
|
||||||
await ref
|
await ref
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Yubico.
|
* Copyright (C) 2022-2023 Yubico.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -20,6 +20,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|||||||
|
|
||||||
import '../../app/message.dart';
|
import '../../app/message.dart';
|
||||||
import '../../app/models.dart';
|
import '../../app/models.dart';
|
||||||
|
import '../../widgets/focus_utils.dart';
|
||||||
import '../../widgets/responsive_dialog.dart';
|
import '../../widgets/responsive_dialog.dart';
|
||||||
import '../models.dart';
|
import '../models.dart';
|
||||||
import '../state.dart';
|
import '../state.dart';
|
||||||
@ -42,6 +43,9 @@ class _ManagePasswordDialogState extends ConsumerState<ManagePasswordDialog> {
|
|||||||
bool _currentIsWrong = false;
|
bool _currentIsWrong = false;
|
||||||
|
|
||||||
_submit() async {
|
_submit() async {
|
||||||
|
|
||||||
|
FocusUtils.unfocus(context);
|
||||||
|
|
||||||
final result = await ref
|
final result = await ref
|
||||||
.read(oathStateProvider(widget.path).notifier)
|
.read(oathStateProvider(widget.path).notifier)
|
||||||
.setPassword(_currentPassword, _newPassword);
|
.setPassword(_currentPassword, _newPassword);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2022 Yubico.
|
* Copyright (C) 2022-2023 Yubico.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -24,6 +24,7 @@ import '../../app/message.dart';
|
|||||||
import '../../app/models.dart';
|
import '../../app/models.dart';
|
||||||
import '../../exception/cancellation_exception.dart';
|
import '../../exception/cancellation_exception.dart';
|
||||||
import '../../desktop/models.dart';
|
import '../../desktop/models.dart';
|
||||||
|
import '../../widgets/focus_utils.dart';
|
||||||
import '../../widgets/responsive_dialog.dart';
|
import '../../widgets/responsive_dialog.dart';
|
||||||
import '../../widgets/utf8_utils.dart';
|
import '../../widgets/utf8_utils.dart';
|
||||||
import '../models.dart';
|
import '../models.dart';
|
||||||
@ -60,6 +61,9 @@ class _RenameAccountDialogState extends ConsumerState<RenameAccountDialog> {
|
|||||||
void _submit() async {
|
void _submit() async {
|
||||||
final l10n = AppLocalizations.of(context)!;
|
final l10n = AppLocalizations.of(context)!;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
FocusUtils.unfocus(context);
|
||||||
|
|
||||||
// Rename credentials
|
// Rename credentials
|
||||||
final renamed = await ref
|
final renamed = await ref
|
||||||
.read(credentialListProvider(widget.device.path).notifier)
|
.read(credentialListProvider(widget.device.path).notifier)
|
||||||
|
18
lib/widgets/focus_utils.dart
Normal file
18
lib/widgets/focus_utils.dart
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:logging/logging.dart';
|
||||||
|
|
||||||
|
import '../app/logging.dart';
|
||||||
|
|
||||||
|
final _log = Logger('FocusUtils');
|
||||||
|
|
||||||
|
class FocusUtils {
|
||||||
|
static void unfocus(BuildContext context) {
|
||||||
|
FocusScopeNode currentFocus = FocusScope.of(context);
|
||||||
|
|
||||||
|
if (!currentFocus.hasPrimaryFocus) {
|
||||||
|
_log.debug('Removing focus...');
|
||||||
|
currentFocus.unfocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user