Reply to comments. Preparing for comment deletion.

This commit is contained in:
Alex Ning 2019-06-14 18:14:49 +08:00
parent 72d811186f
commit 502cbe02ba
11 changed files with 119 additions and 34 deletions

View File

@ -33,9 +33,13 @@
</option> </option>
<option name="values"> <option name="values">
<map> <map>
<entry key="assetSourceType" value="FILE" />
<entry key="color" value="ffffff" /> <entry key="color" value="ffffff" />
<entry key="outputName" value="ic_send_white_24dp" /> <entry key="height" value="20" />
<entry key="sourceFile" value="$USER_HOME$/Downloads/outline-search-24px.svg" /> <entry key="outputName" value="ic_outline_share_20px" />
<entry key="overrideSize" value="true" />
<entry key="sourceFile" value="$USER_HOME$/Downloads/outline-share-20px.svg" />
<entry key="width" value="20" />
</map> </map>
</option> </option>
</PersistentState> </PersistentState>

View File

@ -3,10 +3,10 @@ package ml.docilealligator.infinityforreddit;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
@ -21,6 +21,7 @@ import javax.inject.Named;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import ru.noties.markwon.view.MarkwonView;
public class CommentActivity extends AppCompatActivity { public class CommentActivity extends AppCompatActivity {
@ -28,15 +29,19 @@ public class CommentActivity extends AppCompatActivity {
static final String EXTRA_PARENT_FULLNAME_KEY = "EPFK"; static final String EXTRA_PARENT_FULLNAME_KEY = "EPFK";
static final String EXTRA_COMMENT_DATA_KEY = "ECDK"; static final String EXTRA_COMMENT_DATA_KEY = "ECDK";
static final String EXTRA_PARENT_DEPTH_KEY = "EPDK"; static final String EXTRA_PARENT_DEPTH_KEY = "EPDK";
static final String EXTRA_PARENT_POSITION_KEY = "EPPK";
static final String EXTRA_IS_REPLYING_KEY = "EIRK";
static final int WRITE_COMMENT_REQUEST_CODE = 1; static final int WRITE_COMMENT_REQUEST_CODE = 1;
@BindView(R.id.coordinator_layout_comment_activity) CoordinatorLayout coordinatorLayout; @BindView(R.id.coordinator_layout_comment_activity) CoordinatorLayout coordinatorLayout;
@BindView(R.id.toolbar_comment_activity) Toolbar toolbar; @BindView(R.id.toolbar_comment_activity) Toolbar toolbar;
@BindView(R.id.comment_parent_text_view_comment_activity) TextView commentParentTextView; @BindView(R.id.comment_parent_markwon_view_comment_activity) MarkwonView commentParentMarkwonView;
@BindView(R.id.comment_edit_text_comment_activity) EditText commentEditText; @BindView(R.id.comment_edit_text_comment_activity) EditText commentEditText;
private String parentFullname; private String parentFullname;
private int parentDepth; private int parentDepth;
private int parentPosition;
private boolean isReplying;
@Inject @Inject
@Named("oauth") @Named("oauth")
@ -55,12 +60,18 @@ public class CommentActivity extends AppCompatActivity {
((Infinity) getApplication()).getmAppComponent().inject(this); ((Infinity) getApplication()).getmAppComponent().inject(this);
setSupportActionBar(toolbar);
Intent intent = getIntent(); Intent intent = getIntent();
commentParentTextView.setText(intent.getExtras().getString(EXTRA_COMMENT_PARENT_TEXT_KEY)); commentParentMarkwonView.setMarkdown(intent.getExtras().getString(EXTRA_COMMENT_PARENT_TEXT_KEY));
parentFullname = intent.getExtras().getString(EXTRA_PARENT_FULLNAME_KEY); parentFullname = intent.getExtras().getString(EXTRA_PARENT_FULLNAME_KEY);
parentDepth = intent.getExtras().getInt(EXTRA_PARENT_DEPTH_KEY); parentDepth = intent.getExtras().getInt(EXTRA_PARENT_DEPTH_KEY);
parentPosition = intent.getExtras().getInt(EXTRA_PARENT_POSITION_KEY);
isReplying = intent.getExtras().getBoolean(EXTRA_IS_REPLYING_KEY);
if(isReplying) {
toolbar.setTitle(getString(R.string.comment_activity_label_is_replying));
}
Log.i("fullname", parentFullname);
setSupportActionBar(toolbar);
} }
@Override @Override
@ -89,6 +100,9 @@ public class CommentActivity extends AppCompatActivity {
public void sendCommentSuccess(CommentData commentData) { public void sendCommentSuccess(CommentData commentData) {
Intent returnIntent = new Intent(); Intent returnIntent = new Intent();
returnIntent.putExtra(EXTRA_COMMENT_DATA_KEY, commentData); returnIntent.putExtra(EXTRA_COMMENT_DATA_KEY, commentData);
if(isReplying) {
returnIntent.putExtra(EXTRA_PARENT_POSITION_KEY, parentPosition);
}
setResult(RESULT_OK, returnIntent); setResult(RESULT_OK, returnIntent);
finish(); finish();
} }

View File

@ -1,6 +1,6 @@
package ml.docilealligator.infinityforreddit; package ml.docilealligator.infinityforreddit;
import android.content.Context; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.graphics.ColorFilter; import android.graphics.ColorFilter;
@ -33,7 +33,7 @@ import ru.noties.markwon.SpannableConfiguration;
import ru.noties.markwon.view.MarkwonView; import ru.noties.markwon.view.MarkwonView;
class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter { class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
private Context mContext; private Activity mActivity;
private Retrofit mRetrofit; private Retrofit mRetrofit;
private Retrofit mOauthRetrofit; private Retrofit mOauthRetrofit;
private SharedPreferences mSharedPreferences; private SharedPreferences mSharedPreferences;
@ -43,12 +43,12 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
private String article; private String article;
private Locale locale; private Locale locale;
CommentMultiLevelRecyclerViewAdapter(Context context, Retrofit retrofit, Retrofit oauthRetrofit, CommentMultiLevelRecyclerViewAdapter(Activity activity, Retrofit retrofit, Retrofit oauthRetrofit,
SharedPreferences sharedPreferences, ArrayList<CommentData> commentData, SharedPreferences sharedPreferences, ArrayList<CommentData> commentData,
MultiLevelRecyclerView multiLevelRecyclerView, MultiLevelRecyclerView multiLevelRecyclerView,
String subredditNamePrefixed, String article, Locale locale) { String subredditNamePrefixed, String article, Locale locale) {
super(commentData); super(commentData);
mContext = context; mActivity = activity;
mRetrofit = retrofit; mRetrofit = retrofit;
mOauthRetrofit = oauthRetrofit; mOauthRetrofit = oauthRetrofit;
mSharedPreferences = sharedPreferences; mSharedPreferences = sharedPreferences;
@ -72,28 +72,28 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
String authorPrefixed = "u/" + commentItem.getAuthor(); String authorPrefixed = "u/" + commentItem.getAuthor();
((CommentViewHolder) holder).authorTextView.setText(authorPrefixed); ((CommentViewHolder) holder).authorTextView.setText(authorPrefixed);
((CommentViewHolder) holder).authorTextView.setOnClickListener(view -> { ((CommentViewHolder) holder).authorTextView.setOnClickListener(view -> {
Intent intent = new Intent(mContext, ViewUserDetailActivity.class); Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, commentItem.getAuthor()); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, commentItem.getAuthor());
mContext.startActivity(intent); mActivity.startActivity(intent);
}); });
((CommentViewHolder) holder).commentTimeTextView.setText(commentItem.getCommentTime()); ((CommentViewHolder) holder).commentTimeTextView.setText(commentItem.getCommentTime());
SpannableConfiguration spannableConfiguration = SpannableConfiguration.builder(mContext).linkResolver((view, link) -> { SpannableConfiguration spannableConfiguration = SpannableConfiguration.builder(mActivity).linkResolver((view, link) -> {
if (link.startsWith("/u/") || link.startsWith("u/")) { if (link.startsWith("/u/") || link.startsWith("u/")) {
Intent intent = new Intent(mContext, ViewUserDetailActivity.class); Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, link.substring(3)); intent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, link.substring(3));
mContext.startActivity(intent); mActivity.startActivity(intent);
} else if (link.startsWith("/r/") || link.startsWith("r/")) { } else if (link.startsWith("/r/") || link.startsWith("r/")) {
Intent intent = new Intent(mContext, ViewSubredditDetailActivity.class); Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, link.substring(3)); intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, link.substring(3));
mContext.startActivity(intent); mActivity.startActivity(intent);
} else { } else {
CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(); CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder();
// add share action to menu list // add share action to menu list
builder.addDefaultShareMenuItem(); builder.addDefaultShareMenuItem();
builder.setToolbarColor(mContext.getResources().getColor(R.color.colorPrimary)); builder.setToolbarColor(mActivity.getResources().getColor(R.color.colorPrimary));
CustomTabsIntent customTabsIntent = builder.build(); CustomTabsIntent customTabsIntent = builder.build();
customTabsIntent.launchUrl(mContext, Uri.parse(link)); customTabsIntent.launchUrl(mActivity, Uri.parse(link));
} }
}).build(); }).build();
@ -105,6 +105,17 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
setExpandButton(((CommentViewHolder) holder).expandButton, commentItem.isExpanded()); setExpandButton(((CommentViewHolder) holder).expandButton, commentItem.isExpanded());
} }
((CommentViewHolder) holder).shareButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
String extraText = commentItem.getPermalink();
intent.putExtra(Intent.EXTRA_TEXT, extraText);
mActivity.startActivity(Intent.createChooser(intent, "Share"));
}
});
((CommentViewHolder) holder).expandButton.setOnClickListener(view -> { ((CommentViewHolder) holder).expandButton.setOnClickListener(view -> {
if (commentItem.hasChildren() && commentItem.getChildren().size() > 0) { if (commentItem.hasChildren() && commentItem.getChildren().size() > 0) {
mMultiLevelRecyclerView.toggleItemsGroup(holder.getAdapterPosition()); mMultiLevelRecyclerView.toggleItemsGroup(holder.getAdapterPosition());
@ -132,14 +143,23 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
} }
}); });
((CommentViewHolder) holder).replyButton.setOnClickListener(view -> {
Intent intent = new Intent(mActivity, CommentActivity.class);
intent.putExtra(CommentActivity.EXTRA_PARENT_DEPTH_KEY, commentItem.getDepth() + 1);
intent.putExtra(CommentActivity.EXTRA_COMMENT_PARENT_TEXT_KEY, commentItem.getCommentContent());
intent.putExtra(CommentActivity.EXTRA_PARENT_FULLNAME_KEY, commentItem.getFullName());
intent.putExtra(CommentActivity.EXTRA_IS_REPLYING_KEY, true);
mActivity.startActivityForResult(intent, CommentActivity.WRITE_COMMENT_REQUEST_CODE);
});
switch (commentItem.getVoteType()) { switch (commentItem.getVoteType()) {
case 1: case 1:
((CommentViewHolder) holder).upvoteButton ((CommentViewHolder) holder).upvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.colorPrimary), android.graphics.PorterDuff.Mode.SRC_IN); .setColorFilter(ContextCompat.getColor(mActivity, R.color.colorPrimary), android.graphics.PorterDuff.Mode.SRC_IN);
break; break;
case 2: case 2:
((CommentViewHolder) holder).downvoteButton ((CommentViewHolder) holder).downvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.minusButtonColor), android.graphics.PorterDuff.Mode.SRC_IN); .setColorFilter(ContextCompat.getColor(mActivity, R.color.minusButtonColor), android.graphics.PorterDuff.Mode.SRC_IN);
break; break;
} }
@ -156,7 +176,7 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
commentItem.setVoteType(1); commentItem.setVoteType(1);
newVoteType = RedditUtils.DIR_UPVOTE; newVoteType = RedditUtils.DIR_UPVOTE;
((CommentViewHolder) holder).upvoteButton ((CommentViewHolder) holder).upvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.backgroundColorPrimaryDark), android.graphics.PorterDuff.Mode.SRC_IN); .setColorFilter(ContextCompat.getColor(mActivity, R.color.backgroundColorPrimaryDark), android.graphics.PorterDuff.Mode.SRC_IN);
} else { } else {
//Upvoted before //Upvoted before
commentItem.setVoteType(0); commentItem.setVoteType(0);
@ -172,7 +192,7 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
if(newVoteType.equals(RedditUtils.DIR_UPVOTE)) { if(newVoteType.equals(RedditUtils.DIR_UPVOTE)) {
commentItem.setVoteType(1); commentItem.setVoteType(1);
((CommentViewHolder) holder).upvoteButton ((CommentViewHolder) holder).upvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.backgroundColorPrimaryDark), android.graphics.PorterDuff.Mode.SRC_IN); .setColorFilter(ContextCompat.getColor(mActivity, R.color.backgroundColorPrimaryDark), android.graphics.PorterDuff.Mode.SRC_IN);
} else { } else {
commentItem.setVoteType(0); commentItem.setVoteType(0);
((CommentViewHolder) holder).upvoteButton.clearColorFilter(); ((CommentViewHolder) holder).upvoteButton.clearColorFilter();
@ -184,7 +204,7 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
@Override @Override
public void onVoteThingFail(int position1) { public void onVoteThingFail(int position1) {
Toast.makeText(mContext, R.string.vote_failed, Toast.LENGTH_SHORT).show(); Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
commentItem.setVoteType(previousVoteType); commentItem.setVoteType(previousVoteType);
((CommentViewHolder) holder).scoreTextView.setText(Integer.toString(commentItem.getScore() + previousVoteType)); ((CommentViewHolder) holder).scoreTextView.setText(Integer.toString(commentItem.getScore() + previousVoteType));
((CommentViewHolder) holder).upvoteButton.setColorFilter(previousUpvoteButtonColorFilter); ((CommentViewHolder) holder).upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
@ -206,7 +226,7 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
commentItem.setVoteType(-1); commentItem.setVoteType(-1);
newVoteType = RedditUtils.DIR_DOWNVOTE; newVoteType = RedditUtils.DIR_DOWNVOTE;
((CommentViewHolder) holder).downvoteButton ((CommentViewHolder) holder).downvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.colorAccent), android.graphics.PorterDuff.Mode.SRC_IN); .setColorFilter(ContextCompat.getColor(mActivity, R.color.colorAccent), android.graphics.PorterDuff.Mode.SRC_IN);
} else { } else {
//Downvoted before //Downvoted before
commentItem.setVoteType(0); commentItem.setVoteType(0);
@ -222,7 +242,7 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
if(newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) { if(newVoteType.equals(RedditUtils.DIR_DOWNVOTE)) {
commentItem.setVoteType(-1); commentItem.setVoteType(-1);
((CommentViewHolder) holder).downvoteButton ((CommentViewHolder) holder).downvoteButton
.setColorFilter(ContextCompat.getColor(mContext, R.color.colorAccent), android.graphics.PorterDuff.Mode.SRC_IN); .setColorFilter(ContextCompat.getColor(mActivity, R.color.colorAccent), android.graphics.PorterDuff.Mode.SRC_IN);
} else { } else {
commentItem.setVoteType(0); commentItem.setVoteType(0);
((CommentViewHolder) holder).downvoteButton.clearColorFilter(); ((CommentViewHolder) holder).downvoteButton.clearColorFilter();
@ -234,7 +254,7 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
@Override @Override
public void onVoteThingFail(int position1) { public void onVoteThingFail(int position1) {
Toast.makeText(mContext, R.string.vote_failed, Toast.LENGTH_SHORT).show(); Toast.makeText(mActivity, R.string.vote_failed, Toast.LENGTH_SHORT).show();
commentItem.setVoteType(previousVoteType); commentItem.setVoteType(previousVoteType);
((CommentViewHolder) holder).scoreTextView.setText(Integer.toString(commentItem.getScore() + previousVoteType)); ((CommentViewHolder) holder).scoreTextView.setText(Integer.toString(commentItem.getScore() + previousVoteType));
((CommentViewHolder) holder).upvoteButton.setColorFilter(previousUpvoteButtonColorFilter); ((CommentViewHolder) holder).upvoteButton.setColorFilter(previousUpvoteButtonColorFilter);
@ -263,6 +283,18 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
notifyItemInserted(0); notifyItemInserted(0);
} }
void addChildComment(CommentData comment, int parentPosition) {
List<RecyclerViewItem> childComments = mCommentData.get(parentPosition).getChildren();
if(childComments == null) {
childComments = new ArrayList<>();
}
childComments.add(0, comment);
mCommentData.get(parentPosition).addChildren(childComments);
mCommentData.get(parentPosition).setHasReply(true);
notifyItemChanged(parentPosition);
mMultiLevelRecyclerView.toggleItemsGroup(parentPosition);
}
private void setExpandButton(ImageView expandButton, boolean isExpanded) { private void setExpandButton(ImageView expandButton, boolean isExpanded) {
// set the icon based on the current state // set the icon based on the current state
expandButton.setVisibility(View.VISIBLE); expandButton.setVisibility(View.VISIBLE);
@ -276,8 +308,9 @@ class CommentMultiLevelRecyclerViewAdapter extends MultiLevelAdapter {
@BindView(R.id.plus_button_item_post_comment) ImageView upvoteButton; @BindView(R.id.plus_button_item_post_comment) ImageView upvoteButton;
@BindView(R.id.score_text_view_item_post_comment) TextView scoreTextView; @BindView(R.id.score_text_view_item_post_comment) TextView scoreTextView;
@BindView(R.id.minus_button_item_post_comment) ImageView downvoteButton; @BindView(R.id.minus_button_item_post_comment) ImageView downvoteButton;
@BindView(R.id.expand_button_item_post_comment) ImageView expandButton;
@BindView(R.id.load_more_comments_progress_bar) ProgressBar loadMoreCommentsProgressBar; @BindView(R.id.load_more_comments_progress_bar) ProgressBar loadMoreCommentsProgressBar;
@BindView(R.id.expand_button_item_post_comment) ImageView expandButton;
@BindView(R.id.share_button_item_post_comment) ImageView shareButton;
@BindView(R.id.reply_button_item_post_comment) ImageView replyButton; @BindView(R.id.reply_button_item_post_comment) ImageView replyButton;
@BindView(R.id.vertical_block_item_post_comment) View verticalBlock; @BindView(R.id.vertical_block_item_post_comment) View verticalBlock;

View File

@ -64,7 +64,6 @@ public class JSONUtils {
static final String SUBSCRIBERS_KEY = "subscribers"; static final String SUBSCRIBERS_KEY = "subscribers";
static final String PUBLIC_DESCRIPTION_KEY = "public_description"; static final String PUBLIC_DESCRIPTION_KEY = "public_description";
static final String ACTIVE_USER_COUNT_KEY = "active_user_count"; static final String ACTIVE_USER_COUNT_KEY = "active_user_count";
static final String LINK_ID_KEY = "link_id";
public static final String IS_GOLD_KEY = "is_gold"; public static final String IS_GOLD_KEY = "is_gold";
public static final String IS_FRIEND_KEY = "is_friend"; public static final String IS_FRIEND_KEY = "is_friend";
static final String KIND_KEY = "kind"; static final String KIND_KEY = "kind";

View File

@ -232,7 +232,7 @@ class ParseComment {
private static CommentData parseSingleComment(JSONObject singleCommentData, int parentDepth, Locale locale) throws JSONException { private static CommentData parseSingleComment(JSONObject singleCommentData, int parentDepth, Locale locale) throws JSONException {
String id = singleCommentData.getString(JSONUtils.ID_KEY); String id = singleCommentData.getString(JSONUtils.ID_KEY);
String fullName = singleCommentData.getString(JSONUtils.LINK_ID_KEY); String fullName = singleCommentData.getString(JSONUtils.NAME_KEY);
String author = singleCommentData.getString(JSONUtils.AUTHOR_KEY); String author = singleCommentData.getString(JSONUtils.AUTHOR_KEY);
boolean isSubmitter = singleCommentData.getBoolean(JSONUtils.IS_SUBMITTER_KEY); boolean isSubmitter = singleCommentData.getBoolean(JSONUtils.IS_SUBMITTER_KEY);
String commentContent = ""; String commentContent = "";

View File

@ -77,4 +77,8 @@ public interface RedditAPI {
@FormUrlEncoded @FormUrlEncoded
@POST("/api/comment") @POST("/api/comment")
Call<String> sendComment(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params); Call<String> sendComment(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params);
@FormUrlEncoded
@POST("/api/del")
Call<String> delete(@HeaderMap Map<String, String> headers, @FieldMap Map<String, String> params);
} }

View File

@ -688,6 +688,7 @@ public class ViewPostDetailActivity extends AppCompatActivity {
intent.putExtra(CommentActivity.EXTRA_COMMENT_PARENT_TEXT_KEY, mPost.getTitle()); intent.putExtra(CommentActivity.EXTRA_COMMENT_PARENT_TEXT_KEY, mPost.getTitle());
intent.putExtra(CommentActivity.EXTRA_PARENT_FULLNAME_KEY, mPost.getFullName()); intent.putExtra(CommentActivity.EXTRA_PARENT_FULLNAME_KEY, mPost.getFullName());
intent.putExtra(CommentActivity.EXTRA_PARENT_DEPTH_KEY, 0); intent.putExtra(CommentActivity.EXTRA_PARENT_DEPTH_KEY, 0);
intent.putExtra(CommentActivity.EXTRA_IS_REPLYING_KEY, false);
startActivityForResult(intent, WRITE_COMMENT_REQUEST_CODE); startActivityForResult(intent, WRITE_COMMENT_REQUEST_CODE);
return true; return true;
case android.R.id.home: case android.R.id.home:
@ -703,7 +704,12 @@ public class ViewPostDetailActivity extends AppCompatActivity {
if(data != null && resultCode == RESULT_OK && requestCode == WRITE_COMMENT_REQUEST_CODE) { if(data != null && resultCode == RESULT_OK && requestCode == WRITE_COMMENT_REQUEST_CODE) {
if(data.hasExtra(EXTRA_COMMENT_DATA_KEY)) { if(data.hasExtra(EXTRA_COMMENT_DATA_KEY)) {
CommentData comment = data.getExtras().getParcelable(EXTRA_COMMENT_DATA_KEY); CommentData comment = data.getExtras().getParcelable(EXTRA_COMMENT_DATA_KEY);
mAdapter.addComment(comment); if(comment.getDepth() == 0) {
mAdapter.addComment(comment);
} else {
int parentPosition = data.getExtras().getInt(CommentActivity.EXTRA_PARENT_POSITION_KEY);
mAdapter.addChildComment(comment, parentPosition);
}
} else { } else {
Toast.makeText(this, R.string.send_comment_failed, Toast.LENGTH_SHORT).show(); Toast.makeText(this, R.string.send_comment_failed, Toast.LENGTH_SHORT).show();
} }

View File

@ -0,0 +1,4 @@
<vector android:height="20dp" android:viewportHeight="24"
android:viewportWidth="24" android:width="20dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92s2.92,-1.31 2.92,-2.92c0,-1.61 -1.31,-2.92 -2.92,-2.92zM18,4c0.55,0 1,0.45 1,1s-0.45,1 -1,1 -1,-0.45 -1,-1 0.45,-1 1,-1zM6,13c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1 1,0.45 1,1 -0.45,1 -1,1zM18,20.02c-0.55,0 -1,-0.45 -1,-1s0.45,-1 1,-1 1,0.45 1,1 -0.45,1 -1,1z"/>
</vector>

View File

@ -28,11 +28,18 @@
android:padding="16dp" android:padding="16dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"> app:layout_behavior="@string/appbar_scrolling_view_behavior">
<TextView <!--<TextView
android:id="@+id/comment_parent_text_view_comment_activity" android:id="@+id/comment_parent_text_view_comment_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="16dp" android:layout_marginBottom="16dp"
android:textSize="16sp" />-->
<ru.noties.markwon.view.MarkwonView
android:id="@+id/comment_parent_markwon_view_comment_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:textSize="16sp" /> android:textSize="16sp" />
<EditText <EditText

View File

@ -104,7 +104,7 @@
android:id="@+id/expand_button_item_post_comment" android:id="@+id/expand_button_item_post_comment"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_toStartOf="@id/reply_button_item_post_comment" android:layout_toStartOf="@id/share_button_item_post_comment"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="16dp" android:layout_marginEnd="16dp"
android:tint="@android:color/tab_indicator_text" android:tint="@android:color/tab_indicator_text"
@ -113,6 +113,19 @@
android:focusable="true" android:focusable="true"
android:visibility="gone"/> android:visibility="gone"/>
<ImageView
android:id="@+id/share_button_item_post_comment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toStartOf="@id/reply_button_item_post_comment"
android:layout_centerVertical="true"
android:layout_marginEnd="16dp"
android:src="@drawable/ic_outline_share_20px"
android:tint="@android:color/tab_indicator_text"
android:background="?actionBarItemBackground"
android:clickable="true"
android:focusable="true"/>
<ImageView <ImageView
android:id="@+id/reply_button_item_post_comment" android:id="@+id/reply_button_item_post_comment"
android:layout_width="wrap_content" android:layout_width="wrap_content"

View File

@ -3,6 +3,7 @@
<string name="login_activity_label">Login</string> <string name="login_activity_label">Login</string>
<string name="search_activity_label">Search</string> <string name="search_activity_label">Search</string>
<string name="comment_activity_label">Add Comment</string> <string name="comment_activity_label">Add Comment</string>
<string name="comment_activity_label_is_replying">Reply</string>
<string name="navigation_drawer_open">Open navigation drawer</string> <string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string> <string name="navigation_drawer_close">Close navigation drawer</string>