Allow import of full keys from qr codes

This commit is contained in:
Dominik Schürmann 2014-02-09 21:37:01 +01:00
parent 0c4b809195
commit c744cad8db

View File

@ -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();