From 168456f57ccd80a52c7d95761b1df6827d0b90c8 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Tue, 29 Oct 2019 11:20:16 +0800 Subject: Make Placing vote buttons on the right an option. --- .../Activity/ViewPostDetailActivity.java | 38 +++---- .../Adapter/CommentAndPostRecyclerViewAdapter.java | 67 ++++++++----- .../CommentsListingRecyclerViewAdapter.java | 12 +-- .../Adapter/PostRecyclerViewAdapter.java | 47 +++++++-- .../Event/ChangeVoteButtonsPositionEvent.java | 9 ++ .../infinityforreddit/Fragment/PostFragment.java | 16 ++- .../Settings/MainPreferenceFragment.java | 13 ++- .../infinityforreddit/SharedPreferencesUtils.java | 1 + .../drawable-hdpi/ic_arrow_downward_black_24dp.png | Bin 185 -> 0 bytes .../drawable-hdpi/ic_arrow_upward_black_24dp.png | Bin 197 -> 0 bytes .../drawable-mdpi/ic_arrow_downward_black_24dp.png | Bin 142 -> 0 bytes .../drawable-mdpi/ic_arrow_upward_black_24dp.png | Bin 147 -> 0 bytes .../ic_arrow_downward_black_24dp.png | Bin 221 -> 0 bytes .../drawable-xhdpi/ic_arrow_upward_black_24dp.png | Bin 204 -> 0 bytes .../ic_arrow_downward_black_24dp.png | Bin 283 -> 0 bytes .../drawable-xxhdpi/ic_arrow_upward_black_24dp.png | Bin 302 -> 0 bytes .../ic_arrow_downward_black_24dp.png | Bin 376 -> 0 bytes .../ic_arrow_upward_black_24dp.png | Bin 341 -> 0 bytes .../res/drawable/ic_arrow_downward_black_22dp.xml | 4 - .../res/drawable/ic_arrow_downward_black_24dp.xml | 9 ++ .../res/drawable/ic_arrow_downward_grey_24dp.xml | 9 ++ .../res/drawable/ic_arrow_upward_black_22dp.xml | 4 - .../res/drawable/ic_arrow_upward_black_24dp.xml | 9 ++ .../res/drawable/ic_arrow_upward_grey_24dp.xml | 9 ++ .../res/drawable/ic_baseline_bookmark_24px.xml | 9 -- .../drawable/ic_baseline_bookmark_border_24px.xml | 9 -- app/src/main/res/drawable/ic_bookmark_20dp.xml | 4 - .../main/res/drawable/ic_bookmark_black_24dp.xml | 9 ++ .../main/res/drawable/ic_bookmark_border_20dp.xml | 4 - .../res/drawable/ic_bookmark_border_black_24dp.xml | 9 ++ .../res/drawable/ic_bookmark_border_grey_24dp.xml | 9 ++ .../main/res/drawable/ic_bookmark_grey_24dp.xml | 9 ++ app/src/main/res/drawable/ic_comment_grey_24dp.xml | 9 ++ .../res/drawable/ic_expand_less_black_22dp.xml | 4 - .../main/res/drawable/ic_expand_less_grey_24dp.xml | 4 + .../res/drawable/ic_expand_more_black_20dp.xml | 4 - .../main/res/drawable/ic_expand_more_grey_24dp.xml | 4 + .../main/res/drawable/ic_more_vert_grey_24dp.xml | 9 ++ .../res/drawable/ic_outline_more_vert_24px.xml | 9 -- .../main/res/drawable/ic_outline_share_20px.xml | 4 - .../main/res/drawable/ic_outline_share_24px.xml | 9 -- app/src/main/res/drawable/ic_reply_black_20dp.xml | 4 - app/src/main/res/drawable/ic_reply_grey_24dp.xml | 4 + app/src/main/res/drawable/ic_share_grey_24dp.xml | 9 ++ app/src/main/res/layout/item_comment.xml | 16 ++- app/src/main/res/layout/item_post.xml | 110 +++++++++++++++++---- app/src/main/res/layout/item_post_detail.xml | 91 +++-------------- app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/main_preferences.xml | 16 ++- 49 files changed, 377 insertions(+), 239 deletions(-) create mode 100644 app/src/main/java/ml/docilealligator/infinityforreddit/Event/ChangeVoteButtonsPositionEvent.java delete mode 100644 app/src/main/res/drawable-hdpi/ic_arrow_downward_black_24dp.png delete mode 100644 app/src/main/res/drawable-hdpi/ic_arrow_upward_black_24dp.png delete mode 100644 app/src/main/res/drawable-mdpi/ic_arrow_downward_black_24dp.png delete mode 100644 app/src/main/res/drawable-mdpi/ic_arrow_upward_black_24dp.png delete mode 100644 app/src/main/res/drawable-xhdpi/ic_arrow_downward_black_24dp.png delete mode 100644 app/src/main/res/drawable-xhdpi/ic_arrow_upward_black_24dp.png delete mode 100644 app/src/main/res/drawable-xxhdpi/ic_arrow_downward_black_24dp.png delete mode 100644 app/src/main/res/drawable-xxhdpi/ic_arrow_upward_black_24dp.png delete mode 100644 app/src/main/res/drawable-xxxhdpi/ic_arrow_downward_black_24dp.png delete mode 100644 app/src/main/res/drawable-xxxhdpi/ic_arrow_upward_black_24dp.png delete mode 100644 app/src/main/res/drawable/ic_arrow_downward_black_22dp.xml create mode 100644 app/src/main/res/drawable/ic_arrow_downward_black_24dp.xml create mode 100644 app/src/main/res/drawable/ic_arrow_downward_grey_24dp.xml delete mode 100644 app/src/main/res/drawable/ic_arrow_upward_black_22dp.xml create mode 100644 app/src/main/res/drawable/ic_arrow_upward_black_24dp.xml create mode 100644 app/src/main/res/drawable/ic_arrow_upward_grey_24dp.xml delete mode 100644 app/src/main/res/drawable/ic_baseline_bookmark_24px.xml delete mode 100644 app/src/main/res/drawable/ic_baseline_bookmark_border_24px.xml delete mode 100644 app/src/main/res/drawable/ic_bookmark_20dp.xml create mode 100644 app/src/main/res/drawable/ic_bookmark_black_24dp.xml delete mode 100644 app/src/main/res/drawable/ic_bookmark_border_20dp.xml create mode 100644 app/src/main/res/drawable/ic_bookmark_border_black_24dp.xml create mode 100644 app/src/main/res/drawable/ic_bookmark_border_grey_24dp.xml create mode 100644 app/src/main/res/drawable/ic_bookmark_grey_24dp.xml create mode 100644 app/src/main/res/drawable/ic_comment_grey_24dp.xml delete mode 100644 app/src/main/res/drawable/ic_expand_less_black_22dp.xml create mode 100644 app/src/main/res/drawable/ic_expand_less_grey_24dp.xml delete mode 100644 app/src/main/res/drawable/ic_expand_more_black_20dp.xml create mode 100644 app/src/main/res/drawable/ic_expand_more_grey_24dp.xml create mode 100644 app/src/main/res/drawable/ic_more_vert_grey_24dp.xml delete mode 100644 app/src/main/res/drawable/ic_outline_more_vert_24px.xml delete mode 100644 app/src/main/res/drawable/ic_outline_share_20px.xml delete mode 100644 app/src/main/res/drawable/ic_outline_share_24px.xml delete mode 100644 app/src/main/res/drawable/ic_reply_black_20dp.xml create mode 100644 app/src/main/res/drawable/ic_reply_grey_24dp.xml create mode 100644 app/src/main/res/drawable/ic_share_grey_24dp.xml 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 { + ((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 { @@ -521,13 +525,13 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter { @@ -851,14 +855,14 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter { @@ -307,14 +307,14 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter { @@ -627,13 +631,13 @@ public class PostRecyclerViewAdapter extends PagedListAdapter { //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(); @@ -625,6 +627,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); 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"; diff --git a/app/src/main/res/drawable-hdpi/ic_arrow_downward_black_24dp.png b/app/src/main/res/drawable-hdpi/ic_arrow_downward_black_24dp.png deleted file mode 100644 index b848197a..00000000 Binary files a/app/src/main/res/drawable-hdpi/ic_arrow_downward_black_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-hdpi/ic_arrow_upward_black_24dp.png b/app/src/main/res/drawable-hdpi/ic_arrow_upward_black_24dp.png deleted file mode 100644 index 705f7ae8..00000000 Binary files a/app/src/main/res/drawable-hdpi/ic_arrow_upward_black_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/ic_arrow_downward_black_24dp.png b/app/src/main/res/drawable-mdpi/ic_arrow_downward_black_24dp.png deleted file mode 100644 index 3cc4b130..00000000 Binary files a/app/src/main/res/drawable-mdpi/ic_arrow_downward_black_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/ic_arrow_upward_black_24dp.png b/app/src/main/res/drawable-mdpi/ic_arrow_upward_black_24dp.png deleted file mode 100644 index 368eb65f..00000000 Binary files a/app/src/main/res/drawable-mdpi/ic_arrow_upward_black_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/ic_arrow_downward_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_arrow_downward_black_24dp.png deleted file mode 100644 index 3c147bc5..00000000 Binary files a/app/src/main/res/drawable-xhdpi/ic_arrow_downward_black_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/ic_arrow_upward_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_arrow_upward_black_24dp.png deleted file mode 100644 index f2b35ac2..00000000 Binary files a/app/src/main/res/drawable-xhdpi/ic_arrow_upward_black_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_arrow_downward_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_arrow_downward_black_24dp.png deleted file mode 100644 index ace750c4..00000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_arrow_downward_black_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_arrow_upward_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_arrow_upward_black_24dp.png deleted file mode 100644 index 99622e7c..00000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_arrow_upward_black_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_arrow_downward_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_arrow_downward_black_24dp.png deleted file mode 100644 index 2690b202..00000000 Binary files a/app/src/main/res/drawable-xxxhdpi/ic_arrow_downward_black_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_arrow_upward_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_arrow_upward_black_24dp.png deleted file mode 100644 index fca5022c..00000000 Binary files a/app/src/main/res/drawable-xxxhdpi/ic_arrow_upward_black_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable/ic_arrow_downward_black_22dp.xml b/app/src/main/res/drawable/ic_arrow_downward_black_22dp.xml deleted file mode 100644 index c6c587c6..00000000 --- a/app/src/main/res/drawable/ic_arrow_downward_black_22dp.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_arrow_downward_black_24dp.xml b/app/src/main/res/drawable/ic_arrow_downward_black_24dp.xml new file mode 100644 index 00000000..dd7522fd --- /dev/null +++ b/app/src/main/res/drawable/ic_arrow_downward_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_arrow_downward_grey_24dp.xml b/app/src/main/res/drawable/ic_arrow_downward_grey_24dp.xml new file mode 100644 index 00000000..bc5c4cf5 --- /dev/null +++ b/app/src/main/res/drawable/ic_arrow_downward_grey_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_arrow_upward_black_22dp.xml b/app/src/main/res/drawable/ic_arrow_upward_black_22dp.xml deleted file mode 100644 index 150d5218..00000000 --- a/app/src/main/res/drawable/ic_arrow_upward_black_22dp.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_arrow_upward_black_24dp.xml b/app/src/main/res/drawable/ic_arrow_upward_black_24dp.xml new file mode 100644 index 00000000..fb30b2cb --- /dev/null +++ b/app/src/main/res/drawable/ic_arrow_upward_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_arrow_upward_grey_24dp.xml b/app/src/main/res/drawable/ic_arrow_upward_grey_24dp.xml new file mode 100644 index 00000000..e370580a --- /dev/null +++ b/app/src/main/res/drawable/ic_arrow_upward_grey_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_baseline_bookmark_24px.xml b/app/src/main/res/drawable/ic_baseline_bookmark_24px.xml deleted file mode 100644 index a7ff3655..00000000 --- a/app/src/main/res/drawable/ic_baseline_bookmark_24px.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_baseline_bookmark_border_24px.xml b/app/src/main/res/drawable/ic_baseline_bookmark_border_24px.xml deleted file mode 100644 index 71382d27..00000000 --- a/app/src/main/res/drawable/ic_baseline_bookmark_border_24px.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_bookmark_20dp.xml b/app/src/main/res/drawable/ic_bookmark_20dp.xml deleted file mode 100644 index 6908d298..00000000 --- a/app/src/main/res/drawable/ic_bookmark_20dp.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_bookmark_black_24dp.xml b/app/src/main/res/drawable/ic_bookmark_black_24dp.xml new file mode 100644 index 00000000..a7ff3655 --- /dev/null +++ b/app/src/main/res/drawable/ic_bookmark_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_bookmark_border_20dp.xml b/app/src/main/res/drawable/ic_bookmark_border_20dp.xml deleted file mode 100644 index d77b4ce5..00000000 --- a/app/src/main/res/drawable/ic_bookmark_border_20dp.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_bookmark_border_black_24dp.xml b/app/src/main/res/drawable/ic_bookmark_border_black_24dp.xml new file mode 100644 index 00000000..71382d27 --- /dev/null +++ b/app/src/main/res/drawable/ic_bookmark_border_black_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_bookmark_border_grey_24dp.xml b/app/src/main/res/drawable/ic_bookmark_border_grey_24dp.xml new file mode 100644 index 00000000..377a705f --- /dev/null +++ b/app/src/main/res/drawable/ic_bookmark_border_grey_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_bookmark_grey_24dp.xml b/app/src/main/res/drawable/ic_bookmark_grey_24dp.xml new file mode 100644 index 00000000..3f4a6dd4 --- /dev/null +++ b/app/src/main/res/drawable/ic_bookmark_grey_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_comment_grey_24dp.xml b/app/src/main/res/drawable/ic_comment_grey_24dp.xml new file mode 100644 index 00000000..93d143c8 --- /dev/null +++ b/app/src/main/res/drawable/ic_comment_grey_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_expand_less_black_22dp.xml b/app/src/main/res/drawable/ic_expand_less_black_22dp.xml deleted file mode 100644 index f7a3985f..00000000 --- a/app/src/main/res/drawable/ic_expand_less_black_22dp.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_expand_less_grey_24dp.xml b/app/src/main/res/drawable/ic_expand_less_grey_24dp.xml new file mode 100644 index 00000000..6e5840db --- /dev/null +++ b/app/src/main/res/drawable/ic_expand_less_grey_24dp.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_expand_more_black_20dp.xml b/app/src/main/res/drawable/ic_expand_more_black_20dp.xml deleted file mode 100644 index 2e1e234a..00000000 --- a/app/src/main/res/drawable/ic_expand_more_black_20dp.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_expand_more_grey_24dp.xml b/app/src/main/res/drawable/ic_expand_more_grey_24dp.xml new file mode 100644 index 00000000..71b8f17a --- /dev/null +++ b/app/src/main/res/drawable/ic_expand_more_grey_24dp.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_more_vert_grey_24dp.xml b/app/src/main/res/drawable/ic_more_vert_grey_24dp.xml new file mode 100644 index 00000000..69c1029e --- /dev/null +++ b/app/src/main/res/drawable/ic_more_vert_grey_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_outline_more_vert_24px.xml b/app/src/main/res/drawable/ic_outline_more_vert_24px.xml deleted file mode 100644 index 568cbb4d..00000000 --- a/app/src/main/res/drawable/ic_outline_more_vert_24px.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_outline_share_20px.xml b/app/src/main/res/drawable/ic_outline_share_20px.xml deleted file mode 100644 index 52eda61c..00000000 --- a/app/src/main/res/drawable/ic_outline_share_20px.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_outline_share_24px.xml b/app/src/main/res/drawable/ic_outline_share_24px.xml deleted file mode 100644 index 82ddcec3..00000000 --- a/app/src/main/res/drawable/ic_outline_share_24px.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_reply_black_20dp.xml b/app/src/main/res/drawable/ic_reply_black_20dp.xml deleted file mode 100644 index 1dd3dfed..00000000 --- a/app/src/main/res/drawable/ic_reply_black_20dp.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_reply_grey_24dp.xml b/app/src/main/res/drawable/ic_reply_grey_24dp.xml new file mode 100644 index 00000000..979f0eb2 --- /dev/null +++ b/app/src/main/res/drawable/ic_reply_grey_24dp.xml @@ -0,0 +1,4 @@ + + + diff --git a/app/src/main/res/drawable/ic_share_grey_24dp.xml b/app/src/main/res/drawable/ic_share_grey_24dp.xml new file mode 100644 index 00000000..86f0e234 --- /dev/null +++ b/app/src/main/res/drawable/ic_share_grey_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/layout/item_comment.xml b/app/src/main/res/layout/item_comment.xml index 3c1a3330..1e594578 100644 --- a/app/src/main/res/layout/item_comment.xml +++ b/app/src/main/res/layout/item_comment.xml @@ -83,7 +83,7 @@ android:background="?actionBarItemBackground" android:clickable="true" android:focusable="true" - android:src="@drawable/ic_arrow_upward_black_22dp" + android:src="@drawable/ic_arrow_upward_grey_24dp" android:tint="@android:color/tab_indicator_text" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" @@ -110,7 +110,7 @@ android:background="?actionBarItemBackground" android:clickable="true" android:focusable="true" - android:src="@drawable/ic_arrow_downward_black_22dp" + android:src="@drawable/ic_arrow_downward_grey_24dp" android:tint="@android:color/tab_indicator_text" app:layout_constraintStart_toEndOf="@+id/score_text_view_item_post_comment" app:layout_constraintEnd_toStartOf="@id/more_button_item_post_comment" @@ -126,8 +126,7 @@ android:background="?actionBarItemBackground" android:clickable="true" android:focusable="true" - android:src="@drawable/ic_outline_more_vert_24px" - android:tint="@android:color/tab_indicator_text" + android:src="@drawable/ic_more_vert_grey_24dp" android:visibility="gone" app:layout_constraintEnd_toStartOf="@+id/expand_button_item_post_comment" app:layout_constraintTop_toTopOf="parent" @@ -141,7 +140,7 @@ android:background="?actionBarItemBackground" android:clickable="true" android:focusable="true" - android:src="@drawable/ic_expand_less_black_22dp" + android:src="@drawable/ic_expand_less_grey_24dp" android:tint="@android:color/tab_indicator_text" android:visibility="gone" app:layout_constraintEnd_toStartOf="@+id/save_button_item_post_comment" @@ -156,7 +155,6 @@ android:background="?actionBarItemBackground" android:clickable="true" android:focusable="true" - android:tint="@android:color/tab_indicator_text" app:layout_constraintEnd_toStartOf="@+id/share_button_item_post_comment" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent"/> @@ -169,8 +167,7 @@ android:background="?actionBarItemBackground" android:clickable="true" android:focusable="true" - android:src="@drawable/ic_outline_share_20px" - android:tint="@android:color/tab_indicator_text" + android:src="@drawable/ic_share_grey_24dp" app:layout_constraintEnd_toStartOf="@+id/reply_button_item_post_comment" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent"/> @@ -183,8 +180,7 @@ android:background="?actionBarItemBackground" android:clickable="true" android:focusable="true" - android:src="@drawable/ic_reply_black_20dp" - android:tint="@android:color/tab_indicator_text" + android:src="@drawable/ic_reply_grey_24dp" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent"/> diff --git a/app/src/main/res/layout/item_post.xml b/app/src/main/res/layout/item_post.xml index c702e529..5733f9c5 100644 --- a/app/src/main/res/layout/item_post.xml +++ b/app/src/main/res/layout/item_post.xml @@ -256,7 +256,7 @@ android:background="@color/grey" android:visibility="gone"/> - @@ -265,69 +265,147 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="12dp" - android:src="@drawable/ic_arrow_upward_black_24dp" + android:src="@drawable/ic_arrow_upward_grey_24dp" android:tint="@android:color/tab_indicator_text" android:background="?actionBarItemBackground" android:clickable="true" android:focusable="true" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintStart_toStartOf="parent" /> + app:layout_constraintEnd_toStartOf="@id/score_text_view_item_post" /> + app:layout_constraintEnd_toStartOf="@id/minus_button_item_post" /> + app:layout_constraintEnd_toEndOf="parent" /> + + + app:layout_constraintStart_toEndOf="@id/share_button_item_post" /> + + + + --> + + + + + + + + + app:layout_constraintStart_toEndOf="@id/minus_button_item_post" /> + app:layout_constraintEnd_toEndOf="parent" /> diff --git a/app/src/main/res/layout/item_post_detail.xml b/app/src/main/res/layout/item_post_detail.xml index 9d7b574b..338975e4 100644 --- a/app/src/main/res/layout/item_post_detail.xml +++ b/app/src/main/res/layout/item_post_detail.xml @@ -248,70 +248,17 @@ android:tint="@android:color/tab_indicator_text" android:visibility="gone" /> - - + android:layout_height="wrap_content" + android:id="@+id/bottom_constraint_layout_item_post_detail"> - - + app:layout_constraintStart_toEndOf="@id/minus_button_item_post_detail" /> + app:layout_constraintEnd_toEndOf="parent" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index c0071a81..d8dc8b01 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -287,6 +287,7 @@ Device default Amoled Dark Immersive Interface + Vote Buttons on the Right Lazy Mode Interval Font Size Title Font Size diff --git a/app/src/main/res/xml/main_preferences.xml b/app/src/main/res/xml/main_preferences.xml index 5f3925f4..575dfd38 100644 --- a/app/src/main/res/xml/main_preferences.xml +++ b/app/src/main/res/xml/main_preferences.xml @@ -26,6 +26,17 @@ app:title="@string/settings_immersive_interface_title" app:isPreferenceVisible="false" /> + + + + - -