do nfc dispatching in MainActivity

This commit is contained in:
Vincent Breitmoser 2015-05-17 02:09:58 +02:00
parent bd8e45b556
commit b430ba51eb
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.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 {
}
}
}

View File

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

View File

@ -241,22 +241,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();
}
}