Merge pull request #2323 from wiktor-k/ndef-openpgp4fpr

Add support for NDEF tags with `openpgp4fpr` URIs
This commit is contained in:
Vincent Breitmoser
2018-05-23 13:20:05 +02:00
committed by GitHub
2 changed files with 20 additions and 1 deletions

View File

@@ -743,6 +743,20 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<!-- NFC: Handle NFC tags with "openpgp4fpr" scheme URIs detected from outside our application -->
<intent-filter>
<action android:name="android.nfc.action.NDEF_DISCOVERED" />
<category android:name="android.intent.category.DEFAULT" />
<!-- Android's scheme matcher is case-sensitive, so include most likely variations -->
<data android:scheme="openpgp4fpr" />
<data android:scheme="OPENPGP4FPR" />
<data android:scheme="OpenPGP4FPR" />
<data android:scheme="OpenPGP4Fpr" />
<data android:scheme="OpenPGP4fpr" />
</intent-filter>
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.MainActivity" />

View File

@@ -20,6 +20,7 @@ package org.sufficientlysecure.keychain.ui;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.nfc.NfcAdapter;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment;
@@ -123,7 +124,7 @@ public class ImportKeysActivity extends BaseActivity implements ImportKeysListen
action = ACTION_IMPORT_KEY_FROM_FACEBOOK;
} else if ("http".equalsIgnoreCase(scheme) || "https".equalsIgnoreCase(scheme)) {
action = ACTION_SEARCH_KEYSERVER_FROM_URL;
} else if ("openpgp4fpr".equalsIgnoreCase(scheme)) {
} else if (Constants.FINGERPRINT_SCHEME.equalsIgnoreCase(scheme)) {
action = ACTION_IMPORT_KEY_FROM_KEYSERVER;
extras.putString(EXTRA_FINGERPRINT, dataUri.getSchemeSpecificPart());
} else {
@@ -131,7 +132,11 @@ public class ImportKeysActivity extends BaseActivity implements ImportKeysListen
// delegate action to ACTION_IMPORT_KEY
action = ACTION_IMPORT_KEY;
}
} else if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(action) && Constants.FINGERPRINT_SCHEME.equalsIgnoreCase(scheme)) {
action = ACTION_IMPORT_KEY_FROM_KEYSERVER;
extras.putString(EXTRA_FINGERPRINT, dataUri.getSchemeSpecificPart());
}
if (action == null) {
// -> switch to default below
action = "";