コード例 #1
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.menu_key_list_import:
        callIntentForDrawerItem(Constants.DrawerItems.IMPORT_KEYS);

        return true;
      case R.id.menu_key_list_export:
        mExportHelper.showExportKeysDialog(
            null, Id.type.public_key, Constants.Path.APP_DIR_FILE_PUB, null);

        return true;
      case R.id.menu_key_list_create:
        createKey();

        return true;
      case R.id.menu_key_list_create_expert:
        createKeyExpert();

        return true;
      case R.id.menu_key_list_secret_export:
        mExportHelper.showExportKeysDialog(
            null, Id.type.secret_key, Constants.Path.APP_DIR_FILE_SEC, null);

        return true;
      default:
        return super.onOptionsItemSelected(item);
    }
  }
コード例 #2
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
      case R.id.menu_key_list_secret_create:
        createKey();

        return true;
      case R.id.menu_key_list_secret_create_expert:
        createKeyExpert();

        return true;
      case R.id.menu_key_list_secret_export:
        mExportHelper.showExportKeysDialog(
            null, Id.type.secret_key, Constants.path.APP_DIR_FILE_SEC);

        return true;
      case R.id.menu_key_list_secret_import:
        Intent intentImportFromFile = new Intent(this, ImportKeysActivity.class);
        intentImportFromFile.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_FILE);
        startActivityForResult(intentImportFromFile, 0);

        return true;
      default:
        return super.onOptionsItemSelected(item);
    }
  }
コード例 #3
0
  private void deleteKey(Uri dataUri) {
    // Message is received after key is deleted
    Handler returnHandler =
        new Handler() {
          @Override
          public void handleMessage(Message message) {
            if (message.what == DeleteKeyDialogFragment.MESSAGE_OKAY) {
              Bundle returnData = message.getData();
              if (returnData != null
                  && returnData.containsKey(DeleteKeyDialogFragment.MESSAGE_NOT_DELETED)) {
                // we delete only this key, so MESSAGE_NOT_DELETED will solely contain this key
                Toast.makeText(
                        ViewKeyActivity.this,
                        getString(R.string.error_can_not_delete_contact)
                            + getResources()
                                .getQuantityString(R.plurals.error_can_not_delete_info, 1),
                        Toast.LENGTH_LONG)
                    .show();
              } else {
                setResult(RESULT_CANCELED);
                finish();
              }
            }
          }
        };

    mExportHelper.deleteKey(dataUri, Id.type.public_key, returnHandler);
  }
コード例 #4
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case android.R.id.home:
       Intent homeIntent = new Intent(this, KeyListPublicActivity.class);
       homeIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
       startActivity(homeIntent);
       return true;
     case R.id.menu_key_view_update:
       updateFromKeyserver(mDataUri);
       return true;
     case R.id.menu_key_view_export_keyserver:
       uploadToKeyserver(mDataUri);
       return true;
     case R.id.menu_key_view_export_file:
       long[] ids = new long[] {Long.valueOf(mDataUri.getLastPathSegment())};
       mExportHelper.showExportKeysDialog(
           ids, Id.type.public_key, Constants.path.APP_DIR_FILE_PUB);
       return true;
     case R.id.menu_key_view_share_default_fingerprint:
       shareKey(mDataUri, true);
       return true;
     case R.id.menu_key_view_share_default:
       shareKey(mDataUri, false);
       return true;
     case R.id.menu_key_view_share_qr_code_fingerprint:
       shareKeyQrCode(mDataUri, true);
       return true;
     case R.id.menu_key_view_share_qr_code:
       shareKeyQrCode(mDataUri, false);
       return true;
     case R.id.menu_key_view_share_nfc:
       shareNfc();
       return true;
     case R.id.menu_key_view_share_clipboard:
       copyToClipboard(mDataUri);
       return true;
     case R.id.menu_key_view_delete:
       {
         deleteKey(mDataUri);
         return true;
       }
   }
   return super.onOptionsItemSelected(item);
 }