Ejemplo n.º 1
0
  public void deleteKey(Uri dataUri, Handler deleteHandler) {
    try {
      long masterKeyId =
          new ProviderHelper(mActivity).getCachedPublicKeyRing(dataUri).extractOrGetMasterKeyId();

      // Create a new Messenger for the communication back
      Messenger messenger = new Messenger(deleteHandler);
      DeleteKeyDialogFragment deleteKeyDialog =
          DeleteKeyDialogFragment.newInstance(messenger, new long[] {masterKeyId});
      deleteKeyDialog.show(mActivity.getSupportFragmentManager(), "deleteKeyDialog");
    } catch (PgpGeneralException e) {
      Log.e(Constants.TAG, "key not found!", e);
    }
  }
  /**
   * Show dialog to delete key
   *
   * @param keyRingRowIds
   */
  public void showDeleteKeyDialog(final ActionMode mode, long[] keyRingRowIds) {
    // Message is received after key is deleted
    Handler returnHandler =
        new Handler() {
          @Override
          public void handleMessage(Message message) {
            if (message.what == DeleteKeyDialogFragment.MESSAGE_OKAY) {
              mode.finish();
            }
          }
        };

    // Create a new Messenger for the communication back
    Messenger messenger = new Messenger(returnHandler);

    DeleteKeyDialogFragment deleteKeyDialog =
        DeleteKeyDialogFragment.newInstance(messenger, keyRingRowIds, Id.type.secret_key);

    deleteKeyDialog.show(getActivity().getSupportFragmentManager(), "deleteKeyDialog");
  }