From 0a6b7ed69957cea9582af9e0dd861ed13795d6b5 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Fri, 22 Mar 2024 18:18:30 +0100 Subject: Nicer rating dialog (#7011) --- .../de/danoeh/antennapod/core/util/IntentUtils.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'core') 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); + } + } } -- cgit v1.2.3