mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-27 19:22:14 -05:00
saving fixes
This commit is contained in:
parent
adc6a3ea64
commit
75640934a0
@ -21,6 +21,7 @@ import java.util.ArrayList;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.spongycastle.bcpg.sig.KeyFlags;
|
||||
import org.spongycastle.openpgp.PGPSecretKey;
|
||||
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
@ -224,15 +225,17 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
||||
.BytesToPGPSecretKey(data
|
||||
.getByteArray(KeychainIntentService.RESULT_NEW_KEY2));
|
||||
|
||||
//We must set the key flags here as they are not set when we make the
|
||||
//key pair. Because we are not generating hashed packets there...
|
||||
// add master key
|
||||
mKeys.add(masterKey);
|
||||
mKeysUsages.add(Id.choice.usage.sign_only); //TODO: get from key flags
|
||||
mKeysUsages.add(KeyFlags.CERTIFY_OTHER);
|
||||
|
||||
// add sub key
|
||||
mKeys.add(subKey);
|
||||
mKeysUsages.add(Id.choice.usage.encrypt_only); //TODO: get from key flags
|
||||
mKeysUsages.add(KeyFlags.ENCRYPT_COMMS + KeyFlags.ENCRYPT_STORAGE);
|
||||
|
||||
buildLayout();
|
||||
buildLayout(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -248,7 +251,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
||||
}
|
||||
}
|
||||
} else {
|
||||
buildLayout();
|
||||
buildLayout(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -390,7 +393,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
||||
|
||||
mCurrentPassPhrase = "";
|
||||
|
||||
buildLayout();
|
||||
buildLayout(false);
|
||||
mIsPassPhraseSet = PassphraseCacheService.hasPassphrase(this, masterKeyId);
|
||||
if (!mIsPassPhraseSet) {
|
||||
// check "no passphrase" checkbox and remove button
|
||||
@ -440,8 +443,9 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
||||
/**
|
||||
* Build layout based on mUserId, mKeys and mKeysUsages Vectors. It creates Views for every user
|
||||
* id and key.
|
||||
* @param newKeys
|
||||
*/
|
||||
private void buildLayout() {
|
||||
private void buildLayout(boolean newKeys) {
|
||||
setContentView(R.layout.edit_key_activity);
|
||||
|
||||
// find views
|
||||
@ -461,7 +465,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
||||
mKeysView = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false);
|
||||
mKeysView.setType(Id.type.key);
|
||||
mKeysView.setCanEdit(masterCanSign);
|
||||
mKeysView.setKeys(mKeys, mKeysUsages);
|
||||
mKeysView.setKeys(mKeys, mKeysUsages, newKeys);
|
||||
mKeysView.setEditorListener(this);
|
||||
container.addView(mKeysView);
|
||||
|
||||
@ -607,8 +611,8 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
||||
// start service with intent
|
||||
startService(intent);
|
||||
} catch (PgpGeneralException e) {
|
||||
//Toast.makeText(this, getString(R.string.error_message, e.getMessage()),
|
||||
// Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(this, getString(R.string.error_message, e.getMessage()),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@ -665,10 +669,6 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
||||
throw new PgpGeneralException(e.getMessage());
|
||||
}
|
||||
|
||||
if (userId.equals("")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (editor.isMainUserId()) {
|
||||
userIds.add(0, userId);
|
||||
gotMainUserId = true;
|
||||
|
@ -24,6 +24,7 @@ import java.util.TimeZone;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.spongycastle.bcpg.sig.KeyFlags;
|
||||
import org.spongycastle.openpgp.PGPKeyFlags;
|
||||
import org.spongycastle.openpgp.PGPPublicKey;
|
||||
import org.spongycastle.openpgp.PGPSecretKey;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
@ -216,17 +217,22 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
|
||||
}
|
||||
|
||||
int selectId = 0;
|
||||
if (key.isMasterKey())
|
||||
mChkCertify.setChecked(PgpKeyHelper.isCertificationKey(key));
|
||||
mChkSign.setChecked(PgpKeyHelper.isSigningKey(key));
|
||||
mChkEncrypt.setChecked(PgpKeyHelper.isEncryptionKey(key));
|
||||
mChkAuthenticate.setChecked(PgpKeyHelper.isAuthenticationKey(key));
|
||||
mIsNewKey = isNewKey;
|
||||
if (isNewKey)
|
||||
if (isNewKey) {
|
||||
mUsage = usage;
|
||||
else {
|
||||
mChkCertify.setChecked((usage &= KeyFlags.CERTIFY_OTHER) == KeyFlags.CERTIFY_OTHER);
|
||||
mChkSign.setChecked((usage &= KeyFlags.SIGN_DATA) == KeyFlags.SIGN_DATA);
|
||||
mChkEncrypt.setChecked(((usage &= KeyFlags.ENCRYPT_COMMS) == KeyFlags.ENCRYPT_COMMS) ||
|
||||
((usage &= KeyFlags.ENCRYPT_STORAGE) == KeyFlags.ENCRYPT_STORAGE));
|
||||
mChkAuthenticate.setChecked((usage &= KeyFlags.AUTHENTICATION) == KeyFlags.AUTHENTICATION);
|
||||
} else {
|
||||
mUsage = PgpKeyHelper.getKeyUsage(key);
|
||||
mOriginalUsage = mUsage;
|
||||
if (key.isMasterKey())
|
||||
mChkCertify.setChecked(PgpKeyHelper.isCertificationKey(key));
|
||||
mChkSign.setChecked(PgpKeyHelper.isSigningKey(key));
|
||||
mChkEncrypt.setChecked(PgpKeyHelper.isEncryptionKey(key));
|
||||
mChkAuthenticate.setChecked(PgpKeyHelper.isAuthenticationKey(key));
|
||||
}
|
||||
|
||||
GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
|
||||
|
@ -18,6 +18,7 @@ package org.sufficientlysecure.keychain.ui.widget;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
import org.spongycastle.openpgp.PGPKeyFlags;
|
||||
import org.spongycastle.openpgp.PGPSecretKey;
|
||||
import org.sufficientlysecure.keychain.Id;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
@ -285,7 +286,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
this.updateEditorsVisible();
|
||||
}
|
||||
|
||||
public void setKeys(Vector<PGPSecretKey> list, Vector<Integer> usages) {
|
||||
public void setKeys(Vector<PGPSecretKey> list, Vector<Integer> usages, boolean newKeys) {
|
||||
if (mType != Id.type.key) {
|
||||
return;
|
||||
}
|
||||
@ -298,7 +299,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
false);
|
||||
view.setEditorListener(this);
|
||||
boolean isMasterKey = (mEditors.getChildCount() == 0);
|
||||
view.setValue(list.get(i), isMasterKey, usages.get(i), false);
|
||||
view.setValue(list.get(i), isMasterKey, usages.get(i), newKeys);
|
||||
view.setCanEdit(canEdit);
|
||||
mEditors.addView(view);
|
||||
}
|
||||
@ -370,7 +371,10 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
||||
KeyEditor view = (KeyEditor) mInflater.inflate(R.layout.edit_key_key_item,
|
||||
mEditors, false);
|
||||
view.setEditorListener(SectionView.this);
|
||||
view.setValue(newKey, newKey.isMasterKey(), -1, true);
|
||||
int usage = 0;
|
||||
if (mEditors.getChildCount() == 0)
|
||||
usage = PGPKeyFlags.CAN_CERTIFY;
|
||||
view.setValue(newKey, newKey.isMasterKey(), usage, true);
|
||||
mEditors.addView(view);
|
||||
SectionView.this.updateEditorsVisible();
|
||||
if (mEditorListener != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user