@Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_pager);

    setSupportActionBar((android.support.v7.widget.Toolbar) findViewById(R.id.toolbar));

    pager = finder.find(R.id.vp_pages);

    repository = getIntent().getParcelableExtra(EXTRA_REPOSITORY);
    ids = getCharSequenceArrayExtra(EXTRA_BASES);
    initialPosition = getIntExtra(EXTRA_POSITION);

    adapter = new CommitPagerAdapter(this, repository, ids);
    pager.setAdapter(adapter);
    pager.setOnPageChangeListener(this);
    pager.scheduleSetItem(initialPosition, this);
    onPageSelected(initialPosition);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setSubtitle(InfoUtils.createRepoId(repository));
    avatars.bind(actionBar, repository.owner);
  }
Ejemplo n.º 2
0
  protected void updateComment(final Comment comment) {
    imageGetter.bind(textView(0), comment.getBodyHtml(), comment.getId());
    avatars.bind(imageView(3), comment.getUser());

    setText(1, comment.getUser().getLogin());
    setText(2, TimeUtils.getRelativeTime(comment.getUpdatedAt()));

    final boolean canEdit =
        (isOwner || comment.getUser().getLogin().equals(userName)) && editCommentListener != null;

    final boolean canDelete =
        (isOwner || comment.getUser().getLogin().equals(userName)) && deleteCommentListener != null;

    final ImageView ivMore = view(4);

    if (!canEdit && !canDelete) ivMore.setVisibility(View.INVISIBLE);
    else
      ivMore.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              showMorePopup(ivMore, comment, canEdit, canDelete);
            }
          });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_commit_file_view);

    setSupportActionBar((android.support.v7.widget.Toolbar) findViewById(R.id.toolbar));

    repo = getIntent().getParcelableExtra(EXTRA_REPOSITORY);
    commit = getStringExtra(EXTRA_HEAD);
    sha = getStringExtra(EXTRA_BASE);
    path = getStringExtra(EXTRA_PATH);

    loadingBar = finder.find(R.id.pb_loading);
    codeView = finder.find(R.id.wv_code);

    file = CommitUtils.getName(path);
    isMarkdownFile = MarkdownUtils.isMarkdown(file);

    editor = new SourceEditor(codeView);
    editor.setWrap(PreferenceUtils.getCodePreferences(this).getBoolean(WRAP, false));

    ActionBar actionBar = getSupportActionBar();
    int lastSlash = path.lastIndexOf('/');
    if (lastSlash != -1) actionBar.setTitle(path.substring(lastSlash + 1));
    else actionBar.setTitle(path);
    actionBar.setSubtitle(getString(R.string.commit_prefix) + CommitUtils.abbreviate(commit));
    avatars.bind(actionBar, repo.owner);

    loadContent();
  }
Ejemplo n.º 4
0
 private void updateAssignee() {
   User assignee = issue.assignee;
   String login = assignee != null ? assignee.login : null;
   if (!TextUtils.isEmpty(login)) {
     assigneeText.setText(new StyledText().bold(login));
     assigneeAvatar.setVisibility(VISIBLE);
     avatars.bind(assigneeAvatar, assignee);
   } else {
     assigneeAvatar.setVisibility(GONE);
     assigneeText.setText(R.string.unassigned);
   }
 }
Ejemplo n.º 5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_issue_edit);

    titleText = finder.find(R.id.et_issue_title);
    bodyText = finder.find(R.id.et_issue_body);
    milestoneGraph = finder.find(R.id.ll_milestone_graph);
    milestoneText = finder.find(R.id.tv_milestone);
    milestoneClosed = finder.find(R.id.v_closed);
    assigneeAvatar = finder.find(R.id.iv_assignee_avatar);
    assigneeText = finder.find(R.id.tv_assignee_name);
    labelsText = finder.find(R.id.tv_labels);

    Intent intent = getIntent();

    if (savedInstanceState != null) issue = savedInstanceState.getParcelable(EXTRA_ISSUE);
    if (issue == null) issue = intent.getParcelableExtra(EXTRA_ISSUE);
    if (issue == null) issue = new Issue();

    repository =
        InfoUtils.createRepoFromData(
            intent.getStringExtra(EXTRA_REPOSITORY_OWNER),
            intent.getStringExtra(EXTRA_REPOSITORY_NAME));

    checkCollaboratorStatus();

    setSupportActionBar((android.support.v7.widget.Toolbar) findViewById(R.id.toolbar));

    ActionBar actionBar = getSupportActionBar();
    if (issue.number > 0)
      if (IssueUtils.isPullRequest(issue))
        actionBar.setTitle(getString(R.string.pull_request_title) + issue.number);
      else actionBar.setTitle(getString(R.string.issue_title) + issue.number);
    else actionBar.setTitle(R.string.new_issue);
    actionBar.setSubtitle(InfoUtils.createRepoId(repository));
    avatars.bind(actionBar, (User) intent.getParcelableExtra(EXTRA_USER));

    titleText.addTextChangedListener(
        new TextWatcherAdapter() {

          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {
            super.onTextChanged(s, start, before, count);
            updateSaveMenu(s);
          }
        });

    updateSaveMenu();
    titleText.setText(issue.title);
    bodyText.setText(issue.body);
  }
  public void setUp(
      int fragmentId,
      DrawerLayout drawerLayout,
      NavigationDrawerAdapter adapter,
      AvatarLoader avatar,
      Organization user) {
    mFragmentContainerView = getActivity().findViewById(fragmentId);
    mDrawerLayout = drawerLayout;
    // mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    int drawerWidth =
        checkTabletOrLandscape() ? R.dimen.navigation_drawer_width : materializedWidth();
    mDrawerListView.getLayoutParams().width = drawerWidth;

    View header =
        getActivity().getLayoutInflater().inflate(R.layout.drawer_header, mDrawerListView, false);
    userImage = (ImageView) header.findViewById(R.id.user_picture);
    userRealName = (TextView) header.findViewById(R.id.user_real_name);
    userName = (TextView) header.findViewById(R.id.user_name);

    avatar.bind(userImage, user);
    userName.setText(user.login);

    String name = user.name;
    if (name != null) {
      userRealName.setText(user.name);
    } else {
      userRealName.setVisibility(View.GONE);
    }

    mDrawerListView.addHeaderView(header, null, false);
    mDrawerListView.setAdapter(adapter);
    mDrawerListView.setItemChecked(mCurrentSelectedPosition, true);

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    mDrawerToggle =
        new ActionBarDrawerToggle(
            getActivity(),
            mDrawerLayout,
            R.string.navigation_drawer_open,
            R.string.navigation_drawer_close) {
          @Override
          public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            if (!isAdded()) {
              return;
            }

            getActivity().supportInvalidateOptionsMenu();
          }

          @Override
          public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            if (!isAdded()) {
              return;
            }

            if (!mUserLearnedDrawer) {
              mUserLearnedDrawer = true;
              SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
              sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
            }

            getActivity().supportInvalidateOptionsMenu();
          }
        };

    if (!mUserLearnedDrawer && !mFromSavedInstanceState)
      mDrawerLayout.openDrawer(mFragmentContainerView);

    mDrawerLayout.post(
        new Runnable() {
          @Override
          public void run() {
            mDrawerToggle.syncState();
          }
        });

    mDrawerLayout.setDrawerListener(mDrawerToggle);
  }
Ejemplo n.º 7
0
 @Override
 protected void update(int position, User item) {
   setText(0, item.getLogin());
   loader.bind(imageView(1), item);
   setChecked(2, selected == position);
 }
Ejemplo n.º 8
0
  protected void updateEvent(final IssueEvent event) {
    TypefaceUtils.setOcticons(textView(0));
    String message = String.format("<b>%s</b> %s", event.getActor().getLogin(), event.getEvent());
    avatars.bind(imageView(2), event.getActor());

    String eventString = event.getEvent();

    switch (eventString) {
      case "assigned":
      case "unassigned":
        setText(0, TypefaceUtils.ICON_PERSON);
        textView(0).setTextColor(context.getResources().getColor(R.color.text_description));
        break;
      case "labeled":
      case "unlabeled":
        setText(0, TypefaceUtils.ICON_TAG);
        textView(0).setTextColor(context.getResources().getColor(R.color.text_description));
        break;
      case "referenced":
        setText(0, TypefaceUtils.ICON_BOOKMARK);
        textView(0).setTextColor(context.getResources().getColor(R.color.text_description));
        break;
      case "milestoned":
      case "demilestoned":
        setText(0, TypefaceUtils.ICON_MILESTONE);
        textView(0).setTextColor(context.getResources().getColor(R.color.text_description));
        break;
      case "closed":
        setText(0, TypefaceUtils.ICON_ISSUE_CLOSE);
        textView(0).setTextColor(context.getResources().getColor(R.color.issue_event_closed));
        break;
      case "reopened":
        setText(0, TypefaceUtils.ICON_ISSUE_REOPEN);
        textView(0).setTextColor(context.getResources().getColor(R.color.issue_event_reopened));
        break;
      case "renamed":
        setText(0, TypefaceUtils.ICON_EDIT);
        textView(0).setTextColor(context.getResources().getColor(R.color.text_description));
        break;
      case "merged":
        message +=
            String.format(
                " commit <b>%s</b> into <tt>%s</tt> from <tt>%s</tt>",
                event.getCommitId().substring(0, 6),
                issue.getPullRequest().getBase().getRef(),
                issue.getPullRequest().getHead().getRef());
        setText(0, TypefaceUtils.ICON_MERGE);
        textView(0).setTextColor(context.getResources().getColor(R.color.issue_event_merged));
        break;
      case "locked":
        setText(0, TypefaceUtils.ICON_LOCK);
        textView(0).setTextColor(context.getResources().getColor(R.color.issue_event_lock));
        break;
      case "unlocked":
        setText(0, TypefaceUtils.ICON_KEY);
        textView(0).setTextColor(context.getResources().getColor(R.color.issue_event_lock));
        break;
    }

    message += " " + TimeUtils.getRelativeTime(event.getCreatedAt());
    setText(1, Html.fromHtml(message));
  }