From 85ddc9689c9ed6c73fc1cca6ac4f9c85fd190e8d Mon Sep 17 00:00:00 2001 From: Pfaffenrodt Date: Sat, 29 Oct 2022 13:54:00 +0200 Subject: [PATCH] Extract common html link of third party info --- .../protect/card_locker/AboutContent.java | 39 ++++++++++--------- .../protect/card_locker/ThirdPartyInfo.java | 4 ++ 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/protect/card_locker/AboutContent.java b/app/src/main/java/protect/card_locker/AboutContent.java index 96e2bf71e..42c49b14b 100644 --- a/app/src/main/java/protect/card_locker/AboutContent.java +++ b/app/src/main/java/protect/card_locker/AboutContent.java @@ -73,32 +73,35 @@ public class AboutContent { } public String getThirdPartyLibraries() { - final List USED_LIBRARIES = new ArrayList<>(); - USED_LIBRARIES.add(new ThirdPartyInfo("Color Picker", "https://github.com/jaredrummler/ColorPicker", "Apache 2.0")); - USED_LIBRARIES.add(new ThirdPartyInfo("Commons CSV", "https://commons.apache.org/proper/commons-csv/", "Apache 2.0")); - USED_LIBRARIES.add(new ThirdPartyInfo("NumberPickerPreference", "https://github.com/invissvenska/NumberPickerPreference", "GNU LGPL 3.0")); - USED_LIBRARIES.add(new ThirdPartyInfo("uCrop", "https://github.com/Yalantis/uCrop", "Apache 2.0")); - USED_LIBRARIES.add(new ThirdPartyInfo("Zip4j", "https://github.com/srikanth-lingala/zip4j", "Apache 2.0")); - USED_LIBRARIES.add(new ThirdPartyInfo("ZXing", "https://github.com/zxing/zxing", "Apache 2.0")); - USED_LIBRARIES.add(new ThirdPartyInfo("ZXing Android Embedded", "https://github.com/journeyapps/zxing-android-embedded", "Apache 2.0")); - StringBuilder libs = new StringBuilder().append("
"); - for (ThirdPartyInfo entry : USED_LIBRARIES) { - libs.append("
").append(entry.name()).append(" (").append(entry.license()).append(")"); + final List usedLibraries = new ArrayList<>(); + usedLibraries.add(new ThirdPartyInfo("Color Picker", "https://github.com/jaredrummler/ColorPicker", "Apache 2.0")); + usedLibraries.add(new ThirdPartyInfo("Commons CSV", "https://commons.apache.org/proper/commons-csv/", "Apache 2.0")); + usedLibraries.add(new ThirdPartyInfo("NumberPickerPreference", "https://github.com/invissvenska/NumberPickerPreference", "GNU LGPL 3.0")); + usedLibraries.add(new ThirdPartyInfo("uCrop", "https://github.com/Yalantis/uCrop", "Apache 2.0")); + usedLibraries.add(new ThirdPartyInfo("Zip4j", "https://github.com/srikanth-lingala/zip4j", "Apache 2.0")); + usedLibraries.add(new ThirdPartyInfo("ZXing", "https://github.com/zxing/zxing", "Apache 2.0")); + usedLibraries.add(new ThirdPartyInfo("ZXing Android Embedded", "https://github.com/journeyapps/zxing-android-embedded", "Apache 2.0")); + + StringBuilder result = new StringBuilder("
"); + for (ThirdPartyInfo entry : usedLibraries) { + result.append("
") + .append(entry.toHtml()); } - return libs.toString(); + return result.toString(); } public String getUsedThirdPartyAssets() { - final List USED_ASSETS = new ArrayList<>(); - USED_ASSETS.add(new ThirdPartyInfo("Android icons", "https://fonts.google.com/icons?selected=Material+Icons", "Apache 2.0")); + final List usedAssets = new ArrayList<>(); + usedAssets.add(new ThirdPartyInfo("Android icons", "https://fonts.google.com/icons?selected=Material+Icons", "Apache 2.0")); - StringBuilder resources = new StringBuilder().append("
"); - for (ThirdPartyInfo entry : USED_ASSETS) { - resources.append("
").append(entry.name()).append(" (").append(entry.license()).append(")"); + StringBuilder result = new StringBuilder().append("
"); + for (ThirdPartyInfo entry : usedAssets) { + result.append("
") + .append(entry.toHtml()); } - return resources.toString(); + return result.toString(); } public String getContributorInfo() { diff --git a/app/src/main/java/protect/card_locker/ThirdPartyInfo.java b/app/src/main/java/protect/card_locker/ThirdPartyInfo.java index 5ae578694..e32472bab 100644 --- a/app/src/main/java/protect/card_locker/ThirdPartyInfo.java +++ b/app/src/main/java/protect/card_locker/ThirdPartyInfo.java @@ -22,4 +22,8 @@ public class ThirdPartyInfo { public String license() { return mLicense; } + + public String toHtml() { + return String.format("%s (%s)", url(), name(), license()); + } }