mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-25 00:18:51 -05:00
Allow state loss on dismissal of progress dialogs, fixes #217
This commit is contained in:
parent
d8a91f15df
commit
34d791c9bd
@ -69,12 +69,12 @@ public class KeychainIntentServiceHandler extends Handler {
|
|||||||
|
|
||||||
switch (message.arg1) {
|
switch (message.arg1) {
|
||||||
case MESSAGE_OKAY:
|
case MESSAGE_OKAY:
|
||||||
mProgressDialogFragment.dismiss();
|
mProgressDialogFragment.dismissAllowingStateLoss();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MESSAGE_EXCEPTION:
|
case MESSAGE_EXCEPTION:
|
||||||
mProgressDialogFragment.dismiss();
|
mProgressDialogFragment.dismissAllowingStateLoss();
|
||||||
|
|
||||||
// show error from service
|
// show error from service
|
||||||
if (data.containsKey(DATA_ERROR)) {
|
if (data.containsKey(DATA_ERROR)) {
|
||||||
|
@ -326,28 +326,7 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
|||||||
.BytesToPGPKeyRing(data
|
.BytesToPGPKeyRing(data
|
||||||
.getByteArray(KeychainIntentService.RESULT_NEW_KEY));
|
.getByteArray(KeychainIntentService.RESULT_NEW_KEY));
|
||||||
|
|
||||||
boolean isMasterKey = (mEditors.getChildCount() == 0);
|
addGeneratedKeyToView(newKeyRing);
|
||||||
|
|
||||||
// take only the key from this ring
|
|
||||||
PGPSecretKey newKey = null;
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Iterator<PGPSecretKey> it = newKeyRing.getSecretKeys();
|
|
||||||
|
|
||||||
if (isMasterKey) {
|
|
||||||
newKey = it.next();
|
|
||||||
} else {
|
|
||||||
// first one is the master key
|
|
||||||
it.next();
|
|
||||||
newKey = it.next();
|
|
||||||
}
|
|
||||||
|
|
||||||
// add view with new key
|
|
||||||
KeyEditor view = (KeyEditor) mInflater.inflate(R.layout.edit_key_key_item,
|
|
||||||
mEditors, false);
|
|
||||||
view.setEditorListener(SectionView.this);
|
|
||||||
view.setValue(newKey, isMasterKey, -1);
|
|
||||||
mEditors.addView(view);
|
|
||||||
SectionView.this.updateEditorsVisible();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -361,4 +340,29 @@ public class SectionView extends LinearLayout implements OnClickListener, Editor
|
|||||||
// start service with intent
|
// start service with intent
|
||||||
mActivity.startService(intent);
|
mActivity.startService(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addGeneratedKeyToView(PGPSecretKeyRing newKeyRing) {
|
||||||
|
boolean isMasterKey = (mEditors.getChildCount() == 0);
|
||||||
|
|
||||||
|
// take only the key from this ring
|
||||||
|
PGPSecretKey newKey = null;
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Iterator<PGPSecretKey> it = newKeyRing.getSecretKeys();
|
||||||
|
|
||||||
|
if (isMasterKey) {
|
||||||
|
newKey = it.next();
|
||||||
|
} else {
|
||||||
|
// first one is the master key
|
||||||
|
it.next();
|
||||||
|
newKey = it.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
// add view with new key
|
||||||
|
KeyEditor view = (KeyEditor) mInflater.inflate(R.layout.edit_key_key_item,
|
||||||
|
mEditors, false);
|
||||||
|
view.setEditorListener(SectionView.this);
|
||||||
|
view.setValue(newKey, isMasterKey, -1);
|
||||||
|
mEditors.addView(view);
|
||||||
|
SectionView.this.updateEditorsVisible();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user