Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions app/src/main/java/com/gh4a/activities/BlogActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@
import com.gh4a.model.Feed;

public class BlogActivity extends WebViewerActivity {

private static final String EXTRA_TITLE = "title";
private static final String EXTRA_CONTENT = "content";

public static Intent makeIntent(Context context, Feed blog) {
return new Intent(context, BlogActivity.class)
.putExtra("title", blog.getTitle())
.putExtra("content", blog.getContent());
.putExtra(EXTRA_TITLE, blog.getTitle())
.putExtra(EXTRA_CONTENT, blog.getContent());
}

@Override
Expand Down Expand Up @@ -58,12 +62,12 @@ protected boolean canSwipeToRefresh() {
@Override
protected String generateHtml(String cssTheme, boolean addTitleHeader) {
String title = addTitleHeader ? getDocumentTitle() : null;
return wrapUnthemedHtml(getIntent().getStringExtra("content"), cssTheme, title);
return wrapUnthemedHtml(getIntent().getStringExtra(EXTRA_CONTENT), cssTheme, title);
}

@Override
protected String getDocumentTitle() {
return getIntent().getStringExtra("title");
return getIntent().getStringExtra(EXTRA_TITLE);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@
import com.gh4a.fragment.CollaboratorListFragment;

public class CollaboratorListActivity extends FragmentContainerActivity {

private static final String EXTRA_OWNER = "owner";
private static final String EXTRA_REPO = "repo";

public static Intent makeIntent(Context context, String repoOwner, String repoName) {
return new Intent(context, CollaboratorListActivity.class)
.putExtra("owner", repoOwner)
.putExtra("repo", repoName);
.putExtra(EXTRA_OWNER, repoOwner)
.putExtra(EXTRA_REPO, repoName);
}

private String mUserLogin;
Expand All @@ -48,8 +52,8 @@ protected String getActionBarSubtitle() {

@Override
protected void onInitExtras(Bundle extras) {
mUserLogin = extras.getString("owner");
mRepoName = extras.getString("repo");
mUserLogin = extras.getString(EXTRA_OWNER);
mRepoName = extras.getString(EXTRA_REPO);
}

@Override
Expand Down
29 changes: 18 additions & 11 deletions app/src/main/java/com/gh4a/activities/CommitActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@

public class CommitActivity extends BaseFragmentPagerActivity implements
CommitFragment.CommentUpdateListener, CommitNoteFragment.CommentUpdateListener {

private static final String EXTRA_OWNER = "owner";
private static final String EXTRA_REPO = "repo";
private static final String EXTRA_PR = "pr";
private static final String EXTRA_SHA = "sha";
private static final String EXTRA_INITIAL_COMMENT = "initial_comment";

public static Intent makeIntent(Context context, String repoOwner, String repoName, String sha) {
return makeIntent(context, repoOwner, repoName, -1, sha, null);
}
Expand All @@ -60,11 +67,11 @@ public static Intent makeIntent(Context context, String repoOwner, String repoNa
private static Intent makeIntent(Context context, String repoOwner, String repoName,
int pullRequestNumber, String sha, IntentUtils.InitialCommentMarker initialComment) {
return new Intent(context, CommitActivity.class)
.putExtra("owner", repoOwner)
.putExtra("repo", repoName)
.putExtra("pr", pullRequestNumber)
.putExtra("sha", sha)
.putExtra("initial_comment", initialComment);
.putExtra(EXTRA_OWNER, repoOwner)
.putExtra(EXTRA_REPO, repoName)
.putExtra(EXTRA_PR, pullRequestNumber)
.putExtra(EXTRA_SHA, sha)
.putExtra(EXTRA_INITIAL_COMMENT, initialComment);
}

private static final int ID_LOADER_COMMIT = 0;
Expand Down Expand Up @@ -112,12 +119,12 @@ protected AppBarLayout.ScrollingViewBehavior onCreateSwipeLayoutBehavior() {
@Override
protected void onInitExtras(Bundle extras) {
super.onInitExtras(extras);
mRepoOwner = extras.getString("owner");
mRepoName = extras.getString("repo");
mObjectSha = extras.getString("sha");
mPullRequestNumber = extras.getInt("pr", -1);
mInitialComment = extras.getParcelable("initial_comment");
extras.remove("initial_comment");
mRepoOwner = extras.getString(EXTRA_OWNER);
mRepoName = extras.getString(EXTRA_REPO);
mObjectSha = extras.getString(EXTRA_SHA);
mPullRequestNumber = extras.getInt(EXTRA_PR, -1);
mInitialComment = extras.getParcelable(EXTRA_INITIAL_COMMENT);
extras.remove(EXTRA_INITIAL_COMMENT);
}

@Override
Expand Down
30 changes: 19 additions & 11 deletions app/src/main/java/com/gh4a/activities/CommitHistoryActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,22 @@

public class CommitHistoryActivity extends FragmentContainerActivity implements
CommitListFragment.ContextSelectionCallback {

private static final String EXTRA_OWNER = "owner";
private static final String EXTRA_REPO = "repo";
private static final String EXTRA_REF = "ref";
private static final String EXTRA_PATH = "path";
private static final String EXTRA_BASE_SELECTABLE = "base_selectable";
private static final String EXTRA_COMMIT = "commit";

public static Intent makeIntent(Context context, String repoOwner, String repoName,
String ref, String path, boolean supportBaseSelection) {
return new Intent(context, CommitHistoryActivity.class)
.putExtra("owner", repoOwner)
.putExtra("repo", repoName)
.putExtra("ref", ref)
.putExtra("path", path)
.putExtra("base_selectable", supportBaseSelection);
.putExtra(EXTRA_OWNER, repoOwner)
.putExtra(EXTRA_REPO, repoName)
.putExtra(EXTRA_REF, ref)
.putExtra(EXTRA_PATH, path)
.putExtra(EXTRA_BASE_SELECTABLE, supportBaseSelection);
}

private String mRepoOwner;
Expand All @@ -43,11 +51,11 @@ protected String getActionBarSubtitle() {
@Override
protected void onInitExtras(Bundle extras) {
super.onInitExtras(extras);
mRepoOwner = extras.getString("owner");
mRepoName = extras.getString("repo");
mRef = extras.getString("ref");
mFilePath = extras.getString("path");
mSupportBaseSelection = extras.getBoolean("base_selectable");
mRepoOwner = extras.getString(EXTRA_OWNER);
mRepoName = extras.getString(EXTRA_REPO);
mRef = extras.getString(EXTRA_REF);
mFilePath = extras.getString(EXTRA_PATH);
mSupportBaseSelection = extras.getBoolean(EXTRA_BASE_SELECTABLE);
}

@Override
Expand All @@ -68,7 +76,7 @@ public boolean baseSelectionAllowed() {
@Override
public void onCommitSelectedAsBase(Commit commit) {
Intent result = new Intent();
result.putExtra("commit", commit);
result.putExtra(EXTRA_COMMIT, commit);
setResult(RESULT_OK, result);
finish();
}
Expand Down
22 changes: 14 additions & 8 deletions app/src/main/java/com/gh4a/activities/CompareActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@
import com.gh4a.fragment.CommitCompareFragment;

public class CompareActivity extends FragmentContainerActivity {

private static final String EXTRA_OWNER = "owner";
private static final String EXTRA_REPO = "repo";
private static final String EXTRA_BASE = "base";
private static final String EXTRA_HEAD = "head";

public static Intent makeIntent(Context context, String repoOwner, String repoName,
String baseRef, String headRef) {
return new Intent(context, CompareActivity.class)
.putExtra("owner", repoOwner)
.putExtra("repo", repoName)
.putExtra("base", baseRef)
.putExtra("head", headRef);
.putExtra(EXTRA_OWNER, repoOwner)
.putExtra(EXTRA_REPO, repoName)
.putExtra(EXTRA_BASE, baseRef)
.putExtra(EXTRA_HEAD, headRef);
}

private String mRepoOwner;
Expand All @@ -52,14 +58,14 @@ protected String getActionBarSubtitle() {
@Override
protected void onInitExtras(Bundle extras) {
super.onInitExtras(extras);
mRepoOwner = extras.getString("owner");
mRepoName = extras.getString("repo");
mRepoOwner = extras.getString(EXTRA_OWNER);
mRepoName = extras.getString(EXTRA_REPO);
}

@Override
protected Fragment onCreateFragment() {
String base = getIntent().getStringExtra("base");
String head = getIntent().getStringExtra("head");
String base = getIntent().getStringExtra(EXTRA_BASE);
String head = getIntent().getStringExtra(EXTRA_HEAD);

return CommitCompareFragment.newInstance(mRepoOwner, mRepoName, base, head);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@
import com.gh4a.fragment.ContributorListFragment;

public class ContributorListActivity extends FragmentContainerActivity {

private static final String EXTRA_OWNER = "owner";
private static final String EXTRA_REPO = "repo";

public static Intent makeIntent(Context context, String repoOwner, String repoName) {
return new Intent(context, ContributorListActivity.class)
.putExtra("owner", repoOwner)
.putExtra("repo", repoName);
.putExtra(EXTRA_OWNER, repoOwner)
.putExtra(EXTRA_REPO, repoName);
}

private String mUserLogin;
Expand All @@ -49,8 +53,8 @@ protected String getActionBarSubtitle() {
@Override
protected void onInitExtras(Bundle extras) {
super.onInitExtras(extras);
mUserLogin = extras.getString("owner");
mRepoName = extras.getString("repo");
mUserLogin = extras.getString(EXTRA_OWNER);
mRepoName = extras.getString(EXTRA_REPO);
}

@Override
Expand Down
62 changes: 37 additions & 25 deletions app/src/main/java/com/gh4a/activities/DiffViewerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,33 @@

public abstract class DiffViewerActivity<C extends PositionalCommentBase> extends WebViewerActivity
implements ReactionBar.Callback, ReactionBar.ReactionDetailsCache.Listener {

private static final String EXTRA_OWNER = "owner";
private static final String EXTRA_REPO = "repo";
private static final String EXTRA_SHA = "sha";
private static final String EXTRA_PATH = "path";
private static final String EXTRA_DIFF = "diff";
private static final String EXTRA_COMMENTS = "comments";
private static final String EXTRA_INITIAL_LINE = "initial_line";
private static final String STRING = "highlight_start";
private static final String STRIN = "highlight_end";
private static final String EXTRA_HIGHLIGHT_RIGHT = "highlight_right";
private static final String EXTRA_INITIAL_COMMENT = "initial_comment";

protected static <C extends PositionalCommentBase> Intent fillInIntent(Intent baseIntent,
String repoOwner, String repoName, String commitSha, String path, String diff,
List<C> comments, int initialLine, int highlightStartLine, int highlightEndLine,
boolean highlightisRight, IntentUtils.InitialCommentMarker initialComment) {
return baseIntent.putExtra("owner", repoOwner)
.putExtra("repo", repoName)
.putExtra("sha", commitSha)
.putExtra("path", path)
.putExtra("diff", diff)
.putExtra("comments", comments != null ? new ArrayList<>(comments) : null)
.putExtra("initial_line", initialLine)
.putExtra("highlight_start", highlightStartLine)
.putExtra("highlight_end", highlightEndLine)
.putExtra("highlight_right", highlightisRight)
.putExtra("initial_comment", initialComment);
return baseIntent.putExtra(EXTRA_OWNER, repoOwner)
.putExtra(EXTRA_REPO, repoName)
.putExtra(EXTRA_SHA, commitSha)
.putExtra(EXTRA_PATH, path)
.putExtra(EXTRA_DIFF, diff)
.putExtra(EXTRA_COMMENTS, comments != null ? new ArrayList<>(comments) : null)
.putExtra(EXTRA_INITIAL_LINE, initialLine)
.putExtra(STRING, highlightStartLine)
.putExtra(EXTRA_HIGHLIGHT_RIGHT, highlightisRight)
.putExtra(EXTRA_INITIAL_COMMENT, initialComment);
}

private static final String COMMENT_ADD_URI_FORMAT =
Expand Down Expand Up @@ -168,23 +180,23 @@ protected void onDestroy() {
@Override
protected void onInitExtras(Bundle extras) {
super.onInitExtras(extras);
mRepoOwner = extras.getString("owner");
mRepoName = extras.getString("repo");
mPath = extras.getString("path");
mSha = extras.getString("sha");
mDiff = extras.getString("diff");
mInitialLine = extras.getInt("initial_line", -1);
mHighlightStartLine = extras.getInt("highlight_start", -1);
mHighlightEndLine = extras.getInt("highlight_end", -1);
mHighlightIsRight = extras.getBoolean("highlight_right", false);
mInitialComment = extras.getParcelable("initial_comment");
extras.remove("initial_comment");
mRepoOwner = extras.getString(EXTRA_OWNER);
mRepoName = extras.getString(EXTRA_REPO);
mPath = extras.getString(EXTRA_PATH);
mSha = extras.getString(EXTRA_SHA);
mDiff = extras.getString(EXTRA_DIFF);
mInitialLine = extras.getInt(EXTRA_INITIAL_LINE, -1);
mHighlightStartLine = extras.getInt(STRING, -1);
mHighlightEndLine = extras.getInt(STRIN, -1);
mHighlightIsRight = extras.getBoolean(EXTRA_HIGHLIGHT_RIGHT, false);
mInitialComment = extras.getParcelable(EXTRA_INITIAL_COMMENT);
extras.remove(EXTRA_INITIAL_COMMENT);
}

@Override
protected boolean canSwipeToRefresh() {
// no need for pull-to-refresh if everything was passed in the intent extras
return !getIntent().hasExtra("comments");
return !getIntent().hasExtra(EXTRA_COMMENTS);
}

@Override
Expand Down Expand Up @@ -420,7 +432,7 @@ protected void handleUrlLoad(Uri uri) {

private void refresh() {
// Make sure we load the comments from remote, as we now know they've changed
getIntent().removeExtra("comments");
getIntent().removeExtra(EXTRA_COMMENTS);

// Make sure our callers are aware of the change
setResult(RESULT_OK);
Expand Down Expand Up @@ -454,7 +466,7 @@ private void deleteComment(long id) {

private void loadComments(boolean useIntentExtraIfPresent, boolean force) {
List<C> intentComments = useIntentExtraIfPresent
? getIntent().getParcelableArrayListExtra("comments") : null;
? getIntent().getParcelableArrayListExtra(EXTRA_COMMENTS) : null;
Single<List<C>> commentSingle = intentComments != null
? Single.just(intentComments)
: createCommentSingle(force).compose(makeLoaderSingle(ID_LOADER_COMMENTS, force));
Expand Down
Loading