diff options
author | Dominik <dominik@dominikschuermann.de> | 2012-04-14 15:25:33 +0200 |
---|---|---|
committer | Dominik <dominik@dominikschuermann.de> | 2012-06-13 19:28:22 +0300 |
commit | 30b6cc60f2c7cae3ade18cad8e8223172ff6d9b1 (patch) | |
tree | ad07eb608c7dd43f17ae980da40998b43f22b758 /org_apg | |
parent | 4eebeede2bb9724f7282cc9f8c2421f6f860e159 (diff) | |
download | open-keychain-30b6cc60f2c7cae3ade18cad8e8223172ff6d9b1.tar.gz open-keychain-30b6cc60f2c7cae3ade18cad8e8223172ff6d9b1.tar.bz2 open-keychain-30b6cc60f2c7cae3ade18cad8e8223172ff6d9b1.zip |
intent to create key with default keyring
Diffstat (limited to 'org_apg')
-rw-r--r-- | org_apg/AndroidManifest.xml | 1 | ||||
-rw-r--r-- | org_apg/libs/android-support-v4.jar | bin | 247894 -> 0 bytes | |||
-rw-r--r-- | org_apg/res/values/strings.xml | 1 | ||||
-rw-r--r-- | org_apg/src/org/apg/Apg.java | 40 | ||||
-rw-r--r-- | org_apg/src/org/apg/ui/EditKeyActivity.java | 154 | ||||
-rw-r--r-- | org_apg/src/org/apg/ui/SecretKeyListActivity.java | 4 | ||||
-rw-r--r-- | org_apg/src/org/apg/ui/widget/KeyEditor.java | 76 | ||||
-rw-r--r-- | org_apg/src/org/apg/ui/widget/SectionView.java | 28 | ||||
-rw-r--r-- | org_apg/src/org/apg/util/Constants.java | 6 |
9 files changed, 180 insertions, 130 deletions
diff --git a/org_apg/AndroidManifest.xml b/org_apg/AndroidManifest.xml index 1d2e93d24..4c1eaea63 100644 --- a/org_apg/AndroidManifest.xml +++ b/org_apg/AndroidManifest.xml @@ -78,6 +78,7 @@ android:uiOptions="splitActionBarWhenNarrow" android:windowSoftInputMode="stateHidden" > <intent-filter> + <action android:name="org.apg.intent.CREATE_KEY" /> <action android:name="org.apg.intent.EDIT_KEY" /> <category android:name="android.intent.category.DEFAULT" /> diff --git a/org_apg/libs/android-support-v4.jar b/org_apg/libs/android-support-v4.jar Binary files differdeleted file mode 100644 index d006198e6..000000000 --- a/org_apg/libs/android-support-v4.jar +++ /dev/null diff --git a/org_apg/res/values/strings.xml b/org_apg/res/values/strings.xml index 4da1e6a6c..5499c2bc8 100644 --- a/org_apg/res/values/strings.xml +++ b/org_apg/res/values/strings.xml @@ -28,6 +28,7 @@ <string name="title_authentication">Passphrase</string> <string name="title_createKey">Create Key</string> <string name="title_editKey">Edit Key</string> + <string name="title_createKey">Create Key</string> <string name="title_preferences">Preferences</string> <string name="title_keyServerPreference">Key Server Preference</string> <string name="title_changePassPhrase">Change Passphrase</string> diff --git a/org_apg/src/org/apg/Apg.java b/org_apg/src/org/apg/Apg.java index 97e5715d9..ec4c202e7 100644 --- a/org_apg/src/org/apg/Apg.java +++ b/org_apg/src/org/apg/Apg.java @@ -109,24 +109,27 @@ import java.util.Vector; import java.util.regex.Pattern; public class Apg { - private static final String mApgPackageName = "org.apg"; + private static final String PACKAGE_NAME = "org.apg"; + private static final String INTENT_PREFIX = "org.apg.intent."; public static class Intent { - public static final String DECRYPT = "org.apg.intent.DECRYPT"; - public static final String ENCRYPT = "org.apg.intent.ENCRYPT"; - public static final String DECRYPT_FILE = "org.apg.intent.DECRYPT_FILE"; - public static final String ENCRYPT_FILE = "org.apg.intent.ENCRYPT_FILE"; - public static final String DECRYPT_AND_RETURN = "org.apg.intent.DECRYPT_AND_RETURN"; - public static final String ENCRYPT_AND_RETURN = "org.apg.intent.ENCRYPT_AND_RETURN"; - public static final String SELECT_PUBLIC_KEYS = "org.apg.intent.SELECT_PUBLIC_KEYS"; - public static final String SELECT_SECRET_KEY = "org.apg.intent.SELECT_SECRET_KEY"; - public static final String IMPORT = "org.apg.intent.IMPORT"; - public static final String LOOK_UP_KEY_ID = "org.apg.intent.LOOK_UP_KEY_ID"; - public static final String LOOK_UP_KEY_ID_AND_RETURN = "org.apg.intent.LOOK_UP_KEY_ID_AND_RETURN"; - public static final String GENERATE_SIGNATURE = "org.apg.intent.GENERATE_SIGNATURE"; - public static final String EXPORT_KEY_TO_SERVER = "org.apg.intent.EXPORT_KEY_TO_SERVER"; - public static final String IMPORT_FROM_QR_CODE = "org.apg.intent.IMPORT_FROM_QR_CODE"; - public static final String EDIT_KEY = "org.apg.intent.EDIT_KEY"; + public static final String DECRYPT = INTENT_PREFIX + "DECRYPT"; + public static final String ENCRYPT = INTENT_PREFIX + "ENCRYPT"; + public static final String DECRYPT_FILE = INTENT_PREFIX + "DECRYPT_FILE"; + public static final String ENCRYPT_FILE = INTENT_PREFIX + "ENCRYPT_FILE"; + public static final String DECRYPT_AND_RETURN = INTENT_PREFIX + "DECRYPT_AND_RETURN"; + public static final String ENCRYPT_AND_RETURN = INTENT_PREFIX + "ENCRYPT_AND_RETURN"; + public static final String SELECT_PUBLIC_KEYS = INTENT_PREFIX + "SELECT_PUBLIC_KEYS"; + public static final String SELECT_SECRET_KEY = INTENT_PREFIX + "SELECT_SECRET_KEY"; + public static final String IMPORT = INTENT_PREFIX + "IMPORT"; + public static final String LOOK_UP_KEY_ID = INTENT_PREFIX + "LOOK_UP_KEY_ID"; + public static final String LOOK_UP_KEY_ID_AND_RETURN = INTENT_PREFIX + + "LOOK_UP_KEY_ID_AND_RETURN"; + public static final String GENERATE_SIGNATURE = INTENT_PREFIX + "GENERATE_SIGNATURE"; + public static final String EXPORT_KEY_TO_SERVER = INTENT_PREFIX + "EXPORT_KEY_TO_SERVER"; + public static final String IMPORT_FROM_QR_CODE = INTENT_PREFIX + "IMPORT_FROM_QR_CODE"; + public static final String CREATE_KEY = INTENT_PREFIX + "CREATE_KEY"; + public static final String EDIT_KEY = INTENT_PREFIX + "EDIT_KEY"; } public static final String EXTRA_TEXT = "text"; @@ -157,6 +160,7 @@ public class Apg { public static final String EXTRA_KEY_SERVERS = "keyServers"; public static final String EXTRA_EXPECTED_FINGERPRINT = "expectedFingerprint"; public static final String EXTRA_NO_PASSPHRASE = "noPassphrase"; + public static final String EXTRA_GENERATE_DEFAULT_KEYS = "generateDefaultKeys"; public static final String AUTHORITY = DataProvider.AUTHORITY; @@ -2187,7 +2191,7 @@ public class Apg { public static boolean isReleaseVersion(Context context) { try { - PackageInfo pi = context.getPackageManager().getPackageInfo(mApgPackageName, 0); + PackageInfo pi = context.getPackageManager().getPackageInfo(PACKAGE_NAME, 0); if (pi.versionCode % 100 == 99) { return true; } else { @@ -2204,7 +2208,7 @@ public class Apg { return VERSION; } try { - PackageInfo pi = context.getPackageManager().getPackageInfo(mApgPackageName, 0); + PackageInfo pi = context.getPackageManager().getPackageInfo(PACKAGE_NAME, 0); VERSION = pi.versionName; return VERSION; } catch (NameNotFoundException e) { diff --git a/org_apg/src/org/apg/ui/EditKeyActivity.java b/org_apg/src/org/apg/ui/EditKeyActivity.java index 3809f160d..27a94fd1f 100644 --- a/org_apg/src/org/apg/ui/EditKeyActivity.java +++ b/org_apg/src/org/apg/ui/EditKeyActivity.java @@ -40,8 +40,10 @@ import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.os.Message; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; +import android.view.ViewGroup; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.CheckBox; @@ -52,6 +54,8 @@ import android.widget.Toast; import android.widget.CompoundButton.OnCheckedChangeListener; import java.io.IOException; +import java.security.InvalidAlgorithmParameterException; +import java.security.InvalidParameterException; import java.security.NoSuchAlgorithmException; import java.security.NoSuchProviderException; import java.security.SignatureException; @@ -59,6 +63,7 @@ import java.util.Vector; public class EditKeyActivity extends BaseActivity { private Intent mIntent = null; + private ActionBar mActionBar; private PGPSecretKeyRing mKeyRing = null; @@ -109,60 +114,119 @@ public class EditKeyActivity extends BaseActivity { super.onCreate(savedInstanceState); setContentView(R.layout.edit_key); + mActionBar = getSupportActionBar(); + + // find views + mChangePassPhrase = (Button) findViewById(R.id.edit_key_btn_change_pass_phrase); + mNoPassphrase = (CheckBox) findViewById(R.id.edit_key_no_passphrase); + Vector<String> userIds = new Vector<String>(); Vector<PGPSecretKey> keys = new Vector<PGPSecretKey>(); + Vector<Integer> keysUsages = new Vector<Integer>(); - Intent intent = getIntent(); - long keyId = 0; - if (intent.getExtras() != null) { - keyId = intent.getExtras().getLong(Apg.EXTRA_KEY_ID); - } + // Catch Intents opened from other apps + mIntent = getIntent(); + Bundle extras = mIntent.getExtras(); + if (Apg.Intent.CREATE_KEY.equals(mIntent.getAction())) { + + mActionBar.setTitle(R.string.title_createKey); + + mCurrentPassPhrase = ""; - if (keyId != 0) { - PGPSecretKey masterKey = null; - mKeyRing = Apg.getSecretKeyRing(keyId); - if (mKeyRing != null) { - masterKey = Apg.getMasterKey(mKeyRing); - for (PGPSecretKey key : new IterableIterator<PGPSecretKey>(mKeyRing.getSecretKeys())) { - keys.add(key); + if (extras != null) { + + // disable home button on actionbar because this activity is run from another app + mActionBar.setDisplayShowTitleEnabled(true); + mActionBar.setDisplayHomeAsUpEnabled(false); + mActionBar.setHomeButtonEnabled(false); + + // if userId is given, prefill the fields + if (extras.containsKey(Apg.EXTRA_USER_IDS)) { + Log.d(Constants.TAG, "UserIds are given!"); + userIds.add(extras.getString(Apg.EXTRA_USER_IDS)); } - } - if (masterKey != null) { - for (String userId : new IterableIterator<String>(masterKey.getUserIDs())) { - userIds.add(userId); + + // if no passphrase is given + if (extras.containsKey(Apg.EXTRA_NO_PASSPHRASE)) { + boolean noPassphrase = extras.getBoolean(Apg.EXTRA_NO_PASSPHRASE); + if (noPassphrase) { + // check "no passphrase" checkbox and remove button + mNoPassphrase.setChecked(true); + mChangePassPhrase.setVisibility(View.GONE); + } } - } - } - // Catch Intents opened from other apps - mIntent = getIntent(); - if (Apg.Intent.EDIT_KEY.equals(mIntent.getAction())) { - Bundle extras = mIntent.getExtras(); - if (extras == null) { - extras = new Bundle(); + // generate key + if (extras.containsKey(Apg.EXTRA_GENERATE_DEFAULT_KEYS)) { + boolean generateDefaultKeys = extras + .getBoolean(Apg.EXTRA_GENERATE_DEFAULT_KEYS); + if (generateDefaultKeys) { + + // generate a RSA 2048 key for encryption and signing! + try { + PGPSecretKey masterKey = Apg.createKey(this, Id.choice.algorithm.rsa, + 2048, mCurrentPassPhrase, null); + + // add new masterKey to keys array, which is then added to view + keys.add(masterKey); + keysUsages.add(Id.choice.usage.sign_only); + + PGPSecretKey subKey = Apg.createKey(this, Id.choice.algorithm.rsa, + 2048, mCurrentPassPhrase, masterKey); + + keys.add(subKey); + keysUsages.add(Id.choice.usage.encrypt_only); + + // define usage of this key + } catch (Exception e) { + Log.e(Constants.TAG, "Creating initial key failed: +" + e); + } + } + + } } + } else if (Apg.Intent.EDIT_KEY.equals(mIntent.getAction())) { + + mActionBar.setTitle(R.string.title_editKey); - // disable home button on actionbar because this activity is run from another app - final ActionBar actionBar = getSupportActionBar(); - actionBar.setDisplayShowTitleEnabled(true); - actionBar.setDisplayHomeAsUpEnabled(false); - actionBar.setHomeButtonEnabled(false); + mCurrentPassPhrase = Apg.getEditPassPhrase(); + if (mCurrentPassPhrase == null) { + mCurrentPassPhrase = ""; + } - // if userId is given, prefill the fields - if (extras.containsKey(Apg.EXTRA_USER_IDS)) { - userIds.add(extras.getString(Apg.EXTRA_USER_IDS)); + if (mCurrentPassPhrase.equals("")) { + // check "no passphrase" checkbox and remove button + mNoPassphrase.setChecked(true); + mChangePassPhrase.setVisibility(View.GONE); } - // if userId is given, prefill the fields - if (extras.containsKey(Apg.EXTRA_NO_PASSPHRASE)) { - boolean noPassphrase = extras.getBoolean(Apg.EXTRA_NO_PASSPHRASE); - if (noPassphrase) { - mCurrentPassPhrase = ""; + if (extras != null) { + + if (extras.containsKey(Apg.EXTRA_KEY_ID)) { + long keyId = mIntent.getExtras().getLong(Apg.EXTRA_KEY_ID); + + if (keyId != 0) { + PGPSecretKey masterKey = null; + mKeyRing = Apg.getSecretKeyRing(keyId); + if (mKeyRing != null) { + masterKey = Apg.getMasterKey(mKeyRing); + for (PGPSecretKey key : new IterableIterator<PGPSecretKey>( + mKeyRing.getSecretKeys())) { + keys.add(key); + keysUsages.add(-1); // get usage when view is created + } + } + if (masterKey != null) { + for (String userId : new IterableIterator<String>( + masterKey.getUserIDs())) { + userIds.add(userId); + } + } + } } } } - mChangePassPhrase = (Button) findViewById(R.id.edit_key_btn_change_pass_phrase); mChangePassPhrase.setOnClickListener(new OnClickListener() { public void onClick(View v) { showDialog(Id.dialog.new_pass_phrase); @@ -170,7 +234,6 @@ public class EditKeyActivity extends BaseActivity { }); // disable passphrase when no passphrase checkobox is checked! - mNoPassphrase = (CheckBox) findViewById(R.id.edit_key_no_passphrase); mNoPassphrase.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override @@ -197,20 +260,9 @@ public class EditKeyActivity extends BaseActivity { container.addView(mUserIds); mKeys = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false); mKeys.setType(Id.type.key); - mKeys.setKeys(keys); + mKeys.setKeys(keys, keysUsages); container.addView(mKeys); - mCurrentPassPhrase = Apg.getEditPassPhrase(); - if (mCurrentPassPhrase == null) { - mCurrentPassPhrase = ""; - } - - if (mCurrentPassPhrase.equals("")) { - // check "no passphrase" checkbox and remove button - mNoPassphrase.setChecked(true); - mChangePassPhrase.setVisibility(View.GONE); - } - updatePassPhraseButtonText(); } diff --git a/org_apg/src/org/apg/ui/SecretKeyListActivity.java b/org_apg/src/org/apg/ui/SecretKeyListActivity.java index 0e6d78c03..23ec694ce 100644 --- a/org_apg/src/org/apg/ui/SecretKeyListActivity.java +++ b/org_apg/src/org/apg/ui/SecretKeyListActivity.java @@ -164,13 +164,13 @@ public class SecretKeyListActivity extends KeyListActivity implements OnChildCli private void createKey() { Apg.setEditPassPhrase(""); - Intent intent = new Intent(this, EditKeyActivity.class); + Intent intent = new Intent(Apg.Intent.CREATE_KEY); startActivityForResult(intent, Id.message.create_key); } private void editKey() { long keyId = ((KeyListAdapter) mList.getExpandableListAdapter()).getGroupId(mSelectedItem); - Intent intent = new Intent(this, EditKeyActivity.class); + Intent intent = new Intent(Apg.Intent.EDIT_KEY); intent.putExtra(Apg.EXTRA_KEY_ID, keyId); startActivityForResult(intent, Id.message.edit_key); } diff --git a/org_apg/src/org/apg/ui/widget/KeyEditor.java b/org_apg/src/org/apg/ui/widget/KeyEditor.java index ef98f794a..0e2bd145f 100644 --- a/org_apg/src/org/apg/ui/widget/KeyEditor.java +++ b/org_apg/src/org/apg/ui/widget/KeyEditor.java @@ -59,13 +59,12 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { Button mExpiryDateButton; GregorianCalendar mExpiryDate; - private DatePickerDialog.OnDateSetListener mExpiryDateSetListener = - new DatePickerDialog.OnDateSetListener() { - public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { - GregorianCalendar date = new GregorianCalendar(year, monthOfYear, dayOfMonth); - setExpiryDate(date); - } - }; + private DatePickerDialog.OnDateSetListener mExpiryDateSetListener = new DatePickerDialog.OnDateSetListener() { + public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { + GregorianCalendar date = new GregorianCalendar(year, monthOfYear, dayOfMonth); + setExpiryDate(date); + } + }; public KeyEditor(Context context) { super(context); @@ -86,16 +85,14 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { 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.choice_signOnly)), - new Choice(Id.choice.usage.encrypt_only, - getResources().getString(R.string.choice_encryptOnly)), - new Choice(Id.choice.usage.sign_and_encrypt, - getResources().getString(R.string.choice_signAndEncrypt)), - }; - ArrayAdapter<Choice> adapter = - new ArrayAdapter<Choice>(getContext(), - android.R.layout.simple_spinner_item, choices); + new Choice(Id.choice.usage.sign_only, getResources().getString( + R.string.choice_signOnly)), + new Choice(Id.choice.usage.encrypt_only, getResources().getString( + R.string.choice_encryptOnly)), + new Choice(Id.choice.usage.sign_and_encrypt, getResources().getString( + R.string.choice_signAndEncrypt)), }; + ArrayAdapter<Choice> adapter = new ArrayAdapter<Choice>(getContext(), + android.R.layout.simple_spinner_item, choices); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mUsage.setAdapter(adapter); @@ -111,15 +108,12 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { date = new GregorianCalendar(); } - DatePickerDialog dialog = - new DatePickerDialog(getContext(), mExpiryDateSetListener, - date.get(Calendar.YEAR), - date.get(Calendar.MONTH), - date.get(Calendar.DAY_OF_MONTH)); + DatePickerDialog dialog = new DatePickerDialog(getContext(), + mExpiryDateSetListener, date.get(Calendar.YEAR), date.get(Calendar.MONTH), + date.get(Calendar.DAY_OF_MONTH)); dialog.setCancelable(true); - dialog.setButton(Dialog.BUTTON_NEGATIVE, - getContext().getString(R.string.btn_noDate), - new DialogInterface.OnClickListener() { + dialog.setButton(Dialog.BUTTON_NEGATIVE, getContext() + .getString(R.string.btn_noDate), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { setExpiryDate(null); } @@ -131,7 +125,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { super.onFinishInflate(); } - public void setValue(PGPSecretKey key, boolean isMasterKey) { + public void setValue(PGPSecretKey key, boolean isMasterKey, int usage) { mKey = key; mIsMasterKey = isMasterKey; @@ -147,24 +141,24 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { Vector<Choice> choices = new Vector<Choice>(); boolean isElGamalKey = (key.getPublicKey().getAlgorithm() == PGPPublicKey.ELGAMAL_ENCRYPT); if (!isElGamalKey) { - choices.add(new Choice(Id.choice.usage.sign_only, - getResources().getString(R.string.choice_signOnly))); + choices.add(new Choice(Id.choice.usage.sign_only, getResources().getString( + R.string.choice_signOnly))); } if (!mIsMasterKey) { - choices.add(new Choice(Id.choice.usage.encrypt_only, - getResources().getString(R.string.choice_encryptOnly))); + choices.add(new Choice(Id.choice.usage.encrypt_only, getResources().getString( + R.string.choice_encryptOnly))); } if (!isElGamalKey) { - choices.add(new Choice(Id.choice.usage.sign_and_encrypt, - getResources().getString(R.string.choice_signAndEncrypt))); + choices.add(new Choice(Id.choice.usage.sign_and_encrypt, getResources().getString( + R.string.choice_signAndEncrypt))); } - ArrayAdapter<Choice> adapter = - new ArrayAdapter<Choice>(getContext(), - android.R.layout.simple_spinner_item, choices); + ArrayAdapter<Choice> adapter = new ArrayAdapter<Choice>(getContext(), + android.R.layout.simple_spinner_item, choices); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mUsage.setAdapter(adapter); + // Set value in choice dropdown to key int selectId = 0; if (Apg.isEncryptionKey(key)) { if (Apg.isSigningKey(key)) { @@ -173,7 +167,13 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { selectId = Id.choice.usage.encrypt_only; } } else { - selectId = Id.choice.usage.sign_only; + // set usage if it is predefined + if (usage != -1) { + selectId = usage; + } else { + selectId = Id.choice.usage.sign_only; + } + } for (int i = 0; i < choices.size(); ++i) { @@ -194,6 +194,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { cal.setTime(Apg.getExpiryDate(key)); setExpiryDate(cal); } + } public PGPSecretKey getValue() { @@ -201,7 +202,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { } public void onClick(View v) { - final ViewGroup parent = (ViewGroup)getParent(); + final ViewGroup parent = (ViewGroup) getParent(); if (v == mDeleteButton) { parent.removeView(this); if (mEditorListener != null) { @@ -230,4 +231,5 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener { public int getUsage() { return ((Choice) mUsage.getSelectedItem()).getId(); } + } diff --git a/org_apg/src/org/apg/ui/widget/SectionView.java b/org_apg/src/org/apg/ui/widget/SectionView.java index c62e84c03..556164ca8 100644 --- a/org_apg/src/org/apg/ui/widget/SectionView.java +++ b/org_apg/src/org/apg/ui/widget/SectionView.java @@ -93,7 +93,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor mEditors, false); view.setEditorListener(SectionView.this); boolean isMasterKey = (mEditors.getChildCount() == 0); - view.setValue(mNewKey, isMasterKey); + view.setValue(mNewKey, isMasterKey, -1); mEditors.addView(view); SectionView.this.updateEditorsVisible(); } @@ -260,42 +260,26 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor this.updateEditorsVisible(); } - public void setKeys(Vector<PGPSecretKey> list) { + public void setKeys(Vector<PGPSecretKey> list, Vector<Integer> usages) { if (mType != Id.type.key) { return; } mEditors.removeAllViews(); - for (PGPSecretKey key : list) { + + // go through all keys and set view based on them + for (int i = 0; i < list.size(); i++) { KeyEditor view = (KeyEditor) mInflater.inflate(R.layout.edit_key_key_item, mEditors, false); view.setEditorListener(this); boolean isMasterKey = (mEditors.getChildCount() == 0); - view.setValue(key, isMasterKey); + view.setValue(list.get(i), isMasterKey, usages.get(i)); mEditors.addView(view); } this.updateEditorsVisible(); } - // TODO !!! - public void createInitialKey() { - mEditors.removeAllViews(); - - // create initial key - // PGPSecretKey key = new PGPSecretKey(); - - // for (PGPSecretKey key : list) { - KeyEditor view = (KeyEditor) mInflater.inflate(R.layout.edit_key_key_item, mEditors, false); - view.setEditorListener(this); - boolean isMasterKey = (mEditors.getChildCount() == 0); - // view.setValue(key, isMasterKey); - mEditors.addView(view); - // } - - this.updateEditorsVisible(); - } - private void createKey() { mProgressDialog = new ProgressDialog(getContext()); mProgressDialog.setMessage(getContext().getString(R.string.progress_generating)); diff --git a/org_apg/src/org/apg/util/Constants.java b/org_apg/src/org/apg/util/Constants.java new file mode 100644 index 000000000..819d13700 --- /dev/null +++ b/org_apg/src/org/apg/util/Constants.java @@ -0,0 +1,6 @@ +package org.apg.util; + +public class Constants { + public static final String TAG = "APG"; + +} |