mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-17 21:02:17 -05:00
Allow import of full keys from qr codes
This commit is contained in:
parent
0c4b809195
commit
c744cad8db
@ -98,22 +98,29 @@ public class ImportKeysQrCodeFragment extends Fragment {
|
|||||||
IntentResult scanResult = IntentIntegratorSupportV4.parseActivityResult(requestCode,
|
IntentResult scanResult = IntentIntegratorSupportV4.parseActivityResult(requestCode,
|
||||||
resultCode, data);
|
resultCode, data);
|
||||||
if (scanResult != null && scanResult.getFormatName() != null) {
|
if (scanResult != null && scanResult.getFormatName() != null) {
|
||||||
|
String scannedContent = scanResult.getContents();
|
||||||
|
|
||||||
Log.d(Constants.TAG, "scanResult content: " + scanResult.getContents());
|
Log.d(Constants.TAG, "scannedContent: " + scannedContent);
|
||||||
|
|
||||||
// look if it's fingerprint only
|
// look if it's fingerprint only
|
||||||
if (scanResult.getContents().toLowerCase(Locale.ENGLISH).startsWith(Constants.FINGERPRINT_SCHEME)) {
|
if (scannedContent.toLowerCase(Locale.ENGLISH).startsWith(Constants.FINGERPRINT_SCHEME)) {
|
||||||
importFingerprint(Uri.parse(scanResult.getContents()));
|
importFingerprint(Uri.parse(scanResult.getContents()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// look if it is the whole key
|
// look if it is the whole key
|
||||||
String[] parts = scanResult.getContents().split(",");
|
String[] parts = scannedContent.split(",");
|
||||||
if (parts.length == 3) {
|
if (parts.length == 3) {
|
||||||
importParts(parts);
|
importParts(parts);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// is this a full key encoded as qr code?
|
||||||
|
if (scannedContent.startsWith("-----BEGIN PGP")) {
|
||||||
|
mImportActivity.loadCallback(scannedContent.getBytes(), null, null, null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// fail...
|
// fail...
|
||||||
Toast.makeText(getActivity(), R.string.import_qr_code_wrong, Toast.LENGTH_LONG)
|
Toast.makeText(getActivity(), R.string.import_qr_code_wrong, Toast.LENGTH_LONG)
|
||||||
.show();
|
.show();
|
||||||
|
Loading…
Reference in New Issue
Block a user