Extracted all class hardcoded string

pull/120/head
Michael Schättgen 6 years ago
parent e2bff70109
commit 8b6d2694cc

@ -48,8 +48,8 @@ public class AegisApplication extends Application {
intent.setAction(Intent.ACTION_MAIN);
ShortcutInfo shortcut = new ShortcutInfo.Builder(this, "shortcut_new")
.setShortLabel("New profile")
.setLongLabel("Add new profile")
.setShortLabel(getString(R.string.new_profile))
.setLongLabel(getString(R.string.add_new_profile))
.setIcon(Icon.createWithResource(this, R.drawable.qr_scanner))
.setIntent(intent)
.build();

@ -14,6 +14,7 @@ import java.util.List;
import java.util.UUID;
import me.impy.aegis.BuildConfig;
import me.impy.aegis.R;
public class DatabaseManager {
private static final String FILENAME = "aegis.json";
@ -110,7 +111,7 @@ public class DatabaseManager {
dbFile.setContent(_db.toJson());
}
String dirName = !BuildConfig.DEBUG ? "Aegis" : "AegisDebug";
String dirName = !BuildConfig.DEBUG ? _context.getString(R.string.app_name) : _context.getString(R.string.app_name_dev);
File dir = new File(Environment.getExternalStorageDirectory(), dirName);
if (!dir.exists() && !dir.mkdirs()) {
throw new IOException("error creating external storage directory");

@ -114,8 +114,8 @@ public class AuthActivity extends AegisActivity implements FingerprintUiHelper.C
private void showError() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Decryption error");
builder.setMessage("Master key integrity check failed for every slot. Make sure you didn't mistype your password.");
builder.setTitle(getString(R.string.unlock_vault_error));
builder.setMessage(getString(R.string.unlock_vault_error_description));
builder.setCancelable(false);
builder.setPositiveButton(android.R.string.ok, null);
builder.create().show();

@ -95,7 +95,7 @@ public class EditEntryActivity extends AegisActivity {
_origEntry = (DatabaseEntry) intent.getSerializableExtra("entry");
_isNew = intent.getBooleanExtra("isNew", false);
if (_isNew) {
setTitle("Add profile");
setTitle(R.string.add_new_profile);
}
// set up fields
@ -194,8 +194,8 @@ public class EditEntryActivity extends AegisActivity {
ImagePicker imagePicker = ImagePicker.create(this)
.returnMode(ReturnMode.ALL)
.folderMode(true)
.toolbarFolderTitle("Folder")
.toolbarImageTitle("Tap to select")
.toolbarFolderTitle(getString(R.string.folder))
.toolbarImageTitle(getString(R.string.tap_to_select))
.toolbarArrowColor(Color.BLACK)
.single()
.showCamera(false)
@ -458,7 +458,7 @@ public class EditEntryActivity extends AegisActivity {
private void onSaveError(String msg) {
new AlertDialog.Builder(this)
.setTitle("Error saving profile")
.setTitle(getString(R.string.saving_profile_error))
.setMessage(msg)
.setPositiveButton(android.R.string.ok, null)
.show();

@ -64,9 +64,9 @@ public class IntroActivity extends AppIntro2 implements DerivationTask.Callback
setBarColor(getResources().getColor(R.color.colorPrimary));
SliderPage homeSliderPage = new SliderPage();
homeSliderPage.setTitle("Welcome");
homeSliderPage.setTitle(getString(R.string.welcome));
homeSliderPage.setTitleColor(getResources().getColor(R.color.primary_text_dark));
homeSliderPage.setDescription("Aegis is a secure, free and open source 2FA app");
homeSliderPage.setDescription(getString(R.string.app_description));
homeSliderPage.setDescColor(getResources().getColor(R.color.primary_text_dark));
homeSliderPage.setBgColor(getResources().getColor(R.color.colorSecondary));
addSlide(AppIntroFragment.newInstance(homeSliderPage));
@ -80,8 +80,8 @@ public class IntroActivity extends AppIntro2 implements DerivationTask.Callback
addSlide(_authenticatedSlide);
SliderPage endSliderPage = new SliderPage();
endSliderPage.setTitle("All done!");
endSliderPage.setDescription("Aegis has been set up and is ready to go.");
endSliderPage.setTitle(getString(R.string.setup_completed));
endSliderPage.setDescription(getString(R.string.setup_completed_description));
endSliderPage.setBgColor(getResources().getColor(R.color.colorSecondary));
_endSlide = AppIntroFragment.newInstance(endSliderPage);
addSlide(_endSlide);

@ -137,7 +137,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (!PermissionHelper.checkResults(grantResults)) {
Toast.makeText(this, "Permission denied", Toast.LENGTH_SHORT).show();
Toast.makeText(this, getString(R.string.permission_denied), Toast.LENGTH_SHORT).show();
return;
}
@ -273,7 +273,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
if (!_db.isLoaded() && !_db.fileExists()) {
// the db doesn't exist, start the intro
if (getPreferences().isIntroDone()) {
Toast.makeText(this, "Database file not found, starting intro...", Toast.LENGTH_SHORT).show();
Toast.makeText(this, getString(R.string.vault_not_found), Toast.LENGTH_SHORT).show();
}
Intent intro = new Intent(this, IntroActivity.class);
startActivityForResult(intro, CODE_DO_INTRO);
@ -304,7 +304,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
ClipboardManager clipboard = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("text/plain", entry.getInfo().getOtp());
clipboard.setPrimaryClip(clip);
Toast.makeText(this, "Code copied to the clipboard", Toast.LENGTH_SHORT).show();
Toast.makeText(this, getString(R.string.code_copied), Toast.LENGTH_SHORT).show();
});
dialog.findViewById(R.id.delete_button).setOnClickListener(view -> {
@ -379,7 +379,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
}
}
} catch (DatabaseManagerException e) {
Toast.makeText(this, "An error occurred while trying to load/decrypt the database", Toast.LENGTH_LONG).show();
Toast.makeText(this, getString(R.string.decryption_error), Toast.LENGTH_LONG).show();
startAuthActivity();
return;
}
@ -403,7 +403,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
try {
_db.save();
} catch (DatabaseManagerException e) {
Toast.makeText(this, "An error occurred while trying to save the database", Toast.LENGTH_LONG).show();
Toast.makeText(this, getString(R.string.saving_error), Toast.LENGTH_LONG).show();
}
}

@ -144,14 +144,14 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Pas
dialog.show(getActivity().getSupportFragmentManager(), null);
} else {
new AlertDialog.Builder(getActivity())
.setTitle("Disable encryption")
.setMessage("Are you sure you want to disable encryption? This will cause the database to be stored in plain text")
.setTitle(getString(R.string.disable_encryption))
.setMessage(getString(R.string.disable_encryption_description))
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
try {
_db.disableEncryption();
} catch (DatabaseManagerException e) {
Toast.makeText(getActivity(), "An error occurred while enabling encryption", Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), getString(R.string.encrypting_error), Toast.LENGTH_SHORT).show();
}
updateEncryptionPreference();
}
@ -178,7 +178,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Pas
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (!PermissionHelper.checkResults(grantResults)) {
Toast.makeText(getActivity(), "Permission denied", Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), getString(R.string.permission_denied), Toast.LENGTH_SHORT).show();
return;
}
@ -229,7 +229,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Pas
String[] names = importers.keySet().toArray(new String[importers.size()]);
new AlertDialog.Builder(getActivity())
.setTitle("Select the application you'd like to import a database from")
.setTitle(getString(R.string.choose_application))
.setSingleChoiceItems(names, 0, null)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
@ -256,7 +256,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Pas
try {
importDatabase(_importer);
} catch (DatabaseImporterException e) {
Toast.makeText(getActivity(), "An error occurred while trying to parse the file", Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), getString(R.string.parsing_file_error), Toast.LENGTH_SHORT).show();
}
_importer = null;
@ -273,11 +273,11 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Pas
try (InputStream fileStream = getActivity().getContentResolver().openInputStream(uri)) {
stream = ByteInputStream.create(fileStream);
} catch (FileNotFoundException e) {
Toast.makeText(getActivity(), "Error: File not found", Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), getString(R.string.file_not_found), Toast.LENGTH_SHORT).show();
return;
} catch (IOException e) {
e.printStackTrace();
Toast.makeText(getActivity(), "An error occurred while trying to read the file", Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), getString(R.string.reading_file_error), Toast.LENGTH_SHORT).show();
return;
}
@ -298,7 +298,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Pas
importDatabase(importer);
} catch (DatabaseImporterException e) {
e.printStackTrace();
Toast.makeText(getActivity(), "An error occurred while trying to parse the file", Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), getString(R.string.parsing_file_error), Toast.LENGTH_SHORT).show();
}
}
@ -318,7 +318,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Pas
}
_result.putExtra("needsRecreate", true);
Toast.makeText(getActivity(), String.format(Locale.getDefault(), "Imported %d entries", entries.size()), Toast.LENGTH_LONG).show();
Toast.makeText(getActivity(), String.format(Locale.getDefault(), getString(R.string.imported_entries_count), entries.size()), Toast.LENGTH_LONG).show();
}
private void onExport() {
@ -335,14 +335,14 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Pas
try {
filename = _db.export(checked[0]);
} catch (DatabaseManagerException e) {
Toast.makeText(getActivity(), "An error occurred while trying to export the database", Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), getString(R.string.exporting_database_error), Toast.LENGTH_SHORT).show();
return;
}
// make sure the new file is visible
MediaScannerConnection.scanFile(getActivity(), new String[]{filename}, null, null);
Toast.makeText(getActivity(), "The database has been exported to: " + filename, Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), getString(R.string.export_database_location) + filename, Toast.LENGTH_SHORT).show();
})
.setNegativeButton(android.R.string.cancel, null);
if (_db.isEncryptionEnabled()) {
@ -355,7 +355,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Pas
}
});
} else {
builder.setMessage("This action will export the database out of Android's private storage.");
builder.setMessage(getString(R.string.export_warning));
}
builder.show();
}
@ -374,7 +374,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Pas
try {
_db.save();
} catch (DatabaseManagerException e) {
Toast.makeText(getActivity(), "An error occurred while trying to save the database", Toast.LENGTH_LONG).show();
Toast.makeText(getActivity(), getString(R.string.saving_error), Toast.LENGTH_LONG).show();
return false;
}
@ -400,7 +400,7 @@ public class PreferencesFragment extends PreferenceFragmentCompat implements Pas
@Override
public void onException(Exception e) {
updateEncryptionPreference();
Toast.makeText(getActivity(), "An error occurred while trying to set the password: " + e.getMessage(), Toast.LENGTH_SHORT).show();
Toast.makeText(getActivity(), getString(R.string.encryption_set_password_error) + e.getMessage(), Toast.LENGTH_SHORT).show();
}
private void updateEncryptionPreference() {

@ -47,7 +47,7 @@ public class ScannerActivity extends AegisActivity implements ZXingScannerView.R
if (camera == -1) {
camera = getFrontCameraId();
if (camera == -1) {
Toast.makeText(this, "No cameras available", Toast.LENGTH_LONG).show();
Toast.makeText(this, getString(R.string.no_cameras_available), Toast.LENGTH_LONG).show();
finish();
}
_facing = CAMERA_FACING_FRONT;
@ -117,7 +117,7 @@ public class ScannerActivity extends AegisActivity implements ZXingScannerView.R
setResult(RESULT_OK, intent);
finish();
} catch (GoogleAuthInfoException e) {
Toast.makeText(this, "An error occurred while trying to parse the QR code contents", Toast.LENGTH_SHORT).show();
Toast.makeText(this, getString(R.string.read_qr_error), Toast.LENGTH_SHORT).show();
}
_scannerView.resumeCameraPreview(this);

@ -150,13 +150,13 @@ public class SlotManagerActivity extends AegisActivity implements SlotAdapter.Li
public void onRemoveSlot(Slot slot) {
SlotList slots = _creds.getSlots();
if (slot instanceof PasswordSlot && slots.findAll(PasswordSlot.class).size() <= 1) {
Toast.makeText(this, "You must have at least one password slot", Toast.LENGTH_SHORT).show();
Toast.makeText(this, R.string.password_slot_error, Toast.LENGTH_SHORT).show();
return;
}
new AlertDialog.Builder(this)
.setTitle("Remove slot")
.setMessage("Are you sure you want to remove this slot?")
.setTitle(R.string.remove_slot)
.setMessage(R.string.remove_slot_description)
.setPositiveButton(android.R.string.yes, (dialog, whichButton) -> {
slots.remove(slot);
_adapter.removeSlot(slot);
@ -184,6 +184,6 @@ public class SlotManagerActivity extends AegisActivity implements SlotAdapter.Li
@Override
public void onException(Exception e) {
Toast.makeText(this, "An error occurred while trying to add a new slot: " + e.getMessage(), Toast.LENGTH_SHORT).show();
Toast.makeText(this, getString(R.string.adding_new_slot_error) + e.getMessage(), Toast.LENGTH_SHORT).show();
}
}

@ -13,8 +13,8 @@ public class Dialogs {
public static AlertDialog showDeleteEntryDialog(Activity activity, DialogInterface.OnClickListener onDelete) {
return new AlertDialog.Builder(activity)
.setTitle("Delete entry")
.setMessage("Are you sure you want to delete this entry?")
.setTitle(activity.getString(R.string.delete_entry))
.setMessage(activity.getString(R.string.delete_entry_description))
.setPositiveButton(android.R.string.yes, onDelete)
.setNegativeButton(android.R.string.no, null)
.show();
@ -22,8 +22,8 @@ public class Dialogs {
public static AlertDialog showDiscardDialog(Activity activity, DialogInterface.OnClickListener onSave, DialogInterface.OnClickListener onDiscard) {
return new AlertDialog.Builder(activity)
.setTitle("Discard changes?")
.setMessage("Your changes have not been saved")
.setTitle(activity.getString(R.string.discard_changes))
.setMessage(activity.getString(R.string.discard_changes_description))
.setPositiveButton(R.string.save, onSave)
.setNegativeButton(R.string.discard, onDiscard)
.show();

@ -45,7 +45,7 @@ public class FingerprintDialogFragment extends SlotDialogFragment implements Fin
}
return new AlertDialog.Builder(getActivity())
.setTitle("Register a new fingerprint")
.setTitle(R.string.register_fingerprint)
.setView(view)
.setNegativeButton(android.R.string.cancel, null)
.create();

@ -30,7 +30,7 @@ public class PasswordDialogFragment extends SlotDialogFragment {
EditText textPasswordConfirm = view.findViewById(R.id.text_password_confirm);
AlertDialog alert = new AlertDialog.Builder(getActivity())
.setTitle("Enter a new password")
.setTitle(R.string.set_password)
.setView(view)
.setPositiveButton(android.R.string.ok, null)
.setNegativeButton(android.R.string.cancel, null)

@ -154,9 +154,9 @@ public class CustomAuthenticatedSlide extends Fragment implements FingerprintUiH
public void onUserIllegallyRequestedNextPage() {
String message;
if (!EditTextHelper.areEditTextsEqual(_textPassword, _textPasswordConfirm)) {
message = "Passwords should be equal and non-empty";
message = getString(R.string.password_equality_error);
} else if (!_fingerAuthenticated) {
message = "Register your fingerprint";
message = getString(R.string.register_fingerprint);
} else {
return;
}

@ -57,7 +57,7 @@ public class CustomAuthenticationSlide extends Fragment implements ISlidePolicy,
@Override
public void onUserIllegallyRequestedNextPage() {
Snackbar snackbar = Snackbar.make(getView(), "Please select an authentication method", Snackbar.LENGTH_LONG);
Snackbar snackbar = Snackbar.make(getView(), getString(R.string.snackbar_authentication_method), Snackbar.LENGTH_LONG);
snackbar.show();
}

@ -4,6 +4,7 @@ import android.content.Context;
import javax.crypto.SecretKey;
import me.impy.aegis.R;
import me.impy.aegis.crypto.CryptoUtils;
import me.impy.aegis.crypto.SCryptParameters;
import me.impy.aegis.db.slots.PasswordSlot;
@ -12,7 +13,7 @@ public class DerivationTask extends ProgressDialogTask<DerivationTask.Params, Se
private Callback _cb;
public DerivationTask(Context context, Callback cb) {
super(context, "Deriving key from password");
super(context, context.getString(R.string.encrypting_vault));
_cb = cb;
}

@ -5,6 +5,7 @@ import android.content.Context;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import me.impy.aegis.R;
import me.impy.aegis.crypto.MasterKey;
import me.impy.aegis.db.slots.FingerprintSlot;
import me.impy.aegis.db.slots.PasswordSlot;
@ -18,7 +19,7 @@ public class SlotListTask<T extends Slot> extends ProgressDialogTask<SlotListTas
private Class<T> _type;
public SlotListTask(Class<T> type, Context context, Callback cb) {
super(context, "Decrypting database");
super(context, context.getString(R.string.unlocking_vault));
_cb = cb;
_type = type;
}

@ -33,10 +33,10 @@ public class SlotHolder extends RecyclerView.ViewHolder {
public void setData(Slot slot) {
if (slot instanceof PasswordSlot) {
_slotName.setText("Password");
_slotName.setText(R.string.password);
_slotImg.setImageResource(R.drawable.ic_create_black_24dp);
} else if (slot instanceof FingerprintSlot) {
_slotName.setText("Finger");
_slotName.setText(R.string.authentication_method_fingerprint);
_slotImg.setImageResource(R.drawable.ic_fingerprint_black_24dp);
if (FingerprintHelper.isSupported()) {
try {
@ -47,7 +47,7 @@ public class SlotHolder extends RecyclerView.ViewHolder {
} catch (KeyStoreHandleException e) { }
}
} else if (slot instanceof RawSlot) {
_slotName.setText("Raw");
_slotName.setText(R.string.authentication_method_raw);
_slotImg.setImageResource(R.drawable.ic_vpn_key_black_24dp);
} else {
throw new RuntimeException();

@ -1,5 +1,6 @@
<resources>
<string name="app_name">Aegis</string>
<string name="app_name_dev">AegisDev</string>
<string name="action_settings">Settings</string>
<string name="action_import">Import</string>
<string name="action_delete">Delete</string>
@ -84,4 +85,48 @@
<string name="delete">Delete</string>
<string name="password">Password</string>
<string name="confirm_password">Confirm password</string>
<string name="new_profile">New profile</string>
<string name="add_new_profile">Add new profile</string>
<string name="unlock_vault_error">Couldn\'t unlock vault</string>
<string name="unlock_vault_error_description">Incorrect password. Make sure you didn\'t mistype your password.</string>
<string name="password_equality_error">Passwords should be equal and non-empty</string>
<string name="register_fingerprint">Register your fingerprint</string>
<string name="snackbar_authentication_method">Please select an authentication method</string>
<string name="encrypting_vault">Encrypting the vault</string>
<string name="delete_entry">Delete entry</string>
<string name="delete_entry_description">Are you sure you want to delete this entry?</string>
<string name="discard_changes">Discard changes?</string>
<string name="discard_changes_description">Your changes have not been saved</string>
<string name="folder">Folder</string>
<string name="tap_to_select">Tap to select</string>
<string name="saving_profile_error">Error saving profile</string>
<string name="welcome">Welcome</string>
<string name="app_description">Aegis is a secure, free and open source 2FA app</string>
<string name="setup_completed">Setup completed</string>
<string name="setup_completed_description">Aegis has been setup and is ready to go.</string>
<string name="vault_not_found">Vault not found, starting setup…</string>
<string name="code_copied">Code copied to the clipboard</string>
<string name="decryption_error">An error occurred while trying to unlock the vault</string>
<string name="saving_error">An error occurred while trying to save the vault</string>
<string name="disable_encryption">Disable encryption</string>
<string name="disable_encryption_description">Are you sure you want to disable encryption? This will cause the vault to be stored in plain text.</string>
<string name="encrypting_error">An error occurred while enabling encryption</string>
<string name="permission_denied">Permission denied</string>
<string name="choose_application">Select the application you\'d like to import a database from</string>
<string name="parsing_file_error">An error occurred while trying to parse the file</string>
<string name="file_not_found">Error: File not found</string>
<string name="reading_file_error">An error occurred while trying to read the file</string>
<string name="imported_entries_count">Imported %d entries</string>
<string name="exporting_database_error">An error occurred while trying to export the database</string>
<string name="export_database_location">The database has been exported to:</string>
<string name="export_warning">This action will export the database out of Aegis\' private storage.</string>
<string name="encryption_set_password_error">An error occurred while trying to set the password:</string>
<string name="no_cameras_available">No cameras available</string>
<string name="read_qr_error">An error occurred while trying to read the QR code</string>
<string name="authentication_method_raw">Raw</string>
<string name="unlocking_vault">Unlocking the vault</string>
<string name="password_slot_error">You must have at least one password slot</string>
<string name="remove_slot">Remove slot</string>
<string name="remove_slot_description">Are you sure you want to remove this slot?</string>
<string name="adding_new_slot_error">An error occurred while trying to add a new slot:</string>
</resources>

Loading…
Cancel
Save