diff options
author | ByteHamster <info@bytehamster.com> | 2022-06-09 22:21:57 +0200 |
---|---|---|
committer | ByteHamster <info@bytehamster.com> | 2022-06-09 22:21:57 +0200 |
commit | 0c38218141fe1b164016a491f6f17592df5d18a5 (patch) | |
tree | 44219b8672b0da8224e5e4677d2f25fe5ff776cb /app | |
parent | 6e5004be22f20e3a51697909bf4d1e423252b83c (diff) | |
download | AntennaPod-0c38218141fe1b164016a491f6f17592df5d18a5.zip |
Link to localized website version from about screen
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/assets/website-languages.txt | 4 | ||||
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java | 25 |
2 files changed, 27 insertions, 2 deletions
diff --git a/app/src/main/assets/website-languages.txt b/app/src/main/assets/website-languages.txt new file mode 100644 index 000000000..b52b558f9 --- /dev/null +++ b/app/src/main/assets/website-languages.txt @@ -0,0 +1,4 @@ +en +fr +nl +it diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java index e2c5036df..7f5205db4 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/preferences/MainPreferencesFragment.java @@ -17,6 +17,13 @@ import de.danoeh.antennapod.activity.BugReportActivity; import de.danoeh.antennapod.activity.PreferenceActivity; import de.danoeh.antennapod.core.util.IntentUtils; import de.danoeh.antennapod.fragment.preferences.about.AboutFragment; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.ArrayUtils; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.Locale; public class MainPreferencesFragment extends PreferenceFragmentCompat { @@ -106,7 +113,7 @@ public class MainPreferencesFragment extends PreferenceFragmentCompat { } ); findPreference(PREF_DOCUMENTATION).setOnPreferenceClickListener(preference -> { - IntentUtils.openInBrowser(getContext(), "https://antennapod.org/documentation/"); + IntentUtils.openInBrowser(getContext(), getLocalizedWebsiteLink() + "/documentation/"); return true; }); findPreference(PREF_VIEW_FORUM).setOnPreferenceClickListener(preference -> { @@ -114,7 +121,7 @@ public class MainPreferencesFragment extends PreferenceFragmentCompat { return true; }); findPreference(PREF_CONTRIBUTE).setOnPreferenceClickListener(preference -> { - IntentUtils.openInBrowser(getContext(), "https://antennapod.org/contribute/"); + IntentUtils.openInBrowser(getContext(), getLocalizedWebsiteLink() + "/contribute/"); return true; }); findPreference(PREF_SEND_BUG_REPORT).setOnPreferenceClickListener(preference -> { @@ -123,6 +130,20 @@ public class MainPreferencesFragment extends PreferenceFragmentCompat { }); } + private String getLocalizedWebsiteLink() { + try (InputStream is = getContext().getAssets().open("website-languages.txt")) { + String[] languages = IOUtils.toString(is, StandardCharsets.UTF_8.name()).split("\n"); + String deviceLanguage = Locale.getDefault().getLanguage(); + if (ArrayUtils.contains(languages, deviceLanguage) && !"en".equals(deviceLanguage)) { + return "https://antennapod.org/" + deviceLanguage; + } else { + return "https://antennapod.org"; + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + private void setupSearch() { SearchPreference searchPreference = findPreference("searchPreference"); SearchConfiguration config = searchPreference.getSearchConfiguration(); |