mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-04 13:26:44 +00:00
null-safe testing of device needspin and needspassphrase
This commit is contained in:
parent
d52bade085
commit
1556b8930c
5 changed files with 16 additions and 8 deletions
|
@ -114,7 +114,7 @@ public abstract class DeviceDialog<R> extends Dialog<R> {
|
|||
|
||||
if(operationFingerprints != null) {
|
||||
dialogDevices.removeIf(device -> {
|
||||
return device.getFingerprint() != null && !operationFingerprints.contains(device.getFingerprint()) && !(device.getNeedsPinSent() || device.getNeedsPassphraseSent());
|
||||
return device.getFingerprint() != null && !operationFingerprints.contains(device.getFingerprint()) && !(device.isNeedsPinSent() || device.isNeedsPassphraseSent());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -144,9 +144,9 @@ public class DevicePane extends TitledDescriptionPane {
|
|||
}
|
||||
|
||||
private void initialise(Device device) {
|
||||
if(device.getNeedsPinSent() != null && device.getNeedsPinSent()) {
|
||||
if(device.isNeedsPinSent()) {
|
||||
unlockButton.setVisible(true);
|
||||
} else if(device.getNeedsPassphraseSent() != null && device.getNeedsPassphraseSent()) {
|
||||
} else if(device.isNeedsPassphraseSent()) {
|
||||
setPassphraseButton.setVisible(true);
|
||||
} else if(device.getError() != null) {
|
||||
setError("Error", device.getError());
|
||||
|
@ -165,7 +165,7 @@ public class DevicePane extends TitledDescriptionPane {
|
|||
}
|
||||
|
||||
private void setDefaultStatus() {
|
||||
setDescription(device.getNeedsPinSent() ? "Locked" : device.getNeedsPassphraseSent() ? "Passphrase Required" : "Unlocked");
|
||||
setDescription(device.isNeedsPinSent() ? "Locked" : device.isNeedsPassphraseSent() ? "Passphrase Required" : "Unlocked");
|
||||
}
|
||||
|
||||
private void createUnlockButton() {
|
||||
|
@ -411,7 +411,7 @@ public class DevicePane extends TitledDescriptionPane {
|
|||
setExpanded(false);
|
||||
unlockButton.setVisible(false);
|
||||
|
||||
if(device.getNeedsPassphraseSent()) {
|
||||
if(device.isNeedsPassphraseSent()) {
|
||||
setPassphraseButton.setVisible(true);
|
||||
setPassphraseButton.setDisable(true);
|
||||
setContent(getPassphraseEntry());
|
||||
|
|
|
@ -22,7 +22,7 @@ public class UsbStatusButton extends MenuButton {
|
|||
public void setDevices(List<Device> devices) {
|
||||
for(Device device : devices) {
|
||||
MenuItem deviceItem = new MenuItem(device.getModel().toDisplayString());
|
||||
if(device.getNeedsPinSent()) {
|
||||
if(device.isNeedsPinSent()) {
|
||||
deviceItem.setGraphic(getLockIcon());
|
||||
} else {
|
||||
deviceItem.setGraphic(getLockOpenIcon());
|
||||
|
|
|
@ -41,6 +41,10 @@ public class Device {
|
|||
return needsPinSent;
|
||||
}
|
||||
|
||||
public Boolean isNeedsPinSent() {
|
||||
return needsPinSent != null && needsPinSent;
|
||||
}
|
||||
|
||||
public void setNeedsPinSent(Boolean needsPinSent) {
|
||||
this.needsPinSent = needsPinSent;
|
||||
}
|
||||
|
@ -49,6 +53,10 @@ public class Device {
|
|||
return needsPassphraseSent;
|
||||
}
|
||||
|
||||
public Boolean isNeedsPassphraseSent() {
|
||||
return needsPassphraseSent != null && needsPassphraseSent;
|
||||
}
|
||||
|
||||
public void setNeedsPassphraseSent(Boolean needsPassphraseSent) {
|
||||
this.needsPassphraseSent = needsPassphraseSent;
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ public class ReceiveController extends WalletFormController implements Initializ
|
|||
|
||||
List<Device> addressDevices = devices.stream().filter(device -> walletFingerprints.contains(device.getFingerprint())).collect(Collectors.toList());
|
||||
if(addressDevices.isEmpty()) {
|
||||
addressDevices = devices.stream().filter(device -> device.getNeedsPinSent() || device.getNeedsPassphraseSent()).collect(Collectors.toList());
|
||||
addressDevices = devices.stream().filter(device -> device.isNeedsPinSent() || device.isNeedsPassphraseSent()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
if(!addressDevices.isEmpty()) {
|
||||
|
@ -198,7 +198,7 @@ public class ReceiveController extends WalletFormController implements Initializ
|
|||
|
||||
List<Device> possibleDevices = (List<Device>)displayAddress.getUserData();
|
||||
if(possibleDevices != null && !possibleDevices.isEmpty()) {
|
||||
if(possibleDevices.size() > 1 || possibleDevices.get(0).getNeedsPinSent() || possibleDevices.get(0).getNeedsPassphraseSent()) {
|
||||
if(possibleDevices.size() > 1 || possibleDevices.get(0).isNeedsPinSent() || possibleDevices.get(0).isNeedsPassphraseSent()) {
|
||||
DeviceAddressDialog dlg = new DeviceAddressDialog(wallet, addressDescriptor);
|
||||
dlg.showAndWait();
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue