diff --git a/README.md b/README.md index d2724b5..32eb48f 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ It contains both the classes to represent a UR, and a UR encoder and decoder to Hummingbird is hosted in Maven Central and can be added as a dependency with the following: ``` -implementation('com.sparrowwallet:hummingbird:1.5.2') +implementation('com.sparrowwallet:hummingbird:1.5.3') ``` ## Usage diff --git a/build.gradle b/build.gradle index 772365d..f3cec5b 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ apply plugin: 'com.bmuschko.nexus' archivesBaseName = 'hummingbird' group 'com.sparrowwallet' -version '1.5.2' +version '1.5.3' repositories { mavenCentral() diff --git a/src/main/java/com/sparrowwallet/hummingbird/LegacyURDecoder.java b/src/main/java/com/sparrowwallet/hummingbird/LegacyURDecoder.java index 5221e81..51fcf68 100644 --- a/src/main/java/com/sparrowwallet/hummingbird/LegacyURDecoder.java +++ b/src/main/java/com/sparrowwallet/hummingbird/LegacyURDecoder.java @@ -27,6 +27,24 @@ public class LegacyURDecoder { return true; } + public double getPercentComplete() { + if(fragments.isEmpty()) { + return 0d; + } + + String fragment = fragments.iterator().next(); + String[] components = fragment.split("/"); + if(components.length > 3) { + int[] sequence = checkAndGetSequence(components[1]); + int total = sequence[1]; + if(total > 0 && fragments.size() <= total) { + return (double)fragments.size() / total; + } + } + + return 1d; + } + public static boolean isLegacyURFragment(String fragment) { String[] components = fragment.split("/");