mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-30 20:42:17 -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.GregorianCalendar;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import org.spongycastle.bcpg.sig.KeyFlags;
|
||||||
import org.spongycastle.openpgp.PGPSecretKey;
|
import org.spongycastle.openpgp.PGPSecretKey;
|
||||||
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
import org.spongycastle.openpgp.PGPSecretKeyRing;
|
||||||
import org.sufficientlysecure.keychain.Constants;
|
import org.sufficientlysecure.keychain.Constants;
|
||||||
@ -224,15 +225,17 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
|||||||
.BytesToPGPSecretKey(data
|
.BytesToPGPSecretKey(data
|
||||||
.getByteArray(KeychainIntentService.RESULT_NEW_KEY2));
|
.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
|
// add master key
|
||||||
mKeys.add(masterKey);
|
mKeys.add(masterKey);
|
||||||
mKeysUsages.add(Id.choice.usage.sign_only); //TODO: get from key flags
|
mKeysUsages.add(KeyFlags.CERTIFY_OTHER);
|
||||||
|
|
||||||
// add sub key
|
// add sub key
|
||||||
mKeys.add(subKey);
|
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 {
|
} else {
|
||||||
buildLayout();
|
buildLayout(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,7 +393,7 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
|||||||
|
|
||||||
mCurrentPassPhrase = "";
|
mCurrentPassPhrase = "";
|
||||||
|
|
||||||
buildLayout();
|
buildLayout(false);
|
||||||
mIsPassPhraseSet = PassphraseCacheService.hasPassphrase(this, masterKeyId);
|
mIsPassPhraseSet = PassphraseCacheService.hasPassphrase(this, masterKeyId);
|
||||||
if (!mIsPassPhraseSet) {
|
if (!mIsPassPhraseSet) {
|
||||||
// check "no passphrase" checkbox and remove button
|
// 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
|
* Build layout based on mUserId, mKeys and mKeysUsages Vectors. It creates Views for every user
|
||||||
* id and key.
|
* id and key.
|
||||||
|
* @param newKeys
|
||||||
*/
|
*/
|
||||||
private void buildLayout() {
|
private void buildLayout(boolean newKeys) {
|
||||||
setContentView(R.layout.edit_key_activity);
|
setContentView(R.layout.edit_key_activity);
|
||||||
|
|
||||||
// find views
|
// 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 = (SectionView) inflater.inflate(R.layout.edit_key_section, container, false);
|
||||||
mKeysView.setType(Id.type.key);
|
mKeysView.setType(Id.type.key);
|
||||||
mKeysView.setCanEdit(masterCanSign);
|
mKeysView.setCanEdit(masterCanSign);
|
||||||
mKeysView.setKeys(mKeys, mKeysUsages);
|
mKeysView.setKeys(mKeys, mKeysUsages, newKeys);
|
||||||
mKeysView.setEditorListener(this);
|
mKeysView.setEditorListener(this);
|
||||||
container.addView(mKeysView);
|
container.addView(mKeysView);
|
||||||
|
|
||||||
@ -607,8 +611,8 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
|||||||
// start service with intent
|
// start service with intent
|
||||||
startService(intent);
|
startService(intent);
|
||||||
} catch (PgpGeneralException e) {
|
} catch (PgpGeneralException e) {
|
||||||
//Toast.makeText(this, getString(R.string.error_message, e.getMessage()),
|
Toast.makeText(this, getString(R.string.error_message, e.getMessage()),
|
||||||
// Toast.LENGTH_SHORT).show();
|
Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -665,10 +669,6 @@ public class EditKeyActivity extends ActionBarActivity implements EditorListener
|
|||||||
throw new PgpGeneralException(e.getMessage());
|
throw new PgpGeneralException(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userId.equals("")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (editor.isMainUserId()) {
|
if (editor.isMainUserId()) {
|
||||||
userIds.add(0, userId);
|
userIds.add(0, userId);
|
||||||
gotMainUserId = true;
|
gotMainUserId = true;
|
||||||
|
@ -24,6 +24,7 @@ import java.util.TimeZone;
|
|||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
import org.spongycastle.bcpg.sig.KeyFlags;
|
import org.spongycastle.bcpg.sig.KeyFlags;
|
||||||
|
import org.spongycastle.openpgp.PGPKeyFlags;
|
||||||
import org.spongycastle.openpgp.PGPPublicKey;
|
import org.spongycastle.openpgp.PGPPublicKey;
|
||||||
import org.spongycastle.openpgp.PGPSecretKey;
|
import org.spongycastle.openpgp.PGPSecretKey;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
@ -216,17 +217,22 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int selectId = 0;
|
int selectId = 0;
|
||||||
|
mIsNewKey = isNewKey;
|
||||||
|
if (isNewKey) {
|
||||||
|
mUsage = usage;
|
||||||
|
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())
|
if (key.isMasterKey())
|
||||||
mChkCertify.setChecked(PgpKeyHelper.isCertificationKey(key));
|
mChkCertify.setChecked(PgpKeyHelper.isCertificationKey(key));
|
||||||
mChkSign.setChecked(PgpKeyHelper.isSigningKey(key));
|
mChkSign.setChecked(PgpKeyHelper.isSigningKey(key));
|
||||||
mChkEncrypt.setChecked(PgpKeyHelper.isEncryptionKey(key));
|
mChkEncrypt.setChecked(PgpKeyHelper.isEncryptionKey(key));
|
||||||
mChkAuthenticate.setChecked(PgpKeyHelper.isAuthenticationKey(key));
|
mChkAuthenticate.setChecked(PgpKeyHelper.isAuthenticationKey(key));
|
||||||
mIsNewKey = isNewKey;
|
|
||||||
if (isNewKey)
|
|
||||||
mUsage = usage;
|
|
||||||
else {
|
|
||||||
mUsage = PgpKeyHelper.getKeyUsage(key);
|
|
||||||
mOriginalUsage = mUsage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
|
GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
|
||||||
|
@ -18,6 +18,7 @@ package org.sufficientlysecure.keychain.ui.widget;
|
|||||||
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import org.spongycastle.openpgp.PGPKeyFlags;
|
||||||
import org.spongycastle.openpgp.PGPSecretKey;
|
import org.spongycastle.openpgp.PGPSecretKey;
|
||||||
import org.sufficientlysecure.keychain.Id;
|
import org.sufficientlysecure.keychain.Id;
|
||||||
import org.sufficientlysecure.keychain.R;
|
import org.sufficientlysecure.keychain.R;
|
||||||
@ -285,7 +286,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
|||||||
this.updateEditorsVisible();
|
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) {
|
if (mType != Id.type.key) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -298,7 +299,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
|||||||
false);
|
false);
|
||||||
view.setEditorListener(this);
|
view.setEditorListener(this);
|
||||||
boolean isMasterKey = (mEditors.getChildCount() == 0);
|
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);
|
view.setCanEdit(canEdit);
|
||||||
mEditors.addView(view);
|
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,
|
KeyEditor view = (KeyEditor) mInflater.inflate(R.layout.edit_key_key_item,
|
||||||
mEditors, false);
|
mEditors, false);
|
||||||
view.setEditorListener(SectionView.this);
|
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);
|
mEditors.addView(view);
|
||||||
SectionView.this.updateEditorsVisible();
|
SectionView.this.updateEditorsVisible();
|
||||||
if (mEditorListener != null) {
|
if (mEditorListener != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user