From 6e3ed1d2db1f9dcf8cc90deda4370a1dc058f79b Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sun, 17 May 2015 02:09:58 +0200 Subject: [PATCH] do nfc dispatching in MainActivity --- .../keychain/ui/ImportKeysActivity.java | 7 +++++++ .../org/sufficientlysecure/keychain/ui/MainActivity.java | 5 +++-- .../sufficientlysecure/keychain/ui/base/BaseActivity.java | 4 +++- .../keychain/ui/base/BaseNfcActivity.java | 8 ++------ 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java index 4cba62d5b..ee57dd319 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ImportKeysActivity.java @@ -494,4 +494,11 @@ public class ImportKeysActivity extends BaseNfcActivity { } } + @Override + protected void onNfcPerform() throws IOException { + // this displays the key or moves to the yubikey import dialogue. + super.onNfcPerform(); + // either way, finish afterwards + finish(); + } } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java index 78df612a7..e63e28667 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/MainActivity.java @@ -24,7 +24,6 @@ import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; -import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.View; import android.widget.AdapterView; @@ -39,10 +38,11 @@ import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem; import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.remote.ui.AppsListFragment; +import org.sufficientlysecure.keychain.ui.base.BaseNfcActivity; import org.sufficientlysecure.keychain.util.FabContainer; import org.sufficientlysecure.keychain.util.Preferences; -public class MainActivity extends AppCompatActivity implements FabContainer { +public class MainActivity extends BaseNfcActivity implements FabContainer { public Drawer.Result mDrawerResult; private Toolbar mToolbar; @@ -196,4 +196,5 @@ public class MainActivity extends AppCompatActivity implements FabContainer { } } + } diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/BaseActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/BaseActivity.java index 0e752881f..847d76f30 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/BaseActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/BaseActivity.java @@ -44,7 +44,9 @@ public abstract class BaseActivity extends AppCompatActivity { initToolbar(); } - protected abstract void initLayout(); + protected void initLayout() { + + } protected void initToolbar() { mToolbar = (Toolbar) findViewById(R.id.toolbar); diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/BaseNfcActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/BaseNfcActivity.java index 0dad65e77..fb6060d58 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/BaseNfcActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/base/BaseNfcActivity.java @@ -229,22 +229,18 @@ public abstract class BaseNfcActivity extends BaseActivity { KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(subKeyId)); long masterKeyId = ring.getMasterKeyId(); - Intent intent = new Intent( - BaseNfcActivity.this, ViewKeyActivity.class); + Intent intent = new Intent(this, ViewKeyActivity.class); intent.setData(KeyRings.buildGenericKeyRingUri(masterKeyId)); intent.putExtra(ViewKeyActivity.EXTRA_NFC_AID, nfcAid); intent.putExtra(ViewKeyActivity.EXTRA_NFC_USER_ID, nfcUserId); intent.putExtra(ViewKeyActivity.EXTRA_NFC_FINGERPRINTS, nfcFingerprints); startActivity(intent); - finish(); } catch (PgpKeyNotFoundException e) { - Intent intent = new Intent( - BaseNfcActivity.this, CreateKeyActivity.class); + Intent intent = new Intent(this, CreateKeyActivity.class); intent.putExtra(CreateKeyActivity.EXTRA_NFC_AID, nfcAid); intent.putExtra(CreateKeyActivity.EXTRA_NFC_USER_ID, nfcUserId); intent.putExtra(CreateKeyActivity.EXTRA_NFC_FINGERPRINTS, nfcFingerprints); startActivity(intent); - finish(); } }