various bugs fixed

This commit is contained in:
Craig Raw 2020-08-06 09:23:45 +02:00
parent 53478d9b22
commit 2a6a296cf3
7 changed files with 42 additions and 14 deletions

View file

@ -20,6 +20,7 @@ public class SeedDisplayDialog extends Dialog<Void> {
AnchorPane anchorPane = new AnchorPane();
ScrollPane scrollPane = new ScrollPane();
scrollPane.getStyleClass().add("edge-to-edge");
scrollPane.setPrefHeight(74 + height);
scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
@ -32,6 +33,7 @@ public class SeedDisplayDialog extends Dialog<Void> {
scrollPane.setContent(keystoreAccordion);
MnemonicKeystoreImportPane keystorePane = new MnemonicKeystoreImportPane(decryptedKeystore);
keystorePane.setAnimated(false);
keystoreAccordion.getPanes().add(keystorePane);
stackPane.getChildren().addAll(anchorPane);

View file

@ -52,7 +52,7 @@ public class WalletNameDialog extends Dialog<String> {
dialogPane.getButtonTypes().addAll(okButtonType);
Button okButton = (Button) dialogPane.lookupButton(okButtonType);
BooleanBinding isInvalid = Bindings.createBooleanBinding(() ->
name.getText().length() == 0 || Storage.getWalletFile(name.getText()).exists(), name.textProperty());
name.getText().length() == 0 || Storage.walletExists(name.getText()), name.textProperty());
okButton.disableProperty().bind(isInvalid);
name.setPromptText("Wallet Name");

View file

@ -46,7 +46,6 @@ public class Storage {
public Storage(File walletFile) {
this.walletFile = walletFile;
this.gson = getGson();
this.encryptionPubKey = NO_PASSWORD_KEY;
}
public File getWalletFile() {

View file

@ -436,9 +436,9 @@ public class HeadersController extends TransactionFormController implements Init
blockchainForm.setVisible(true);
if(currentHeight == null) {
blockStatus.setText(blockTransaction.getBlockHash() == null ? "Unconfirmed" : "Confirmed");
blockStatus.setText(blockTransaction.getHeight() > 0 ? "Confirmed" : "Unconfirmed");
} else {
int confirmations = blockTransaction.getBlockHash() == null ? 0 : currentHeight - blockTransaction.getHeight() + 1;
int confirmations = blockTransaction.getHeight() > 0 ? currentHeight - blockTransaction.getHeight() + 1 : 0;
if(confirmations == 0) {
blockStatus.setText("Unconfirmed");
} else if(confirmations == 1) {

View file

@ -15,6 +15,7 @@ import com.sparrowwallet.sparrow.control.WalletPasswordDialog;
import com.sparrowwallet.sparrow.event.StorageEvent;
import com.sparrowwallet.sparrow.event.TimedEvent;
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5;
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5Brands;
import com.sparrowwallet.sparrow.io.Storage;
import com.sparrowwallet.sparrow.keystoreimport.KeystoreImportDialog;
import com.sparrowwallet.sparrow.event.SettingsChangedEvent;
@ -48,6 +49,9 @@ public class KeystoreController extends WalletFormController implements Initiali
@FXML
private Label type;
@FXML
private Button viewSeedButton;
@FXML
private Button importButton;
@ -84,6 +88,8 @@ public class KeystoreController extends WalletFormController implements Initiali
selectSourcePane.setVisible(false);
}
viewSeedButton.managedProperty().bind(viewSeedButton.visibleProperty());
updateType();
label.setText(keystore.getLabel());
@ -170,15 +176,10 @@ public class KeystoreController extends WalletFormController implements Initiali
private void updateType() {
type.setText(getTypeLabel(keystore));
if(keystore.getSource() == KeystoreSource.SW_SEED) {
Glyph searchGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.EYE);
searchGlyph.setFontSize(12);
type.setGraphic(searchGlyph);
} else {
type.setGraphic(null);
}
type.setGraphic(getTypeIcon(keystore));
viewSeedButton.setVisible(keystore.getSource() == KeystoreSource.SW_SEED);
importButton.setText(keystore.getSource() == KeystoreSource.SW_WATCH ? "Import..." : "Edit...");
importButton.setText(keystore.getSource() == KeystoreSource.SW_WATCH ? "Import..." : "Replace...");
boolean editable = (keystore.getSource() == KeystoreSource.SW_WATCH);
fingerprint.setEditable(editable);
@ -200,6 +201,20 @@ public class KeystoreController extends WalletFormController implements Initiali
}
}
private Glyph getTypeIcon(Keystore keystore) {
switch (keystore.getSource()) {
case HW_USB:
return new Glyph(FontAwesome5Brands.FONT_NAME, FontAwesome5Brands.Glyph.USB);
case HW_AIRGAPPED:
return new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.SD_CARD);
case SW_SEED:
return new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.LAPTOP);
case SW_WATCH:
default:
return new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.EYE);
}
}
public void importKeystore(ActionEvent event) {
KeystoreSource initialSource = keystore.getSource();
if(initialSource == null || !KeystoreImportDialog.getSupportedSources().contains(initialSource)) {
@ -232,7 +247,7 @@ public class KeystoreController extends WalletFormController implements Initiali
}
}
public void showSeed(MouseEvent event) {
public void showSeed(ActionEvent event) {
int keystoreIndex = getWalletForm().getWallet().getKeystores().indexOf(keystore);
Wallet copy = getWalletForm().getWallet().copy();

View file

@ -16,3 +16,7 @@
#fingerprint, #derivation, #xpub {
-fx-font-family: Courier;
}
#type {
-fx-padding: 0 17 0 0;
}

View file

@ -20,7 +20,15 @@
<Form fx:id="keystoreForm" GridPane.columnIndex="0" GridPane.rowIndex="0">
<Fieldset inputGrow="SOMETIMES" text="">
<Field text="Type:">
<Label fx:id="type" contentDisplay="RIGHT" graphicTextGap="5" onMouseClicked="#showSeed"/>
<Label fx:id="type" graphicTextGap="8"/>
<Button fx:id="viewSeedButton" onAction="#showSeed">
<graphic>
<Glyph fontFamily="Font Awesome 5 Free Solid" fontSize="12" icon="KEY" />
</graphic>
<tooltip>
<Tooltip text="View Seed..."/>
</tooltip>
</Button>
<Pane HBox.hgrow="ALWAYS" />
<Button fx:id="importButton" text="Import..." onAction="#importKeystore"/>
</Field>