diff options
Diffstat (limited to 'OpenKeychain/src/main/java/org')
-rw-r--r-- | OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java index 4e8a14008..3ddaccad3 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/ViewKeyActivity.java @@ -88,6 +88,7 @@ public class ViewKeyActivity extends BaseActivity implements private ImageButton mActionEncryptText; private ImageButton mActionVerify; private ImageButton mActionEdit; + private ImageButton mActionNfc; private FloatingActionButton mFab; private AspectRatioImageView mPhoto; private ImageButton mQrCode; @@ -123,6 +124,7 @@ public class ViewKeyActivity extends BaseActivity implements mActionEncryptText = (ImageButton) findViewById(R.id.view_key_action_encrypt_text); mActionVerify = (ImageButton) findViewById(R.id.view_key_action_verify); mActionEdit = (ImageButton) findViewById(R.id.view_key_action_edit); + mActionNfc = (ImageButton) findViewById(R.id.view_key_action_nfc); mFab = (FloatingActionButton) findViewById(R.id.fab); mPhoto = (AspectRatioImageView) findViewById(R.id.view_key_photo); mQrCode = (ImageButton) findViewById(R.id.view_key_qr_code); @@ -187,6 +189,13 @@ public class ViewKeyActivity extends BaseActivity implements } }); + mActionNfc.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + invokeNfcBeam(); + } + }); + // Prepare the loaders. Either re-connect with an existing ones, // or start new ones. @@ -270,6 +279,15 @@ public class ViewKeyActivity extends BaseActivity implements return super.onOptionsItemSelected(item); } + @TargetApi(Build.VERSION_CODES.LOLLIPOP) + private void invokeNfcBeam() { + // Check for available NFC Adapter + mNfcAdapter = NfcAdapter.getDefaultAdapter(this); + if (mNfcAdapter != null) { + mNfcAdapter.invokeBeam(this); + } + } + private void scanQrCode() { Intent scanQrCode = new Intent(this, QrCodeScanActivity.class); scanQrCode.setAction(QrCodeScanActivity.ACTION_SCAN_WITH_RESULT); @@ -623,6 +641,7 @@ public class ViewKeyActivity extends BaseActivity implements mActionEncryptText.setVisibility(View.GONE); mActionVerify.setVisibility(View.GONE); mActionEdit.setVisibility(View.GONE); + mActionNfc.setVisibility(View.GONE); mFab.setVisibility(View.GONE); mQrCodeLayout.setVisibility(View.GONE); } else if (isExpired) { @@ -641,6 +660,7 @@ public class ViewKeyActivity extends BaseActivity implements mActionEncryptFile.setVisibility(View.GONE); mActionEncryptText.setVisibility(View.GONE); mActionVerify.setVisibility(View.GONE); + mActionNfc.setVisibility(View.GONE); mFab.setVisibility(View.GONE); mQrCodeLayout.setVisibility(View.GONE); } else if (mIsSecret) { @@ -675,6 +695,13 @@ public class ViewKeyActivity extends BaseActivity implements mActionEncryptText.setVisibility(View.VISIBLE); mActionVerify.setVisibility(View.GONE); mActionEdit.setVisibility(View.VISIBLE); + + // invokeBeam is available from API 21 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + mActionNfc.setVisibility(View.VISIBLE); + } else { + mActionNfc.setVisibility(View.GONE); + } mFab.setVisibility(View.VISIBLE); mFab.setIconDrawable(getResources().getDrawable(R.drawable.ic_repeat_white_24dp)); } else { @@ -682,6 +709,7 @@ public class ViewKeyActivity extends BaseActivity implements mActionEncryptText.setVisibility(View.VISIBLE); mActionEdit.setVisibility(View.GONE); mQrCodeLayout.setVisibility(View.GONE); + mActionNfc.setVisibility(View.GONE); if (isVerified) { mStatusText.setText(R.string.view_key_verified); |