Refactoring: Remove class LangUtils (#4763)
This commit is contained in:
parent
63dcedeb8f
commit
c10d1a1d79
|
@ -9,10 +9,10 @@ import java.io.FileNotFoundException;
|
|||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import de.danoeh.antennapod.core.export.ExportWriter;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.util.LangUtils;
|
||||
import io.reactivex.Observable;
|
||||
|
||||
/**
|
||||
|
@ -44,7 +44,7 @@ public class DocumentFileExportWorker {
|
|||
if (outputStream == null) {
|
||||
throw new IOException();
|
||||
}
|
||||
writer = new OutputStreamWriter(outputStream, LangUtils.UTF_8);
|
||||
writer = new OutputStreamWriter(outputStream, Charset.forName("UTF-8"));
|
||||
exportWriter.writeDocument(DBReader.getFeedList(), writer, context);
|
||||
subscriber.onNext(output);
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -8,11 +8,11 @@ import java.io.File;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import de.danoeh.antennapod.core.export.ExportWriter;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.util.LangUtils;
|
||||
import io.reactivex.Observable;
|
||||
|
||||
/**
|
||||
|
@ -47,7 +47,7 @@ public class ExportWorker {
|
|||
return Observable.create(subscriber -> {
|
||||
OutputStreamWriter writer = null;
|
||||
try {
|
||||
writer = new OutputStreamWriter(new FileOutputStream(output), LangUtils.UTF_8);
|
||||
writer = new OutputStreamWriter(new FileOutputStream(output), Charset.forName("UTF-8"));
|
||||
exportWriter.writeDocument(DBReader.getFeedList(), writer, context);
|
||||
subscriber.onNext(output);
|
||||
} catch (IOException e) {
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.io.OutputStreamWriter;
|
|||
import java.io.Reader;
|
||||
import java.io.Writer;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.DigestInputStream;
|
||||
import java.security.DigestOutputStream;
|
||||
import java.security.MessageDigest;
|
||||
|
@ -34,7 +35,6 @@ import de.danoeh.antennapod.core.feed.Feed;
|
|||
import de.danoeh.antennapod.core.storage.DBReader;
|
||||
import de.danoeh.antennapod.core.storage.DownloadRequestException;
|
||||
import de.danoeh.antennapod.core.storage.DownloadRequester;
|
||||
import de.danoeh.antennapod.core.util.LangUtils;
|
||||
|
||||
public class OpmlBackupAgent extends BackupAgentHelper {
|
||||
private static final String OPML_BACKUP_KEY = "opml";
|
||||
|
@ -73,9 +73,9 @@ public class OpmlBackupAgent extends BackupAgentHelper {
|
|||
try {
|
||||
digester = MessageDigest.getInstance("MD5");
|
||||
writer = new OutputStreamWriter(new DigestOutputStream(byteStream, digester),
|
||||
LangUtils.UTF_8);
|
||||
Charset.forName("UTF-8"));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
writer = new OutputStreamWriter(byteStream, LangUtils.UTF_8);
|
||||
writer = new OutputStreamWriter(byteStream, Charset.forName("UTF-8"));
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -138,9 +138,9 @@ public class OpmlBackupAgent extends BackupAgentHelper {
|
|||
try {
|
||||
digester = MessageDigest.getInstance("MD5");
|
||||
reader = new InputStreamReader(new DigestInputStream(data, digester),
|
||||
LangUtils.UTF_8);
|
||||
Charset.forName("UTF-8"));
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
reader = new InputStreamReader(data, LangUtils.UTF_8);
|
||||
reader = new InputStreamReader(data, Charset.forName("UTF-8"));
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -1,124 +0,0 @@
|
|||
package de.danoeh.antennapod.core.util;
|
||||
|
||||
import androidx.collection.ArrayMap;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class LangUtils {
|
||||
|
||||
private LangUtils(){}
|
||||
|
||||
public static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
|
||||
private static final ArrayMap<String, String> languages;
|
||||
static {
|
||||
languages = new ArrayMap<>();
|
||||
languages.put("af", "Afrikaans");
|
||||
languages.put("sq", "Albanian");
|
||||
languages.put("sq", "Albanian");
|
||||
languages.put("eu", "Basque");
|
||||
languages.put("be", "Belarusian");
|
||||
languages.put("bg", "Bulgarian");
|
||||
languages.put("ca", "Catalan");
|
||||
languages.put("Chinese (Simplified)", "zh-cn");
|
||||
languages.put("Chinese (Traditional)", "zh-tw");
|
||||
languages.put("hr", "Croatian");
|
||||
languages.put("cs", "Czech");
|
||||
languages.put("da", "Danish");
|
||||
languages.put("nl", "Dutch");
|
||||
languages.put("nl-be", "Dutch (Belgium)");
|
||||
languages.put("nl-nl", "Dutch (Netherlands)");
|
||||
languages.put("en", "English");
|
||||
languages.put("en-au", "English (Australia)");
|
||||
languages.put("en-bz", "English (Belize)");
|
||||
languages.put("en-ca", "English (Canada)");
|
||||
languages.put("en-ie", "English (Ireland)");
|
||||
languages.put("en-jm", "English (Jamaica)");
|
||||
languages.put("en-nz", "English (New Zealand)");
|
||||
languages.put("en-ph", "English (Phillipines)");
|
||||
languages.put("en-za", "English (South Africa)");
|
||||
languages.put("en-tt", "English (Trinidad)");
|
||||
languages.put("en-gb", "English (United Kingdom)");
|
||||
languages.put("en-us", "English (United States)");
|
||||
languages.put("en-zw", "English (Zimbabwe)");
|
||||
languages.put("et", "Estonian");
|
||||
languages.put("fo", "Faeroese");
|
||||
languages.put("fi", "Finnish");
|
||||
languages.put("fr", "French");
|
||||
languages.put("fr-be", "French (Belgium)");
|
||||
languages.put("fr-ca", "French (Canada)");
|
||||
languages.put("fr-fr", "French (France)");
|
||||
languages.put("fr-lu", "French (Luxembourg)");
|
||||
languages.put("fr-mc", "French (Monaco)");
|
||||
languages.put("fr-ch", "French (Switzerland)");
|
||||
languages.put("gl", "Galician");
|
||||
languages.put("gd", "Gaelic");
|
||||
languages.put("de", "German");
|
||||
languages.put("de-at", "German (Austria)");
|
||||
languages.put("de-de", "German (Germany)");
|
||||
languages.put("de-li", "German (Liechtenstein)");
|
||||
languages.put("de-lu", "German (Luxembourg)");
|
||||
languages.put("de-ch", "German (Switzerland)");
|
||||
languages.put("el", "Greek");
|
||||
languages.put("haw", "Hawaiian");
|
||||
languages.put("hu", "Hungarian");
|
||||
languages.put("is", "Icelandic");
|
||||
languages.put("in", "Indonesian");
|
||||
languages.put("ga", "Irish");
|
||||
languages.put("it", "Italian");
|
||||
languages.put("it-it", "Italian (Italy)");
|
||||
languages.put("it-ch", "Italian (Switzerland)");
|
||||
languages.put("ja", "Japanese");
|
||||
languages.put("ko", "Korean");
|
||||
languages.put("mk", "Macedonian");
|
||||
languages.put("no", "Norwegian");
|
||||
languages.put("pl", "Polish");
|
||||
languages.put("pt", "Portugese");
|
||||
languages.put("pt-br", "Portugese (Brazil)");
|
||||
languages.put("pt-pt", "Portugese (Portugal");
|
||||
languages.put("ro", "Romanian");
|
||||
languages.put("ro-mo", "Romanian (Moldova)");
|
||||
languages.put("ro-ro", "Romanian (Romania");
|
||||
languages.put("ru", "Russian");
|
||||
languages.put("ru-mo", "Russian (Moldova)");
|
||||
languages.put("ru-ru", "Russian (Russia)");
|
||||
languages.put("sr", "Serbian");
|
||||
languages.put("sk", "Slovak");
|
||||
languages.put("sl", "Slovenian");
|
||||
languages.put("es", "Spanish");
|
||||
languages.put("es-ar", "Spanish (Argentinia)");
|
||||
languages.put("es=bo", "Spanish (Bolivia)");
|
||||
languages.put("es-cl", "Spanish (Chile)");
|
||||
languages.put("es-co", "Spanish (Colombia)");
|
||||
languages.put("es-cr", "Spanish (Costa Rica)");
|
||||
languages.put("es-do", "Spanish (Dominican Republic)");
|
||||
languages.put("es-ec", "Spanish (Ecuador)");
|
||||
languages.put("es-sv", "Spanish (El Salvador)");
|
||||
languages.put("es-gt", "Spanish (Guatemala)");
|
||||
languages.put("es-hn", "Spanish (Honduras)");
|
||||
languages.put("es-mx", "Spanish (Mexico)");
|
||||
languages.put("es-ni", "Spanish (Nicaragua)");
|
||||
languages.put("es-pa", "Spanish (Panama)");
|
||||
languages.put("es-py", "Spanish (Paraguay)");
|
||||
languages.put("es-pe", "Spanish (Peru)");
|
||||
languages.put("es-pr", "Spanish (Puerto Rico)");
|
||||
languages.put("es-es", "Spanish (Spain)");
|
||||
languages.put("es-uy", "Spanish (Uruguay)");
|
||||
languages.put("es-ve", "Spanish (Venezuela)");
|
||||
languages.put("sv", "Swedish");
|
||||
languages.put("sv-fi", "Swedish (Finland)");
|
||||
languages.put("sv-se", "Swedish (Sweden)");
|
||||
languages.put("tr", "Turkish");
|
||||
languages.put("uk", "Ukranian");
|
||||
}
|
||||
|
||||
/** Finds language string for key or returns the language key if it can't be found. */
|
||||
public static String getLanguageString(String key) {
|
||||
String language = languages.get(key);
|
||||
if (language != null) {
|
||||
return language;
|
||||
} else {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue