use usage argument if needed

This commit is contained in:
Ashley Hughes 2014-02-04 22:02:53 +00:00
parent fe3db8f0e6
commit 6d40bc3c0c
2 changed files with 7 additions and 5 deletions

View File

@ -146,7 +146,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
} }
} }
public void setValue(PGPSecretKey key, boolean isMasterKey, int usage) { public void setValue(PGPSecretKey key, boolean isMasterKey, int usage, boolean isNewKey) {
mKey = key; mKey = key;
mIsMasterKey = isMasterKey; mIsMasterKey = isMasterKey;
@ -190,8 +190,10 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
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));
mUsage = PgpKeyHelper.getKeyUsage(key); if (isNewKey)
// TODO: use usage argument? mUsage = usage;
else
mUsage = PgpKeyHelper.getKeyUsage(key);
GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC")); GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
cal.setTime(PgpKeyHelper.getCreationDate(key)); cal.setTime(PgpKeyHelper.getCreationDate(key));

View File

@ -272,7 +272,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)); view.setValue(list.get(i), isMasterKey, usages.get(i), false);
view.setCanEdit(canEdit); view.setCanEdit(canEdit);
mEditors.addView(view); mEditors.addView(view);
} }
@ -344,7 +344,7 @@ 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); view.setValue(newKey, newKey.isMasterKey(), -1, true);
mEditors.addView(view); mEditors.addView(view);
SectionView.this.updateEditorsVisible(); SectionView.this.updateEditorsVisible();
} }