mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-04 21:36:45 +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));
|
contentBox.setPadding(new Insets(10, 30, 10, 30));
|
||||||
|
|
||||||
double width = TextUtils.computeTextWidth(details.getFont(), message, 0.0D);
|
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
|
//Handle long words like txids
|
||||||
OptionalDouble maxWordLength = Arrays.stream(message.split(" ")).mapToDouble(word -> TextUtils.computeTextWidth(details.getFont(), message, 0.0D)).max();
|
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
|
@Override
|
||||||
public boolean isEncrypted(File file) {
|
public boolean isEncrypted(File file) {
|
||||||
if(FileType.BINARY.equals(IOUtils.getFileType(file))) {
|
return (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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -7,7 +7,7 @@ public class IOUtils {
|
||||||
public static FileType getFileType(File file) {
|
public static FileType getFileType(File file) {
|
||||||
try {
|
try {
|
||||||
String type = Files.probeContentType(file.toPath());
|
String type = Files.probeContentType(file.toPath());
|
||||||
if (type == null) {
|
if(type == null) {
|
||||||
if(file.getName().toLowerCase().endsWith("txn") || file.getName().toLowerCase().endsWith("psbt")) {
|
if(file.getName().toLowerCase().endsWith("txn") || file.getName().toLowerCase().endsWith("psbt")) {
|
||||||
return FileType.TEXT;
|
return FileType.TEXT;
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,8 @@ public class IOUtils {
|
||||||
String line = br.readLine();
|
String line = br.readLine();
|
||||||
if(line.startsWith("01000000") || line.startsWith("cHNid")) {
|
if(line.startsWith("01000000") || line.startsWith("cHNid")) {
|
||||||
return FileType.TEXT;
|
return FileType.TEXT;
|
||||||
|
} else if(line.startsWith("{")) {
|
||||||
|
return FileType.JSON;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue