From d347cdde3e4522c2c3a06127309a521aff20ca5d Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Mon, 5 Apr 2021 19:43:49 +0200 Subject: [PATCH] Add license info for third party things in About screen --- .../protect/card_locker/AboutActivity.java | 34 ++++++++----------- .../protect/card_locker/ThirdPartyInfo.java | 25 ++++++++++++++ app/src/main/res/layout/about_activity.xml | 3 +- 3 files changed, 42 insertions(+), 20 deletions(-) create mode 100644 app/src/main/java/protect/card_locker/ThirdPartyInfo.java diff --git a/app/src/main/java/protect/card_locker/AboutActivity.java b/app/src/main/java/protect/card_locker/AboutActivity.java index 0367ad75b..964711ce5 100644 --- a/app/src/main/java/protect/card_locker/AboutActivity.java +++ b/app/src/main/java/protect/card_locker/AboutActivity.java @@ -8,10 +8,9 @@ import android.util.Log; import android.view.MenuItem; import android.widget.TextView; -import com.google.common.collect.ImmutableMap; - +import java.util.ArrayList; import java.util.Calendar; -import java.util.Map; +import java.util.List; import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; @@ -35,30 +34,27 @@ public class AboutActivity extends AppCompatActivity actionBar.setDisplayHomeAsUpEnabled(true); } - final Map USED_LIBRARIES = new ImmutableMap.Builder() - .put("Commons CSV", "https://commons.apache.org/proper/commons-csv/") - .put("Guava", "https://github.com/google/guava") - .put("ZXing", "https://github.com/zxing/zxing") - .put("ZXing Android Embedded", "https://github.com/journeyapps/zxing-android-embedded") - .put("Color Picker", "https://github.com/jaredrummler/ColorPicker") - .put("NumberPickerPreference", "https://github.com/invissvenska/NumberPickerPreference") - .build(); + final List USED_LIBRARIES = new ArrayList<>(); + USED_LIBRARIES.add(new ThirdPartyInfo("Commons CSV", "https://commons.apache.org/proper/commons-csv/", "Apache 2.0")); + USED_LIBRARIES.add(new ThirdPartyInfo("Guava", "https://github.com/google/guava", "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")); + USED_LIBRARIES.add(new ThirdPartyInfo("Color Picker", "https://github.com/jaredrummler/ColorPicker", "Apache 2.0")); + USED_LIBRARIES.add(new ThirdPartyInfo("NumberPickerPreference", "https://github.com/invissvenska/NumberPickerPreference", "GNU LGPL 3.0")); - final Map USED_ASSETS = ImmutableMap.of - ( - "Android icons", "https://www.apache.org/licenses/LICENSE-2.0.txt" - ); + final List USED_ASSETS = new ArrayList<>(); + USED_ASSETS.add(new ThirdPartyInfo("Android icons", "https://fonts.google.com/icons?selected=Material+Icons", "Apache 2.0")); StringBuilder libs = new StringBuilder().append("
"); - for (Map.Entry entry : USED_LIBRARIES.entrySet()) + for (ThirdPartyInfo entry : USED_LIBRARIES) { - libs.append("
").append(entry.getKey()).append("
"); + libs.append("
").append(entry.name()).append(" (").append(entry.license()).append(")
"); } StringBuilder resources = new StringBuilder().append("
"); - for (Map.Entry entry : USED_ASSETS.entrySet()) + for (ThirdPartyInfo entry : USED_ASSETS) { - resources.append("
").append(entry.getKey()).append("
"); + resources.append("
").append(entry.name()).append(" (").append(entry.license()).append(")
"); } String appName = getString(R.string.app_name); diff --git a/app/src/main/java/protect/card_locker/ThirdPartyInfo.java b/app/src/main/java/protect/card_locker/ThirdPartyInfo.java new file mode 100644 index 000000000..5ae578694 --- /dev/null +++ b/app/src/main/java/protect/card_locker/ThirdPartyInfo.java @@ -0,0 +1,25 @@ +package protect.card_locker; + +public class ThirdPartyInfo { + private final String mName; + private final String mUrl; + private final String mLicense; + + public ThirdPartyInfo(String name, String url, String license) { + mName = name; + mUrl = url; + mLicense = license; + } + + public String name() { + return mName; + } + + public String url() { + return mUrl; + } + + public String license() { + return mLicense; + } +} diff --git a/app/src/main/res/layout/about_activity.xml b/app/src/main/res/layout/about_activity.xml index 2e29a7804..949a16f88 100644 --- a/app/src/main/res/layout/about_activity.xml +++ b/app/src/main/res/layout/about_activity.xml @@ -26,7 +26,8 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="?attr/actionBarSize" - android:orientation="vertical"> + android:orientation="vertical" + android:padding="10dp">