mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-02 20:36:44 +00:00
more import fixes
This commit is contained in:
parent
af525797ff
commit
d49f85fe5b
3 changed files with 5 additions and 16 deletions
|
@ -125,7 +125,7 @@ public class TitledDescriptionPane extends TitledPane {
|
|||
contentBox.setPadding(new Insets(10, 30, 10, 30));
|
||||
|
||||
double width = TextUtils.computeTextWidth(details.getFont(), message, 0.0D);
|
||||
double numLines = Math.max(1, width / 400);
|
||||
double numLines = Math.max(1, Math.ceil(width / 400d));
|
||||
|
||||
//Handle long words like txids
|
||||
OptionalDouble maxWordLength = Arrays.stream(message.split(" ")).mapToDouble(word -> TextUtils.computeTextWidth(details.getFont(), message, 0.0D)).max();
|
||||
|
|
|
@ -266,20 +266,7 @@ public class Electrum implements KeystoreFileImport, WalletImport, WalletExport
|
|||
|
||||
@Override
|
||||
public boolean isEncrypted(File file) {
|
||||
if(FileType.BINARY.equals(IOUtils.getFileType(file))) {
|
||||
try {
|
||||
try(Scanner s = new Scanner(file)) {
|
||||
if(s.hasNextLine() && s.nextLine().equals("{")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch(FileNotFoundException e) {
|
||||
//Can't happen
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return (FileType.BINARY.equals(IOUtils.getFileType(file)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,7 +7,7 @@ public class IOUtils {
|
|||
public static FileType getFileType(File file) {
|
||||
try {
|
||||
String type = Files.probeContentType(file.toPath());
|
||||
if (type == null) {
|
||||
if(type == null) {
|
||||
if(file.getName().toLowerCase().endsWith("txn") || file.getName().toLowerCase().endsWith("psbt")) {
|
||||
return FileType.TEXT;
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ public class IOUtils {
|
|||
String line = br.readLine();
|
||||
if(line.startsWith("01000000") || line.startsWith("cHNid")) {
|
||||
return FileType.TEXT;
|
||||
} else if(line.startsWith("{")) {
|
||||
return FileType.JSON;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue