Connect YubiKey URL to OpenKeychain

This commit is contained in:
Dominik Schürmann
2015-06-29 21:17:12 +02:00
parent a9c606d49b
commit 7009e504b9
3 changed files with 35 additions and 15 deletions

View File

@@ -95,15 +95,15 @@
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.MainActivity" /> android:value=".ui.MainActivity" />
<!-- Connect with YubiKeys. This Activity will automatically show/import/create key --> <!-- Connect with YubiKeys. This Activity will automatically show/import/create YubiKeys -->
<!--<intent-filter>--> <intent-filter android:label="@string/app_name">
<!--<action android:name="android.nfc.action.NDEF_DISCOVERED"/>--> <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
<!--<category android:name="android.intent.category.DEFAULT"/>--> <category android:name="android.intent.category.DEFAULT"/>
<!--<data--> <data
<!--android:scheme="https"--> android:scheme="https"
<!--android:host="my.yubico.com"--> android:host="my.yubico.com"
<!--android:pathPrefix="/neo"/>--> android:pathPrefix="/neo"/>
<!--</intent-filter>--> </intent-filter>
</activity> </activity>
<activity <activity
android:name=".ui.EditKeyActivity" android:name=".ui.EditKeyActivity"

View File

@@ -18,6 +18,7 @@
package org.sufficientlysecure.keychain.ui; package org.sufficientlysecure.keychain.ui;
import android.content.Intent; import android.content.Intent;
import android.nfc.NfcAdapter;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
@@ -62,6 +63,23 @@ public class CreateKeyActivity extends BaseNfcActivity {
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
// React on NDEF_DISCOVERED from Manifest
// NOTE: ACTION_NDEF_DISCOVERED and not ACTION_TAG_DISCOVERED like in BaseNfcActivity
if (NfcAdapter.ACTION_NDEF_DISCOVERED.equals(getIntent().getAction())) {
try {
handleTagDiscoveredIntent(getIntent());
} catch (CardException e) {
handleNfcError(e);
} catch (IOException e) {
handleNfcError(e);
}
setTitle(R.string.title_manage_my_keys);
// done
return;
}
// Check whether we're recreating a previously destroyed instance // Check whether we're recreating a previously destroyed instance
if (savedInstanceState != null) { if (savedInstanceState != null) {
// Restore value of members from saved state // Restore value of members from saved state
@@ -96,14 +114,16 @@ public class CreateKeyActivity extends BaseNfcActivity {
} else { } else {
Fragment frag = CreateKeyYubiKeyBlankFragment.newInstance(); Fragment frag = CreateKeyYubiKeyBlankFragment.newInstance();
loadFragment(frag, FragAction.START); loadFragment(frag, FragAction.START);
setTitle(R.string.title_manage_my_keys);
} }
// done
return; return;
} else {
// normal key creation
CreateKeyStartFragment frag = CreateKeyStartFragment.newInstance();
loadFragment(frag, FragAction.START);
} }
// normal key creation
CreateKeyStartFragment frag = CreateKeyStartFragment.newInstance();
loadFragment(frag, FragAction.START);
} }
if (mFirstTime) { if (mFirstTime) {

View File

@@ -94,7 +94,7 @@ public abstract class BaseNfcActivity extends BaseActivity {
public void onNewIntent(Intent intent) { public void onNewIntent(Intent intent) {
if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) { if (NfcAdapter.ACTION_TAG_DISCOVERED.equals(intent.getAction())) {
try { try {
handleNdefDiscoveredIntent(intent); handleTagDiscoveredIntent(intent);
} catch (CardException e) { } catch (CardException e) {
handleNfcError(e); handleNfcError(e);
} catch (IOException e) { } catch (IOException e) {
@@ -278,7 +278,7 @@ public abstract class BaseNfcActivity extends BaseActivity {
* on ISO SmartCard Systems specification. * on ISO SmartCard Systems specification.
* *
*/ */
protected void handleNdefDiscoveredIntent(Intent intent) throws IOException { protected void handleTagDiscoveredIntent(Intent intent) throws IOException {
Tag detectedTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); Tag detectedTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);