aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2019-10-29 05:52:30 +0000
committerAlex Ning <chineseperson5@gmail.com>2019-10-29 05:52:30 +0000
commitb9733e69e9fe58a972401d58cfdb344c7abf8328 (patch)
tree4e32fbda0043a4c01cb19ddea9b30d9c71ccbfd7 /app/src/main/java
parent11a69ad3338b3c75e5befd00cff9673869dd603a (diff)
downloadinfinity-for-reddit-b9733e69e9fe58a972401d58cfdb344c7abf8328.tar
infinity-for-reddit-b9733e69e9fe58a972401d58cfdb344c7abf8328.tar.gz
infinity-for-reddit-b9733e69e9fe58a972401d58cfdb344c7abf8328.tar.bz2
infinity-for-reddit-b9733e69e9fe58a972401d58cfdb344c7abf8328.tar.lz
infinity-for-reddit-b9733e69e9fe58a972401d58cfdb344c7abf8328.tar.xz
infinity-for-reddit-b9733e69e9fe58a972401d58cfdb344c7abf8328.tar.zst
infinity-for-reddit-b9733e69e9fe58a972401d58cfdb344c7abf8328.zip
Placing vote buttons on the right for comments is now available.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java27
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java32
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java2
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java3
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Post.java4
5 files changed, 63 insertions, 5 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
index 169a5cee..97c7fb98 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
@@ -510,7 +510,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
mActivity.startActivityForResult(intent, WRITE_COMMENT_REQUEST_CODE);
});
- ((PostDetailViewHolder) holder).commentsCountTextView.setText(Integer.toString(mPost.getnComments()));
+ ((PostDetailViewHolder) holder).commentsCountTextView.setText(Integer.toString(mPost.getNComments()));
if (mPost.isSaved()) {
((PostDetailViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
@@ -1697,6 +1697,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
TextView commentTimeTextView;
@BindView(R.id.comment_markdown_view_item_post_comment)
TextView commentMarkdownView;
+ @BindView(R.id.bottom_constraint_layout_item_post_comment)
+ ConstraintLayout bottomConstraintLayout;
@BindView(R.id.up_vote_button_item_post_comment)
ImageView upVoteButton;
@BindView(R.id.score_text_view_item_post_comment)
@@ -1768,6 +1770,29 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
expandButton.performClick();
return true;
});
+
+ if (mVoteButtonsOnTheRight) {
+ ConstraintSet constraintSet = new ConstraintSet();
+ constraintSet.clone(bottomConstraintLayout);
+ constraintSet.clear(upVoteButton.getId(), ConstraintSet.START);
+ constraintSet.clear(scoreTextView.getId(), ConstraintSet.START);
+ constraintSet.clear(downVoteButton.getId(), ConstraintSet.START);
+ constraintSet.clear(expandButton.getId(), ConstraintSet.END);
+ constraintSet.clear(saveButton.getId(), ConstraintSet.END);
+ constraintSet.clear(replyButton.getId(), ConstraintSet.END);
+ constraintSet.clear(shareButton.getId(), ConstraintSet.END);
+ constraintSet.connect(upVoteButton.getId(), ConstraintSet.END, scoreTextView.getId(), ConstraintSet.START);
+ constraintSet.connect(scoreTextView.getId(), ConstraintSet.END, downVoteButton.getId(), ConstraintSet.START);
+ constraintSet.connect(downVoteButton.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
+ constraintSet.connect(moreButton.getId(), ConstraintSet.START, expandButton.getId(), ConstraintSet.END);
+ constraintSet.connect(moreButton.getId(), ConstraintSet.END, upVoteButton.getId(), ConstraintSet.END);
+ constraintSet.connect(expandButton.getId(), ConstraintSet.START, saveButton.getId(), ConstraintSet.END);
+ constraintSet.connect(saveButton.getId(), ConstraintSet.START, replyButton.getId(), ConstraintSet.END);
+ constraintSet.connect(replyButton.getId(), ConstraintSet.START, shareButton.getId(), ConstraintSet.END);
+ constraintSet.connect(shareButton.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START);
+ constraintSet.setHorizontalBias(moreButton.getId(), 0);
+ constraintSet.applyTo(bottomConstraintLayout);
+ }
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java
index 5924fa94..0ac21d44 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java
@@ -17,6 +17,8 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
+import androidx.constraintlayout.widget.ConstraintLayout;
+import androidx.constraintlayout.widget.ConstraintSet;
import androidx.core.content.ContextCompat;
import androidx.paging.PagedListAdapter;
import androidx.recyclerview.widget.DiffUtil;
@@ -64,11 +66,13 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
private String mAccountName;
private int mTextColorPrimaryDark;
private int mColorAccent;
+ private boolean mVoteButtonsOnTheRight;
private NetworkState networkState;
private RetryLoadingMoreCallback mRetryLoadingMoreCallback;
public CommentsListingRecyclerViewAdapter(Context context, Retrofit oauthRetrofit,
String accessToken, String accountName,
+ boolean voteButtonsOnTheRight,
RetryLoadingMoreCallback retryLoadingMoreCallback) {
super(DIFF_CALLBACK);
mContext = context;
@@ -94,6 +98,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
.build();
mAccessToken = accessToken;
mAccountName = accountName;
+ mVoteButtonsOnTheRight = voteButtonsOnTheRight;
mRetryLoadingMoreCallback = retryLoadingMoreCallback;
mTextColorPrimaryDark = mContext.getResources().getColor(R.color.colorPrimaryDarkDayNightTheme);
mColorAccent = mContext.getResources().getColor(R.color.colorAccent);
@@ -407,6 +412,8 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
TextView commentTimeTextView;
@BindView(R.id.comment_markdown_view_item_post_comment)
TextView commentMarkdownView;
+ @BindView(R.id.bottom_constraint_layout_item_post_comment)
+ ConstraintLayout bottomConstraintLayout;
@BindView(R.id.up_vote_button_item_post_comment)
ImageView upvoteButton;
@BindView(R.id.score_text_view_item_post_comment)
@@ -417,6 +424,8 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
ImageView moreButton;
@BindView(R.id.save_button_item_post_comment)
ImageView saveButton;
+ @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)
@@ -425,6 +434,29 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
DataViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
+
+ if (mVoteButtonsOnTheRight) {
+ ConstraintSet constraintSet = new ConstraintSet();
+ constraintSet.clone(bottomConstraintLayout);
+ constraintSet.clear(upvoteButton.getId(), ConstraintSet.START);
+ constraintSet.clear(scoreTextView.getId(), ConstraintSet.START);
+ constraintSet.clear(downvoteButton.getId(), ConstraintSet.START);
+ constraintSet.clear(expandButton.getId(), ConstraintSet.END);
+ constraintSet.clear(saveButton.getId(), ConstraintSet.END);
+ constraintSet.clear(replyButton.getId(), ConstraintSet.END);
+ constraintSet.clear(shareButton.getId(), ConstraintSet.END);
+ constraintSet.connect(upvoteButton.getId(), ConstraintSet.END, scoreTextView.getId(), ConstraintSet.START);
+ constraintSet.connect(scoreTextView.getId(), ConstraintSet.END, downvoteButton.getId(), ConstraintSet.START);
+ constraintSet.connect(downvoteButton.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
+ constraintSet.connect(moreButton.getId(), ConstraintSet.START, expandButton.getId(), ConstraintSet.END);
+ constraintSet.connect(moreButton.getId(), ConstraintSet.END, upvoteButton.getId(), ConstraintSet.END);
+ constraintSet.connect(expandButton.getId(), ConstraintSet.START, saveButton.getId(), ConstraintSet.END);
+ constraintSet.connect(saveButton.getId(), ConstraintSet.START, replyButton.getId(), ConstraintSet.END);
+ constraintSet.connect(replyButton.getId(), ConstraintSet.START, shareButton.getId(), ConstraintSet.END);
+ constraintSet.connect(shareButton.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START);
+ constraintSet.setHorizontalBias(moreButton.getId(), 0);
+ constraintSet.applyTo(bottomConstraintLayout);
+ }
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
index 6be7c9e7..e221d03e 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
@@ -616,7 +616,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}, fullName, newVoteType, holder.getAdapterPosition());
});
- ((DataViewHolder) holder).commentsCountTextView.setText(Integer.toString(post.getnComments()));
+ ((DataViewHolder) holder).commentsCountTextView.setText(Integer.toString(post.getNComments()));
if (post.isSaved()) {
((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java
index 48823b32..7b721869 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/CommentsListingFragment.java
@@ -143,9 +143,10 @@ public class CommentsListingFragment extends Fragment implements FragmentCommuni
private void bindView(Resources resources) {
mCommentRecyclerView.setLayoutManager(new LinearLayoutManager(activity));
+ boolean voteButtonsOnTheRight = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
mAdapter = new CommentsListingRecyclerViewAdapter(activity, mOauthRetrofit,
getArguments().getString(EXTRA_ACCESS_TOKEN), getArguments().getString(EXTRA_ACCOUNT_NAME),
- () -> mCommentViewModel.retryLoadingMore());
+ voteButtonsOnTheRight, () -> mCommentViewModel.retryLoadingMore());
String username = getArguments().getString(EXTRA_USERNAME);
String sort = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_USER_COMMENT, SortType.Type.NEW.value);
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Post.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Post.java
index 1f2c3681..47f4a6a3 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Post.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Post.java
@@ -323,11 +323,11 @@ public class Post implements Parcelable {
this.previewHeight = previewHeight;
}
- public int getnComments() {
+ public int getNComments() {
return nComments;
}
- public void setnComments(int nComments) {
+ public void setNComments(int nComments) {
this.nComments = nComments;
}