diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2024-03-22 18:18:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-22 18:18:30 +0100 |
commit | 0a6b7ed69957cea9582af9e0dd861ed13795d6b5 (patch) | |
tree | 317262009e7e439a9d85c643fb1f6e864f1d4507 /core | |
parent | 27aa5cba96299dd14569f8a5f6da60bb88352d60 (diff) | |
download | AntennaPod-0a6b7ed69957cea9582af9e0dd861ed13795d6b5.zip |
Nicer rating dialog (#7011)
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/util/IntentUtils.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/IntentUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/IntentUtils.java index 959a3e574..8b30b4eac 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/IntentUtils.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/IntentUtils.java @@ -9,8 +9,14 @@ import android.net.Uri; import android.util.Log; import android.widget.Toast; import de.danoeh.antennapod.core.R; +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.List; +import java.util.Locale; public class IntentUtils { private static final String TAG = "IntentUtils"; @@ -45,4 +51,19 @@ public class IntentUtils { Log.e(TAG, Log.getStackTraceString(e)); } } + + + public static String getLocalizedWebsiteLink(Context context) { + try (InputStream is = context.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); + } + } } |