diff --git a/build.gradle b/build.gradle index 1578f9dd..d1d87d6e 100644 --- a/build.gradle +++ b/build.gradle @@ -56,7 +56,15 @@ compileJava { } run { - applicationDefaultJvmArgs = ["-Xdock:name=Sparrow", "-Xdock:icon=/Users/scy/git/sparrow/src/main/resources/sparrow.png", "--add-opens=javafx.graphics/com.sun.javafx.css=org.controlsfx.controls", "--add-opens=javafx.graphics/javafx.scene=org.controlsfx.controls", "--add-opens=javafx.controls/com.sun.javafx.scene.control.behavior=org.controlsfx.controls", "--add-opens=javafx.controls/com.sun.javafx.scene.control.inputmap=org.controlsfx.controls", "--add-opens=javafx.graphics/com.sun.javafx.scene.traversal=org.controlsfx.controls", "--add-opens=javafx.base/com.sun.javafx.event=org.controlsfx.controls", "--add-opens=javafx.controls/javafx.scene.control.cell=com.sparrowwallet.sparrow", "--add-opens=org.controlsfx.controls/impl.org.controlsfx.skin=com.sparrowwallet.sparrow"] + applicationDefaultJvmArgs = ["-Xdock:name=Sparrow", "-Xdock:icon=/Users/scy/git/sparrow/src/main/resources/sparrow.png", + "--add-opens=javafx.graphics/com.sun.javafx.css=org.controlsfx.controls", + "--add-opens=javafx.graphics/javafx.scene=org.controlsfx.controls", + "--add-opens=javafx.controls/com.sun.javafx.scene.control.behavior=org.controlsfx.controls", + "--add-opens=javafx.controls/com.sun.javafx.scene.control.inputmap=org.controlsfx.controls", + "--add-opens=javafx.graphics/com.sun.javafx.scene.traversal=org.controlsfx.controls", + "--add-opens=javafx.base/com.sun.javafx.event=org.controlsfx.controls", + "--add-opens=javafx.controls/javafx.scene.control.cell=com.sparrowwallet.sparrow", + "--add-opens=org.controlsfx.controls/impl.org.controlsfx.skin=com.sparrowwallet.sparrow"] } jlink { @@ -66,12 +74,20 @@ jlink { requires 'java.xml'; requires 'java.logging' requires 'javafx.base'; + requires 'com.fasterxml.jackson.databind'; } options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages', '--ignore-signing-information', '--exclude-files', '**.png'] launcher { name = 'sparrow' - jvmArgs = ["--add-opens=javafx.graphics/com.sun.javafx.css=org.controlsfx.controls", "--add-opens=javafx.graphics/javafx.scene=org.controlsfx.controls", "--add-opens=javafx.controls/com.sun.javafx.scene.control.behavior=org.controlsfx.controls", "--add-opens=javafx.controls/com.sun.javafx.scene.control.inputmap=org.controlsfx.controls", "--add-opens=javafx.graphics/com.sun.javafx.scene.traversal=org.controlsfx.controls", "--add-opens=javafx.base/com.sun.javafx.event=org.controlsfx.controls", "--add-opens=javafx.controls/javafx.scene.control.cell=com.sparrowwallet.sparrow", "--add-opens=org.controlsfx.controls/impl.org.controlsfx.skin=com.sparrowwallet.sparrow"] + jvmArgs = ["--add-opens=javafx.graphics/com.sun.javafx.css=org.controlsfx.controls", + "--add-opens=javafx.graphics/javafx.scene=org.controlsfx.controls", + "--add-opens=javafx.controls/com.sun.javafx.scene.control.behavior=org.controlsfx.controls", + "--add-opens=javafx.controls/com.sun.javafx.scene.control.inputmap=org.controlsfx.controls", + "--add-opens=javafx.graphics/com.sun.javafx.scene.traversal=org.controlsfx.controls", + "--add-opens=javafx.base/com.sun.javafx.event=org.controlsfx.controls", + "--add-opens=javafx.controls/javafx.scene.control.cell=com.sparrowwallet.sparrow", + "--add-opens=org.controlsfx.controls/impl.org.controlsfx.skin=com.sparrowwallet.sparrow"] } addExtraDependencies("javafx") jpackage { diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index e7c6a198..9fd3b6cd 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -607,7 +607,7 @@ public class AppController implements Initializable { } else { if(usbStatus == null) { usbStatus = new UsbStatusButton(); - statusBar.getRightItems().add(usbStatus); + statusBar.getRightItems().add(0, usbStatus); } else { usbStatus.getItems().remove(0, usbStatus.getItems().size()); } diff --git a/src/main/java/com/sparrowwallet/sparrow/MainApp.java b/src/main/java/com/sparrowwallet/sparrow/MainApp.java index fce946c1..dce50956 100644 --- a/src/main/java/com/sparrowwallet/sparrow/MainApp.java +++ b/src/main/java/com/sparrowwallet/sparrow/MainApp.java @@ -24,7 +24,7 @@ public class MainApp extends Application { GlyphFontRegistry.register(new FontAwesome5Brands()); Mode mode = Config.get().getMode(); - if(true || mode == null) { + if(mode == null) { WelcomeDialog welcomeDialog = new WelcomeDialog(getHostServices()); Optional optionalMode = welcomeDialog.showAndWait(); if(optionalMode.isPresent()) { diff --git a/src/main/java/com/sparrowwallet/sparrow/io/Hwi.java b/src/main/java/com/sparrowwallet/sparrow/io/Hwi.java index ee2d47c7..60f13cd3 100644 --- a/src/main/java/com/sparrowwallet/sparrow/io/Hwi.java +++ b/src/main/java/com/sparrowwallet/sparrow/io/Hwi.java @@ -87,6 +87,16 @@ public class Hwi { private synchronized File getHwiExecutable() { File hwiExecutable = Config.get().getHwi(); + if(hwiExecutable != null && hwiExecutable.exists()) { + if(!testHwi(hwiExecutable)) { + if(Platform.getCurrent().getPlatformId().toLowerCase().equals("mac")) { + deleteDirectory(hwiExecutable.getParentFile()); + } else { + hwiExecutable.delete(); + } + } + } + if(hwiExecutable == null || !hwiExecutable.exists()) { try { Platform platform = Platform.getCurrent(); @@ -147,6 +157,29 @@ public class Hwi { return hwiExecutable; } + private boolean testHwi(File hwiExecutable) { + try { + List command = List.of(hwiExecutable.getAbsolutePath(), "enumerate"); + ProcessBuilder processBuilder = new ProcessBuilder(command); + Process process = processBuilder.start(); + int exitValue = process.waitFor(); + return exitValue == 0; + } catch (Exception e) { + return false; + } + } + + private boolean deleteDirectory(File directoryToBeDeleted) { + File[] allContents = directoryToBeDeleted.listFiles(); + if (allContents != null) { + for (File file : allContents) { + deleteDirectory(file); + } + } + + return directoryToBeDeleted.delete(); + } + public static File newFile(File destinationDir, ZipEntry zipEntry, Set setFilePermissions) throws IOException { String destDirPath = destinationDir.getCanonicalPath(); diff --git a/src/main/resources/com/sparrowwallet/sparrow/app.css b/src/main/resources/com/sparrowwallet/sparrow/app.css index 014d467c..99e937c6 100644 --- a/src/main/resources/com/sparrowwallet/sparrow/app.css +++ b/src/main/resources/com/sparrowwallet/sparrow/app.css @@ -27,4 +27,5 @@ .status-bar .right-items { -fx-alignment: center-right; -fx-padding: 0 0 0 8; + -fx-spacing: 10; }