-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
278 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
app/src/main/java/com/gh4a/activities/ReviewChangesActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package com.gh4a.activities; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.annotation.AttrRes; | ||
import android.support.design.widget.CoordinatorLayout; | ||
import android.support.v4.app.FragmentActivity; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
import com.gh4a.Gh4Application; | ||
import com.gh4a.R; | ||
import com.gh4a.widget.EditorBottomSheet; | ||
|
||
import org.eclipse.egit.github.core.RepositoryId; | ||
import org.eclipse.egit.github.core.service.PullRequestService; | ||
|
||
import java.io.IOException; | ||
|
||
public class ReviewChangesActivity extends AppCompatActivity implements EditorBottomSheet.Callback { | ||
|
||
public static Intent makeEditIntent(Context context, String repoOwner, String repoName, | ||
int prNumber, String body) { | ||
return makeIntent(context, repoOwner, repoName, prNumber) | ||
.putExtra("body", body); | ||
} | ||
|
||
|
||
public static Intent makeIntent(Context context, String repoOwner, String repoName, | ||
int prNumber) { | ||
return new Intent(context, ReviewChangesActivity.class) | ||
.putExtra("owner", repoOwner) | ||
.putExtra("repo", repoName) | ||
.putExtra("pr", prNumber); | ||
} | ||
|
||
private CoordinatorLayout mRootLayout; | ||
protected EditorBottomSheet mEditorSheet; | ||
|
||
@Override | ||
public void onCreate(Bundle savedInstanceState) { | ||
setTheme(Gh4Application.THEME == R.style.DarkTheme | ||
? R.style.BottomSheetDarkTheme : R.style.BottomSheetLightTheme); | ||
super.onCreate(savedInstanceState); | ||
|
||
setContentView(R.layout.comment_editor); | ||
|
||
mRootLayout = findViewById(R.id.coordinator_layout); | ||
mEditorSheet = findViewById(R.id.bottom_sheet); | ||
|
||
mEditorSheet.setCallback(this); | ||
mEditorSheet.setCommentText(getIntent().getStringExtra("body"), false); | ||
|
||
@AttrRes int highlightColorAttr = getIntent().getIntExtra("highlight_color_attr", 0); | ||
if (highlightColorAttr != 0) { | ||
mEditorSheet.setHighlightColor(highlightColorAttr); | ||
} | ||
|
||
setResult(RESULT_CANCELED); | ||
} | ||
|
||
@Override | ||
public int getCommentEditorHintResId() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void onSendCommentInBackground(String body) throws IOException { | ||
Bundle extras = getIntent().getExtras(); | ||
RepositoryId repoId = new RepositoryId(extras.getString("owner"), extras.getString("repo")); | ||
|
||
PullRequestService service = | ||
(PullRequestService) Gh4Application.get().getService(Gh4Application.PULL_SERVICE); | ||
|
||
service.createReview(repoId, extras.getInt("pr"), body); | ||
} | ||
|
||
@Override | ||
public void onCommentSent() { | ||
setResult(RESULT_OK); | ||
finish(); | ||
} | ||
|
||
@Override | ||
public FragmentActivity getActivity() { | ||
return this; | ||
} | ||
|
||
@Override | ||
public CoordinatorLayout getRootLayout() { | ||
return mRootLayout; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
github-api/src/main/java/org/eclipse/egit/github/core/DraftPullRequestReviewComment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.eclipse.egit.github.core; | ||
|
||
import java.io.Serializable; | ||
|
||
public class DraftPullRequestReviewComment implements Serializable { | ||
private static final long serialVersionUID = -2754992759480082133L; | ||
|
||
private String path; | ||
private int position; | ||
private String body; | ||
|
||
public String getPath() { | ||
return path; | ||
} | ||
|
||
public DraftPullRequestReviewComment setPath(String path) { | ||
this.path = path; | ||
return this; | ||
} | ||
|
||
public int getPosition() { | ||
return position; | ||
} | ||
|
||
public DraftPullRequestReviewComment setPosition(int position) { | ||
this.position = position; | ||
return this; | ||
} | ||
|
||
public String getBody() { | ||
return body; | ||
} | ||
|
||
public DraftPullRequestReviewComment setBody(String body) { | ||
this.body = body; | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters