do nfc dispatching in MainActivity

This commit is contained in:
Vincent Breitmoser 2015-05-17 02:09:58 +02:00
parent 1fcd9d3fde
commit 6e3ed1d2db
4 changed files with 15 additions and 9 deletions

View File

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

View File

@ -24,7 +24,6 @@ import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.View; import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
@ -39,10 +38,11 @@ import com.mikepenz.materialdrawer.model.interfaces.IDrawerItem;
import org.sufficientlysecure.keychain.R; import org.sufficientlysecure.keychain.R;
import org.sufficientlysecure.keychain.operations.results.OperationResult; import org.sufficientlysecure.keychain.operations.results.OperationResult;
import org.sufficientlysecure.keychain.remote.ui.AppsListFragment; 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.FabContainer;
import org.sufficientlysecure.keychain.util.Preferences; import org.sufficientlysecure.keychain.util.Preferences;
public class MainActivity extends AppCompatActivity implements FabContainer { public class MainActivity extends BaseNfcActivity implements FabContainer {
public Drawer.Result mDrawerResult; public Drawer.Result mDrawerResult;
private Toolbar mToolbar; private Toolbar mToolbar;
@ -196,4 +196,5 @@ public class MainActivity extends AppCompatActivity implements FabContainer {
} }
} }
} }

View File

@ -44,7 +44,9 @@ public abstract class BaseActivity extends AppCompatActivity {
initToolbar(); initToolbar();
} }
protected abstract void initLayout(); protected void initLayout() {
}
protected void initToolbar() { protected void initToolbar() {
mToolbar = (Toolbar) findViewById(R.id.toolbar); mToolbar = (Toolbar) findViewById(R.id.toolbar);

View File

@ -229,22 +229,18 @@ public abstract class BaseNfcActivity extends BaseActivity {
KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(subKeyId)); KeyRings.buildUnifiedKeyRingsFindBySubkeyUri(subKeyId));
long masterKeyId = ring.getMasterKeyId(); long masterKeyId = ring.getMasterKeyId();
Intent intent = new Intent( Intent intent = new Intent(this, ViewKeyActivity.class);
BaseNfcActivity.this, ViewKeyActivity.class);
intent.setData(KeyRings.buildGenericKeyRingUri(masterKeyId)); intent.setData(KeyRings.buildGenericKeyRingUri(masterKeyId));
intent.putExtra(ViewKeyActivity.EXTRA_NFC_AID, nfcAid); intent.putExtra(ViewKeyActivity.EXTRA_NFC_AID, nfcAid);
intent.putExtra(ViewKeyActivity.EXTRA_NFC_USER_ID, nfcUserId); intent.putExtra(ViewKeyActivity.EXTRA_NFC_USER_ID, nfcUserId);
intent.putExtra(ViewKeyActivity.EXTRA_NFC_FINGERPRINTS, nfcFingerprints); intent.putExtra(ViewKeyActivity.EXTRA_NFC_FINGERPRINTS, nfcFingerprints);
startActivity(intent); startActivity(intent);
finish();
} catch (PgpKeyNotFoundException e) { } catch (PgpKeyNotFoundException e) {
Intent intent = new Intent( Intent intent = new Intent(this, CreateKeyActivity.class);
BaseNfcActivity.this, CreateKeyActivity.class);
intent.putExtra(CreateKeyActivity.EXTRA_NFC_AID, nfcAid); intent.putExtra(CreateKeyActivity.EXTRA_NFC_AID, nfcAid);
intent.putExtra(CreateKeyActivity.EXTRA_NFC_USER_ID, nfcUserId); intent.putExtra(CreateKeyActivity.EXTRA_NFC_USER_ID, nfcUserId);
intent.putExtra(CreateKeyActivity.EXTRA_NFC_FINGERPRINTS, nfcFingerprints); intent.putExtra(CreateKeyActivity.EXTRA_NFC_FINGERPRINTS, nfcFingerprints);
startActivity(intent); startActivity(intent);
finish();
} }
} }