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),
width: screenSize.width,
height: screenSize.height),
child: Text(
status != ScanStatus.error
? l10n.l_point_camera_scan
: l10n.l_invalid_qr,
style: const TextStyle(color: Colors.white),
textAlign: TextAlign.center,
child: Padding(
padding: const EdgeInsets.all(4.0),
child: Text(
status != ScanStatus.error
? l10n.l_point_camera_scan
: 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:flutter_gen/gen_l10n/app_localizations.dart';
import '../../android/state.dart';
import '../../core/state.dart';
import '../../management/models.dart';
import '../models.dart';
@ -118,6 +119,26 @@ class DevicePickerContent extends ConsumerWidget {
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 = [
if (showUsb)
_DeviceRow(
@ -130,6 +151,8 @@ class DevicePickerContent extends ConsumerWidget {
selected: currentNode == null,
extended: extended,
),
if (androidNoKeyWidget != null)
androidNoKeyWidget,
...devices.map(
(e) => e.path == currentNode?.path
? _buildCurrentDeviceRow(

View File

@ -20,11 +20,11 @@ import 'dart:io';
import 'package:archive/archive.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:io/io.dart';
import 'package:logging/logging.dart';
import 'package:path/path.dart';
import 'package:path_provider/path_provider.dart';
import 'package:yubico_authenticator/app/logging.dart';
import 'package:io/io.dart';
import 'icon_cache.dart';
import 'icon_pack.dart';
@ -116,7 +116,16 @@ class IconPackManager extends StateNotifier<AsyncValue<IconPack?>> {
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) {
final filename = file.name;
if (file.size > 0) {
@ -172,7 +181,8 @@ class IconPackManager extends StateNotifier<AsyncValue<IconPack?>> {
} catch (e) {
_log.error('Failed to copy icon pack files to destination: $e');
_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;
}