mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-02 13:32:19 -05:00
Merge pull request #232 from ashh87/export-with-certs
Small import/export fixes
This commit is contained in:
commit
2b0a7f2bf8
@ -206,30 +206,6 @@ public class PgpImportExport {
|
|||||||
mContext.getString(R.string.error_external_storage_not_ready));
|
mContext.getString(R.string.error_external_storage_not_ready));
|
||||||
}
|
}
|
||||||
|
|
||||||
// export public keyrings...
|
|
||||||
ArmoredOutputStream outPub = new ArmoredOutputStream(outStream);
|
|
||||||
outPub.setHeader("Version", PgpHelper.getFullVersion(mContext));
|
|
||||||
|
|
||||||
int numKeys = 0;
|
|
||||||
for (int i = 0; i < keyRingMasterKeyIds.size(); ++i) {
|
|
||||||
// double the needed time if exporting both public and secret parts
|
|
||||||
if (keyType == Id.type.secret_key) {
|
|
||||||
updateProgress(i * 100 / keyRingMasterKeyIds.size() / 2, 100);
|
|
||||||
} else {
|
|
||||||
updateProgress(i * 100 / keyRingMasterKeyIds.size(), 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
PGPPublicKeyRing publicKeyRing = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(
|
|
||||||
mContext, keyRingMasterKeyIds.get(i));
|
|
||||||
|
|
||||||
if (publicKeyRing != null) {
|
|
||||||
publicKeyRing.encode(outPub);
|
|
||||||
}
|
|
||||||
++numKeys;
|
|
||||||
}
|
|
||||||
outPub.close();
|
|
||||||
|
|
||||||
// if we export secret keyrings, append all secret parts after the public parts
|
|
||||||
if (keyType == Id.type.secret_key) {
|
if (keyType == Id.type.secret_key) {
|
||||||
ArmoredOutputStream outSec = new ArmoredOutputStream(outStream);
|
ArmoredOutputStream outSec = new ArmoredOutputStream(outStream);
|
||||||
outSec.setHeader("Version", PgpHelper.getFullVersion(mContext));
|
outSec.setHeader("Version", PgpHelper.getFullVersion(mContext));
|
||||||
@ -245,9 +221,30 @@ public class PgpImportExport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
outSec.close();
|
outSec.close();
|
||||||
|
} else {
|
||||||
|
// export public keyrings...
|
||||||
|
ArmoredOutputStream outPub = new ArmoredOutputStream(outStream);
|
||||||
|
outPub.setHeader("Version", PgpHelper.getFullVersion(mContext));
|
||||||
|
|
||||||
|
for (int i = 0; i < keyRingMasterKeyIds.size(); ++i) {
|
||||||
|
// double the needed time if exporting both public and secret parts
|
||||||
|
if (keyType == Id.type.secret_key) {
|
||||||
|
updateProgress(i * 100 / keyRingMasterKeyIds.size() / 2, 100);
|
||||||
|
} else {
|
||||||
|
updateProgress(i * 100 / keyRingMasterKeyIds.size(), 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
returnData.putInt(KeychainIntentService.RESULT_EXPORT, numKeys);
|
PGPPublicKeyRing publicKeyRing = ProviderHelper.getPGPPublicKeyRingByMasterKeyId(
|
||||||
|
mContext, keyRingMasterKeyIds.get(i));
|
||||||
|
|
||||||
|
if (publicKeyRing != null) {
|
||||||
|
publicKeyRing.encode(outPub);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outPub.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
returnData.putInt(KeychainIntentService.RESULT_EXPORT, keyRingMasterKeyIds.size());
|
||||||
|
|
||||||
updateProgress(R.string.progress_done, 100, 100);
|
updateProgress(R.string.progress_done, 100, 100);
|
||||||
|
|
||||||
|
@ -98,8 +98,9 @@ public class ImportKeysAdapter extends ArrayAdapter<ImportKeysListEntry> {
|
|||||||
if (userIdSplit[0] != null && userIdSplit[0].length() > 0) {
|
if (userIdSplit[0] != null && userIdSplit[0].length() > 0) {
|
||||||
// show red user id if it is a secret key
|
// show red user id if it is a secret key
|
||||||
if (entry.secretKey) {
|
if (entry.secretKey) {
|
||||||
userId = mActivity.getString(R.string.secret_key) + " " + userId;
|
userId = mActivity.getString(R.string.secret_key) + " " + userIdSplit[0];
|
||||||
mainUserId.setTextColor(Color.RED);
|
mainUserId.setTextColor(Color.RED);
|
||||||
|
mainUserId.setText(userId);
|
||||||
} else {
|
} else {
|
||||||
mainUserId.setText(userIdSplit[0]);
|
mainUserId.setText(userIdSplit[0]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user