diff --git a/drongo b/drongo index 0f008b89..c675e395 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit 0f008b8985253c4fd0025c136d0a23ac3082537f +Subproject commit c675e395dbbf386d2371ac3819b2a4539bf25e95 diff --git a/src/main/java/com/sparrowwallet/sparrow/MainApp.java b/src/main/java/com/sparrowwallet/sparrow/MainApp.java index 8f01bec8..3a5c43d4 100644 --- a/src/main/java/com/sparrowwallet/sparrow/MainApp.java +++ b/src/main/java/com/sparrowwallet/sparrow/MainApp.java @@ -43,7 +43,7 @@ public class MainApp extends Application { KeystoreImportDialog dlg = new KeystoreImportDialog(wallet); dlg.showAndWait(); -// stage.show(); + stage.show(); } public static void main(String[] args) { diff --git a/src/main/java/com/sparrowwallet/sparrow/glyphfont/FontAwesome5.java b/src/main/java/com/sparrowwallet/sparrow/glyphfont/FontAwesome5.java index bed8d015..9cf13995 100644 --- a/src/main/java/com/sparrowwallet/sparrow/glyphfont/FontAwesome5.java +++ b/src/main/java/com/sparrowwallet/sparrow/glyphfont/FontAwesome5.java @@ -17,6 +17,7 @@ public class FontAwesome5 extends GlyphFont { public static enum Glyph implements INamedCharacter { CIRCLE('\uf111'), EXCLAMATION_CIRCLE('\uf06a'), + EYE('\uf06e'), LAPTOP('\uf109'), SD_CARD('\uf7c2'), WALLET('\uf555'); diff --git a/src/main/java/com/sparrowwallet/sparrow/keystoreimport/KeystoreImportController.java b/src/main/java/com/sparrowwallet/sparrow/keystoreimport/KeystoreImportController.java index d0d69d67..786916a0 100644 --- a/src/main/java/com/sparrowwallet/sparrow/keystoreimport/KeystoreImportController.java +++ b/src/main/java/com/sparrowwallet/sparrow/keystoreimport/KeystoreImportController.java @@ -4,10 +4,12 @@ import com.sparrowwallet.drongo.wallet.KeystoreSource; import com.sparrowwallet.drongo.wallet.Wallet; import com.sparrowwallet.sparrow.AppController; import com.sparrowwallet.sparrow.io.Device; +import javafx.application.Platform; import javafx.fxml.FXML; import javafx.fxml.FXMLLoader; import javafx.fxml.Initializable; import javafx.scene.Node; +import javafx.scene.control.Toggle; import javafx.scene.control.ToggleGroup; import javafx.scene.layout.StackPane; @@ -51,6 +53,15 @@ public class KeystoreImportController implements Initializable { }); } + public void selectSource(KeystoreSource keystoreSource) { + for(Toggle toggle : importMenu.getToggles()) { + if(toggle.getUserData().equals(keystoreSource)) { + Platform.runLater(() -> importMenu.selectToggle(toggle)); + return; + } + } + } + void showUsbDevices(List devices) { FXMLLoader loader = setImportPane("hw_usb-devices"); HwUsbDevicesController controller = loader.getController(); diff --git a/src/main/java/com/sparrowwallet/sparrow/keystoreimport/KeystoreImportDialog.java b/src/main/java/com/sparrowwallet/sparrow/keystoreimport/KeystoreImportDialog.java index 3b5756d0..beb97f93 100644 --- a/src/main/java/com/sparrowwallet/sparrow/keystoreimport/KeystoreImportDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/keystoreimport/KeystoreImportDialog.java @@ -2,6 +2,7 @@ package com.sparrowwallet.sparrow.keystoreimport; import com.google.common.eventbus.Subscribe; import com.sparrowwallet.drongo.wallet.Keystore; +import com.sparrowwallet.drongo.wallet.KeystoreSource; import com.sparrowwallet.drongo.wallet.Wallet; import com.sparrowwallet.sparrow.AppController; import com.sparrowwallet.sparrow.EventManager; @@ -20,6 +21,10 @@ public class KeystoreImportDialog extends Dialog { private Keystore keystore; public KeystoreImportDialog(Wallet wallet) { + this(wallet, KeystoreSource.HW_USB); + } + + public KeystoreImportDialog(Wallet wallet, KeystoreSource initialSource) { EventManager.get().register(this); final DialogPane dialogPane = getDialogPane(); @@ -28,6 +33,7 @@ public class KeystoreImportDialog extends Dialog { dialogPane.setContent(Borders.wrap(ksiLoader.load()).lineBorder().outerPadding(0).innerPadding(0).buildAll()); keystoreImportController = ksiLoader.getController(); keystoreImportController.initializeView(wallet); + keystoreImportController.selectSource(initialSource); final ButtonType cancelButtonType = new javafx.scene.control.ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE); dialogPane.getButtonTypes().addAll(cancelButtonType); diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/KeystoreController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/KeystoreController.java index e4550aa0..d63b8899 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/KeystoreController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/KeystoreController.java @@ -12,14 +12,13 @@ import javafx.application.Platform; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.fxml.Initializable; -import javafx.scene.control.Control; -import javafx.scene.control.Label; -import javafx.scene.control.TextArea; -import javafx.scene.control.TextField; +import javafx.scene.control.*; +import javafx.scene.layout.StackPane; import org.controlsfx.validation.ValidationResult; import org.controlsfx.validation.ValidationSupport; import org.controlsfx.validation.Validator; import org.controlsfx.validation.decoration.StyleClassValidationDecoration; +import tornadofx.control.Form; import java.net.URL; import java.util.Optional; @@ -29,6 +28,9 @@ import java.util.stream.Collectors; public class KeystoreController extends WalletFormController implements Initializable { private Keystore keystore; + @FXML + private StackPane selectSourcePane; + @FXML private Label type; @@ -60,6 +62,8 @@ public class KeystoreController extends WalletFormController implements Initiali public void initializeView() { Platform.runLater(this::setupValidation); + selectSourcePane.managedProperty().bind(selectSourcePane.visibleProperty()); + updateType(); label.setText(keystore.getLabel()); @@ -97,6 +101,16 @@ public class KeystoreController extends WalletFormController implements Initiali }); } + public void selectSource(ActionEvent event) { + ToggleButton sourceButton = (ToggleButton)event.getSource(); + KeystoreSource keystoreSource = (KeystoreSource)sourceButton.getUserData(); + if(keystoreSource != KeystoreSource.SW_WATCH) { + launchImportDialog(keystoreSource); + } else { + selectSourcePane.setVisible(false); + } + } + public TextField getLabel() { return label; } @@ -150,27 +164,33 @@ public class KeystoreController extends WalletFormController implements Initiali return "Software Wallet"; case SW_WATCH: default: - return "Software Wallet (Watch Only)"; + return "Watch Only Wallet"; } } public void importKeystore(ActionEvent event) { - KeystoreImportDialog dlg = new KeystoreImportDialog(getWalletForm().getWallet()); - Optional result = dlg.showAndWait(); - if(result.isPresent()) { - Keystore importedKeystore = result.get(); - keystore.setSource(importedKeystore.getSource()); - keystore.setWalletModel(importedKeystore.getWalletModel()); - keystore.setLabel(importedKeystore.getLabel()); - keystore.setKeyDerivation(importedKeystore.getKeyDerivation()); - keystore.setExtendedPublicKey(importedKeystore.getExtendedPublicKey()); - keystore.setSeed(importedKeystore.getSeed()); + launchImportDialog(KeystoreSource.HW_USB); + } - updateType(); - label.setText(keystore.getLabel()); - fingerprint.setText(keystore.getKeyDerivation().getMasterFingerprint()); - derivation.setText(keystore.getKeyDerivation().getDerivationPath()); - xpub.setText(keystore.getExtendedPublicKey().toString()); + private void launchImportDialog(KeystoreSource initialSource) { + KeystoreImportDialog dlg = new KeystoreImportDialog(getWalletForm().getWallet(), initialSource); + Optional result = dlg.showAndWait(); + if (result.isPresent()) { + selectSourcePane.setVisible(false); + + Keystore importedKeystore = result.get(); + keystore.setSource(importedKeystore.getSource()); + keystore.setWalletModel(importedKeystore.getWalletModel()); + keystore.setLabel(importedKeystore.getLabel()); + keystore.setKeyDerivation(importedKeystore.getKeyDerivation()); + keystore.setExtendedPublicKey(importedKeystore.getExtendedPublicKey()); + keystore.setSeed(importedKeystore.getSeed()); + + updateType(); + label.setText(keystore.getLabel()); + fingerprint.setText(keystore.getKeyDerivation().getMasterFingerprint()); + derivation.setText(keystore.getKeyDerivation().getDerivationPath()); + xpub.setText(keystore.getExtendedPublicKey().toString()); } } } diff --git a/src/main/resources/com/sparrowwallet/sparrow/keystoreimport/keystoreimport.css b/src/main/resources/com/sparrowwallet/sparrow/keystoreimport/keystoreimport.css index 7f34159e..54dece77 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/keystoreimport/keystoreimport.css +++ b/src/main/resources/com/sparrowwallet/sparrow/keystoreimport/keystoreimport.css @@ -47,6 +47,7 @@ .titled-pane > .title > .arrow-button > .arrow { visibility: hidden; -fx-translate-x: -1000; + -fx-padding: 0; } .main-label .text { diff --git a/src/main/resources/com/sparrowwallet/sparrow/keystoreimport/keystoreimport.fxml b/src/main/resources/com/sparrowwallet/sparrow/keystoreimport/keystoreimport.fxml index 656939b9..adf91c7f 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/keystoreimport/keystoreimport.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/keystoreimport/keystoreimport.fxml @@ -26,7 +26,7 @@ - + diff --git a/src/main/resources/com/sparrowwallet/sparrow/wallet/keystore.css b/src/main/resources/com/sparrowwallet/sparrow/wallet/keystore.css index e268adc2..270d10b3 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/wallet/keystore.css +++ b/src/main/resources/com/sparrowwallet/sparrow/wallet/keystore.css @@ -1,3 +1,14 @@ +#selectSourcePane { + -fx-padding: 50 25 50 25; + -fx-background-color: -fx-background; +} + +#selectSourcePane .toggle-button { + -fx-pref-height: 130px; + -fx-pref-width: 200px; + -fx-padding: 20px; +} + .form .fieldset:horizontal .label-container { -fx-pref-width: 140px; } diff --git a/src/main/resources/com/sparrowwallet/sparrow/wallet/keystore.fxml b/src/main/resources/com/sparrowwallet/sparrow/wallet/keystore.fxml index 7491ef08..d1cbe8d0 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/wallet/keystore.fxml +++ b/src/main/resources/com/sparrowwallet/sparrow/wallet/keystore.fxml @@ -10,11 +10,14 @@ + + + -
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +