Un-hardcode strings resources

This commit is contained in:
SerpentSpirale 2021-09-09 22:56:39 +02:00 committed by SerpentSpirale
parent f48a05e3b5
commit a6df620b0f
3 changed files with 12 additions and 6 deletions

View File

@ -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();
}

View File

@ -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"

View File

@ -160,6 +160,13 @@
<string name="control_customkey">Send custom keycode</string>
<string name="control_scaleup">Scale up</string>
<string name="control_scaledown">Scale down</string>
<!-- ImportControlActivity Strings -->
<string name="import_control_invalid_file">Invalid or corrupted file</string>
<string name="import_control_import_button">import controls</string>
<string name="import_control_verifying_file">File is being verified, please wait and try again…</string>
<string name="import_control_invalid_name">Invalid name or file already exists</string>
<string name="import_control_done">Importation done</string>
<!--
<string name="control_more3"></string>
<string name="control_more4"></string>