This commit is contained in:
Adam Velebil 2023-08-31 15:32:31 +02:00
commit 9c1c00adcc
No known key found for this signature in database
GPG Key ID: C9B1E4A3CBBD2E10
3 changed files with 45 additions and 9 deletions

View File

@ -44,12 +44,15 @@ class QRScannerUI extends StatelessWidget {
screenSize.height + scannerAreaWidth / 2.0 + 8.0), screenSize.height + scannerAreaWidth / 2.0 + 8.0),
width: screenSize.width, width: screenSize.width,
height: screenSize.height), height: screenSize.height),
child: Text( child: Padding(
status != ScanStatus.error padding: const EdgeInsets.all(4.0),
? l10n.l_point_camera_scan child: Text(
: l10n.l_invalid_qr, status != ScanStatus.error
style: const TextStyle(color: Colors.white), ? l10n.l_point_camera_scan
textAlign: TextAlign.center, : l10n.l_invalid_qr,
style: const TextStyle(color: Colors.white),
textAlign: TextAlign.center,
),
), ),
), ),

View File

@ -19,6 +19,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../../android/state.dart';
import '../../core/state.dart'; import '../../core/state.dart';
import '../../management/models.dart'; import '../../management/models.dart';
import '../models.dart'; import '../models.dart';
@ -118,6 +119,26 @@ class DevicePickerContent extends ConsumerWidget {
final showUsb = isDesktop && devices.whereType<UsbYubiKeyNode>().isEmpty; final showUsb = isDesktop && devices.whereType<UsbYubiKeyNode>().isEmpty;
Widget? androidNoKeyWidget;
if (isAndroid && devices.isEmpty) {
var hasNfcSupport = ref.watch(androidNfcSupportProvider);
var isNfcEnabled = ref.watch(androidNfcStateProvider);
final subtitle = hasNfcSupport && isNfcEnabled
? l10n.l_insert_or_tap_yk
: l10n.l_insert_yk;
androidNoKeyWidget = _DeviceRow(
leading: const DeviceAvatar(child: Icon(Icons.usb)),
title: l10n.l_no_yk_present,
subtitle: subtitle,
onTap: () {
ref.read(currentDeviceProvider.notifier).setCurrentDevice(null);
},
selected: currentNode == null,
extended: extended,
);
}
List<Widget> children = [ List<Widget> children = [
if (showUsb) if (showUsb)
_DeviceRow( _DeviceRow(
@ -130,6 +151,8 @@ class DevicePickerContent extends ConsumerWidget {
selected: currentNode == null, selected: currentNode == null,
extended: extended, extended: extended,
), ),
if (androidNoKeyWidget != null)
androidNoKeyWidget,
...devices.map( ...devices.map(
(e) => e.path == currentNode?.path (e) => e.path == currentNode?.path
? _buildCurrentDeviceRow( ? _buildCurrentDeviceRow(

View File

@ -20,11 +20,11 @@ import 'dart:io';
import 'package:archive/archive.dart'; import 'package:archive/archive.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:io/io.dart';
import 'package:logging/logging.dart'; import 'package:logging/logging.dart';
import 'package:path/path.dart'; import 'package:path/path.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
import 'package:yubico_authenticator/app/logging.dart'; import 'package:yubico_authenticator/app/logging.dart';
import 'package:io/io.dart';
import 'icon_cache.dart'; import 'icon_cache.dart';
import 'icon_pack.dart'; import 'icon_pack.dart';
@ -116,7 +116,16 @@ class IconPackManager extends StateNotifier<AsyncValue<IconPack?>> {
final unpackDirectory = Directory(join(tempDirectory.path, 'unpack')); final unpackDirectory = Directory(join(tempDirectory.path, 'unpack'));
final archive = ZipDecoder().decodeBytes(bytes, verify: true); Archive archive;
try {
archive = ZipDecoder().decodeBytes(bytes, verify: true);
} on Exception catch (_) {
_log.error('File is not an icon pack: zip decoding failed');
_lastError = l10n.l_invalid_icon_pack;
state = AsyncValue.error('File is not an icon pack', StackTrace.current);
return false;
}
for (final file in archive) { for (final file in archive) {
final filename = file.name; final filename = file.name;
if (file.size > 0) { if (file.size > 0) {
@ -172,7 +181,8 @@ class IconPackManager extends StateNotifier<AsyncValue<IconPack?>> {
} catch (e) { } catch (e) {
_log.error('Failed to copy icon pack files to destination: $e'); _log.error('Failed to copy icon pack files to destination: $e');
_lastError = l10n.l_icon_pack_copy_failed; _lastError = l10n.l_icon_pack_copy_failed;
state = AsyncValue.error('Failed to copy icon pack files.', StackTrace.current); state = AsyncValue.error(
'Failed to copy icon pack files.', StackTrace.current);
return false; return false;
} }