aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/ml
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2019-10-29 03:20:16 +0000
committerAlex Ning <chineseperson5@gmail.com>2019-10-29 03:20:16 +0000
commit168456f57ccd80a52c7d95761b1df6827d0b90c8 (patch)
tree900e4e25b097b54ebdf88e0cbcefc1b7779e3b0f /app/src/main/java/ml
parent3a81ca17e864dd76d77d4a6bd41ccfdcc54bbe1e (diff)
downloadinfinity-for-reddit-168456f57ccd80a52c7d95761b1df6827d0b90c8.tar
infinity-for-reddit-168456f57ccd80a52c7d95761b1df6827d0b90c8.tar.gz
infinity-for-reddit-168456f57ccd80a52c7d95761b1df6827d0b90c8.tar.bz2
infinity-for-reddit-168456f57ccd80a52c7d95761b1df6827d0b90c8.tar.lz
infinity-for-reddit-168456f57ccd80a52c7d95761b1df6827d0b90c8.tar.xz
infinity-for-reddit-168456f57ccd80a52c7d95761b1df6827d0b90c8.tar.zst
infinity-for-reddit-168456f57ccd80a52c7d95761b1df6827d0b90c8.zip
Make Placing vote buttons on the right an option.
Diffstat (limited to 'app/src/main/java/ml')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java38
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java67
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java47
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeVoteButtonsPositionEvent.java9
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java16
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java13
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java1
8 files changed, 143 insertions, 60 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
index 4bb8711e..6bafbebe 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Activity/ViewPostDetailActivity.java
@@ -159,6 +159,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
private String mSingleCommentId;
private boolean mNeedBlurNsfw;
private boolean mNeedBlurSpoiler;
+ private boolean mVoteButtonsOnTheRight;
private boolean showToast = false;
private boolean isSortingComments = false;
private LinearLayoutManager mLinearLayoutManager;
@@ -232,6 +233,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
mNeedBlurNsfw = mSharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_NSFW_KEY, true);
mNeedBlurSpoiler = mSharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_SPOILER_KEY, false);
+ mVoteButtonsOnTheRight = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
mGlide = Glide.with(this);
mLocale = getResources().getConfiguration().locale;
@@ -239,7 +241,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
mLinearLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(mLinearLayoutManager);
- mSingleCommentId = getIntent().hasExtra(EXTRA_SINGLE_COMMENT_ID) ? getIntent().getExtras().getString(EXTRA_SINGLE_COMMENT_ID) : null;
+ mSingleCommentId = getIntent().getStringExtra(EXTRA_SINGLE_COMMENT_ID);
if (savedInstanceState == null) {
if (mSingleCommentId != null) {
isSingleCommentThreadMode = true;
@@ -336,10 +338,10 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
if (mAccessToken != null) {
if (mPost.isSaved()) {
saveItem.setVisible(true);
- saveItem.setIcon(R.drawable.ic_baseline_bookmark_24px);
+ saveItem.setIcon(R.drawable.ic_bookmark_black_24dp);
} else {
saveItem.setVisible(true);
- saveItem.setIcon(R.drawable.ic_baseline_bookmark_border_24px);
+ saveItem.setIcon(R.drawable.ic_bookmark_border_black_24dp);
}
if (mPost.isHidden()) {
@@ -385,6 +387,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
mAdapter = new CommentAndPostRecyclerViewAdapter(ViewPostDetailActivity.this, mRetrofit,
mOauthRetrofit, mRedditDataRoomDatabase, mGlide, mAccessToken, mAccountName, mPost,
mLocale, mSingleCommentId, isSingleCommentThreadMode, mNeedBlurNsfw, mNeedBlurSpoiler,
+ mVoteButtonsOnTheRight,
new CommentAndPostRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() {
@Override
public void updatePost(Post post) {
@@ -473,10 +476,10 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
if (mAccessToken != null) {
if (post.isSaved()) {
saveItem.setVisible(true);
- saveItem.setIcon(R.drawable.ic_baseline_bookmark_24px);
+ saveItem.setIcon(R.drawable.ic_bookmark_black_24dp);
} else {
saveItem.setVisible(true);
- saveItem.setIcon(R.drawable.ic_baseline_bookmark_border_24px);
+ saveItem.setIcon(R.drawable.ic_bookmark_border_black_24dp);
}
if (post.isHidden()) {
@@ -505,6 +508,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
mRetrofit, mOauthRetrofit, mRedditDataRoomDatabase, mGlide,
mAccessToken, mAccountName, mPost, mLocale, mSingleCommentId,
isSingleCommentThreadMode, mNeedBlurNsfw, mNeedBlurSpoiler,
+ mVoteButtonsOnTheRight,
new CommentAndPostRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() {
@Override
public void updatePost(Post post) {
@@ -727,10 +731,10 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
if (mAccessToken != null) {
if (post.isSaved()) {
saveItem.setVisible(true);
- saveItem.setIcon(R.drawable.ic_baseline_bookmark_24px);
+ saveItem.setIcon(R.drawable.ic_bookmark_black_24dp);
} else {
saveItem.setVisible(true);
- saveItem.setIcon(R.drawable.ic_baseline_bookmark_border_24px);
+ saveItem.setIcon(R.drawable.ic_bookmark_border_black_24dp);
}
if (post.isHidden()) {
@@ -962,10 +966,10 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
if (mMenu != null) {
if (event.post.isSaved()) {
mMenu.findItem(R.id.action_save_view_post_detail_activity).setIcon(getResources()
- .getDrawable(R.drawable.ic_baseline_bookmark_24px));
+ .getDrawable(R.drawable.ic_bookmark_black_24dp));
} else {
mMenu.findItem(R.id.action_save_view_post_detail_activity).setIcon(getResources()
- .getDrawable(R.drawable.ic_baseline_bookmark_border_24px));
+ .getDrawable(R.drawable.ic_bookmark_border_black_24dp));
}
}
mAdapter.updatePost(mPost);
@@ -1022,10 +1026,10 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
if (mAccessToken != null) {
if (mPost.isSaved()) {
saveItem.setVisible(true);
- saveItem.setIcon(R.drawable.ic_baseline_bookmark_24px);
+ saveItem.setIcon(R.drawable.ic_bookmark_black_24dp);
} else {
saveItem.setVisible(true);
- saveItem.setIcon(R.drawable.ic_baseline_bookmark_border_24px);
+ saveItem.setIcon(R.drawable.ic_bookmark_border_black_24dp);
}
if (mPost.isHidden()) {
@@ -1104,13 +1108,13 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
case R.id.action_save_view_post_detail_activity:
if (mPost != null && mAccessToken != null) {
if (mPost.isSaved()) {
- item.setIcon(R.drawable.ic_baseline_bookmark_border_24px);
+ item.setIcon(R.drawable.ic_bookmark_border_black_24dp);
SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, mPost.getFullName(),
new SaveThing.SaveThingListener() {
@Override
public void success() {
mPost.setSaved(false);
- item.setIcon(R.drawable.ic_baseline_bookmark_border_24px);
+ item.setIcon(R.drawable.ic_bookmark_border_black_24dp);
showMessage(R.string.post_unsaved_success);
EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition));
}
@@ -1118,19 +1122,19 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
@Override
public void failed() {
mPost.setSaved(true);
- item.setIcon(R.drawable.ic_baseline_bookmark_24px);
+ item.setIcon(R.drawable.ic_bookmark_black_24dp);
showMessage(R.string.post_unsaved_failed);
EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition));
}
});
} else {
- item.setIcon(R.drawable.ic_baseline_bookmark_24px);
+ item.setIcon(R.drawable.ic_bookmark_black_24dp);
SaveThing.saveThing(mOauthRetrofit, mAccessToken, mPost.getFullName(),
new SaveThing.SaveThingListener() {
@Override
public void success() {
mPost.setSaved(true);
- item.setIcon(R.drawable.ic_baseline_bookmark_24px);
+ item.setIcon(R.drawable.ic_bookmark_black_24dp);
showMessage(R.string.post_saved_success);
EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition));
}
@@ -1138,7 +1142,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
@Override
public void failed() {
mPost.setSaved(false);
- item.setIcon(R.drawable.ic_baseline_bookmark_border_24px);
+ item.setIcon(R.drawable.ic_bookmark_border_black_24dp);
showMessage(R.string.post_saved_failed);
EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition));
}
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 84585046..169a5cee 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentAndPostRecyclerViewAdapter.java
@@ -23,6 +23,8 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
+import androidx.constraintlayout.widget.ConstraintLayout;
+import androidx.constraintlayout.widget.ConstraintSet;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
@@ -102,6 +104,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
private boolean mIsSingleCommentThreadMode;
private boolean mNeedBlurNSFW;
private boolean mNeedBlurSpoiler;
+ private boolean mVoteButtonsOnTheRight;
private CommentRecyclerViewAdapterCallback mCommentRecyclerViewAdapterCallback;
private boolean isInitiallyLoading;
private boolean isInitiallyLoadingFailed;
@@ -113,7 +116,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
RedditDataRoomDatabase redditDataRoomDatabase, RequestManager glide,
String accessToken, String accountName, Post post, Locale locale,
String singleCommentId, boolean isSingleCommentThreadMode,
- boolean needBlurNSFW, boolean needBlurSpoiler,
+ boolean needBlurNSFW, boolean needBlurSpoiler, boolean voteButtonsOnTheRight,
CommentRecyclerViewAdapterCallback commentRecyclerViewAdapterCallback) {
mActivity = activity;
mRetrofit = retrofit;
@@ -149,6 +152,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
mIsSingleCommentThreadMode = isSingleCommentThreadMode;
mNeedBlurNSFW = needBlurNSFW;
mNeedBlurSpoiler = needBlurSpoiler;
+ mVoteButtonsOnTheRight = voteButtonsOnTheRight;
mCommentRecyclerViewAdapterCallback = commentRecyclerViewAdapterCallback;
isInitiallyLoading = true;
isInitiallyLoadingFailed = false;
@@ -492,7 +496,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
break;
}
- ((PostDetailViewHolder) holder).commentButton.setOnClickListener(view -> {
+ ((PostDetailViewHolder) holder).commentsCountTextView.setOnClickListener(view -> {
if (mAccessToken == null) {
Toast.makeText(mActivity, R.string.login_first, Toast.LENGTH_SHORT).show();
return;
@@ -509,9 +513,9 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
((PostDetailViewHolder) holder).commentsCountTextView.setText(Integer.toString(mPost.getnComments()));
if (mPost.isSaved()) {
- ((PostDetailViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_24px);
+ ((PostDetailViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
} else {
- ((PostDetailViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_border_24px);
+ ((PostDetailViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
}
((PostDetailViewHolder) holder).saveButton.setOnClickListener(view -> {
@@ -521,13 +525,13 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
}
if (mPost.isSaved()) {
- ((PostDetailViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_border_24px);
+ ((PostDetailViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, mPost.getFullName(),
new SaveThing.SaveThingListener() {
@Override
public void success() {
mPost.setSaved(false);
- ((PostDetailViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_border_24px);
+ ((PostDetailViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
Toast.makeText(mActivity, R.string.post_unsaved_success, Toast.LENGTH_SHORT).show();
mCommentRecyclerViewAdapterCallback.updatePost(mPost);
}
@@ -535,19 +539,19 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
@Override
public void failed() {
mPost.setSaved(true);
- ((PostDetailViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_24px);
+ ((PostDetailViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
Toast.makeText(mActivity, R.string.post_unsaved_failed, Toast.LENGTH_SHORT).show();
mCommentRecyclerViewAdapterCallback.updatePost(mPost);
}
});
} else {
- ((PostDetailViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_24px);
+ ((PostDetailViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
SaveThing.saveThing(mOauthRetrofit, mAccessToken, mPost.getFullName(),
new SaveThing.SaveThingListener() {
@Override
public void success() {
mPost.setSaved(true);
- ((PostDetailViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_24px);
+ ((PostDetailViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
Toast.makeText(mActivity, R.string.post_saved_success, Toast.LENGTH_SHORT).show();
mCommentRecyclerViewAdapterCallback.updatePost(mPost);
}
@@ -555,7 +559,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
@Override
public void failed() {
mPost.setSaved(false);
- ((PostDetailViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_border_24px);
+ ((PostDetailViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
Toast.makeText(mActivity, R.string.post_saved_failed, Toast.LENGTH_SHORT).show();
mCommentRecyclerViewAdapterCallback.updatePost(mPost);
}
@@ -655,9 +659,9 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
if (comment.hasReply()) {
if (comment.isExpanded()) {
- ((CommentViewHolder) holder).expandButton.setImageResource(R.drawable.ic_expand_less_black_22dp);
+ ((CommentViewHolder) holder).expandButton.setImageResource(R.drawable.ic_expand_less_grey_24dp);
} else {
- ((CommentViewHolder) holder).expandButton.setImageResource(R.drawable.ic_expand_more_black_20dp);
+ ((CommentViewHolder) holder).expandButton.setImageResource(R.drawable.ic_expand_more_grey_24dp);
}
((CommentViewHolder) holder).expandButton.setVisibility(View.VISIBLE);
}
@@ -839,9 +843,9 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
});
if (comment.isSaved()) {
- ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_20dp);
+ ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
} else {
- ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_20dp);
+ ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
}
((CommentViewHolder) holder).saveButton.setOnClickListener(view -> {
@@ -851,14 +855,14 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
@Override
public void success() {
comment.setSaved(false);
- ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_20dp);
+ ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
Toast.makeText(mActivity, R.string.comment_unsaved_success, Toast.LENGTH_SHORT).show();
}
@Override
public void failed() {
comment.setSaved(true);
- ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_20dp);
+ ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
Toast.makeText(mActivity, R.string.comment_unsaved_failed, Toast.LENGTH_SHORT).show();
}
});
@@ -868,14 +872,14 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
@Override
public void success() {
comment.setSaved(true);
- ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_20dp);
+ ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
Toast.makeText(mActivity, R.string.comment_saved_success, Toast.LENGTH_SHORT).show();
}
@Override
public void failed() {
comment.setSaved(false);
- ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_20dp);
+ ((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
Toast.makeText(mActivity, R.string.comment_saved_failed, Toast.LENGTH_SHORT).show();
}
});
@@ -1469,14 +1473,14 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
AspectRatioImageView mImageView;
@BindView(R.id.image_view_no_preview_link_item_post_detail)
ImageView mNoPreviewLinkImageView;
+ @BindView(R.id.bottom_constraint_layout_item_post_detail)
+ ConstraintLayout mBottomConstraintLayout;
@BindView(R.id.plus_button_item_post_detail)
ImageView mUpvoteButton;
@BindView(R.id.score_text_view_item_post_detail)
TextView mScoreTextView;
@BindView(R.id.minus_button_item_post_detail)
ImageView mDownvoteButton;
- @BindView(R.id.comment_button_item_post_detail)
- ImageView commentButton;
@BindView(R.id.comments_count_item_post_detail)
TextView commentsCountTextView;
@BindView(R.id.save_button_item_post_detail)
@@ -1662,6 +1666,25 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
}
}, mPost.getFullName(), newVoteType);
});
+
+ if (mVoteButtonsOnTheRight) {
+ ConstraintSet constraintSet = new ConstraintSet();
+ constraintSet.clone(mBottomConstraintLayout);
+ constraintSet.clear(mUpvoteButton.getId(), ConstraintSet.START);
+ constraintSet.clear(mScoreTextView.getId(), ConstraintSet.START);
+ constraintSet.clear(mDownvoteButton.getId(), ConstraintSet.START);
+ constraintSet.clear(saveButton.getId(), ConstraintSet.END);
+ constraintSet.clear(mShareButton.getId(), ConstraintSet.END);
+ constraintSet.connect(mUpvoteButton.getId(), ConstraintSet.END, mScoreTextView.getId(), ConstraintSet.START);
+ constraintSet.connect(mScoreTextView.getId(), ConstraintSet.END, mDownvoteButton.getId(), ConstraintSet.START);
+ constraintSet.connect(mDownvoteButton.getId(), ConstraintSet.END, ConstraintSet.PARENT_ID, ConstraintSet.END);
+ constraintSet.connect(commentsCountTextView.getId(), ConstraintSet.START, saveButton.getId(), ConstraintSet.END);
+ constraintSet.connect(commentsCountTextView.getId(), ConstraintSet.END, mUpvoteButton.getId(), ConstraintSet.START);
+ constraintSet.connect(saveButton.getId(), ConstraintSet.START, mShareButton.getId(), ConstraintSet.END);
+ constraintSet.connect(mShareButton.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START);
+ constraintSet.setHorizontalBias(commentsCountTextView.getId(), 0);
+ constraintSet.applyTo(mBottomConstraintLayout);
+ }
}
}
@@ -1726,11 +1749,11 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
if(commentPosition < mVisibleComments.size()) {
if (mVisibleComments.get(commentPosition).isExpanded()) {
collapseChildren(commentPosition);
- expandButton.setImageResource(R.drawable.ic_expand_more_black_20dp);
+ expandButton.setImageResource(R.drawable.ic_expand_more_grey_24dp);
} else {
expandChildren(commentPosition);
mVisibleComments.get(commentPosition).setExpanded(true);
- expandButton.setImageResource(R.drawable.ic_expand_less_black_22dp);
+ expandButton.setImageResource(R.drawable.ic_expand_less_grey_24dp);
}
}
}
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 8085a1a3..5924fa94 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/CommentsListingRecyclerViewAdapter.java
@@ -295,9 +295,9 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
});
if (comment.isSaved()) {
- ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_20dp);
+ ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
} else {
- ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_20dp);
+ ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
}
((DataViewHolder) holder).saveButton.setOnClickListener(view -> {
@@ -307,14 +307,14 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
@Override
public void success() {
comment.setSaved(false);
- ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_20dp);
+ ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
Toast.makeText(mContext, R.string.comment_unsaved_success, Toast.LENGTH_SHORT).show();
}
@Override
public void failed() {
comment.setSaved(true);
- ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_20dp);
+ ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
Toast.makeText(mContext, R.string.comment_unsaved_failed, Toast.LENGTH_SHORT).show();
}
});
@@ -324,14 +324,14 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
@Override
public void success() {
comment.setSaved(true);
- ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_20dp);
+ ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
Toast.makeText(mContext, R.string.comment_saved_success, Toast.LENGTH_SHORT).show();
}
@Override
public void failed() {
comment.setSaved(false);
- ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_20dp);
+ ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
Toast.makeText(mContext, R.string.comment_saved_failed, Toast.LENGTH_SHORT).show();
}
});
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 04827aea..6be7c9e7 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Adapter/PostRecyclerViewAdapter.java
@@ -20,6 +20,8 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.cardview.widget.CardView;
+import androidx.constraintlayout.widget.ConstraintLayout;
+import androidx.constraintlayout.widget.ConstraintSet;
import androidx.core.content.ContextCompat;
import androidx.paging.PagedListAdapter;
import androidx.recyclerview.widget.DiffUtil;
@@ -96,6 +98,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
private boolean canStartActivity = true;
private int mPostType;
private boolean mDisplaySubredditName;
+ private boolean mVoteButtonsOnTheRight;
private boolean mNeedBlurNSFW;
private boolean mNeedBlurSpoiler;
private NetworkState networkState;
@@ -104,7 +107,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
public PostRecyclerViewAdapter(Context context, Retrofit oauthRetrofit, Retrofit retrofit,
RedditDataRoomDatabase redditDataRoomDatabase, String accessToken,
int postType, boolean displaySubredditName, boolean needBlurNSFW,
- boolean needBlurSpoiler, Callback callback) {
+ boolean needBlurSpoiler, boolean voteButtonsOnTheRight, Callback callback) {
super(DIFF_CALLBACK);
if (context != null) {
mContext = context;
@@ -115,6 +118,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
mDisplaySubredditName = displaySubredditName;
mNeedBlurNSFW = needBlurNSFW;
mNeedBlurSpoiler = needBlurSpoiler;
+ mVoteButtonsOnTheRight = voteButtonsOnTheRight;
mGlide = Glide.with(mContext.getApplicationContext());
mRedditDataRoomDatabase = redditDataRoomDatabase;
mUserDao = redditDataRoomDatabase.userDao();
@@ -615,9 +619,9 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
((DataViewHolder) holder).commentsCountTextView.setText(Integer.toString(post.getnComments()));
if (post.isSaved()) {
- ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_24px);
+ ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
} else {
- ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_border_24px);
+ ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
}
((DataViewHolder) holder).saveButton.setOnClickListener(view -> {
@@ -627,13 +631,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
}
if (post.isSaved()) {
- ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_border_24px);
+ ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
SaveThing.unsaveThing(mOauthRetrofit, mAccessToken, post.getFullName(),
new SaveThing.SaveThingListener() {
@Override
public void success() {
post.setSaved(false);
- ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_border_24px);
+ ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
Toast.makeText(mContext, R.string.post_unsaved_success, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
@@ -641,19 +645,19 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
@Override
public void failed() {
post.setSaved(true);
- ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_24px);
+ ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
Toast.makeText(mContext, R.string.post_unsaved_failed, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
});
} else {
- ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_24px);
+ ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
SaveThing.saveThing(mOauthRetrofit, mAccessToken, post.getFullName(),
new SaveThing.SaveThingListener() {
@Override
public void success() {
post.setSaved(true);
- ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_24px);
+ ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
Toast.makeText(mContext, R.string.post_saved_success, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
@@ -661,7 +665,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
@Override
public void failed() {
post.setSaved(false);
- ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_baseline_bookmark_border_24px);
+ ((DataViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
Toast.makeText(mContext, R.string.post_saved_failed, Toast.LENGTH_SHORT).show();
EventBus.getDefault().post(new PostUpdateEventToDetailActivity(post));
}
@@ -736,6 +740,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
return super.getItemCount();
}
+ public void setVoteButtonsPosition(boolean voteButtonsOnTheRight) {
+ mVoteButtonsOnTheRight = voteButtonsOnTheRight;
+ }
+
public void setBlurNSFW(boolean needBlurNSFW) {
mNeedBlurNSFW = needBlurNSFW;
}
@@ -841,6 +849,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
ImageView noPreviewLinkImageView;
@BindView(R.id.content_text_view_item_post)
TextView contentTextView;
+ @BindView(R.id.bottom_constraint_layout_item_post)
+ ConstraintLayout bottomConstraintLayout;
@BindView(R.id.plus_button_item_post)
ImageView upvoteButton;
@BindView(R.id.score_text_view_item_post)
@@ -860,6 +870,25 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
scoreTextView.setOnClickListener(view -> {
//Do nothing in order to prevent clicking this to start ViewPostDetailActivity
});
+
+ 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(saveButton.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(commentsCountTextView.getId(), ConstraintSet.START, saveButton.getId(), ConstraintSet.END);
+ constraintSet.connect(commentsCountTextView.getId(), ConstraintSet.END, upvoteButton.getId(), ConstraintSet.START);
+ constraintSet.connect(saveButton.getId(), ConstraintSet.START, shareButton.getId(), ConstraintSet.END);
+ constraintSet.connect(shareButton.getId(), ConstraintSet.START, ConstraintSet.PARENT_ID, ConstraintSet.START);
+ constraintSet.setHorizontalBias(commentsCountTextView.getId(), 0);
+ constraintSet.applyTo(bottomConstraintLayout);
+ }
}
}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeVoteButtonsPositionEvent.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeVoteButtonsPositionEvent.java
new file mode 100644
index 00000000..00f506ab
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeVoteButtonsPositionEvent.java
@@ -0,0 +1,9 @@
+package ml.docilealligator.infinityforreddit.Event;
+
+public class ChangeVoteButtonsPositionEvent {
+ public boolean voteButtonsOnTheRight;
+
+ public ChangeVoteButtonsPositionEvent(boolean voteButtonsOnTheRight) {
+ this.voteButtonsOnTheRight = voteButtonsOnTheRight;
+ }
+}
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
index e5f8c2f3..921763c6 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Fragment/PostFragment.java
@@ -51,6 +51,7 @@ import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity
import ml.docilealligator.infinityforreddit.Adapter.PostRecyclerViewAdapter;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
+import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent;
import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToPostList;
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
import ml.docilealligator.infinityforreddit.Infinity;
@@ -275,6 +276,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
boolean nsfw = mSharedPreferences.getBoolean(SharedPreferencesUtils.NSFW_KEY, false);
boolean needBlurNsfw = mSharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_NSFW_KEY, true);
boolean needBlurSpoiler = mSharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_SPOILER_KEY, false);
+ boolean voteButtonsOnTheRight = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
PostViewModel.Factory factory;
@@ -288,7 +290,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
accessToken, postType, true, needBlurNsfw, needBlurSpoiler,
- new PostRecyclerViewAdapter.Callback() {
+ voteButtonsOnTheRight, new PostRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
mPostViewModel.retryLoadingMore();
@@ -348,7 +350,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
accessToken, postType, displaySubredditName, needBlurNsfw, needBlurSpoiler,
- new PostRecyclerViewAdapter.Callback() {
+ voteButtonsOnTheRight, new PostRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
mPostViewModel.retryLoadingMore();
@@ -393,7 +395,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
accessToken, postType, true, needBlurNsfw, needBlurSpoiler,
- new PostRecyclerViewAdapter.Callback() {
+ voteButtonsOnTheRight, new PostRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
mPostViewModel.retryLoadingMore();
@@ -431,7 +433,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
accessToken, postType, true, needBlurNsfw, needBlurSpoiler,
- new PostRecyclerViewAdapter.Callback() {
+ voteButtonsOnTheRight, new PostRecyclerViewAdapter.Callback() {
@Override
public void retryLoadingMore() {
mPostViewModel.retryLoadingMore();
@@ -626,6 +628,12 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
}
@Subscribe
+ public void onChangeVoteButtonsPositionEvent(ChangeVoteButtonsPositionEvent event) {
+ mAdapter.setVoteButtonsPosition(event.voteButtonsOnTheRight);
+ refreshAdapter();
+ }
+
+ @Subscribe
public void onChangeNSFWBlurEvent(ChangeNSFWBlurEvent event) {
mAdapter.setBlurNSFW(event.needBlurNSFW);
refreshAdapter();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java
index 9e366424..dcc1c201 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/Settings/MainPreferenceFragment.java
@@ -19,6 +19,7 @@ import javax.inject.Inject;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
+import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent;
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.R;
@@ -47,12 +48,13 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
SwitchPreference amoledDarkSwitch = findPreference(SharedPreferencesUtils.AMOLED_DARK_KEY);
SwitchPreference immersiveInterfaceSwitch = findPreference(SharedPreferencesUtils.IMMERSIVE_INTERFACE_KEY);
+ SwitchPreference voteButtonsOnTheRightSwitch = findPreference(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY);
SwitchPreference nsfwSwitch = findPreference(SharedPreferencesUtils.NSFW_KEY);
SwitchPreference blurNSFWSwitch = findPreference(SharedPreferencesUtils.BLUR_NSFW_KEY);
SwitchPreference blurSpoilerSwitch = findPreference(SharedPreferencesUtils.BLUR_SPOILER_KEY);
ListPreference themePreference = findPreference(SharedPreferencesUtils.THEME_KEY);
- if(amoledDarkSwitch != null) {
+ if (amoledDarkSwitch != null) {
amoledDarkSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
if((getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_NO) {
EventBus.getDefault().post(new RecreateActivityEvent());
@@ -62,7 +64,7 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
});
}
- if(immersiveInterfaceSwitch != null) {
+ if (immersiveInterfaceSwitch != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
immersiveInterfaceSwitch.setVisible(true);
immersiveInterfaceSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
@@ -74,6 +76,13 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
}
}
+ if (voteButtonsOnTheRightSwitch != null) {
+ voteButtonsOnTheRightSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
+ EventBus.getDefault().post(new ChangeVoteButtonsPositionEvent((Boolean) newValue));
+ return true;
+ });
+ }
+
if (nsfwSwitch != null) {
nsfwSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
EventBus.getDefault().post(new ChangeNSFWEvent((Boolean) newValue));
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java
index 334aff47..b11f4c32 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/SharedPreferencesUtils.java
@@ -29,6 +29,7 @@ public class SharedPreferencesUtils {
public static final String CONTENT_FONT_SIZE_KEY = "content_font_size";
public static final String AMOLED_DARK_KEY = "amoled_dark";
public static final String IMMERSIVE_INTERFACE_KEY = "immersive_interface";
+ public static final String VOTE_BUTTONS_ON_THE_RIGHT_KEY = "vote_buttons_on_the_right";
public static final String SORT_TYPE_BEST_POST = "sort_type_best_post";
public static final String SORT_TIME_BEST_POST = "sort_time_best_post";
public static final String SORT_TYPE_ALL_POST = "sort_type_all_post";