From a6df620b0fbb7c0cf2d3aa5443a0f0ebb96d8d33 Mon Sep 17 00:00:00 2001 From: SerpentSpirale Date: Thu, 9 Sep 2021 22:56:39 +0200 Subject: [PATCH] Un-hardcode strings resources --- .../java/net/kdt/pojavlaunch/ImportControlActivity.java | 9 ++++----- .../src/main/res/layout/import_control_layout.xml | 2 +- app_pojavlauncher/src/main/res/values/strings.xml | 7 +++++++ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/ImportControlActivity.java b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/ImportControlActivity.java index 7eb0b0bd5..01c532473 100644 --- a/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/ImportControlActivity.java +++ b/app_pojavlauncher/src/main/java/net/kdt/pojavlaunch/ImportControlActivity.java @@ -80,7 +80,7 @@ public class ImportControlActivity extends Activity { else runOnUiThread(() -> { Toast.makeText( ImportControlActivity.this, - "Invalid or corrupted file", + getText(R.string.import_control_invalid_file), Toast.LENGTH_SHORT).show(); finishAndRemoveTask(); }); @@ -95,17 +95,16 @@ public class ImportControlActivity extends Activity { String fileName = trimFileName(mEditText.getText().toString()); //Step 1 check for suffixes. if(!isFileNameValid(fileName)){ - Toast.makeText(this, "Invalid name or file already exists", Toast.LENGTH_SHORT).show(); + Toast.makeText(this, getText(R.string.import_control_invalid_name), Toast.LENGTH_SHORT).show(); return; } if(!mIsFileVerified){ - Toast.makeText(this, "The file is being verified, please wait and retry", Toast.LENGTH_LONG).show(); + Toast.makeText(this, getText(R.string.import_control_verifying_file), Toast.LENGTH_LONG).show(); return; } - Toast.makeText(getApplicationContext(), "Starting importation", Toast.LENGTH_SHORT).show(); - new File(Tools.CTRLMAP_PATH + "/TMP_IMPORT_FILE.json").renameTo(new File(Tools.CTRLMAP_PATH + "/" + fileName + ".json")); + Toast.makeText(getApplicationContext(), getText(R.string.import_control_done), Toast.LENGTH_SHORT).show(); finishAndRemoveTask(); } diff --git a/app_pojavlauncher/src/main/res/layout/import_control_layout.xml b/app_pojavlauncher/src/main/res/layout/import_control_layout.xml index e8a9790dc..4e5704f38 100644 --- a/app_pojavlauncher/src/main/res/layout/import_control_layout.xml +++ b/app_pojavlauncher/src/main/res/layout/import_control_layout.xml @@ -57,7 +57,7 @@ android:background="@drawable/mine_button_background" android:onClick="startImport" - android:text="IMPORT" + android:text="@string/import_control_import_button" android:textColor="@android:color/white" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="@+id/editText_import_control_file_name" diff --git a/app_pojavlauncher/src/main/res/values/strings.xml b/app_pojavlauncher/src/main/res/values/strings.xml index 520b29f9e..28614e8b5 100644 --- a/app_pojavlauncher/src/main/res/values/strings.xml +++ b/app_pojavlauncher/src/main/res/values/strings.xml @@ -160,6 +160,13 @@ Send custom keycode Scale up Scale down + + + Invalid or corrupted file + import controls + File is being verified, please wait and try again… + Invalid name or file already exists + Importation done