a lot of renaming of IDs, following a strict naming scheme again, moved most strings into string.xml in preparation for internationalization, APG.java still has to be changed to allow that, as it isn't Context aware in most methods

This commit is contained in:
Thialfihar
2010-05-13 20:41:32 +00:00
parent 5f6a098914
commit b527ae8b6d
34 changed files with 493 additions and 408 deletions

View File

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

View File

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

View File

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