From 94d339ca22d4f12b4fdfd0921cc1a17f29ec8ad8 Mon Sep 17 00:00:00 2001 From: Michael <13953785+Laserlicht@users.noreply.github.com> Date: Mon, 10 Apr 2023 17:24:15 +0200 Subject: [PATCH] Android Launcher - Language (#1914) * codepage -> language * Update strings.xml * change mod repo on android --- .../java/eu/vcmi/vcmi/ActivityLauncher.java | 10 ++-- .../main/java/eu/vcmi/vcmi/ActivityMods.java | 2 +- .../src/main/java/eu/vcmi/vcmi/Config.java | 16 +++---- .../vcmi/settings/CodepageSettingDialog.java | 40 ---------------- ...er.java => LanguageSettingController.java} | 16 +++---- .../vcmi/settings/LanguageSettingDialog.java | 47 +++++++++++++++++++ .../src/main/res/values-de/strings.xml | 6 +-- .../src/main/res/values-pl/strings.xml | 6 +-- .../src/main/res/values-ru/strings.xml | 8 ++-- .../src/main/res/values-uk/strings.xml | 8 ++-- .../vcmi-app/src/main/res/values/strings.xml | 6 +-- 11 files changed, 86 insertions(+), 79 deletions(-) delete mode 100644 android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/CodepageSettingDialog.java rename android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/{CodepageSettingController.java => LanguageSettingController.java} (53%) create mode 100644 android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/LanguageSettingDialog.java diff --git a/android/vcmi-app/src/main/java/eu/vcmi/vcmi/ActivityLauncher.java b/android/vcmi-app/src/main/java/eu/vcmi/vcmi/ActivityLauncher.java index d5f6a5b00..fde7580af 100644 --- a/android/vcmi-app/src/main/java/eu/vcmi/vcmi/ActivityLauncher.java +++ b/android/vcmi-app/src/main/java/eu/vcmi/vcmi/ActivityLauncher.java @@ -18,7 +18,7 @@ import java.util.List; import eu.vcmi.vcmi.content.AsyncLauncherInitialization; import eu.vcmi.vcmi.settings.AdventureAiController; -import eu.vcmi.vcmi.settings.CodepageSettingController; +import eu.vcmi.vcmi.settings.LanguageSettingController; import eu.vcmi.vcmi.settings.CopyDataController; import eu.vcmi.vcmi.settings.ExportDataController; import eu.vcmi.vcmi.settings.LauncherSettingController; @@ -45,7 +45,7 @@ public class ActivityLauncher extends ActivityWithToolbar private TextView mErrorMessage; private Config mConfig; private LauncherSettingController mCtrlScreenRes; - private LauncherSettingController mCtrlCodepage; + private LauncherSettingController mCtrlLanguage; private LauncherSettingController mCtrlPointerMode; private LauncherSettingController mCtrlStart; private LauncherSettingController mCtrlPointerMulti; @@ -203,7 +203,7 @@ public class ActivityLauncher extends ActivityWithToolbar (mCtrlExport = new ExportDataController(this)).init(R.id.launcher_btn_export); new ModsBtnController(this, v -> startActivity(new Intent(ActivityLauncher.this, ActivityMods.class))).init(R.id.launcher_btn_mods); mCtrlScreenRes = new ScreenResSettingController(this).init(R.id.launcher_btn_res, mConfig); - mCtrlCodepage = new CodepageSettingController(this).init(R.id.launcher_btn_cp, mConfig); + mCtrlLanguage = new LanguageSettingController(this).init(R.id.launcher_btn_cp, mConfig); mCtrlPointerMode = new PointerModeSettingController(this).init(R.id.launcher_btn_pointer_mode, mConfig); mCtrlPointerMulti = new PointerMultiplierSettingController(this).init(R.id.launcher_btn_pointer_multi, mConfig); mCtrlSoundVol = new SoundSettingController(this).init(R.id.launcher_btn_volume_sound, mConfig); @@ -211,7 +211,7 @@ public class ActivityLauncher extends ActivityWithToolbar mAiController = new AdventureAiController(this).init(R.id.launcher_btn_adventure_ai, mConfig); mActualSettings.clear(); - mActualSettings.add(mCtrlCodepage); + mActualSettings.add(mCtrlLanguage); mActualSettings.add(mCtrlScreenRes); mActualSettings.add(mCtrlPointerMode); mActualSettings.add(mCtrlPointerMulti); @@ -267,7 +267,7 @@ public class ActivityLauncher extends ActivityWithToolbar private void onConfigUpdated() { updateCtrlConfig(mCtrlScreenRes, mConfig); - updateCtrlConfig(mCtrlCodepage, mConfig); + updateCtrlConfig(mCtrlLanguage, mConfig); updateCtrlConfig(mCtrlPointerMode, mConfig); updateCtrlConfig(mCtrlPointerMulti, mConfig); updateCtrlConfig(mCtrlSoundVol, mConfig); diff --git a/android/vcmi-app/src/main/java/eu/vcmi/vcmi/ActivityMods.java b/android/vcmi-app/src/main/java/eu/vcmi/vcmi/ActivityMods.java index 7b010b903..31fdd60ff 100644 --- a/android/vcmi-app/src/main/java/eu/vcmi/vcmi/ActivityMods.java +++ b/android/vcmi-app/src/main/java/eu/vcmi/vcmi/ActivityMods.java @@ -50,7 +50,7 @@ import eu.vcmi.vcmi.util.ServerResponse; public class ActivityMods extends ActivityWithToolbar { private static final boolean ENABLE_REPO_DOWNLOADING = true; - private static final String REPO_URL = "https://raw.githubusercontent.com/vcmi/vcmi-mods-repository/develop/github.json"; + private static final String REPO_URL = "https://raw.githubusercontent.com/vcmi/vcmi-mods-repository/develop/vcmi-1.2.json"; private VCMIModsRepo mRepo; private RecyclerView mRecycler; diff --git a/android/vcmi-app/src/main/java/eu/vcmi/vcmi/Config.java b/android/vcmi-app/src/main/java/eu/vcmi/vcmi/Config.java index 65bd3093b..e894c52e0 100644 --- a/android/vcmi-app/src/main/java/eu/vcmi/vcmi/Config.java +++ b/android/vcmi-app/src/main/java/eu/vcmi/vcmi/Config.java @@ -14,13 +14,13 @@ import eu.vcmi.vcmi.util.Log; */ public class Config { - public static final String DEFAULT_CODEPAGE = "CP1250"; + public static final String DEFAULT_LANGUAGE = "english"; public static final int DEFAULT_MUSIC_VALUE = 5; public static final int DEFAULT_SOUND_VALUE = 5; public static final int DEFAULT_SCREEN_RES_W = 800; public static final int DEFAULT_SCREEN_RES_H = 600; - public String mCodepage; + public String mLanguage; public int mResolutionWidth; public int mResolutionHeight; public boolean mSwipeEnabled; @@ -85,7 +85,7 @@ public class Config final Config config = new Config(); final JSONObject general = accessNode(obj, "general"); final JSONObject server = accessNode(obj, "server"); - config.mCodepage = loadEntry(general, "encoding", DEFAULT_CODEPAGE); + config.mLanguage = loadEntry(general, "language", DEFAULT_LANGUAGE); config.mVolumeSound = loadEntry(general, "sound", DEFAULT_SOUND_VALUE); config.mVolumeMusic = loadEntry(general, "music", DEFAULT_MUSIC_VALUE); config.mSwipeEnabled = loadEntry(general, "swipe", true); @@ -101,9 +101,9 @@ public class Config return config; } - public void updateCodepage(final String s) + public void updateLanguage(final String s) { - mCodepage = s; + mLanguage = s; mIsModified = true; } @@ -202,9 +202,9 @@ public class Config final JSONObject screenRes = screenResNode == null ? new JSONObject() : screenResNode; final JSONObject server = serverNode == null ? new JSONObject() : serverNode; - if (mCodepage != null) + if (mLanguage != null) { - general.put("encoding", mCodepage); + general.put("language", mLanguage); } general.put("swipe", mSwipeEnabled); @@ -230,4 +230,4 @@ public class Config return root.toString(); } -} \ No newline at end of file +} diff --git a/android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/CodepageSettingDialog.java b/android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/CodepageSettingDialog.java deleted file mode 100644 index 3656d3ba9..000000000 --- a/android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/CodepageSettingDialog.java +++ /dev/null @@ -1,40 +0,0 @@ -package eu.vcmi.vcmi.settings; - -import java.util.ArrayList; -import java.util.List; - -import eu.vcmi.vcmi.R; - -/** - * @author F - */ -public class CodepageSettingDialog extends LauncherSettingDialog -{ - private static final List AVAILABLE_CODEPAGES = new ArrayList<>(); - - static - { - AVAILABLE_CODEPAGES.add("CP1250"); - AVAILABLE_CODEPAGES.add("CP1251"); - AVAILABLE_CODEPAGES.add("CP1252"); - AVAILABLE_CODEPAGES.add("GBK"); - AVAILABLE_CODEPAGES.add("GB2312"); - } - - public CodepageSettingDialog() - { - super(AVAILABLE_CODEPAGES); - } - - @Override - protected int dialogTitleResId() - { - return R.string.launcher_btn_cp_title; - } - - @Override - protected CharSequence itemName(final String item) - { - return item; - } -} diff --git a/android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/CodepageSettingController.java b/android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/LanguageSettingController.java similarity index 53% rename from android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/CodepageSettingController.java rename to android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/LanguageSettingController.java index 93d319df7..e4e226419 100644 --- a/android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/CodepageSettingController.java +++ b/android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/LanguageSettingController.java @@ -8,9 +8,9 @@ import eu.vcmi.vcmi.R; /** * @author F */ -public class CodepageSettingController extends LauncherSettingWithDialogController +public class LanguageSettingController extends LauncherSettingWithDialogController { - public CodepageSettingController(final AppCompatActivity activity) + public LanguageSettingController(final AppCompatActivity activity) { super(activity); } @@ -18,20 +18,20 @@ public class CodepageSettingController extends LauncherSettingWithDialogControll @Override protected LauncherSettingDialog dialog() { - return new CodepageSettingDialog(); + return new LanguageSettingDialog(); } @Override public void onItemChosen(final String item) { - mConfig.updateCodepage(item); + mConfig.updateLanguage(item); updateContent(); } @Override protected String mainText() { - return mActivity.getString(R.string.launcher_btn_cp_title); + return mActivity.getString(R.string.launcher_btn_language_title); } @Override @@ -41,8 +41,8 @@ public class CodepageSettingController extends LauncherSettingWithDialogControll { return ""; } - return mConfig.mCodepage == null || mConfig.mCodepage.isEmpty() - ? mActivity.getString(R.string.launcher_btn_cp_subtitle_unknown) - : mActivity.getString(R.string.launcher_btn_cp_subtitle, mConfig.mCodepage); + return mConfig.mLanguage == null || mConfig.mLanguage.isEmpty() + ? mActivity.getString(R.string.launcher_btn_language_subtitle_unknown) + : mActivity.getString(R.string.launcher_btn_language_subtitle, mConfig.mLanguage); } } diff --git a/android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/LanguageSettingDialog.java b/android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/LanguageSettingDialog.java new file mode 100644 index 000000000..1fb5e8894 --- /dev/null +++ b/android/vcmi-app/src/main/java/eu/vcmi/vcmi/settings/LanguageSettingDialog.java @@ -0,0 +1,47 @@ +package eu.vcmi.vcmi.settings; + +import java.util.ArrayList; +import java.util.List; + +import eu.vcmi.vcmi.R; + +/** + * @author F + */ +public class LanguageSettingDialog extends LauncherSettingDialog +{ + private static final List AVAILABLE_LANGUAGES = new ArrayList<>(); + + static + { + AVAILABLE_LANGUAGES.add("english"); + AVAILABLE_LANGUAGES.add("chinese"); + AVAILABLE_LANGUAGES.add("french"); + AVAILABLE_LANGUAGES.add("german"); + AVAILABLE_LANGUAGES.add("korean"); + AVAILABLE_LANGUAGES.add("polish"); + AVAILABLE_LANGUAGES.add("russian"); + AVAILABLE_LANGUAGES.add("spanish"); + AVAILABLE_LANGUAGES.add("ukrainian"); + AVAILABLE_LANGUAGES.add("other_cp1250"); + AVAILABLE_LANGUAGES.add("other_cp1251"); + AVAILABLE_LANGUAGES.add("other_cp1252"); + } + + public LanguageSettingDialog() + { + super(AVAILABLE_LANGUAGES); + } + + @Override + protected int dialogTitleResId() + { + return R.string.launcher_btn_language_title; + } + + @Override + protected CharSequence itemName(final String item) + { + return item; + } +} diff --git a/android/vcmi-app/src/main/res/values-de/strings.xml b/android/vcmi-app/src/main/res/values-de/strings.xml index df616c931..04bc85961 100644 --- a/android/vcmi-app/src/main/res/values-de/strings.xml +++ b/android/vcmi-app/src/main/res/values-de/strings.xml @@ -10,9 +10,9 @@ Aktuelle VCMI-Version: %1$s Mods Neue Burgen, Kreaturen, Objekte und Erweiterungen hinzufügen - Zeichensatz - Aktuell: unbekannt - Aktuell: %1$s + Sprache + Aktuell: unbekannt + Aktuell: %1$s Zeigermodus ändern Aktuell: %1$s Aktuell: %1$s diff --git a/android/vcmi-app/src/main/res/values-pl/strings.xml b/android/vcmi-app/src/main/res/values-pl/strings.xml index 771fb9495..0061449d0 100644 --- a/android/vcmi-app/src/main/res/values-pl/strings.xml +++ b/android/vcmi-app/src/main/res/values-pl/strings.xml @@ -10,9 +10,9 @@ Obecna wersja VCMI: %1$s Mody Zainstaluj nowe frakcje, obiekty, dodatki - Strona kodowa - Obecnie: nieznane - Obecnie: %1$s + Język + Obecnie: nieznane + Obecnie: %1$s Zmień tryb kursora Obecnie: %1$s Mnożnik prędkości kursora diff --git a/android/vcmi-app/src/main/res/values-ru/strings.xml b/android/vcmi-app/src/main/res/values-ru/strings.xml index b78cd4f05..7caa88ebb 100644 --- a/android/vcmi-app/src/main/res/values-ru/strings.xml +++ b/android/vcmi-app/src/main/res/values-ru/strings.xml @@ -10,9 +10,9 @@ Текущая версия VCMI: %1$s Моды Добавить новые замки, существа, объекты, расширения - Кодовая страница - Текущая: неизвестно - Текущая: %1$s + Язык + Текущая: неизвестно + Текущая: %1$s Изменить режим управления указателем Currently: %1$s Текущая: %1$s @@ -60,4 +60,4 @@ Загрузить данные VCMI во внутреннее хранилище Скопировать данные VCMI во внутреннее хранилище. Вы можете загрузить старую папку vcmi-data от версии 0.99 или файлы Героев Копируем %1$s - \ No newline at end of file + diff --git a/android/vcmi-app/src/main/res/values-uk/strings.xml b/android/vcmi-app/src/main/res/values-uk/strings.xml index 10ed5c286..095441f32 100644 --- a/android/vcmi-app/src/main/res/values-uk/strings.xml +++ b/android/vcmi-app/src/main/res/values-uk/strings.xml @@ -10,9 +10,9 @@ Поточна версія VCMI: %1$s Моди Додати нові замки, істот, об’єкти, розширення - Кодова сторінка - Поточна: невідомо - Поточна: %1$s + Мова + Поточна: невідомо + Поточна: %1$s Змінити режим керування курсором Поточна: %1$s Поточна: %1$s @@ -60,4 +60,4 @@ Завантажити дані VCMI у внутрішнє сховище Копіювати дані VCMI у внутрішнє сховище. Ви можете завантажити стару папку vcmi-data від версії 0.99 чи файли героїв Копіюємо %1$s - \ No newline at end of file + diff --git a/android/vcmi-app/src/main/res/values/strings.xml b/android/vcmi-app/src/main/res/values/strings.xml index 8858a876e..563911f18 100644 --- a/android/vcmi-app/src/main/res/values/strings.xml +++ b/android/vcmi-app/src/main/res/values/strings.xml @@ -15,9 +15,9 @@ Current VCMI version: %1$s Mods Install new factions, objects, extras - Codepage - Currently: unknown - Currently: %1$s + Language + Currently: unknown + Currently: %1$s Change pointer mode Currently: %1$s Relative pointer speed multiplier