always show tapsigner in airgapped import options

This commit is contained in:
Craig Raw 2023-04-05 08:24:18 +02:00
parent fe4468d49d
commit 483e4c8f38
2 changed files with 9 additions and 6 deletions

View file

@ -33,6 +33,8 @@ import javax.smartcardio.CardException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
import static com.sparrowwallet.sparrow.io.CardApi.isReaderAvailable;
public class CardImportPane extends TitledDescriptionPane { public class CardImportPane extends TitledDescriptionPane {
private static final Logger log = LoggerFactory.getLogger(CardImportPane.class); private static final Logger log = LoggerFactory.getLogger(CardImportPane.class);
@ -62,6 +64,12 @@ public class CardImportPane extends TitledDescriptionPane {
} }
private void importCard() { private void importCard() {
if(!isReaderAvailable()) {
setError("No reader", "No card reader was detected.");
importButton.setDisable(false);
return;
}
if(pin.get().length() < 6) { if(pin.get().length() < 6) {
setDescription(pin.get().isEmpty() ? "Enter PIN code" : "PIN code too short"); setDescription(pin.get().isEmpty() ? "Enter PIN code" : "PIN code too short");
setContent(getPinEntry()); setContent(getPinEntry());

View file

@ -15,8 +15,6 @@ import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import static com.sparrowwallet.sparrow.io.CardApi.isReaderAvailable;
public class HwAirgappedController extends KeystoreImportDetailController { public class HwAirgappedController extends KeystoreImportDetailController {
private static final Logger log = LoggerFactory.getLogger(HwAirgappedController.class); private static final Logger log = LoggerFactory.getLogger(HwAirgappedController.class);
@ -40,10 +38,7 @@ public class HwAirgappedController extends KeystoreImportDetailController {
} }
} }
List<KeystoreCardImport> cardImporters = Collections.emptyList(); List<KeystoreCardImport> cardImporters = List.of(new Tapsigner());
if(isReaderAvailable()) {
cardImporters = List.of(new Tapsigner());
}
for(KeystoreCardImport importer : cardImporters) { for(KeystoreCardImport importer : cardImporters) {
if(!importer.isDeprecated() || Config.get().isShowDeprecatedImportExport()) { if(!importer.isDeprecated() || Config.get().isShowDeprecatedImportExport()) {
CardImportPane importPane = new CardImportPane(getMasterController().getWallet(), importer, getMasterController().getRequiredDerivation()); CardImportPane importPane = new CardImportPane(getMasterController().getWallet(), importer, getMasterController().getRequiredDerivation());