private void share(boolean fingerprintOnly, boolean toClipboard) {
    Activity activity = getActivity();
    if (activity == null || mFingerprint == null) {
      return;
    }
    ProviderHelper providerHelper = new ProviderHelper(activity);

    try {
      String content;
      if (fingerprintOnly) {
        String fingerprint = KeyFormattingUtils.convertFingerprintToHex(mFingerprint);
        if (!toClipboard) {
          content = Constants.FINGERPRINT_SCHEME + ":" + fingerprint;
        } else {
          content = fingerprint;
        }
      } else {
        content =
            providerHelper.getKeyRingAsArmoredString(
                KeychainContract.KeyRingData.buildPublicKeyRingUri(mDataUri));
      }

      if (toClipboard) {
        ClipboardManager clipMan =
            (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
        if (clipMan == null) {
          Notify.create(activity, R.string.error_clipboard_copy, Style.ERROR);
          return;
        }

        ClipData clip = ClipData.newPlainText(Constants.CLIPBOARD_LABEL, content);
        clipMan.setPrimaryClip(clip);

        Notify.create(
                activity,
                fingerprintOnly
                    ? R.string.fingerprint_copied_to_clipboard
                    : R.string.key_copied_to_clipboard,
                Notify.Style.OK)
            .show();
        return;
      }

      // Android will fail with android.os.TransactionTooLargeException if key is too big
      // see http://www.lonestarprod.com/?p=34
      if (content.length() >= 86389) {
        Notify.create(activity, R.string.key_too_big_for_sharing, Notify.Style.ERROR).show();
        return;
      }

      // let user choose application
      Intent sendIntent = new Intent(Intent.ACTION_SEND);
      sendIntent.putExtra(Intent.EXTRA_TEXT, content);
      sendIntent.setType("text/plain");

      // Bluetooth Share will convert text/plain sent via EXTRA_TEXT to HTML
      // Add replacement extra to send a text/plain file instead.
      try {
        TemporaryStorageProvider shareFileProv = new TemporaryStorageProvider();
        Uri contentUri =
            TemporaryStorageProvider.createFile(
                activity,
                KeyFormattingUtils.convertFingerprintToHex(mFingerprint)
                    + Constants.FILE_EXTENSION_ASC);

        BufferedWriter contentWriter =
            new BufferedWriter(
                new OutputStreamWriter(
                    new ParcelFileDescriptor.AutoCloseOutputStream(
                        shareFileProv.openFile(contentUri, "w"))));
        contentWriter.write(content);
        contentWriter.close();

        sendIntent.putExtra(Intent.EXTRA_STREAM, contentUri);
      } catch (FileNotFoundException e) {
        Log.e(Constants.TAG, "error creating temporary Bluetooth key share file!", e);
        // no need for a snackbar because one sharing option doesn't work
        // Notify.create(getActivity(), R.string.error_temp_file, Notify.Style.ERROR).show();
      }

      String title =
          getString(
              fingerprintOnly ? R.string.title_share_fingerprint_with : R.string.title_share_key);
      Intent shareChooser = Intent.createChooser(sendIntent, title);

      startActivity(shareChooser);

    } catch (PgpGeneralException | IOException e) {
      Log.e(Constants.TAG, "error processing key!", e);
      Notify.create(activity, R.string.error_key_processing, Notify.Style.ERROR).show();
    } catch (ProviderHelper.NotFoundException e) {
      Log.e(Constants.TAG, "key not found!", e);
      Notify.create(activity, R.string.error_key_not_found, Notify.Style.ERROR).show();
    }
  }
 private void editKey(Uri dataUri) {
   Intent editIntent = new Intent(getActivity(), EditKeyActivity.class);
   editIntent.setData(KeychainContract.KeyRingData.buildSecretKeyRingUri(dataUri));
   startActivityForResult(editIntent, 0);
 }