From 137c8db23549b039ec2dc77345333b3d8cd699db Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 29 Aug 2020 09:31:43 +0200 Subject: [PATCH] Added contributors list to about --- FAQ.md | 3 + .../java/eu/faircode/email/ActivityView.java | 2 +- .../java/eu/faircode/email/Contributor.java | 100 ++++++++++++++++++ .../java/eu/faircode/email/FragmentAbout.java | 20 ++++ .../main/java/eu/faircode/email/Helper.java | 1 - app/src/main/res/layout/fragment_about.xml | 20 ++++ app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/contributors.xml | 11 ++ 8 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/eu/faircode/email/Contributor.java create mode 100644 app/src/main/res/xml/contributors.xml diff --git a/FAQ.md b/FAQ.md index a67cbd15c9..4f3edec410 100644 --- a/FAQ.md +++ b/FAQ.md @@ -1123,6 +1123,9 @@ Alternatively, you might be able to enable the *Files* app again using the Andro Yes, you can translate the texts of FairEmail in your own language [on Crowdin](https://crowdin.com/project/open-source-email). Registration is free. +If you would like your name or alias to be included in the list of contributors in *About* the app, +please [contact me](https://contact.faircode.eu/?product=fairemailsupport). +
diff --git a/app/src/main/java/eu/faircode/email/ActivityView.java b/app/src/main/java/eu/faircode/email/ActivityView.java index b38991b091..faa1672453 100644 --- a/app/src/main/java/eu/faircode/email/ActivityView.java +++ b/app/src/main/java/eu/faircode/email/ActivityView.java @@ -1144,7 +1144,7 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB } private void onMenuTranslate() { - Helper.view(this, Uri.parse(Helper.CROWDIN_URI), true); + Helper.viewFAQ(this, 26); } private void onMenuIssue() { diff --git a/app/src/main/java/eu/faircode/email/Contributor.java b/app/src/main/java/eu/faircode/email/Contributor.java new file mode 100644 index 0000000000..0e5a74c8bc --- /dev/null +++ b/app/src/main/java/eu/faircode/email/Contributor.java @@ -0,0 +1,100 @@ +package eu.faircode.email; + +/* + This file is part of FairEmail. + + FairEmail is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + FairEmail is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with FairEmail. If not, see . + + Copyright 2018-2020 by Marcel Bokhorst (M66B) +*/ + +import android.content.Context; +import android.content.res.XmlResourceParser; +import android.text.TextUtils; + +import org.xmlpull.v1.XmlPullParser; + +import java.util.ArrayList; +import java.util.List; + +public class Contributor { + public String name; + public String alias; + public String contribution; + + private Contributor() { + } + + static List loadContributors(Context context) { + List result = null; + try { + Contributor contributor = null; + XmlResourceParser xml = context.getResources().getXml(R.xml.contributors); + int eventType = xml.getEventType(); + while (eventType != XmlPullParser.END_DOCUMENT) { + if (eventType == XmlPullParser.START_TAG) { + String name = xml.getName(); + if ("contributors".equals(name)) + result = new ArrayList<>(); + else if ("contributor".equals(name)) { + contributor = new Contributor(); + contributor.name = xml.getAttributeValue(null, "name"); + contributor.alias = xml.getAttributeValue(null, "alias"); + contributor.contribution = xml.getAttributeValue(null, "contribution"); + } else + throw new IllegalAccessException(name); + } else if (eventType == XmlPullParser.END_TAG) { + if ("contributor".equals(xml.getName())) { + result.add(contributor); + contributor = null; + } + } + + eventType = xml.next(); + } + } catch (Throwable ex) { + Log.e(ex); + } + + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + + if (!TextUtils.isEmpty(name)) + sb.append(name); + + if (!TextUtils.isEmpty(alias)) { + if (sb.length() > 0) + sb.append(' '); + if (!TextUtils.isEmpty(name)) + sb.append('('); + sb.append(alias); + if (!TextUtils.isEmpty(name)) + sb.append(')'); + } + + sb.append(" - "); + + if (!TextUtils.isEmpty(contribution)) { + if (sb.length() > 0) + sb.append(' '); + sb.append(contribution); + } + + return sb.toString(); + } +} diff --git a/app/src/main/java/eu/faircode/email/FragmentAbout.java b/app/src/main/java/eu/faircode/email/FragmentAbout.java index 3d226e25d1..81272f415a 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAbout.java +++ b/app/src/main/java/eu/faircode/email/FragmentAbout.java @@ -19,20 +19,26 @@ package eu.faircode.email; Copyright 2018-2020 by Marcel Bokhorst (M66B) */ +import android.content.Context; import android.graphics.Paint; import android.net.Uri; import android.os.Bundle; import android.text.TextUtils; +import android.util.TypedValue; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; +import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.core.widget.TextViewCompat; + +import java.util.List; public class FragmentAbout extends FragmentBase { @Override @@ -46,6 +52,7 @@ public class FragmentAbout extends FragmentBase { TextView tvVersion = view.findViewById(R.id.tvVersion); TextView tvRelease = view.findViewById(R.id.tvRelease); TextView tvGplV3 = view.findViewById(R.id.tvGplV3); + LinearLayout llContributors = view.findViewById(R.id.llContributors); tvVersion.setText(getString(R.string.title_version, BuildConfig.VERSION_NAME)); tvRelease.setText(BuildConfig.RELEASE_NAME); @@ -58,6 +65,19 @@ public class FragmentAbout extends FragmentBase { } }); + final Context context = getContext(); + + TypedValue style = new TypedValue(); + context.getTheme().resolveAttribute(R.style.TextAppearance_AppCompat_Small, style, true); + + List contributors = Contributor.loadContributors(context); + for (Contributor contributor : contributors) { + TextView tv = new TextView(context); + TextViewCompat.setTextAppearance(tv, style.data); + tv.setText(contributor.toString()); + llContributors.addView(tv); + } + return view; } diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java index 1cc42df13a..ca3ae94563 100644 --- a/app/src/main/java/eu/faircode/email/Helper.java +++ b/app/src/main/java/eu/faircode/email/Helper.java @@ -152,7 +152,6 @@ public class Helper { static final String XDA_URI = "https://forum.xda-developers.com/showthread.php?t=3824168"; static final String SUPPORT_URI = "https://contact.faircode.eu/?product=fairemailsupport"; static final String TEST_URI = "https://play.google.com/apps/testing/" + BuildConfig.APPLICATION_ID; - static final String CROWDIN_URI = "https://crowdin.com/project/open-source-email"; static final String GRAVATAR_PRIVACY_URI = "https://meta.stackexchange.com/questions/44717/is-gravatar-a-privacy-risk"; static final String LICENSE_URI = "https://www.gnu.org/licenses/gpl-3.0.html"; diff --git a/app/src/main/res/layout/fragment_about.xml b/app/src/main/res/layout/fragment_about.xml index 4ea0cf4e78..b47b339678 100644 --- a/app/src/main/res/layout/fragment_about.xml +++ b/app/src/main/res/layout/fragment_about.xml @@ -62,6 +62,26 @@ android:layout_height="wrap_content" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f8f032e6ed..d37066ce78 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -133,6 +133,7 @@ Welcome End-user license agreement GNU General Public License - Version 3 + Contributors I agree I disagree diff --git a/app/src/main/res/xml/contributors.xml b/app/src/main/res/xml/contributors.xml new file mode 100644 index 0000000000..60f5a0c01e --- /dev/null +++ b/app/src/main/res/xml/contributors.xml @@ -0,0 +1,11 @@ + + + + +