예제 #1
0
  public TurboIssue(String repoId, Issue issue) {
    this.id = issue.getNumber();
    this.title = issue.getTitle() == null ? "" : issue.getTitle();
    this.creator = issue.getUser().getLogin();
    this.createdAt = Utility.dateToLocalDateTime(issue.getCreatedAt());
    this.isPullRequest = isPullRequest(issue);

    this.description = issue.getBody() == null ? "" : issue.getBody();
    this.updatedAt =
        issue.getUpdatedAt() != null
            ? Utility.dateToLocalDateTime(issue.getUpdatedAt())
            : this.createdAt;
    this.commentCount = issue.getComments();
    this.isOpen = issue.getState().equals(STATE_OPEN);
    this.assignee =
        issue.getAssignee() == null
            ? Optional.empty()
            : Optional.of(issue.getAssignee().getLogin());
    this.labels = issue.getLabels().stream().map(Label::getName).collect(Collectors.toList());
    this.milestone =
        issue.getMilestone() == null
            ? Optional.empty()
            : Optional.of(issue.getMilestone().getNumber());

    this.metadata = IssueMetadata.empty();
    this.repoId = repoId;
    this.markedReadAt = Optional.empty();
  }
  @Override
  public void onCreateOptionsMenu(Menu optionsMenu, MenuInflater inflater) {
    inflater.inflate(R.menu.issue_view, optionsMenu);
    MenuItem editItem = optionsMenu.findItem(R.id.m_edit);
    stateItem = optionsMenu.findItem(R.id.m_state);
    if (editItem != null && stateItem != null) {
      boolean canEdit;
      if (issue != null) canEdit = isCollaborator || issue.getUser().getLogin().equals(loggedUser);
      else canEdit = isCollaborator;

      editItem.setVisible(canEdit);
      stateItem.setVisible(canEdit);
    }
    updateStateItem(issue);
  }
예제 #3
0
  protected Issue createIssue(org.eclipse.egit.github.core.Issue githubIssue) {
    Issue issue = new Issue();

    issue.setKey(String.valueOf(githubIssue.getNumber()));
    issue.setId(String.valueOf(githubIssue.getNumber()));

    issue.setLink(this.githubIssueURL + githubIssue.getNumber());

    issue.setCreated(githubIssue.getCreatedAt());

    issue.setUpdated(githubIssue.getUpdatedAt());

    if (githubIssue.getAssignee() != null) {
      if (githubIssue.getAssignee().getName() != null) {
        issue.setAssignee(githubIssue.getAssignee().getName());
      } else {
        issue.setAssignee(githubIssue.getAssignee().getLogin());
      }
    }

    issue.setTitle(githubIssue.getTitle());

    issue.setSummary(githubIssue.getTitle());

    if (githubIssue.getMilestone() != null) {
      issue.addFixVersion(githubIssue.getMilestone().getTitle());
    }

    issue.setReporter(githubIssue.getUser().getLogin());

    if (githubIssue.getClosedAt() != null) {
      issue.setStatus("closed");
    } else {
      issue.setStatus("open");
    }

    List<Label> labels = githubIssue.getLabels();
    if (labels != null && !labels.isEmpty()) {
      issue.setType(labels.get(0).getName());
    }

    return issue;
  }
  private void updateHeader(final Issue issue) {
    if (!isUsable()) return;

    boolean isPullRequest = IssueUtils.isPullRequest(issue);
    titleText.setText(issue.getTitle());

    String body = issue.getBodyHtml();
    if (!TextUtils.isEmpty(body)) bodyImageGetter.bind(bodyText, body, issue.getId());
    else bodyText.setText(R.string.no_description_given);

    authorText.setText(issue.getUser().getLogin());
    createdDateText.setText(
        new StyledText().append(getString(R.string.prefix_opened)).append(issue.getCreatedAt()));
    avatars.bind(creatorAvatar, issue.getUser());

    if (isPullRequest && issue.getPullRequest().getCommits() > 0) {
      ViewUtils.setGone(commitsView, false);

      TextView icon = (TextView) headerView.findViewById(R.id.tv_commit_icon);
      TypefaceUtils.setOcticons(icon);
      icon.setText(TypefaceUtils.ICON_GIT_COMMIT);

      String commits =
          getString(R.string.pull_request_commits, issue.getPullRequest().getCommits());
      ((TextView) headerView.findViewById(R.id.tv_pull_request_commits)).setText(commits);
    } else ViewUtils.setGone(commitsView, true);

    boolean open = STATE_OPEN.equals(issue.getState());
    if (!open) {
      StyledText text = new StyledText();
      if (isPullRequest && issue.getPullRequest().isMerged()) {
        text.bold(getString(R.string.merged));
        stateText.setBackgroundResource(R.color.state_background_merged);
      } else {
        text.bold(getString(R.string.closed));
        stateText.setBackgroundResource(R.color.state_background_closed);
      }
      Date closedAt = issue.getClosedAt();
      if (closedAt != null) text.append(' ').append(closedAt);
      stateText.setText(text);
    }
    ViewUtils.setGone(stateText, open);

    User assignee = issue.getAssignee();
    if (assignee != null) {
      StyledText name = new StyledText();
      name.bold(assignee.getLogin());
      name.append(' ').append(getString(R.string.assigned));
      assigneeText.setText(name);
      assigneeAvatar.setVisibility(VISIBLE);
      avatars.bind(assigneeAvatar, assignee);
    } else {
      assigneeAvatar.setVisibility(GONE);
      assigneeText.setText(R.string.unassigned);
    }

    List<Label> labels = issue.getLabels();
    if (labels != null && !labels.isEmpty()) {
      LabelDrawableSpan.setText(labelsArea, labels);
      labelsArea.setVisibility(VISIBLE);
    } else labelsArea.setVisibility(GONE);

    if (issue.getMilestone() != null) {
      Milestone milestone = issue.getMilestone();
      StyledText milestoneLabel = new StyledText();
      milestoneLabel.append(getString(R.string.milestone_prefix));
      milestoneLabel.append(' ');
      milestoneLabel.bold(milestone.getTitle());
      milestoneText.setText(milestoneLabel);
      float closed = milestone.getClosedIssues();
      float total = closed + milestone.getOpenIssues();
      if (total > 0) {
        ((LayoutParams) milestoneProgressArea.getLayoutParams()).weight = closed / total;
        milestoneProgressArea.setVisibility(VISIBLE);
      } else milestoneProgressArea.setVisibility(GONE);
      milestoneArea.setVisibility(VISIBLE);
    } else milestoneArea.setVisibility(GONE);

    String state = issue.getState();
    if (state != null && state.length() > 0)
      state = state.substring(0, 1).toUpperCase(Locale.US) + state.substring(1);
    else state = "";

    ViewUtils.setGone(progress, true);
    ViewUtils.setGone(list, false);
    updateStateItem(issue);
  }