diff options
Diffstat (limited to 'src')
18 files changed, 300 insertions, 301 deletions
diff --git a/src/org/thialfihar/android/apg/Apg.java b/src/org/thialfihar/android/apg/Apg.java index efff72bd0..bc5523863 100644 --- a/src/org/thialfihar/android/apg/Apg.java +++ b/src/org/thialfihar/android/apg/Apg.java @@ -977,7 +977,7 @@ public class Apg { public static String getMainUserIdSafe(Context context, PGPPublicKey key) {
String userId = getMainUserId(key);
if (userId == null) {
- userId = context.getResources().getString(R.string.unknown_user_id);
+ userId = context.getResources().getString(R.string.unknownUserId);
}
return userId;
}
@@ -985,7 +985,7 @@ public class Apg { public static String getMainUserIdSafe(Context context, PGPSecretKey key) {
String userId = getMainUserId(key);
if (userId == null) {
- userId = context.getResources().getString(R.string.unknown_user_id);
+ userId = context.getResources().getString(R.string.unknownUserId);
}
return userId;
}
diff --git a/src/org/thialfihar/android/apg/AskForSecretKeyPassPhrase.java b/src/org/thialfihar/android/apg/AskForSecretKeyPassPhrase.java index d3d424166..afc8e4320 100644 --- a/src/org/thialfihar/android/apg/AskForSecretKeyPassPhrase.java +++ b/src/org/thialfihar/android/apg/AskForSecretKeyPassPhrase.java @@ -45,21 +45,21 @@ public class AskForSecretKeyPassPhrase { if (secretKeyId == 0) {
secretKey = null;
- alert.setMessage("Pass phrase for symmetric encryption");
+ alert.setMessage(context.getString(R.string.passPhraseForSymmetricEncryption));
} else {
secretKey = Apg.getMasterKey(Apg.findSecretKeyRing(secretKeyId));
if (secretKey == null) {
return null;
}
String userId = Apg.getMainUserIdSafe(context, secretKey);
- alert.setMessage("Pass phrase for " + userId);
+ alert.setMessage(context.getString(R.string.passPhraseFor, userId));
}
LayoutInflater inflater =
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.pass_phrase, null);
- final EditText input = (EditText) view.findViewById(R.id.pass_phrase);
- final EditText inputNotUsed = (EditText) view.findViewById(R.id.pass_phrase_again);
+ final EditText input = (EditText) view.findViewById(R.id.passPhrase);
+ final EditText inputNotUsed = (EditText) view.findViewById(R.id.passPhraseAgain);
inputNotUsed.setVisibility(View.GONE);
alert.setView(view);
@@ -77,7 +77,7 @@ public class AskForSecretKeyPassPhrase { new BouncyCastleProvider());
} catch (PGPException e) {
Toast.makeText(activity,
- R.string.wrong_pass_phrase,
+ R.string.wrongPassPhrase,
Toast.LENGTH_SHORT).show();
return;
}
diff --git a/src/org/thialfihar/android/apg/BaseActivity.java b/src/org/thialfihar/android/apg/BaseActivity.java index 15a9b7156..bf386f1ed 100644 --- a/src/org/thialfihar/android/apg/BaseActivity.java +++ b/src/org/thialfihar/android/apg/BaseActivity.java @@ -70,27 +70,27 @@ public class BaseActivity extends Activity mProgressDialog.setCancelable(false);
switch (id) {
case Id.dialog.encrypting: {
- mProgressDialog.setMessage("initializing...");
+ mProgressDialog.setMessage(this.getString(R.string.progress_initializing));
return mProgressDialog;
}
case Id.dialog.decrypting: {
- mProgressDialog.setMessage("initializing...");
+ mProgressDialog.setMessage(this.getString(R.string.progress_initializing));
return mProgressDialog;
}
case Id.dialog.saving: {
- mProgressDialog.setMessage("saving...");
+ mProgressDialog.setMessage(this.getString(R.string.progress_saving));
return mProgressDialog;
}
case Id.dialog.importing: {
- mProgressDialog.setMessage("importing...");
+ mProgressDialog.setMessage(this.getString(R.string.progress_importing));
return mProgressDialog;
}
case Id.dialog.exporting: {
- mProgressDialog.setMessage("exporting...");
+ mProgressDialog.setMessage(this.getString(R.string.progress_exporting));
return mProgressDialog;
}
@@ -109,8 +109,8 @@ public class BaseActivity extends Activity AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setIcon(android.R.drawable.ic_dialog_alert);
- alert.setTitle("Error");
- alert.setMessage("The pass phrases didn't match.");
+ alert.setTitle(R.string.error);
+ alert.setMessage(R.string.passPhrasesDoNotMatch);
alert.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
@@ -127,8 +127,8 @@ public class BaseActivity extends Activity AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setIcon(android.R.drawable.ic_dialog_alert);
- alert.setTitle("Error");
- alert.setMessage("Empty pass phrases are not supported.");
+ alert.setTitle(R.string.error);
+ alert.setMessage(R.string.passPhraseMustNotBeEmpty);
alert.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
@@ -145,24 +145,28 @@ public class BaseActivity extends Activity AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setIcon(android.R.drawable.ic_dialog_alert);
- alert.setTitle("Warning");
- alert.setMessage("Are you sure you want to delete\n" + getDeleteFile() + "?");
+ alert.setTitle(R.string.warning);
+ alert.setMessage(this.getString(R.string.fileDeleteConfirmation, getDeleteFile()));
alert.setPositiveButton(android.R.string.ok,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- removeDialog(Id.dialog.delete_file);
- File file = new File(getDeleteFile());
- String msg = "";
- if (file.delete()) {
- msg = "Successfully deleted.";
- } else {
- msg = "Error: deleting '" + file + "' failed";
- }
- Toast.makeText(BaseActivity.this,
- msg, Toast.LENGTH_SHORT).show();
- }
- });
+ new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ removeDialog(Id.dialog.delete_file);
+ File file = new File(getDeleteFile());
+ String msg = "";
+ if (file.delete()) {
+ msg = BaseActivity.this.getString(
+ R.string.fileDeleteSuccessful);
+ } else {
+ msg = BaseActivity.this.getString(
+ R.string.errorMessage,
+ BaseActivity.this.getString(
+ R.string.error_fileDeleteFailed, file));
+ }
+ Toast.makeText(BaseActivity.this,
+ msg, Toast.LENGTH_SHORT).show();
+ }
+ });
alert.setNegativeButton(android.R.string.cancel,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
diff --git a/src/org/thialfihar/android/apg/DecryptActivity.java b/src/org/thialfihar/android/apg/DecryptActivity.java index dd825eaa8..5593c25f2 100644 --- a/src/org/thialfihar/android/apg/DecryptActivity.java +++ b/src/org/thialfihar/android/apg/DecryptActivity.java @@ -91,9 +91,9 @@ public class DecryptActivity extends BaseActivity { setContentView(R.layout.decrypt); mSource = (ViewFlipper) findViewById(R.id.source); - mSourceLabel = (TextView) findViewById(R.id.source_label); - mSourcePrevious = (ImageView) findViewById(R.id.source_previous); - mSourceNext = (ImageView) findViewById(R.id.source_next); + mSourceLabel = (TextView) findViewById(R.id.sourceLabel); + mSourcePrevious = (ImageView) findViewById(R.id.sourcePrevious); + mSourceNext = (ImageView) findViewById(R.id.sourceNext); mSourcePrevious.setClickable(true); mSourcePrevious.setOnClickListener(new OnClickListener() { @@ -128,14 +128,14 @@ public class DecryptActivity extends BaseActivity { mMessage = (EditText) findViewById(R.id.message); mDecryptButton = (Button) findViewById(R.id.btn_decrypt); mReplyButton = (Button) findViewById(R.id.btn_reply); - mSignatureLayout = (LinearLayout) findViewById(R.id.layout_signature); + mSignatureLayout = (LinearLayout) findViewById(R.id.signature); mSignatureStatusImage = (ImageView) findViewById(R.id.ic_signature_status); - mUserId = (TextView) findViewById(R.id.main_user_id); - mUserIdRest = (TextView) findViewById(R.id.main_user_id_rest); + mUserId = (TextView) findViewById(R.id.mainUserId); + mUserIdRest = (TextView) findViewById(R.id.mainUserIdRest); // measure the height of the source_file view and set the message view's min height to that, // so it fills mSource fully... bit of a hack. - View tmp = findViewById(R.id.source_file); + View tmp = findViewById(R.id.sourceFile); tmp.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); int height = tmp.getMeasuredHeight(); mMessage.setMinimumHeight(height); @@ -149,12 +149,12 @@ public class DecryptActivity extends BaseActivity { } }); - mDeleteAfter = (CheckBox) findViewById(R.id.delete_after_decryption); + mDeleteAfter = (CheckBox) findViewById(R.id.deleteAfterDecryption); // default: message source mSource.setInAnimation(null); mSource.setOutAnimation(null); - while (mSource.getCurrentView().getId() != R.id.source_message) { + while (mSource.getCurrentView().getId() != R.id.sourceMessage) { mSource.showNext(); } @@ -206,12 +206,12 @@ public class DecryptActivity extends BaseActivity { } else if (intent.getAction() != null && intent.getAction().equals(Apg.Intent.DECRYPT_FILE)) { mSource.setInAnimation(null); mSource.setOutAnimation(null); - while (mSource.getCurrentView().getId() != R.id.source_file) { + while (mSource.getCurrentView().getId() != R.id.sourceFile) { mSource.showNext(); } } - if (mSource.getCurrentView().getId() == R.id.source_message && + if (mSource.getCurrentView().getId() == R.id.sourceMessage && mMessage.getText().length() == 0) { ClipboardManager clip = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); String data = ""; @@ -222,7 +222,7 @@ public class DecryptActivity extends BaseActivity { if (matcher.matches()) { data = matcher.group(1); mMessage.setText(data); - Toast.makeText(this, R.string.using_clipboard_content, Toast.LENGTH_SHORT).show(); + Toast.makeText(this, R.string.usingClipboardContent, Toast.LENGTH_SHORT).show(); } } @@ -243,7 +243,7 @@ public class DecryptActivity extends BaseActivity { }); mReplyButton.setVisibility(View.INVISIBLE); - if (mSource.getCurrentView().getId() == R.id.source_message && + if (mSource.getCurrentView().getId() == R.id.sourceMessage && mMessage.getText().length() > 0) { mDecryptButton.performClick(); } @@ -258,14 +258,14 @@ public class DecryptActivity extends BaseActivity { intent.setData(Uri.parse("file://" + filename)); - intent.putExtra(FileManager.EXTRA_TITLE, "Select file to decrypt..."); - intent.putExtra(FileManager.EXTRA_BUTTON_TEXT, "Open"); + intent.putExtra(FileManager.EXTRA_TITLE, getString(R.string.filemanager_titleDecrypt)); + intent.putExtra(FileManager.EXTRA_BUTTON_TEXT, R.string.filemanager_btnOpen); try { startActivityForResult(intent, Id.request.filename); } catch (ActivityNotFoundException e) { // No compatible file manager was found. - Toast.makeText(this, R.string.no_filemanager_installed, Toast.LENGTH_SHORT).show(); + Toast.makeText(this, R.string.oiFilemanagerNotInstalled, Toast.LENGTH_SHORT).show(); } } @@ -281,13 +281,13 @@ public class DecryptActivity extends BaseActivity { private void updateSource() { switch (mSource.getCurrentView().getId()) { - case R.id.source_file: { + case R.id.sourceFile: { mSourceLabel.setText(R.string.label_file); mDecryptButton.setText(R.string.btn_decrypt); break; } - case R.id.source_message: { + case R.id.sourceMessage: { mSourceLabel.setText(R.string.label_message); mDecryptButton.setText(R.string.btn_decrypt); break; @@ -300,7 +300,7 @@ public class DecryptActivity extends BaseActivity { } private void decryptClicked() { - if (mSource.getCurrentView().getId() == R.id.source_file) { + if (mSource.getCurrentView().getId() == R.id.sourceFile) { mDecryptTarget = Id.target.file; } else { mDecryptTarget = Id.target.message; @@ -316,13 +316,15 @@ public class DecryptActivity extends BaseActivity { } if (mInputFilename.equals("")) { - Toast.makeText(this, "Select a file first.", Toast.LENGTH_SHORT).show(); + Toast.makeText(this, R.string.noFileSelected, Toast.LENGTH_SHORT).show(); return; } File file = new File(mInputFilename); if (!file.exists() || !file.isFile()) { - Toast.makeText(this, "Error: file not found", Toast.LENGTH_SHORT).show(); + Toast.makeText(this, getString(R.string.errorMessage, + getString(R.string.error_fileNotFound)), + Toast.LENGTH_SHORT).show(); return; } } @@ -350,7 +352,7 @@ public class DecryptActivity extends BaseActivity { try { setSecretKeyId(Apg.getDecryptionKeyId(in)); if (getSecretKeyId() == 0) { - throw new Apg.GeneralException("no suitable secret key found"); + throw new Apg.GeneralException(getString(R.string.error_noSecretKeyFound)); } mAssumeSymmetricEncryption = false; } catch (Apg.NoAsymmetricEncryptionException e) { @@ -363,21 +365,22 @@ public class DecryptActivity extends BaseActivity { in = new ByteArrayInputStream(mMessage.getText().toString().getBytes()); } if (!Apg.hasSymmetricEncryption(in)) { - throw new Apg.GeneralException("no known kind of encryption found"); + throw new Apg.GeneralException(getString(R.string.error_noKnownEncryptionFound)); } mAssumeSymmetricEncryption = true; } showDialog(Id.dialog.pass_phrase); } catch (FileNotFoundException e) { - error = "file not found: " + e.getLocalizedMessage(); + error = getString(R.string.error_fileNotFound); } catch (IOException e) { error = e.getLocalizedMessage(); } catch (Apg.GeneralException e) { error = e.getLocalizedMessage(); } if (error != null) { - Toast.makeText(this, "Error: " + error, Toast.LENGTH_SHORT).show(); + Toast.makeText(this, getString(R.string.errorMessage, error), + Toast.LENGTH_SHORT).show(); } } @@ -481,12 +484,13 @@ public class DecryptActivity extends BaseActivity { String error = data.getString("error"); if (error != null) { Toast.makeText(DecryptActivity.this, - "Error: " + data.getString("error"), + getString(R.string.errorMessage, + data.getString("error")), Toast.LENGTH_SHORT).show(); return; } - Toast.makeText(this, "Successfully decrypted.", Toast.LENGTH_SHORT).show(); + Toast.makeText(this, R.string.decryptionSuccessful, Toast.LENGTH_SHORT).show(); switch (mDecryptTarget) { case Id.target.message: { String decryptedMessage = data.getString("decryptedMessage"); @@ -514,7 +518,7 @@ public class DecryptActivity extends BaseActivity { mSignatureKeyId = data.getLong("signatureKeyId"); mUserIdRest.setText("id: " + Long.toHexString(mSignatureKeyId & 0xffffffffL)); if (userId == null) { - userId = getResources().getString(R.string.unknown_user_id); + userId = getResources().getString(R.string.unknownUserId); } String chunks[] = userId.split(" <", 2); userId = chunks[0]; @@ -583,9 +587,8 @@ public class DecryptActivity extends BaseActivity { protected Dialog onCreateDialog(int id) { switch (id) { case Id.dialog.output_filename: { - return FileDialog.build(this, "Decrypt to file", - "Please specify which file to decrypt to.\n" + - "WARNING! File will be overwritten if it exists.", + return FileDialog.build(this, getString(R.string.title_decryptToFile), + getString(R.string.specifyFileToDecryptTo), mOutputFilename, new FileDialog.OnClickListener() { @@ -601,8 +604,8 @@ public class DecryptActivity extends BaseActivity { removeDialog(Id.dialog.output_filename); } }, - getString(R.string.filemanager_title_save), - getString(R.string.filemanager_btn_save), + getString(R.string.filemanager_titleSave), + getString(R.string.filemanager_btnSave), Id.request.output_filename); } diff --git a/src/org/thialfihar/android/apg/EditKeyActivity.java b/src/org/thialfihar/android/apg/EditKeyActivity.java index a1c281030..6fd21178c 100644 --- a/src/org/thialfihar/android/apg/EditKeyActivity.java +++ b/src/org/thialfihar/android/apg/EditKeyActivity.java @@ -103,11 +103,11 @@ public class EditKeyActivity extends BaseActivity implements OnClickListener { LinearLayout container = (LinearLayout) findViewById(R.id.container); mUserIds = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false); - mUserIds.setType(SectionView.TYPE_USER_ID); + mUserIds.setType(Id.type.user_id); mUserIds.setUserIds(userIds); container.addView(mUserIds); mKeys = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false); - mKeys.setType(SectionView.TYPE_KEY); + mKeys.setType(Id.type.key); mKeys.setKeys(keys); container.addView(mKeys); @@ -122,7 +122,7 @@ public class EditKeyActivity extends BaseActivity implements OnClickListener { @Override public boolean onCreateOptionsMenu(Menu menu) { menu.add(0, Id.menu.option.new_pass_phrase, 0, - (havePassPhrase() ? "Change Pass Phrase" : "Set Pass Phrase")) + (havePassPhrase() ? R.string.menu_changePassPhrase : R.string.menu_setPassPhrase)) .setIcon(android.R.drawable.ic_menu_add); return true; } @@ -149,17 +149,17 @@ public class EditKeyActivity extends BaseActivity implements OnClickListener { AlertDialog.Builder alert = new AlertDialog.Builder(this); if (havePassPhrase()) { - alert.setTitle("Change Pass Phrase"); + alert.setTitle(R.string.title_changePassPhrase); } else { - alert.setTitle("Set Pass Phrase"); + alert.setTitle(R.string.title_setPassPhrase); } - alert.setMessage("Enter the pass phrase twice."); + alert.setMessage(R.string.enterPassPhraseTwice); LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.pass_phrase, null); - final EditText input1 = (EditText) view.findViewById(R.id.pass_phrase); - final EditText input2 = (EditText) view.findViewById(R.id.pass_phrase_again); + final EditText input1 = (EditText) view.findViewById(R.id.passPhrase); + final EditText input2 = (EditText) view.findViewById(R.id.passPhraseAgain); alert.setView(view); @@ -213,7 +213,7 @@ public class EditKeyActivity extends BaseActivity implements OnClickListener { private void saveClicked() { if (!havePassPhrase()) { - Toast.makeText(this, R.string.set_a_pass_phrase, Toast.LENGTH_SHORT).show(); + Toast.makeText(this, R.string.setAPassPhrase, Toast.LENGTH_SHORT).show(); return; } showDialog(Id.dialog.saving); @@ -265,10 +265,10 @@ public class EditKeyActivity extends BaseActivity implements OnClickListener { String error = data.getString("error"); if (error != null) { Toast.makeText(EditKeyActivity.this, - "Error: " + data.getString("error"), + getString(R.string.errorMessage, data.getString("error")), Toast.LENGTH_SHORT).show(); } else { - Toast.makeText(EditKeyActivity.this, R.string.key_saved, Toast.LENGTH_SHORT).show(); + Toast.makeText(EditKeyActivity.this, R.string.keySaved, Toast.LENGTH_SHORT).show(); setResult(RESULT_OK); finish(); } diff --git a/src/org/thialfihar/android/apg/EncryptActivity.java b/src/org/thialfihar/android/apg/EncryptActivity.java index e98a4c785..fae6e6aa6 100644 --- a/src/org/thialfihar/android/apg/EncryptActivity.java +++ b/src/org/thialfihar/android/apg/EncryptActivity.java @@ -101,9 +101,9 @@ public class EncryptActivity extends BaseActivity { setContentView(R.layout.encrypt); mSource = (ViewFlipper) findViewById(R.id.source); - mSourceLabel = (TextView) findViewById(R.id.source_label); - mSourcePrevious = (ImageView) findViewById(R.id.source_previous); - mSourceNext = (ImageView) findViewById(R.id.source_next); + mSourceLabel = (TextView) findViewById(R.id.sourceLabel); + mSourcePrevious = (ImageView) findViewById(R.id.sourcePrevious); + mSourceNext = (ImageView) findViewById(R.id.sourceNext); mSourcePrevious.setClickable(true); mSourcePrevious.setOnClickListener(new OnClickListener() { @@ -136,9 +136,9 @@ public class EncryptActivity extends BaseActivity { mSourceLabel.setOnClickListener(nextSourceClickListener); mMode = (ViewFlipper) findViewById(R.id.mode); - mModeLabel = (TextView) findViewById(R.id.mode_label); - mModePrevious = (ImageView) findViewById(R.id.mode_previous); - mModeNext = (ImageView) findViewById(R.id.mode_next); + mModeLabel = (TextView) findViewById(R.id.modeLabel); + mModePrevious = (ImageView) findViewById(R.id.modePrevious); + mModeNext = (ImageView) findViewById(R.id.modeNext); mModePrevious.setClickable(true); mModePrevious.setOnClickListener(new OnClickListener() { @@ -172,17 +172,17 @@ public class EncryptActivity extends BaseActivity { mMessage = (EditText) findViewById(R.id.message); mSelectKeysButton = (Button) findViewById(R.id.btn_selectEncryptKeys); mEncryptButton = (Button) findViewById(R.id.btn_encrypt); - mEncryptToClipboardButton = (Button) findViewById(R.id.btn_encrypt_to_clipboard); + mEncryptToClipboardButton = (Button) findViewById(R.id.btn_encryptToClipboard); mSign = (CheckBox) findViewById(R.id.sign); - mMainUserId = (TextView) findViewById(R.id.main_user_id); - mMainUserIdRest = (TextView) findViewById(R.id.main_user_id_rest); + mMainUserId = (TextView) findViewById(R.id.mainUserId); + mMainUserIdRest = (TextView) findViewById(R.id.mainUserIdRest); - mPassPhrase = (EditText) findViewById(R.id.pass_phrase); - mPassPhraseAgain = (EditText) findViewById(R.id.pass_phrase_again); + mPassPhrase = (EditText) findViewById(R.id.passPhrase); + mPassPhraseAgain = (EditText) findViewById(R.id.passPhraseAgain); // measure the height of the source_file view and set the message view's min height to that, // so it fills mSource fully... bit of a hack. - View tmp = findViewById(R.id.source_file); + View tmp = findViewById(R.id.sourceFile); tmp.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED); int height = tmp.getMeasuredHeight(); mMessage.setMinimumHeight(height); @@ -196,12 +196,11 @@ public class EncryptActivity extends BaseActivity { } }); - mDeleteAfter = (CheckBox) findViewById(R.id.delete_after_encryption); + mDeleteAfter = (CheckBox) findViewById(R.id.deleteAfterEncryption); - mAsciiArmour = (CheckBox) findViewById(R.id.ascii_armour); + mAsciiArmour = (CheckBox) findViewById(R.id.asciiArmour); mAsciiArmour.setChecked(getDefaultAsciiArmour()); mAsciiArmour.setOnClickListener(new OnClickListener() { - @Override public void onClick(View view) { guessOutputFilename(); @@ -302,13 +301,13 @@ public class EncryptActivity extends BaseActivity { } mSource.setInAnimation(null); mSource.setOutAnimation(null); - while (mSource.getCurrentView().getId() != R.id.source_message) { + while (mSource.getCurrentView().getId() != R.id.sourceMessage) { mSource.showNext(); } } else if (intent.getAction().equals(Apg.Intent.ENCRYPT_FILE)) { mSource.setInAnimation(null); mSource.setOutAnimation(null); - while (mSource.getCurrentView().getId() != R.id.source_file) { + while (mSource.getCurrentView().getId() != R.id.sourceFile) { mSource.showNext(); } } @@ -326,14 +325,14 @@ public class EncryptActivity extends BaseActivity { intent.setData(Uri.parse("file://" + filename)); - intent.putExtra(FileManager.EXTRA_TITLE, "Select file to encrypt..."); - intent.putExtra(FileManager.EXTRA_BUTTON_TEXT, "Open"); + intent.putExtra(FileManager.EXTRA_TITLE, R.string.filemanager_titleEncrypt); + intent.putExtra(FileManager.EXTRA_BUTTON_TEXT, R.string.filemanager_btnOpen); try { startActivityForResult(intent, Id.request.filename); } catch (ActivityNotFoundException e) { // No compatible file manager was found. - Toast.makeText(this, R.string.no_filemanager_installed, Toast.LENGTH_SHORT).show(); + Toast.makeText(this, R.string.oiFilemanagerNotInstalled, Toast.LENGTH_SHORT).show(); } } @@ -346,14 +345,14 @@ public class EncryptActivity extends BaseActivity { private void updateSource() { switch (mSource.getCurrentView().getId()) { - case R.id.source_file: { + case R.id.sourceFile: { mSourceLabel.setText(R.string.label_file); mEncryptButton.setText(R.string.btn_encrypt); mEncryptToClipboardButton.setEnabled(false); break; } - case R.id.source_message: { + case R.id.sourceMessage: { mSourceLabel.setText(R.string.label_message); mEncryptButton.setText(R.string.btn_send); mEncryptToClipboardButton.setEnabled(true); @@ -368,12 +367,12 @@ public class EncryptActivity extends BaseActivity { private void updateMode() { switch (mMode.getCurrentView().getId()) { - case R.id.mode_asymmetric: { + case R.id.modeAsymmetric: { mModeLabel.setText(R.string.label_asymmetric); break; } - case R.id.mode_symmetric: { + case R.id.modeSymmetric: { mModeLabel.setText(R.string.label_symmetric); break; } @@ -390,7 +389,7 @@ public class EncryptActivity extends BaseActivity { } private void encryptClicked() { - if (mSource.getCurrentView().getId() == R.id.source_file) { + if (mSource.getCurrentView().getId() == R.id.sourceFile) { mEncryptTarget = Id.target.file; } else { mEncryptTarget = Id.target.email; @@ -406,43 +405,44 @@ public class EncryptActivity extends BaseActivity { } if (mInputFilename.equals("")) { - Toast.makeText(this, "Select a file first.", Toast.LENGTH_SHORT).show(); + Toast.makeText(this, R.string.noFileSelected, Toast.LENGTH_SHORT).show(); return; } File file = new File(mInputFilename); if (!file.exists() || !file.isFile()) { - Toast.makeText(this, "Error: file not found", Toast.LENGTH_SHORT).show(); + Toast.makeText(this, getString(R.string.errorMessage, + getString(R.string.error_fileNotFound)), + Toast.LENGTH_SHORT).show(); return; } } // symmetric encryption - if (mMode.getCurrentView().getId() == R.id.mode_symmetric) { + if (mMode.getCurrentView().getId() == R.id.modeSymmetric) { boolean gotPassPhrase = false; String passPhrase = mPassPhrase.getText().toString(); String passPhraseAgain = mPassPhraseAgain.getText().toString(); if (!passPhrase.equals(passPhraseAgain)) { - Toast.makeText(this, "Pass phrases don't match.", Toast.LENGTH_SHORT).show(); + Toast.makeText(this, R.string.passPhrasesDoNotMatch, Toast.LENGTH_SHORT).show(); return; } gotPassPhrase = (passPhrase.length() != 0); if (!gotPassPhrase) { - Toast.makeText(this, "Enter a pass phrase.", Toast.LENGTH_SHORT).show(); + Toast.makeText(this, R.string.passPhraseMustNotBeEmpty, Toast.LENGTH_SHORT).show(); return; } } else { boolean encryptIt = mEncryptionKeyIds != null && mEncryptionKeyIds.length > 0; // for now require at least one form of encryption for files if (!encryptIt && mEncryptTarget == Id.target.file) { - Toast.makeText(this, "Select at least one encryption key.", - Toast.LENGTH_SHORT).show(); + Toast.makeText(this, R.string.selectEncryptionKey, Toast.LENGTH_SHORT).show(); return; } if (!encryptIt && getSecretKeyId() == 0) { - Toast.makeText(this, "Select at least one encryption key or a signature key.", + Toast.makeText(this, R.string.selectEncryptionOrSignatureKey, Toast.LENGTH_SHORT).show(); return; } @@ -495,7 +495,7 @@ public class EncryptActivity extends BaseActivity { boolean signOnly = false; String passPhrase = null; - if (mMode.getCurrentView().getId() == R.id.mode_symmetric) { + if (mMode.getCurrentView().getId() == R.id.modeSymmetric) { passPhrase = mPassPhrase.getText().toString(); if (passPhrase.length() == 0) { passPhrase = null; @@ -510,7 +510,7 @@ public class EncryptActivity extends BaseActivity { if (mInputFilename.startsWith(Environment.getExternalStorageDirectory().getAbsolutePath()) || mOutputFilename.startsWith(Environment.getExternalStorageDirectory().getAbsolutePath())) { if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { - throw new GeneralException("external storage not ready"); + throw new GeneralException(getString(R.string.error_externalStorageNotReady)); } } @@ -583,12 +583,12 @@ public class EncryptActivity extends BaseActivity { private void updateView() { if (mEncryptionKeyIds == null || mEncryptionKeyIds.length == 0) { - mSelectKeysButton.setText(R.string.no_keys_selected); + mSelectKeysButton.setText(R.string.noKeysSelected); } else if (mEncryptionKeyIds.length == 1) { - mSelectKeysButton.setText(R.string.one_key_selected); + mSelectKeysButton.setText(R.string.oneKeySelected); } else { mSelectKeysButton.setText("" + mEncryptionKeyIds.length + " " + - getResources().getString(R.string.n_keys_selected)); + getResources().getString(R.string.nKeysSelected)); } if (getSecretKeyId() == 0) { @@ -596,7 +596,7 @@ public class EncryptActivity extends BaseActivity { mMainUserId.setText(""); mMainUserIdRest.setText(""); } else { - String uid = getResources().getString(R.string.unknown_user_id); + String uid = getResources().getString(R.string.unknownUserId); String uidExtra = ""; PGPSecretKeyRing keyRing = Apg.getSecretKeyRing(getSecretKeyId()); if (keyRing != null) { @@ -699,7 +699,7 @@ public class EncryptActivity extends BaseActivity { String error = data.getString("error"); if (error != null) { Toast.makeText(EncryptActivity.this, - "Error: " + data.getString("error"), + getString(R.string.errorMessage, data.getString("error")), Toast.LENGTH_SHORT).show(); return; } else { @@ -708,7 +708,7 @@ public class EncryptActivity extends BaseActivity { case Id.target.clipboard: { ClipboardManager clip = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); clip.setText(message); - Toast.makeText(this, "Successfully encrypted to clipboard.", + Toast.makeText(this, R.string.encryptionToClipboardSuccessful, Toast.LENGTH_SHORT).show(); break; } @@ -726,11 +726,12 @@ public class EncryptActivity extends BaseActivity { new String[] { mSendTo }); } EncryptActivity.this. - startActivity(Intent.createChooser(emailIntent, "Send mail...")); + startActivity(Intent.createChooser(emailIntent, + getString(R.string.title_sendEmail))); } case Id.target.file: { - Toast.makeText(this, "Successfully encrypted.", Toast.LENGTH_SHORT).show(); + Toast.makeText(this, R.string.encryptionSuccessful, Toast.LENGTH_SHORT).show(); if (mDeleteAfter.isChecked()) { setDeleteFile(mInputFilename); showDialog(Id.dialog.delete_file); @@ -750,9 +751,8 @@ public class EncryptActivity extends BaseActivity { protected Dialog onCreateDialog(int id) { switch (id) { case Id.dialog.output_filename: { - return FileDialog.build(this, "Encrypt to file", - "Please specify which file to encrypt to.\n" + - "WARNING! File will be overwritten if it exists.", + return FileDialog.build(this, getString(R.string.title_encryptToFile), + getString(R.string.specifyFileToEncryptTo), mOutputFilename, new FileDialog.OnClickListener() { @@ -768,8 +768,8 @@ public class EncryptActivity extends BaseActivity { removeDialog(Id.dialog.output_filename); } }, - getString(R.string.filemanager_title_save), - getString(R.string.filemanager_btn_save), + getString(R.string.filemanager_titleSave), + getString(R.string.filemanager_btnSave), Id.request.output_filename); } diff --git a/src/org/thialfihar/android/apg/FileDialog.java b/src/org/thialfihar/android/apg/FileDialog.java index 891606362..22d64fc84 100644 --- a/src/org/thialfihar/android/apg/FileDialog.java +++ b/src/org/thialfihar/android/apg/FileDialog.java @@ -113,7 +113,7 @@ public class FileDialog { mActivity.startActivityForResult(intent, mRequestCode);
} catch (ActivityNotFoundException e) {
// No compatible file manager was found.
- Toast.makeText(mActivity, R.string.no_filemanager_installed, Toast.LENGTH_SHORT).show();
+ Toast.makeText(mActivity, R.string.oiFilemanagerNotInstalled, Toast.LENGTH_SHORT).show();
}
}
}
diff --git a/src/org/thialfihar/android/apg/Id.java b/src/org/thialfihar/android/apg/Id.java index 98ea2ebf8..e208cdfcc 100644 --- a/src/org/thialfihar/android/apg/Id.java +++ b/src/org/thialfihar/android/apg/Id.java @@ -81,6 +81,8 @@ public final class Id { public static final class type {
public static final int public_key = 0x21070001;
public static final int secret_key = 0x21070002;
+ public static final int user_id = 0x21070003;
+ public static final int key = 0x21070004;
}
public static final class choice {
diff --git a/src/org/thialfihar/android/apg/MailListActivity.java b/src/org/thialfihar/android/apg/MailListActivity.java index 7ad0d7fd1..f0abe8f45 100644 --- a/src/org/thialfihar/android/apg/MailListActivity.java +++ b/src/org/thialfihar/android/apg/MailListActivity.java @@ -196,7 +196,7 @@ public class MailListActivity extends ListActivity { Message message = (Message) getItem(position);
TextView subject = (TextView) view.findViewById(R.id.subject);
- TextView email = (TextView) view.findViewById(R.id.email_address);
+ TextView email = (TextView) view.findViewById(R.id.emailAddress);
ImageView status = (ImageView) view.findViewById(R.id.ic_status);
subject.setText(message.subject);
diff --git a/src/org/thialfihar/android/apg/MainActivity.java b/src/org/thialfihar/android/apg/MainActivity.java index 39e9b7aa9..4bf585df4 100644 --- a/src/org/thialfihar/android/apg/MainActivity.java +++ b/src/org/thialfihar/android/apg/MainActivity.java @@ -57,7 +57,7 @@ public class MainActivity extends BaseActivity { Button decryptMessageButton = (Button) findViewById(R.id.btn_decryptMessage); Button encryptFileButton = (Button) findViewById(R.id.btn_encryptFile); Button decryptFileButton = (Button) findViewById(R.id.btn_decryptFile); - mAccounts = (ListView) findViewById(R.id.account_list); + mAccounts = (ListView) findViewById(R.id.accounts); encryptMessageButton.setOnClickListener(new OnClickListener() { @Override @@ -126,44 +126,46 @@ public class MainActivity extends BaseActivity { case Id.dialog.new_account: { AlertDialog.Builder alert = new AlertDialog.Builder(this); - alert.setTitle("Add Account"); - alert.setMessage("Specify the Google Mail account you want to add."); + alert.setTitle(R.string.title_addAccount); + alert.setMessage(R.string.specifyGoogleMailAccount); final EditText input = new EditText(this); alert.setView(input); alert.setPositiveButton(android.R.string.ok, - new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int id) { - MainActivity.this.removeDialog(Id.dialog.new_account); - String accountName = "" + input.getText(); - - Cursor testCursor = - managedQuery(Uri.parse("content://gmail-ls/conversations/" + - accountName), - null, null, null, null); - if (testCursor == null) { - Toast.makeText(MainActivity.this, - "Error: account '" + accountName + - "' not found", - Toast.LENGTH_SHORT).show(); - return; - } - - ContentValues values = new ContentValues(); - values.put(Accounts.NAME, accountName); - try { - MainActivity.this.getContentResolver() - .insert(Accounts.CONTENT_URI, - values); - } catch (SQLException e) { - Toast.makeText(MainActivity.this, - "Error: failed to add account '" + - accountName + "'", - Toast.LENGTH_SHORT).show(); - } - } - }); + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int id) { + MainActivity.this.removeDialog(Id.dialog.new_account); + String accountName = "" + input.getText(); + + Cursor testCursor = + managedQuery(Uri.parse("content://gmail-ls/conversations/" + + accountName), + null, null, null, null); + if (testCursor == null) { + Toast.makeText(MainActivity.this, + getString(R.string.errorMessage, + getString(R.string.error_accountNotFound, + accountName)), + Toast.LENGTH_SHORT).show(); + return; + } + + ContentValues values = new ContentValues(); + values.put(Accounts.NAME, accountName); + try { + MainActivity.this.getContentResolver() + .insert(Accounts.CONTENT_URI, + values); + } catch (SQLException e) { + Toast.makeText(MainActivity.this, + getString(R.string.errorMessage, + getString(R.string.error_addingAccountFailed, + accountName)), + Toast.LENGTH_SHORT).show(); + } + } + }); alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @@ -302,10 +304,10 @@ public class MainActivity extends BaseActivity { public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); - TextView nameTextView = (TextView) v.findViewById(R.id.account_name); + TextView nameTextView = (TextView) v.findViewById(R.id.accountName); if (nameTextView != null) { menu.setHeaderTitle(nameTextView.getText()); - menu.add(0, Id.menu.delete, 0, "Delete Account"); + menu.add(0, Id.menu.delete, 0, R.string.menu_deleteAccount); } } @@ -348,7 +350,7 @@ public class MainActivity extends BaseActivity { @Override public void bindView(View view, Context context, Cursor cursor) { - TextView nameTextView = (TextView) view.findViewById(R.id.account_name); + TextView nameTextView = (TextView) view.findViewById(R.id.accountName); int nameIndex = cursor.getColumnIndex(Accounts.NAME); final String account = cursor.getString(nameIndex); nameTextView.setText(account); diff --git a/src/org/thialfihar/android/apg/PreferencesActivity.java b/src/org/thialfihar/android/apg/PreferencesActivity.java index fe13d4f3b..607bb9c8b 100644 --- a/src/org/thialfihar/android/apg/PreferencesActivity.java +++ b/src/org/thialfihar/android/apg/PreferencesActivity.java @@ -39,9 +39,9 @@ public class PreferencesActivity extends BaseActivity { super.onCreate(savedInstanceState);
setContentView(R.layout.preferences);
- mEncryptionAlgorithm = (Spinner) findViewById(R.id.encryption_algorithm);
- mHashAlgorithm = (Spinner) findViewById(R.id.hash_algorithm);
- mAsciiArmour = (CheckBox) findViewById(R.id.ascii_armour);
+ mEncryptionAlgorithm = (Spinner) findViewById(R.id.encryptionAlgorithm);
+ mHashAlgorithm = (Spinner) findViewById(R.id.hashAlgorithm);
+ mAsciiArmour = (CheckBox) findViewById(R.id.asciiArmour);
mAsciiArmour.setChecked(getDefaultAsciiArmour());
diff --git a/src/org/thialfihar/android/apg/PublicKeyListActivity.java b/src/org/thialfihar/android/apg/PublicKeyListActivity.java index f8eacb101..caf28a391 100644 --- a/src/org/thialfihar/android/apg/PublicKeyListActivity.java +++ b/src/org/thialfihar/android/apg/PublicKeyListActivity.java @@ -68,9 +68,9 @@ public class PublicKeyListActivity extends BaseActivity { @Override
public boolean onCreateOptionsMenu(Menu menu) {
- menu.add(0, Id.menu.option.import_keys, 0, "Import Keys")
+ menu.add(0, Id.menu.option.import_keys, 0, R.string.menu_importKeys)
.setIcon(android.R.drawable.ic_menu_add);
- menu.add(0, Id.menu.option.export_keys, 1, "Export Keys")
+ menu.add(0, Id.menu.option.export_keys, 1, R.string.menu_exportKeys)
.setIcon(android.R.drawable.ic_menu_save);
return true;
}
@@ -107,8 +107,8 @@ public class PublicKeyListActivity extends BaseActivity { PGPPublicKeyRing keyRing = Apg.getPublicKeyRings().get(groupPosition);
String userId = Apg.getMainUserIdSafe(this, Apg.getMasterKey(keyRing));
menu.setHeaderTitle(userId);
- menu.add(0, Id.menu.export, 0, "Export Key");
- menu.add(0, Id.menu.delete, 1, "Delete Key");
+ menu.add(0, Id.menu.export, 0, R.string.menu_exportKey);
+ menu.add(0, Id.menu.delete, 1, R.string.menu_deleteKey);
}
}
@@ -151,11 +151,11 @@ public class PublicKeyListActivity extends BaseActivity { String userId = Apg.getMainUserIdSafe(this, Apg.getMasterKey(keyRing));
AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle("Warning ");
- builder.setMessage("Do you really want to delete the key '" + userId + "'?\n" +
- "You can't undo this!");
+ builder.setTitle(R.string.warning);
+ builder.setMessage(getString(R.string.keyDeletionConfirmation, userId));
builder.setIcon(android.R.drawable.ic_dialog_alert);
- builder.setPositiveButton("Delete", new DialogInterface.OnClickListener() {
+ builder.setPositiveButton(R.string.btn_delete,
+ new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
deleteKey(mSelectedItem);
mSelectedItem = -1;
@@ -173,8 +173,8 @@ public class PublicKeyListActivity extends BaseActivity { }
case Id.dialog.import_keys: {
- return FileDialog.build(this, "Import Keys",
- "Please specify which file to import from.",
+ return FileDialog.build(this, getString(R.string.title_importKeys),
+ getString(R.string.specifyFileToImportFrom),
mImportFilename,
new FileDialog.OnClickListener() {
@@ -190,8 +190,8 @@ public class PublicKeyListActivity extends BaseActivity { removeDialog(Id.dialog.import_keys);
}
},
- getString(R.string.filemanager_title_open),
- getString(R.string.filemanager_btn_open),
+ getString(R.string.filemanager_titleOpen),
+ getString(R.string.filemanager_btnOpen),
Id.request.filename);
}
@@ -201,17 +201,14 @@ public class PublicKeyListActivity extends BaseActivity { }
case Id.dialog.export_keys: {
- String title = "Export Key";
+ String title = (singleKeyExport ?
+ getString(R.string.title_exportKey) :
+ getString(R.string.title_exportKeys));
- if (!singleKeyExport) {
- // plural "Keys"
- title += "s";
- }
final int thisDialogId = (singleKeyExport ? Id.dialog.export_key : Id.dialog.export_keys);
return FileDialog.build(this, title,
- "Please specify which file to export to.\n" +
- "WARNING! File will be overwritten if it exists.",
+ getString(R.string.specifyFileToExportTo),
mExportFilename,
new FileDialog.OnClickListener() {
@@ -227,8 +224,8 @@ public class PublicKeyListActivity extends BaseActivity { removeDialog(thisDialogId);
}
},
- getString(R.string.filemanager_title_save),
- getString(R.string.filemanager_btn_save),
+ getString(R.string.filemanager_titleSave),
+ getString(R.string.filemanager_btnSave),
Id.request.filename);
}
@@ -280,7 +277,7 @@ public class PublicKeyListActivity extends BaseActivity { data = Apg.exportKeyRings(this, keys, filename, this);
}
} catch (FileNotFoundException e) {
- error = "file '" + filename + "' not found";
+ error = getString(R.string.error_fileNotFound);
} catch (IOException e) {
error = e.getMessage();
} catch (PGPException e) {
@@ -327,21 +324,20 @@ public class PublicKeyListActivity extends BaseActivity { String error = data.getString("error");
if (error != null) {
Toast.makeText(PublicKeyListActivity.this,
- "Error: " + data.getString("error"),
+ getString(R.string.errorMessage, data.getString("error")),
Toast.LENGTH_SHORT).show();
} else {
int added = data.getInt("added");
int updated = data.getInt("updated");
String message;
if (added > 0 && updated > 0) {
- message = "Succssfully added " + added + " keys and updated " +
- updated + " keys.";
+ message = getString(R.string.keysAddedAndUpdated, added, updated);
} else if (added > 0) {
- message = "Succssfully added " + added + " keys.";
+ message = getString(R.string.keysAdded, added);
} else if (updated > 0) {
- message = "Succssfully updated " + updated + " keys.";
+ message = getString(R.string.keysUpdated, updated);
} else {
- message = "No keys added or updated.";
+ message = getString(R.string.noKeysAddedOrUpdated);
}
Toast.makeText(PublicKeyListActivity.this, message,
Toast.LENGTH_SHORT).show();
@@ -356,17 +352,17 @@ public class PublicKeyListActivity extends BaseActivity { String error = data.getString("error");
if (error != null) {
Toast.makeText(PublicKeyListActivity.this,
- "Error: " + data.getString("error"),
+ getString(R.string.errorMessage, data.getString("error")),
Toast.LENGTH_SHORT).show();
} else {
int exported = data.getInt("exported");
String message;
if (exported == 1) {
- message = "Succssfully exported 1 key.";
+ message = getString(R.string.keyExported);
} else if (exported > 0) {
- message = "Succssfully exported " + exported + " keys.";
+ message = getString(R.string.keysExported);
} else{
- message = "No keys exported.";
+ message = getString(R.string.noKeysExported);
}
Toast.makeText(PublicKeyListActivity.this, message,
Toast.LENGTH_SHORT).show();
@@ -481,9 +477,9 @@ public class PublicKeyListActivity extends BaseActivity { view = mInflater.inflate(R.layout.key_list_group_item, null);
view.setBackgroundResource(android.R.drawable.list_selector_background);
- TextView mainUserId = (TextView) view.findViewById(R.id.main_user_id);
+ TextView mainUserId = (TextView) view.findViewById(R.id.mainUserId);
mainUserId.setText("");
- TextView mainUserIdRest = (TextView) view.findViewById(R.id.main_user_id_rest);
+ TextView mainUserIdRest = (TextView) view.findViewById(R.id.mainUserIdRest);
mainUserIdRest.setText("");
String userId = Apg.getMainUserId(key);
@@ -497,7 +493,7 @@ public class PublicKeyListActivity extends BaseActivity { }
if (mainUserId.getText().length() == 0) {
- mainUserId.setText(R.string.unknown_user_id);
+ mainUserId.setText(R.string.unknownUserId);
}
if (mainUserIdRest.getText().length() == 0) {
@@ -525,22 +521,22 @@ public class PublicKeyListActivity extends BaseActivity { view = mInflater.inflate(R.layout.key_list_child_item_sub_key, null);
}
- TextView keyId = (TextView) view.findViewById(R.id.key_id);
+ TextView keyId = (TextView) view.findViewById(R.id.keyId);
String keyIdStr = Long.toHexString(key.getKeyID() & 0xffffffffL);
while (keyIdStr.length() < 8) {
keyIdStr = "0" + keyIdStr;
}
keyId.setText(keyIdStr);
- TextView keyDetails = (TextView) view.findViewById(R.id.key_details);
+ TextView keyDetails = (TextView) view.findViewById(R.id.keyDetails);
String algorithmStr = Apg.getAlgorithmInfo(key);
keyDetails.setText("(" + algorithmStr + ")");
- ImageView encryptIcon = (ImageView) view.findViewById(R.id.ic_encrypt_key);
+ ImageView encryptIcon = (ImageView) view.findViewById(R.id.ic_encryptKey);
if (!Apg.isEncryptionKey(key)) {
encryptIcon.setVisibility(View.GONE);
}
- ImageView signIcon = (ImageView) view.findViewById(R.id.ic_sign_key);
+ ImageView signIcon = (ImageView) view.findViewById(R.id.ic_signKey);
if (!Apg.isSigningKey(key)) {
signIcon.setVisibility(View.GONE);
}
@@ -549,7 +545,7 @@ public class PublicKeyListActivity extends BaseActivity { case KeyChild.USER_ID: {
view = mInflater.inflate(R.layout.key_list_child_item_user_id, null);
- TextView userId = (TextView) view.findViewById(R.id.user_id);
+ TextView userId = (TextView) view.findViewById(R.id.userId);
userId.setText(child.userId);
break;
}
diff --git a/src/org/thialfihar/android/apg/SecretKeyListActivity.java b/src/org/thialfihar/android/apg/SecretKeyListActivity.java index 09f341680..a3661c7cb 100644 --- a/src/org/thialfihar/android/apg/SecretKeyListActivity.java +++ b/src/org/thialfihar/android/apg/SecretKeyListActivity.java @@ -70,11 +70,11 @@ public class SecretKeyListActivity extends BaseActivity implements OnChildClickL @Override
public boolean onCreateOptionsMenu(Menu menu) {
- menu.add(0, Id.menu.option.import_keys, 0, "Import Keys")
+ menu.add(0, Id.menu.option.import_keys, 0, R.string.menu_importKeys)
.setIcon(android.R.drawable.ic_menu_add);
- menu.add(0, Id.menu.option.export_keys, 1, "Export Keys")
+ menu.add(0, Id.menu.option.export_keys, 1, R.string.menu_exportKeys)
.setIcon(android.R.drawable.ic_menu_save);
- menu.add(1, Id.menu.option.create, 2, "Create Key")
+ menu.add(1, Id.menu.option.create, 2, R.string.menu_createKey)
.setIcon(android.R.drawable.ic_menu_add);
return true;
}
@@ -116,9 +116,9 @@ public class SecretKeyListActivity extends BaseActivity implements OnChildClickL PGPSecretKeyRing keyRing = Apg.getSecretKeyRings().get(groupPosition);
String userId = Apg.getMainUserIdSafe(this, Apg.getMasterKey(keyRing));
menu.setHeaderTitle(userId);
- menu.add(0, Id.menu.edit, 0, "Edit Key");
- menu.add(0, Id.menu.export, 1, "Export Key");
- menu.add(0, Id.menu.delete, 2, "Delete Key");
+ menu.add(0, Id.menu.edit, 0, R.string.menu_editKey);
+ menu.add(0, Id.menu.export, 1, R.string.menu_exportKey);
+ menu.add(0, Id.menu.delete, 2, R.string.menu_deleteKey);
}
}
@@ -176,11 +176,11 @@ public class SecretKeyListActivity extends BaseActivity implements OnChildClickL String userId = Apg.getMainUserIdSafe(this, Apg.getMasterKey(keyRing));
AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setTitle("Warning ");
- builder.setMessage("Do you really want to delete the key '" + userId + "'?\n" +
- "You can't undo this!");
+ builder.setTitle(R.string.warning);
+ builder.setMessage(getString(R.string.secretKeyDeletionConfirmation, userId));
builder.setIcon(android.R.drawable.ic_dialog_alert);
- builder.setPositiveButton("Delete", new DialogInterface.OnClickListener() {
+ builder.setPositiveButton(R.string.btn_delete,
+ new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
deleteKey(mSelectedItem);
mSelectedItem = -1;
@@ -198,8 +198,8 @@ public class SecretKeyListActivity extends BaseActivity implements OnChildClickL }
case Id.dialog.import_keys: {
- return FileDialog.build(this, "Import Keys",
- "Please specify which file to import from.",
+ return FileDialog.build(this, getString(R.string.title_importKeys),
+ getString(R.string.specifyFileToImportFrom),
mImportFilename,
new FileDialog.OnClickListener() {
@@ -215,8 +215,8 @@ public class SecretKeyListActivity extends BaseActivity implements OnChildClickL removeDialog(Id.dialog.import_keys);
}
},
- getString(R.string.filemanager_title_open),
- getString(R.string.filemanager_btn_open),
+ getString(R.string.filemanager_titleOpen),
+ getString(R.string.filemanager_btnOpen),
Id.request.filename);
}
@@ -226,18 +226,14 @@ public class SecretKeyListActivity extends BaseActivity implements OnChildClickL }
case Id.dialog.export_keys: {
- String title = "Export Key";
+ String title = (singleKeyExport ?
+ getString(R.string.title_exportKey) :
+ getString(R.string.title_exportKeys));
- if (!singleKeyExport) {
- // plural "Keys"
- title += "s";
- }
- final int thisDialogId = (singleKeyExport ? Id.dialog.delete_key : Id.dialog.export_keys);
+ final int thisDialogId = (singleKeyExport ? Id.dialog.export_key : Id.dialog.export_keys);
return FileDialog.build(this, title,
- "Please specify which file to export to.\n" +
- "WARNING! You are about to export SECRET keys.\n" +
- "WARNING! File will be overwritten if it exists.",
+ getString(R.string.specifyFileToExportSecretKeysTo),
mExportFilename,
new FileDialog.OnClickListener() {
@@ -253,8 +249,8 @@ public class SecretKeyListActivity extends BaseActivity implements OnChildClickL removeDialog(thisDialogId);
}
},
- getString(R.string.filemanager_title_save),
- getString(R.string.filemanager_btn_save),
+ getString(R.string.filemanager_titleSave),
+ getString(R.string.filemanager_btnSave),
Id.request.filename);
}
@@ -363,7 +359,7 @@ public class SecretKeyListActivity extends BaseActivity implements OnChildClickL data = Apg.exportKeyRings(this, keys, filename, this);
}
} catch (FileNotFoundException e) {
- error = "file '" + filename + "' not found";
+ error = getString(R.string.error_fileNotFound);
} catch (IOException e) {
error = e.getMessage();
} catch (PGPException e) {
@@ -410,21 +406,20 @@ public class SecretKeyListActivity extends BaseActivity implements OnChildClickL String error = data.getString("error");
if (error != null) {
Toast.makeText(SecretKeyListActivity.this,
- "Error: " + data.getString("error"),
+ getString(R.string.errorMessage, data.getString("error")),
Toast.LENGTH_SHORT).show();
} else {
int added = data.getInt("added");
int updated = data.getInt("updated");
String message;
if (added > 0 && updated > 0) {
- message = "Succssfully added " + added + " keys and updated " +
- updated + " keys.";
+ message = getString(R.string.keysAddedAndUpdated, added, updated);
} else if (added > 0) {
- message = "Succssfully added " + added + " keys.";
+ message = getString(R.string.keysAdded, added);
} else if (updated > 0) {
- message = "Succssfully updated " + updated + " keys.";
+ message = getString(R.string.keysUpdated, updated);
} else {
- message = "No keys added or updated.";
+ message = getString(R.string.noKeysAddedOrUpdated);
}
Toast.makeText(SecretKeyListActivity.this, message,
Toast.LENGTH_SHORT).show();
@@ -439,17 +434,17 @@ public class SecretKeyListActivity extends BaseActivity implements OnChildClickL String error = data.getString("error");
if (error != null) {
Toast.makeText(SecretKeyListActivity.this,
- "Error: " + data.getString("error"),
+ getString(R.string.errorMessage, data.getString("error")),
Toast.LENGTH_SHORT).show();
} else {
int exported = data.getInt("exported");
String message;
if (exported == 1) {
- message = "Succssfully exported 1 key.";
+ message = getString(R.string.keyExported);
} else if (exported > 0) {
- message = "Succssfully exported " + exported + " keys.";
+ message = getString(R.string.keysExported);
} else{
- message = "No keys exported.";
+ message = getString(R.string.noKeysExported);
}
Toast.makeText(SecretKeyListActivity.this, message,
Toast.LENGTH_SHORT).show();
@@ -563,9 +558,9 @@ public class SecretKeyListActivity extends BaseActivity implements OnChildClickL view = mInflater.inflate(R.layout.key_list_group_item, null);
view.setBackgroundResource(android.R.drawable.list_selector_background);
- TextView mainUserId = (TextView) view.findViewById(R.id.main_user_id);
+ TextView mainUserId = (TextView) view.findViewById(R.id.mainUserId);
mainUserId.setText("");
- TextView mainUserIdRest = (TextView) view.findViewById(R.id.main_user_id_rest);
+ TextView mainUserIdRest = (TextView) view.findViewById(R.id.mainUserIdRest);
mainUserIdRest.setText("");
String userId = Apg.getMainUserId(key);
@@ -579,7 +574,7 @@ public class SecretKeyListActivity extends BaseActivity implements OnChildClickL }
if (mainUserId.getText().length() == 0) {
- mainUserId.setText(R.string.unknown_user_id);
+ mainUserId.setText(R.string.unknownUserId);
}
if (mainUserIdRest.getText().length() == 0) {
@@ -607,22 +602,22 @@ public class SecretKeyListActivity extends BaseActivity implements OnChildClickL view = mInflater.inflate(R.layout.key_list_child_item_sub_key, null);
}
- TextView keyId = (TextView) view.findViewById(R.id.key_id);
+ TextView keyId = (TextView) view.findViewById(R.id.keyId);
String keyIdStr = Long.toHexString(key.getKeyID() & 0xffffffffL);
while (keyIdStr.length() < 8) {
keyIdStr = "0" + keyIdStr;
}
keyId.setText(keyIdStr);
- TextView keyDetails = (TextView) view.findViewById(R.id.key_details);
+ TextView keyDetails = (TextView) view.findViewById(R.id.keyDetails);
String algorithmStr = Apg.getAlgorithmInfo(key);
keyDetails.setText("(" + algorithmStr + ")");
- ImageView encryptIcon = (ImageView) view.findViewById(R.id.ic_encrypt_key);
+ ImageView encryptIcon = (ImageView) view.findViewById(R.id.ic_encryptKey);
if (!Apg.isEncryptionKey(key)) {
encryptIcon.setVisibility(View.GONE);
}
- ImageView signIcon = (ImageView) view.findViewById(R.id.ic_sign_key);
+ ImageView signIcon = (ImageView) view.findViewById(R.id.ic_signKey);
if (!Apg.isSigningKey(key)) {
signIcon.setVisibility(View.GONE);
}
@@ -631,7 +626,7 @@ public class SecretKeyListActivity extends BaseActivity implements OnChildClickL case KeyChild.USER_ID: {
view = mInflater.inflate(R.layout.key_list_child_item_user_id, null);
- TextView userId = (TextView) view.findViewById(R.id.user_id);
+ TextView userId = (TextView) view.findViewById(R.id.userId);
userId.setText(child.userId);
break;
}
diff --git a/src/org/thialfihar/android/apg/SelectPublicKeyListAdapter.java b/src/org/thialfihar/android/apg/SelectPublicKeyListAdapter.java index 12d0c5d53..1b0b82fd8 100644 --- a/src/org/thialfihar/android/apg/SelectPublicKeyListAdapter.java +++ b/src/org/thialfihar/android/apg/SelectPublicKeyListAdapter.java @@ -113,18 +113,18 @@ public class SelectPublicKeyListAdapter extends BaseAdapter { Vector<PGPPublicKey> encryptKeys = Apg.getEncryptKeys(keyRing);
Vector<PGPPublicKey> usableKeys = Apg.getUsableEncryptKeys(keyRing);
- TextView mainUserId = (TextView) view.findViewById(R.id.main_user_id);
- mainUserId.setText(R.string.unknown_user_id);
- TextView mainUserIdRest = (TextView) view.findViewById(R.id.main_user_id_rest);
+ TextView mainUserId = (TextView) view.findViewById(R.id.mainUserId);
+ mainUserId.setText(R.string.unknownUserId);
+ TextView mainUserIdRest = (TextView) view.findViewById(R.id.mainUserIdRest);
mainUserIdRest.setText("");
- TextView keyId = (TextView) view.findViewById(R.id.key_id);
- keyId.setText("<no key>");
+ TextView keyId = (TextView) view.findViewById(R.id.keyId);
+ keyId.setText(R.string.noKey);
TextView creation = (TextView) view.findViewById(R.id.creation);
- creation.setText("-");
+ creation.setText(R.string.noDate);
TextView expiry = (TextView) view.findViewById(R.id.expiry);
- expiry.setText("no expire");
+ expiry.setText(R.string.noExpiry);
TextView status = (TextView) view.findViewById(R.id.status);
- status.setText("???");
+ status.setText(R.string.unknownStatus);
if (key != null) {
String userId = Apg.getMainUserId(key);
@@ -147,17 +147,17 @@ public class SelectPublicKeyListAdapter extends BaseAdapter { PGPPublicKey timespanKey = key;
if (usableKeys.size() > 0) {
timespanKey = usableKeys.get(0);
- status.setText("can encrypt");
+ status.setText(R.string.canEncrypt);
} else if (encryptKeys.size() > 0) {
timespanKey = encryptKeys.get(0);
Date now = new Date();
if (now.compareTo(Apg.getCreationDate(timespanKey)) > 0) {
- status.setText("not valid");
+ status.setText(R.string.notValid);
} else {
- status.setText("expired");
+ status.setText(R.string.expired);
}
} else {
- status.setText("no key");
+ status.setText(R.string.noKey);
}
creation.setText(DateFormat.getDateInstance().format(Apg.getCreationDate(timespanKey)));
diff --git a/src/org/thialfihar/android/apg/SelectSecretKeyListActivity.java b/src/org/thialfihar/android/apg/SelectSecretKeyListActivity.java index a0335075c..b6811d6e3 100644 --- a/src/org/thialfihar/android/apg/SelectSecretKeyListActivity.java +++ b/src/org/thialfihar/android/apg/SelectSecretKeyListActivity.java @@ -134,18 +134,18 @@ public class SelectSecretKeyListActivity extends BaseActivity { } } - TextView mainUserId = (TextView) view.findViewById(R.id.main_user_id); - mainUserId.setText(R.string.unknown_user_id); - TextView mainUserIdRest = (TextView) view.findViewById(R.id.main_user_id_rest); + TextView mainUserId = (TextView) view.findViewById(R.id.mainUserId); + mainUserId.setText(R.string.unknownUserId); + TextView mainUserIdRest = (TextView) view.findViewById(R.id.mainUserIdRest); mainUserIdRest.setText(""); - TextView keyId = (TextView) view.findViewById(R.id.key_id); - keyId.setText("<no key>"); + TextView keyId = (TextView) view.findViewById(R.id.keyId); + keyId.setText(R.string.noKey); TextView creation = (TextView) view.findViewById(R.id.creation); - creation.setText(""); + creation.setText(R.string.noDate); TextView expiry = (TextView) view.findViewById(R.id.expiry); - expiry.setText(""); + expiry.setText(R.string.noExpiry); TextView status = (TextView) view.findViewById(R.id.status); - status.setText("???"); + status.setText(R.string.unknownStatus); if (key != null) { String userId = Apg.getMainUserId(key); @@ -171,17 +171,17 @@ public class SelectSecretKeyListActivity extends BaseActivity { PGPSecretKey timespanKey = key; if (usableKeys.size() > 0) { timespanKey = usableKeys.get(0); - status.setText("can sign"); + status.setText(R.string.canSign); } else if (signingKeys.size() > 0) { timespanKey = signingKeys.get(0); Date now = new Date(); if (now.compareTo(Apg.getCreationDate(timespanKey)) > 0) { - status.setText("not valid"); + status.setText(R.string.notValid); } else { - status.setText("expired"); + status.setText(R.string.expired); } } else { - status.setText("no key"); + status.setText(R.string.noKey); } creation.setText(DateFormat.getDateInstance().format(Apg.getCreationDate(timespanKey))); diff --git a/src/org/thialfihar/android/apg/ui/widget/KeyEditor.java b/src/org/thialfihar/android/apg/ui/widget/KeyEditor.java index c490686ea..bc38fba4c 100644 --- a/src/org/thialfihar/android/apg/ui/widget/KeyEditor.java +++ b/src/org/thialfihar/android/apg/ui/widget/KeyEditor.java @@ -81,17 +81,17 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { setAlwaysDrawnWithCacheEnabled(true);
mAlgorithm = (TextView) findViewById(R.id.algorithm);
- mKeyId = (TextView) findViewById(R.id.key_id);
+ mKeyId = (TextView) findViewById(R.id.keyId);
mCreationDate = (TextView) findViewById(R.id.creation);
mExpiryDateButton = (Button) findViewById(R.id.expiry);
mUsage = (Spinner) findViewById(R.id.usage);
Choice choices[] = {
new Choice(Id.choice.usage.sign_only,
- getResources().getString(R.string.sign_only)),
+ getResources().getString(R.string.choice_signOnly)),
new Choice(Id.choice.usage.encrypt_only,
- getResources().getString(R.string.encrypt_only)),
+ getResources().getString(R.string.choice_encryptOnly)),
new Choice(Id.choice.usage.sign_and_encrypt,
- getResources().getString(R.string.sign_and_encrypt)),
+ getResources().getString(R.string.choice_signAndEncrypt)),
};
ArrayAdapter<Choice> adapter =
new ArrayAdapter<Choice>(getContext(),
@@ -99,7 +99,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mUsage.setAdapter(adapter);
- mDeleteButton = (ImageButton) findViewById(R.id.edit_delete);
+ mDeleteButton = (ImageButton) findViewById(R.id.delete);
mDeleteButton.setOnClickListener(this);
setExpiryDate(null);
@@ -118,7 +118,8 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { date.get(Calendar.MONTH),
date.get(Calendar.DAY_OF_MONTH));
dialog.setCancelable(true);
- dialog.setButton(Dialog.BUTTON_NEGATIVE, "None",
+ dialog.setButton(Dialog.BUTTON_NEGATIVE,
+ getContext().getString(R.string.btn_noDate),
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
setExpiryDate(null);
@@ -154,15 +155,15 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { boolean isElGamalKey = (key.getPublicKey().getAlgorithm() == PGPPublicKey.ELGAMAL_ENCRYPT);
if (!isElGamalKey) {
choices.add(new Choice(Id.choice.usage.sign_only,
- getResources().getString(R.string.sign_only)));
+ getResources().getString(R.string.choice_signOnly)));
}
if (!mIsMasterKey) {
choices.add(new Choice(Id.choice.usage.encrypt_only,
- getResources().getString(R.string.encrypt_only)));
+ getResources().getString(R.string.choice_encryptOnly)));
}
if (!isElGamalKey) {
choices.add(new Choice(Id.choice.usage.sign_and_encrypt,
- getResources().getString(R.string.sign_and_encrypt)));
+ getResources().getString(R.string.choice_signAndEncrypt)));
}
ArrayAdapter<Choice> adapter =
diff --git a/src/org/thialfihar/android/apg/ui/widget/SectionView.java b/src/org/thialfihar/android/apg/ui/widget/SectionView.java index 865267660..3b2c93773 100644 --- a/src/org/thialfihar/android/apg/ui/widget/SectionView.java +++ b/src/org/thialfihar/android/apg/ui/widget/SectionView.java @@ -50,9 +50,6 @@ import android.widget.TextView; import android.widget.Toast;
public class SectionView extends LinearLayout implements OnClickListener, EditorListener, Runnable {
- public static final int TYPE_USER_ID = 1;
- public static final int TYPE_KEY = 2;
-
private LayoutInflater mInflater;
private View mAdd;
private ViewGroup mEditors;
@@ -82,7 +79,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor String error = data.getString("error");
if (error != null) {
Toast.makeText(getContext(),
- "Error: " + error,
+ getContext().getString(R.string.errorMessage, error),
Toast.LENGTH_SHORT).show();
}
@@ -116,12 +113,12 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor public void setType(int type) {
mType = type;
switch (type) {
- case TYPE_USER_ID: {
+ case Id.type.user_id: {
mTitle.setText(R.string.section_userIds);
break;
}
- case TYPE_KEY: {
+ case Id.type.key: {
mTitle.setText(R.string.section_keys);
break;
}
@@ -163,7 +160,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor /** {@inheritDoc} */
public void onClick(View v) {
switch (mType) {
- case TYPE_USER_ID: {
+ case Id.type.user_id: {
UserIdEditor view =
(UserIdEditor) mInflater.inflate(R.layout.edit_key_user_id_item,
mEditors, false);
@@ -175,15 +172,13 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor break;
}
- case TYPE_KEY: {
+ case Id.type.key: {
AlertDialog.Builder dialog = new AlertDialog.Builder(getContext());
View view = mInflater.inflate(R.layout.create_key, null);
dialog.setView(view);
- dialog.setTitle("Create Key");
- dialog.setMessage("Note: only subkeys support ElGamal, and for ElGamal " +
- "the nearest keysize of 1536, 2048, 3072, 4096, or 8192 " +
- "will be used");
+ dialog.setTitle(R.string.title_createKey);
+ dialog.setMessage(R.string.keyCreationElGamalInfo);
boolean wouldBeMasterKey = (mEditors.getChildCount() == 0);
@@ -252,7 +247,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor }
public void setUserIds(Vector<String> list) {
- if (mType != TYPE_USER_ID) {
+ if (mType != Id.type.user_id) {
return;
}
@@ -272,7 +267,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor }
public void setKeys(Vector<PGPSecretKey> list) {
- if (mType != TYPE_KEY) {
+ if (mType != Id.type.key) {
return;
}
@@ -291,7 +286,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor private void createKey() {
mProgressDialog = new ProgressDialog(getContext());
- mProgressDialog.setMessage("Generating key, this can take a while...");
+ mProgressDialog.setMessage(getContext().getString(R.string.progress_generating));
mProgressDialog.setCancelable(false);
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
mProgressDialog.show();
diff --git a/src/org/thialfihar/android/apg/ui/widget/UserIdEditor.java b/src/org/thialfihar/android/apg/ui/widget/UserIdEditor.java index a7e762b4f..5d710257a 100644 --- a/src/org/thialfihar/android/apg/ui/widget/UserIdEditor.java +++ b/src/org/thialfihar/android/apg/ui/widget/UserIdEditor.java @@ -81,9 +81,9 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene setDrawingCacheEnabled(true);
setAlwaysDrawnWithCacheEnabled(true);
- mDeleteButton = (ImageButton) findViewById(R.id.edit_delete);
+ mDeleteButton = (ImageButton) findViewById(R.id.delete);
mDeleteButton.setOnClickListener(this);
- mIsMainUserId = (RadioButton) findViewById(R.id.is_main_user_id);
+ mIsMainUserId = (RadioButton) findViewById(R.id.isMainUserId);
mIsMainUserId.setOnClickListener(this);
mName = (EditText) findViewById(R.id.name);
@@ -124,7 +124,8 @@ public class UserIdEditor extends LinearLayout implements Editor, OnClickListene if (email.length() > 0) {
Matcher emailMatcher = EMAIL_PATTERN.matcher(email);
if (!emailMatcher.matches()) {
- throw new InvalidEmailException("invalid email '" + email + "'");
+ throw new InvalidEmailException(
+ getContext().getString(R.string.error_invalidEmail, email));
}
}
|