add percent complete to legacyurdecoder, bump to 1.5.3

This commit is contained in:
Craig Raw 2021-03-24 08:36:50 +02:00
parent 78c29d6eaa
commit 2b24027b16
3 changed files with 20 additions and 2 deletions

View file

@ -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: 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 ## Usage

View file

@ -16,7 +16,7 @@ apply plugin: 'com.bmuschko.nexus'
archivesBaseName = 'hummingbird' archivesBaseName = 'hummingbird'
group 'com.sparrowwallet' group 'com.sparrowwallet'
version '1.5.2' version '1.5.3'
repositories { repositories {
mavenCentral() mavenCentral()

View file

@ -27,6 +27,24 @@ public class LegacyURDecoder {
return true; 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) { public static boolean isLegacyURFragment(String fragment) {
String[] components = fragment.split("/"); String[] components = fragment.split("/");