Android: Replace inline strings with string resource references
This commit is contained in:
@ -12,7 +12,7 @@ public class AndroidProgressCallback {
|
||||
public AndroidProgressCallback(Activity context) {
|
||||
mContext = context;
|
||||
mDialog = new ProgressDialog(context);
|
||||
mDialog.setMessage("Please wait...");
|
||||
mDialog.setMessage(context.getString(R.string.android_progress_callback_please_wait));
|
||||
mDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
|
||||
mDialog.setIndeterminate(false);
|
||||
mDialog.setMax(100);
|
||||
@ -54,7 +54,7 @@ public class AndroidProgressCallback {
|
||||
new AlertDialog.Builder(mContext)
|
||||
.setTitle("Error")
|
||||
.setMessage(message)
|
||||
.setPositiveButton("OK", (dialog, button) -> {
|
||||
.setPositiveButton(mContext.getString(R.string.android_progress_callback_ok), (dialog, button) -> {
|
||||
dialog.dismiss();
|
||||
})
|
||||
.setOnDismissListener((dialogInterface) -> {
|
||||
@ -78,9 +78,9 @@ public class AndroidProgressCallback {
|
||||
Object lock = new Object();
|
||||
mContext.runOnUiThread(() -> {
|
||||
new AlertDialog.Builder(mContext)
|
||||
.setTitle("Information")
|
||||
.setTitle(mContext.getString(R.string.android_progress_callback_information))
|
||||
.setMessage(message)
|
||||
.setPositiveButton("OK", (dialog, button) -> {
|
||||
.setPositiveButton(mContext.getString(R.string.android_progress_callback_ok), (dialog, button) -> {
|
||||
dialog.dismiss();
|
||||
})
|
||||
.setOnDismissListener((dialogInterface) -> {
|
||||
@ -108,13 +108,13 @@ public class AndroidProgressCallback {
|
||||
ConfirmationResult result = new ConfirmationResult();
|
||||
mContext.runOnUiThread(() -> {
|
||||
new AlertDialog.Builder(mContext)
|
||||
.setTitle("Confirmation")
|
||||
.setTitle(mContext.getString(R.string.android_progress_callback_confirmation))
|
||||
.setMessage(message)
|
||||
.setPositiveButton("Yes", (dialog, button) -> {
|
||||
.setPositiveButton(mContext.getString(R.string.android_progress_callback_yes), (dialog, button) -> {
|
||||
result.result = true;
|
||||
dialog.dismiss();
|
||||
})
|
||||
.setNegativeButton("No", (dialog, button) -> {
|
||||
.setNegativeButton(mContext.getString(R.string.android_progress_callback_no), (dialog, button) -> {
|
||||
result.result = false;
|
||||
dialog.dismiss();
|
||||
})
|
||||
|
||||
@ -60,9 +60,9 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||
private void reportErrorOnUIThread(String message) {
|
||||
// Toast.makeText(this, message, Toast.LENGTH_LONG);
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle("Error")
|
||||
.setTitle(R.string.emulation_activity_error)
|
||||
.setMessage(message)
|
||||
.setPositiveButton("OK", (dialog, button) -> {
|
||||
.setPositiveButton(R.string.emulation_activity_ok, (dialog, button) -> {
|
||||
dialog.dismiss();
|
||||
enableFullscreenImmersive();
|
||||
})
|
||||
@ -77,9 +77,9 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||
runOnUiThread(() -> {
|
||||
// Toast.makeText(this, message, Toast.LENGTH_LONG);
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle("Error")
|
||||
.setTitle(R.string.emulation_activity_error)
|
||||
.setMessage(message)
|
||||
.setPositiveButton("OK", (dialog, button) -> {
|
||||
.setPositiveButton(R.string.emulation_activity_ok, (dialog, button) -> {
|
||||
dialog.dismiss();
|
||||
enableFullscreenImmersive();
|
||||
synchronized (lock) {
|
||||
@ -448,11 +448,11 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
|
||||
CharSequence[] items = new CharSequence[(codes != null) ? (codes.length + 1) : 1];
|
||||
items[0] = "Import Patch Codes...";
|
||||
items[0] = getString(R.string.emulation_activity_import_patch_codes);
|
||||
if (codes != null) {
|
||||
for (int i = 0; i < codes.length; i++) {
|
||||
final PatchCode cc = codes[i];
|
||||
items[i + 1] = String.format("%s %s", cc.isEnabled() ? "(ON)" : "(OFF)", cc.getDescription());
|
||||
items[i + 1] = String.format("%s %s", cc.isEnabled() ? getString(R.string.emulation_activity_patch_on) : getString(R.string.emulation_activity_patch_off), cc.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
@ -465,7 +465,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
intent.setType("*/*");
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
startActivityForResult(Intent.createChooser(intent, "Choose Patch Code File"), REQUEST_IMPORT_PATCH_CODES);
|
||||
startActivityForResult(Intent.createChooser(intent, getString(R.string.emulation_activity_choose_patch_code_file)), REQUEST_IMPORT_PATCH_CODES);
|
||||
}
|
||||
});
|
||||
builder.setOnCancelListener(dialogInterface -> onMenuClosed());
|
||||
@ -475,7 +475,7 @@ public class EmulationActivity extends AppCompatActivity implements SurfaceHolde
|
||||
private void importPatchesFromFile(Uri uri) {
|
||||
String str = FileUtil.readFileFromUri(this, uri, 512 * 1024);
|
||||
if (str == null || !AndroidHostInterface.getInstance().importPatchCodesFromString(str)) {
|
||||
reportErrorOnUIThread("Failed to import patch codes. Make sure you selected a PCSXR or Libretro format file.");
|
||||
reportErrorOnUIThread(getString(R.string.emulation_activity_failed_to_import_patch_codes));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -135,7 +135,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Intent i = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
||||
i.addCategory(Intent.CATEGORY_DEFAULT);
|
||||
i.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
|
||||
startActivityForResult(Intent.createChooser(i, "Choose directory"),
|
||||
startActivityForResult(Intent.createChooser(i, getString(R.string.main_activity_choose_directory)),
|
||||
REQUEST_ADD_DIRECTORY_TO_GAME_LIST);
|
||||
}
|
||||
|
||||
@ -190,11 +190,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
String path = FileUtil.getFullPathFromUri(uri, this);
|
||||
if (path.length() < 5) {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle("Error")
|
||||
.setMessage("Failed to get path for the selected file. Please make sure the file is in internal/external storage.\n\n" +
|
||||
"Tap the overflow button in the directory selector.\nSelect \"Show Internal Storage\".\n" +
|
||||
"Tap the menu button and select your device name or SD card.")
|
||||
.setPositiveButton("OK", (dialog, button) -> {
|
||||
.setTitle(R.string.main_activity_error)
|
||||
.setMessage(R.string.main_activity_get_path_from_file_error)
|
||||
.setPositiveButton(R.string.main_activity_ok, (dialog, button) -> {
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
@ -208,11 +206,9 @@ public class MainActivity extends AppCompatActivity {
|
||||
String path = FileUtil.getFullPathFromTreeUri(treeUri, this);
|
||||
if (path.length() < 5) {
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle("Error")
|
||||
.setMessage("Failed to get path for the selected directory. Please make sure the directory is in internal/external storage.\n\n" +
|
||||
"Tap the overflow button in the directory selector.\nSelect \"Show Internal Storage\".\n" +
|
||||
"Tap the menu button and select your device name or SD card.")
|
||||
.setPositiveButton("OK", (dialog, button) -> {
|
||||
.setTitle(R.string.main_activity_error)
|
||||
.setMessage(R.string.main_activity_get_path_from_directory_error)
|
||||
.setPositiveButton(R.string.main_activity_ok, (dialog, button) -> {
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
@ -298,7 +294,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(this,
|
||||
"External storage permissions are required to use DuckStation.",
|
||||
R.string.main_activity_external_storage_permissions_error,
|
||||
Toast.LENGTH_LONG);
|
||||
finish();
|
||||
}
|
||||
@ -320,7 +316,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
intent.setType("*/*");
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
startActivityForResult(Intent.createChooser(intent, "Choose Disc Image"), REQUEST_START_FILE);
|
||||
startActivityForResult(Intent.createChooser(intent, getString(R.string.main_activity_choose_disc_image)), REQUEST_START_FILE);
|
||||
}
|
||||
|
||||
private boolean doBIOSCheck() {
|
||||
@ -328,10 +324,10 @@ public class MainActivity extends AppCompatActivity {
|
||||
return true;
|
||||
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle("Missing BIOS Image")
|
||||
.setMessage("No BIOS image was found in DuckStation's bios directory. Do you with to locate and import a BIOS image now?")
|
||||
.setPositiveButton("Yes", (dialog, button) -> importBIOSImage())
|
||||
.setNegativeButton("No", (dialog, button) -> {
|
||||
.setTitle(R.string.main_activity_missing_bios_image)
|
||||
.setMessage(R.string.main_activity_missing_bios_image_prompt)
|
||||
.setPositiveButton(R.string.main_activity_yes, (dialog, button) -> importBIOSImage())
|
||||
.setNegativeButton(R.string.main_activity_no, (dialog, button) -> {
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
@ -343,7 +339,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
intent.setType("*/*");
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
startActivityForResult(Intent.createChooser(intent, "Choose BIOS Image"), REQUEST_IMPORT_BIOS_IMAGE);
|
||||
startActivityForResult(Intent.createChooser(intent, getString(R.string.main_activity_choose_bios_image)), REQUEST_IMPORT_BIOS_IMAGE);
|
||||
}
|
||||
|
||||
private void onImportBIOSImageResult(Uri uri) {
|
||||
@ -354,7 +350,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
try {
|
||||
stream = getContentResolver().openInputStream(uri);
|
||||
} catch (FileNotFoundException e) {
|
||||
Toast.makeText(this, "Failed to open BIOS image.", Toast.LENGTH_LONG);
|
||||
Toast.makeText(this, R.string.main_activity_failed_to_open_bios_image, Toast.LENGTH_LONG);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -365,13 +361,13 @@ public class MainActivity extends AppCompatActivity {
|
||||
while ((len = stream.read(buffer)) > 0) {
|
||||
os.write(buffer, 0, len);
|
||||
if (os.size() > MAX_BIOS_SIZE) {
|
||||
throw new IOException("BIOS image is too large.");
|
||||
throw new IOException(getString(R.string.main_activity_bios_image_too_large));
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
new AlertDialog.Builder(this)
|
||||
.setMessage("Failed to read BIOS image: " + e.getMessage())
|
||||
.setPositiveButton("OK", (dialog, button) -> {
|
||||
.setMessage(getString(R.string.main_activity_failed_to_read_bios_image_prefix) + e.getMessage())
|
||||
.setPositiveButton(R.string.main_activity_ok, (dialog, button) -> {
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
@ -379,11 +375,11 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
String importResult = AndroidHostInterface.getInstance().importBIOSImage(os.toByteArray());
|
||||
String message = (importResult == null) ? "This BIOS image is invalid, or has already been imported." : ("BIOS '" + importResult + "' imported.");
|
||||
String message = (importResult == null) ? getString(R.string.main_activity_invalid_error) : ("BIOS '" + importResult + "' imported.");
|
||||
|
||||
new AlertDialog.Builder(this)
|
||||
.setMessage(message)
|
||||
.setPositiveButton("OK", (dialog, button) -> {
|
||||
.setPositiveButton(R.string.main_activity_ok, (dialog, button) -> {
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
@ -392,14 +388,14 @@ public class MainActivity extends AppCompatActivity {
|
||||
private void showVersion() {
|
||||
final String message = AndroidHostInterface.getFullScmVersion();
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle("Version")
|
||||
.setTitle(R.string.main_activity_show_version_title)
|
||||
.setMessage(message)
|
||||
.setPositiveButton("OK", (dialog, button) -> {
|
||||
.setPositiveButton(R.string.main_activity_ok, (dialog, button) -> {
|
||||
})
|
||||
.setNeutralButton("Copy", (dialog, button) -> {
|
||||
.setNeutralButton(R.string.main_activity_copy, (dialog, button) -> {
|
||||
ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
|
||||
if (clipboard != null)
|
||||
clipboard.setPrimaryClip(ClipData.newPlainText("Version", message));
|
||||
clipboard.setPrimaryClip(ClipData.newPlainText(getString(R.string.main_activity_show_version_title), message));
|
||||
})
|
||||
.create()
|
||||
.show();
|
||||
|
||||
Reference in New Issue
Block a user