Example #1
0
  /**
   * Returns usage selections of keys from the SectionView
   *
   * @param keysView
   * @return
   */
  private Vector<Integer> getKeysUsages(SectionView keysView) throws PGPMain.GeneralException {
    Vector<Integer> getKeysUsages = new Vector<Integer>();

    ViewGroup keyEditors = keysView.getEditors();

    if (keyEditors.getChildCount() == 0) {
      throw new PGPMain.GeneralException(getString(R.string.error_keyNeedsMasterKey));
    }

    for (int i = 0; i < keyEditors.getChildCount(); ++i) {
      KeyEditor editor = (KeyEditor) keyEditors.getChildAt(i);
      getKeysUsages.add(editor.getUsage());
    }

    return getKeysUsages;
  }
Example #2
0
  /**
   * Returns user ids from the SectionView
   *
   * @param userIdsView
   * @return
   */
  private Vector<String> getUserIds(SectionView userIdsView) throws PGPMain.GeneralException {
    Vector<String> userIds = new Vector<String>();

    ViewGroup userIdEditors = userIdsView.getEditors();

    boolean gotMainUserId = false;
    for (int i = 0; i < userIdEditors.getChildCount(); ++i) {
      UserIdEditor editor = (UserIdEditor) userIdEditors.getChildAt(i);
      String userId = null;
      try {
        userId = editor.getValue();
      } catch (UserIdEditor.NoNameException e) {
        throw new PGPMain.GeneralException(this.getString(R.string.error_userIdNeedsAName));
      } catch (UserIdEditor.NoEmailException e) {
        throw new PGPMain.GeneralException(
            this.getString(R.string.error_userIdNeedsAnEmailAddress));
      } catch (UserIdEditor.InvalidEmailException e) {
        throw new PGPMain.GeneralException(e.getMessage());
      }

      if (userId.equals("")) {
        continue;
      }

      if (editor.isMainUserId()) {
        userIds.insertElementAt(userId, 0);
        gotMainUserId = true;
      } else {
        userIds.add(userId);
      }
    }

    if (userIds.size() == 0) {
      throw new PGPMain.GeneralException(getString(R.string.error_keyNeedsAUserId));
    }

    if (!gotMainUserId) {
      throw new PGPMain.GeneralException(getString(R.string.error_mainUserIdMustNotBeEmpty));
    }

    return userIds;
  }
Example #3
0
 private long getMasterKeyId() {
   if (mKeysView.getEditors().getChildCount() == 0) {
     return 0;
   }
   return ((KeyEditor) mKeysView.getEditors().getChildAt(0)).getValue().getKeyID();
 }