示例#1
0
  @Nullable
  @Override
  public Element getState() {

    // create the class root tag
    Element rootTag = new Element(XML_ROOT_NAME_Key_MANAGER);

    // create the team root xml tag
    Element teamRootTag = new Element(XML_ROOT_NAME_TEAM_MANAGER);

    for (Team team : teamList) {

      // create elements with the teams
      Element teamElement = new Element(XML_TEAM_MANAGER_TEAM);
      teamElement.addContent(new Element(XML_TEAM_MANAGER_NAME).setText(team.getName()));
      teamElement.addContent(new Element(XML_TEAM_MANAGER_TOKEN).setText(team.getToken()));
      // set the distributions list if it has one
      if (team.getDistributionList() != null) {
        teamElement.addContent(
            new Element(XML_TEAM_MANAGER_DISTRIBUTION_LIST).setText(team.getDistributionList()));
      }

      teamRootTag.addContent(teamElement);
    }

    // add the team elements
    rootTag.addContent(teamRootTag);

    if (apiKey != null) {
      // set the api key
      Element apiKeyTag = new Element(XML_ROOT_NAME_API_KEY).setText(apiKey);
      rootTag.addContent(apiKeyTag);
    }

    if (apkFilePath != null) {
      // set the apk file path
      Element filePathTag = new Element(XML_ROOT_NAME_APK_FILE_PATH).setText(apkFilePath);
      rootTag.addContent(filePathTag);
    }

    if (selectedModuleName != null) {
      // set the user selected module
      Element moduleName =
          new Element(XML_ROOT_NAME_SELECTED_MODULE_NAME).setText(selectedModuleName);
      rootTag.addContent(moduleName);
    }

    if (selectedProjectName != null) {
      // set the user selected project
      Element projectName =
          new Element(XML_ROOT_NAME_SELECTED_PROJECT_NAME).setText(selectedProjectName);
      rootTag.addContent(projectName);
    }

    return rootTag;
  }
示例#2
0
  /**
   * Returns the list of teams
   *
   * @return list of teams
   */
  public ArrayList<Team> getTeamList() {

    if (teamList == null || teamList.size() < 1) {
      // if the list is empty or null, add the first item that will be used to add new team objects
      teamList = new ArrayList<Team>();
      Team firstObject = new Team();
      firstObject.setName("Add new Team");
      firstObject.setToken("");
      teamList.add(firstObject);
    }

    return teamList;
  }
示例#3
0
  /**
   * Parses a team xml element into a team object
   *
   * @param teamElement team element
   * @return parsed team object
   */
  public Team parseTeamElement(Element teamElement) {

    Team team = new Team();

    Iterator teamComponents = teamElement.getDescendants();
    // iterate through the Team components (token/name)
    while (teamComponents.hasNext()) {

      Object elementComponents = teamComponents.next();

      if (!(elementComponents instanceof Element)) {
        continue;
      }

      Element component = (Element) elementComponents;

      if (component.getName().equals(XML_TEAM_MANAGER_NAME)) {
        // if the name is found, set the name of the team
        team.setName(component.getText());

      } else if (component.getName().equals(XML_TEAM_MANAGER_TOKEN)) {
        // if the token is found, set the token of the team
        team.setToken(component.getText());

      } else if (component.getName().equals(XML_TEAM_MANAGER_DISTRIBUTION_LIST)) {
        // if the token is found, set the token of the team
        team.setDistributionList(component.getText());
      }
    }

    if (team.getName() != null) {
      // add the parsed team to the list
      return team;
    }

    return null;
  }