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(); diff --git a/makeRelease.sh b/makeRelease.sh index 289e7fd42..34c79f319 100755 --- a/makeRelease.sh +++ b/makeRelease.sh @@ -1,18 +1,4 @@ #!/bin/sh -if [ "$#" -ne 2 ]; then - echo "Usage:\n ./makeRelease 1.2.3rc0 Directory/" - exit 1 -fi - -set -e -DEST=$2 -VERSION_NAME=$1 - -rm CONTRIBUTORS -./createDevelopersList.py -./createTranslatorsList.py - -./gradlew clean assemblePlayDebug assemblePlayRelease -cp app/build/outputs/apk/app-play-debug.apk $DEST/AntennaPod_${VERSION_NAME}_debug.apk -cp app/build/outputs/apk/app-play-release.apk $DEST/AntennaPod_${VERSION_NAME}_release.apk +curl -s https://raw.githubusercontent.com/AntennaPod/antennapod.github.io/master/_config.yml | yq -r ".languages[]" > ./app/src/main/assets/website-languages.txt +python ./createContributors.py