mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-25 02:18:23 +01:00
Setting default post layout is now available. Add an option to hide the divider in post compact layout.
This commit is contained in:
parent
b04ad8956d
commit
cb91543690
@ -3,10 +3,8 @@ package ml.docilealligator.infinityforreddit.Activity;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.ColorStateList;
|
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.graphics.Color;
|
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
@ -27,7 +25,6 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.appcompat.app.ActionBarDrawerToggle;
|
import androidx.appcompat.app.ActionBarDrawerToggle;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
import androidx.core.view.GravityCompat;
|
import androidx.core.view.GravityCompat;
|
||||||
import androidx.core.widget.NestedScrollView;
|
import androidx.core.widget.NestedScrollView;
|
||||||
import androidx.drawerlayout.widget.DrawerLayout;
|
import androidx.drawerlayout.widget.DrawerLayout;
|
||||||
@ -464,8 +461,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
|
|||||||
lp.setAnchorId(View.NO_ID);
|
lp.setAnchorId(View.NO_ID);
|
||||||
lp.gravity = Gravity.END | Gravity.BOTTOM;
|
lp.gravity = Gravity.END | Gravity.BOTTOM;
|
||||||
fab.setLayoutParams(lp);
|
fab.setLayoutParams(lp);
|
||||||
fab.setImageTintList(ColorStateList.valueOf(Color.WHITE));
|
|
||||||
fab.setBackgroundTintList(ColorStateList.valueOf(ContextCompat.getColor(this, R.color.backgroundColorPrimary)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fab.setVisibility(View.VISIBLE);
|
fab.setVisibility(View.VISIBLE);
|
||||||
|
@ -102,6 +102,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
private boolean mNeedBlurNSFW;
|
private boolean mNeedBlurNSFW;
|
||||||
private boolean mNeedBlurSpoiler;
|
private boolean mNeedBlurSpoiler;
|
||||||
private boolean mShowElapsedTime;
|
private boolean mShowElapsedTime;
|
||||||
|
private boolean mShowDividerInCompactLayout;
|
||||||
private NetworkState networkState;
|
private NetworkState networkState;
|
||||||
private Callback mCallback;
|
private Callback mCallback;
|
||||||
private ShareLinkBottomSheetFragment mShareLinkBottomSheetFragment;
|
private ShareLinkBottomSheetFragment mShareLinkBottomSheetFragment;
|
||||||
@ -110,7 +111,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
RedditDataRoomDatabase redditDataRoomDatabase, String accessToken,
|
RedditDataRoomDatabase redditDataRoomDatabase, String accessToken,
|
||||||
int postType, int postLayout, boolean displaySubredditName,
|
int postType, int postLayout, boolean displaySubredditName,
|
||||||
boolean needBlurNSFW, boolean needBlurSpoiler, boolean voteButtonsOnTheRight,
|
boolean needBlurNSFW, boolean needBlurSpoiler, boolean voteButtonsOnTheRight,
|
||||||
boolean showElapsedTime, Callback callback) {
|
boolean showElapsedTime, boolean showDividerInCompactLayout, Callback callback) {
|
||||||
super(DIFF_CALLBACK);
|
super(DIFF_CALLBACK);
|
||||||
if (activity != null) {
|
if (activity != null) {
|
||||||
mActivity = activity;
|
mActivity = activity;
|
||||||
@ -123,6 +124,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
mNeedBlurSpoiler = needBlurSpoiler;
|
mNeedBlurSpoiler = needBlurSpoiler;
|
||||||
mVoteButtonsOnTheRight = voteButtonsOnTheRight;
|
mVoteButtonsOnTheRight = voteButtonsOnTheRight;
|
||||||
mShowElapsedTime = showElapsedTime;
|
mShowElapsedTime = showElapsedTime;
|
||||||
|
mShowDividerInCompactLayout = showDividerInCompactLayout;
|
||||||
mPostLayout = postLayout;
|
mPostLayout = postLayout;
|
||||||
mGlide = Glide.with(mActivity.getApplicationContext());
|
mGlide = Glide.with(mActivity.getApplicationContext());
|
||||||
mRedditDataRoomDatabase = redditDataRoomDatabase;
|
mRedditDataRoomDatabase = redditDataRoomDatabase;
|
||||||
@ -891,6 +893,12 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
((PostCompactViewHolder) holder).postTimeTextView.setText(postTime);
|
((PostCompactViewHolder) holder).postTimeTextView.setText(postTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mShowDividerInCompactLayout) {
|
||||||
|
((PostCompactViewHolder) holder).divider.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
((PostCompactViewHolder) holder).divider.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
((PostCompactViewHolder) holder).titleTextView.setText(title);
|
((PostCompactViewHolder) holder).titleTextView.setText(title);
|
||||||
((PostCompactViewHolder) holder).scoreTextView.setText(Integer.toString(post.getScore() + post.getVoteType()));
|
((PostCompactViewHolder) holder).scoreTextView.setText(Integer.toString(post.getScore() + post.getVoteType()));
|
||||||
|
|
||||||
@ -1377,6 +1385,10 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
mShowElapsedTime = showElapsedTime;
|
mShowElapsedTime = showElapsedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setShowDividerInCompactLayout(boolean showDividerInCompactLayout) {
|
||||||
|
mShowDividerInCompactLayout = showDividerInCompactLayout;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean hasExtraRow() {
|
private boolean hasExtraRow() {
|
||||||
return networkState != null && networkState.getStatus() != NetworkState.Status.SUCCESS;
|
return networkState != null && networkState.getStatus() != NetworkState.Status.SUCCESS;
|
||||||
}
|
}
|
||||||
@ -1601,6 +1613,8 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
ImageView saveButton;
|
ImageView saveButton;
|
||||||
@BindView(R.id.share_button_item_post_compact)
|
@BindView(R.id.share_button_item_post_compact)
|
||||||
ImageView shareButton;
|
ImageView shareButton;
|
||||||
|
@BindView(R.id.divider_item_post_compact)
|
||||||
|
View divider;
|
||||||
|
|
||||||
PostCompactViewHolder(View itemView) {
|
PostCompactViewHolder(View itemView) {
|
||||||
super(itemView);
|
super(itemView);
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.Event;
|
||||||
|
|
||||||
|
public class ChangePostLayoutEvent {
|
||||||
|
public int postLayout;
|
||||||
|
|
||||||
|
public ChangePostLayoutEvent(int postLayout) {
|
||||||
|
this.postLayout = postLayout;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package ml.docilealligator.infinityforreddit.Event;
|
||||||
|
|
||||||
|
public class ShowDividerInCompactLayoutPreferenceEvent {
|
||||||
|
public boolean showDividerInCompactLayout;
|
||||||
|
|
||||||
|
public ShowDividerInCompactLayoutPreferenceEvent(boolean showDividerInCompactLayout) {
|
||||||
|
this.showDividerInCompactLayout = showDividerInCompactLayout;
|
||||||
|
}
|
||||||
|
}
|
@ -53,10 +53,12 @@ import ml.docilealligator.infinityforreddit.Activity.MainActivity;
|
|||||||
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
|
import ml.docilealligator.infinityforreddit.Activity.ViewSubredditDetailActivity;
|
||||||
import ml.docilealligator.infinityforreddit.Adapter.PostRecyclerViewAdapter;
|
import ml.docilealligator.infinityforreddit.Adapter.PostRecyclerViewAdapter;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent;
|
||||||
|
import ml.docilealligator.infinityforreddit.Event.ChangePostLayoutEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeShowElapsedTimeEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeShowElapsedTimeEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToPostList;
|
import ml.docilealligator.infinityforreddit.Event.PostUpdateEventToPostList;
|
||||||
|
import ml.docilealligator.infinityforreddit.Event.ShowDividerInCompactLayoutPreferenceEvent;
|
||||||
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
import ml.docilealligator.infinityforreddit.FragmentCommunicator;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.NetworkState;
|
import ml.docilealligator.infinityforreddit.NetworkState;
|
||||||
@ -318,6 +320,8 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
boolean needBlurSpoiler = mSharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_SPOILER_KEY, false);
|
boolean needBlurSpoiler = mSharedPreferences.getBoolean(SharedPreferencesUtils.BLUR_SPOILER_KEY, false);
|
||||||
boolean voteButtonsOnTheRight = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
|
boolean voteButtonsOnTheRight = mSharedPreferences.getBoolean(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY, false);
|
||||||
boolean showElapsedTime = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
|
boolean showElapsedTime = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY, false);
|
||||||
|
boolean showDividerInCompactLayout = mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_DIVIDER_IN_COMPACT_LAYOUT, true);
|
||||||
|
int defaultPostLayout = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY, "0"));
|
||||||
|
|
||||||
if (postType == PostDataSource.TYPE_SEARCH) {
|
if (postType == PostDataSource.TYPE_SEARCH) {
|
||||||
String subredditName = getArguments().getString(EXTRA_NAME);
|
String subredditName = getArguments().getString(EXTRA_NAME);
|
||||||
@ -326,11 +330,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
String sort = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, SortType.Type.RELEVANCE.name());
|
String sort = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SEARCH_POST, SortType.Type.RELEVANCE.name());
|
||||||
String sortTime = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SEARCH_POST, SortType.Time.ALL.name());
|
String sortTime = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SEARCH_POST, SortType.Time.ALL.name());
|
||||||
SortType sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
|
SortType sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
|
||||||
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, SharedPreferencesUtils.POST_LAYOUT_CARD);
|
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SEARCH_POST, defaultPostLayout);
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
||||||
accessToken, postType, postLayout, true, needBlurNsfw, needBlurSpoiler,
|
accessToken, postType, postLayout, true, needBlurNsfw, needBlurSpoiler,
|
||||||
voteButtonsOnTheRight, showElapsedTime, new PostRecyclerViewAdapter.Callback() {
|
voteButtonsOnTheRight, showElapsedTime, showDividerInCompactLayout, new PostRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void retryLoadingMore() {
|
public void retryLoadingMore() {
|
||||||
mPostViewModel.retryLoadingMore();
|
mPostViewModel.retryLoadingMore();
|
||||||
@ -369,20 +373,20 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
if(sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) {
|
if(sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) {
|
||||||
sortTime = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_POPULAR_POST, SortType.Time.ALL.name());
|
sortTime = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_POPULAR_POST, SortType.Time.ALL.name());
|
||||||
}
|
}
|
||||||
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_POPULAR_POST, SharedPreferencesUtils.POST_LAYOUT_CARD);
|
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_POPULAR_POST, defaultPostLayout);
|
||||||
} else {
|
} else {
|
||||||
sort = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_ALL_POST, SortType.Type.HOT.name());
|
sort = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_ALL_POST, SortType.Type.HOT.name());
|
||||||
if(sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) {
|
if(sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) {
|
||||||
sortTime = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_ALL_POST, SortType.Time.ALL.name());
|
sortTime = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_ALL_POST, SortType.Time.ALL.name());
|
||||||
}
|
}
|
||||||
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_ALL_POST, SharedPreferencesUtils.POST_LAYOUT_CARD);
|
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_ALL_POST, defaultPostLayout);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sort = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST, SortType.Type.HOT.name());
|
sort = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST, SortType.Type.HOT.name());
|
||||||
if(sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) {
|
if(sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) {
|
||||||
sortTime = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST, SortType.Time.ALL.name());
|
sortTime = mSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST, SortType.Time.ALL.name());
|
||||||
}
|
}
|
||||||
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + subredditName, SharedPreferencesUtils.POST_LAYOUT_CARD);
|
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_SUBREDDIT_POST_BASE + subredditName, defaultPostLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sortTime != null) {
|
if(sortTime != null) {
|
||||||
@ -393,7 +397,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
||||||
accessToken, postType, postLayout, displaySubredditName, needBlurNsfw, needBlurSpoiler,
|
accessToken, postType, postLayout, displaySubredditName, needBlurNsfw, needBlurSpoiler,
|
||||||
voteButtonsOnTheRight, showElapsedTime, new PostRecyclerViewAdapter.Callback() {
|
voteButtonsOnTheRight, showElapsedTime, showDividerInCompactLayout, new PostRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void retryLoadingMore() {
|
public void retryLoadingMore() {
|
||||||
mPostViewModel.retryLoadingMore();
|
mPostViewModel.retryLoadingMore();
|
||||||
@ -431,7 +435,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
SortType.Time.ALL.name());
|
SortType.Time.ALL.name());
|
||||||
}
|
}
|
||||||
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + multiRedditPath,
|
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_MULTI_REDDIT_POST_BASE + multiRedditPath,
|
||||||
SharedPreferencesUtils.POST_LAYOUT_CARD);
|
defaultPostLayout);
|
||||||
|
|
||||||
if(sortTime != null) {
|
if(sortTime != null) {
|
||||||
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
|
sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
|
||||||
@ -441,7 +445,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
||||||
accessToken, postType, postLayout, true, needBlurNsfw, needBlurSpoiler,
|
accessToken, postType, postLayout, true, needBlurNsfw, needBlurSpoiler,
|
||||||
voteButtonsOnTheRight, showElapsedTime, new PostRecyclerViewAdapter.Callback() {
|
voteButtonsOnTheRight, showElapsedTime, showDividerInCompactLayout, new PostRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void retryLoadingMore() {
|
public void retryLoadingMore() {
|
||||||
mPostViewModel.retryLoadingMore();
|
mPostViewModel.retryLoadingMore();
|
||||||
@ -483,11 +487,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
} else {
|
} else {
|
||||||
sortType = new SortType(SortType.Type.valueOf(sort));
|
sortType = new SortType(SortType.Type.valueOf(sort));
|
||||||
}
|
}
|
||||||
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, SharedPreferencesUtils.POST_LAYOUT_CARD);
|
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_USER_POST_BASE + username, defaultPostLayout);
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
||||||
accessToken, postType, postLayout, true, needBlurNsfw, needBlurSpoiler,
|
accessToken, postType, postLayout, true, needBlurNsfw, needBlurSpoiler,
|
||||||
voteButtonsOnTheRight, showElapsedTime, new PostRecyclerViewAdapter.Callback() {
|
voteButtonsOnTheRight, showElapsedTime, showDividerInCompactLayout, new PostRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void retryLoadingMore() {
|
public void retryLoadingMore() {
|
||||||
mPostViewModel.retryLoadingMore();
|
mPostViewModel.retryLoadingMore();
|
||||||
@ -522,11 +526,11 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
} else {
|
} else {
|
||||||
sortType = new SortType(SortType.Type.valueOf(sort));
|
sortType = new SortType(SortType.Type.valueOf(sort));
|
||||||
}
|
}
|
||||||
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, SharedPreferencesUtils.POST_LAYOUT_CARD);
|
postLayout = mSharedPreferences.getInt(SharedPreferencesUtils.POST_LAYOUT_FRONT_PAGE_POST, defaultPostLayout);
|
||||||
|
|
||||||
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
mAdapter = new PostRecyclerViewAdapter(activity, mOauthRetrofit, mRetrofit, mRedditDataRoomDatabase,
|
||||||
accessToken, postType, postLayout, true, needBlurNsfw, needBlurSpoiler,
|
accessToken, postType, postLayout, true, needBlurNsfw, needBlurSpoiler,
|
||||||
voteButtonsOnTheRight, showElapsedTime, new PostRecyclerViewAdapter.Callback() {
|
voteButtonsOnTheRight, showElapsedTime, showDividerInCompactLayout, new PostRecyclerViewAdapter.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void retryLoadingMore() {
|
public void retryLoadingMore() {
|
||||||
mPostViewModel.retryLoadingMore();
|
mPostViewModel.retryLoadingMore();
|
||||||
@ -754,6 +758,17 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
|
|||||||
refreshAdapter();
|
refreshAdapter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onChangePostLayoutEvent(ChangePostLayoutEvent event) {
|
||||||
|
changePostLayout(event.postLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onShowDividerInCompactLayoutPreferenceEvent(ShowDividerInCompactLayoutPreferenceEvent event) {
|
||||||
|
mAdapter.setShowDividerInCompactLayout(event.showDividerInCompactLayout);
|
||||||
|
refreshAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
private void refreshAdapter() {
|
private void refreshAdapter() {
|
||||||
int previousPosition = -1;
|
int previousPosition = -1;
|
||||||
if (mLinearLayoutManager != null) {
|
if (mLinearLayoutManager != null) {
|
||||||
|
@ -18,10 +18,12 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWBlurEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeNSFWEvent;
|
||||||
|
import ml.docilealligator.infinityforreddit.Event.ChangePostLayoutEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeShowElapsedTimeEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeShowElapsedTimeEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeSpoilerBlurEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent;
|
import ml.docilealligator.infinityforreddit.Event.ChangeVoteButtonsPositionEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
|
import ml.docilealligator.infinityforreddit.Event.RecreateActivityEvent;
|
||||||
|
import ml.docilealligator.infinityforreddit.Event.ShowDividerInCompactLayoutPreferenceEvent;
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
import ml.docilealligator.infinityforreddit.Utils.SharedPreferencesUtils;
|
||||||
@ -52,6 +54,8 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
|
|||||||
SwitchPreference bottomAppBarSwitch = findPreference(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY);
|
SwitchPreference bottomAppBarSwitch = findPreference(SharedPreferencesUtils.BOTTOM_APP_BAR_KEY);
|
||||||
SwitchPreference voteButtonsOnTheRightSwitch = findPreference(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY);
|
SwitchPreference voteButtonsOnTheRightSwitch = findPreference(SharedPreferencesUtils.VOTE_BUTTONS_ON_THE_RIGHT_KEY);
|
||||||
SwitchPreference showElapsedTimeSwitch = findPreference(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY);
|
SwitchPreference showElapsedTimeSwitch = findPreference(SharedPreferencesUtils.SHOW_ELAPSED_TIME_KEY);
|
||||||
|
ListPreference defaultPostLayoutSwitch = findPreference(SharedPreferencesUtils.DEFAULT_POST_LAYOUT_KEY);
|
||||||
|
SwitchPreference showDividerInCompactLayout = findPreference(SharedPreferencesUtils.SHOW_DIVIDER_IN_COMPACT_LAYOUT);
|
||||||
SwitchPreference nsfwSwitch = findPreference(SharedPreferencesUtils.NSFW_KEY);
|
SwitchPreference nsfwSwitch = findPreference(SharedPreferencesUtils.NSFW_KEY);
|
||||||
SwitchPreference blurNSFWSwitch = findPreference(SharedPreferencesUtils.BLUR_NSFW_KEY);
|
SwitchPreference blurNSFWSwitch = findPreference(SharedPreferencesUtils.BLUR_NSFW_KEY);
|
||||||
SwitchPreference blurSpoilerSwitch = findPreference(SharedPreferencesUtils.BLUR_SPOILER_KEY);
|
SwitchPreference blurSpoilerSwitch = findPreference(SharedPreferencesUtils.BLUR_SPOILER_KEY);
|
||||||
@ -100,6 +104,20 @@ public class MainPreferenceFragment extends PreferenceFragmentCompat {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (defaultPostLayoutSwitch != null) {
|
||||||
|
defaultPostLayoutSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
|
EventBus.getDefault().post(new ChangePostLayoutEvent(Integer.parseInt((String) newValue)));
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showDividerInCompactLayout != null) {
|
||||||
|
showDividerInCompactLayout.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
|
EventBus.getDefault().post(new ShowDividerInCompactLayoutPreferenceEvent((Boolean) newValue));
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (nsfwSwitch != null) {
|
if (nsfwSwitch != null) {
|
||||||
nsfwSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
|
nsfwSwitch.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||||
EventBus.getDefault().post(new ChangeNSFWEvent((Boolean) newValue));
|
EventBus.getDefault().post(new ChangeNSFWEvent((Boolean) newValue));
|
||||||
|
@ -62,6 +62,8 @@ public class SharedPreferencesUtils {
|
|||||||
public static final int POST_LAYOUT_COMPACT = 1;
|
public static final int POST_LAYOUT_COMPACT = 1;
|
||||||
public static final String PULL_NOTIFICATION_TIME = "pull_notification_time";
|
public static final String PULL_NOTIFICATION_TIME = "pull_notification_time";
|
||||||
public static final String SHOW_ELAPSED_TIME_KEY = "show_elapsed_time";
|
public static final String SHOW_ELAPSED_TIME_KEY = "show_elapsed_time";
|
||||||
|
public static final String DEFAULT_POST_LAYOUT_KEY = "default_post_layout";
|
||||||
|
public static final String SHOW_DIVIDER_IN_COMPACT_LAYOUT = "show_divider_in_compact_layout";
|
||||||
public static final String SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL = "swipe_to_go_back_from_post_detail";
|
public static final String SWIPE_RIGHT_TO_GO_BACK_FROM_POST_DETAIL = "swipe_to_go_back_from_post_detail";
|
||||||
public static final String VOLUME_KEYS_NAVIGATE_COMMENTS = "volume_keys_navigate_comments";
|
public static final String VOLUME_KEYS_NAVIGATE_COMMENTS = "volume_keys_navigate_comments";
|
||||||
public static final String VOLUME_KEYS_NAVIGATE_POSTS = "volume_keys_navigate_posts";
|
public static final String VOLUME_KEYS_NAVIGATE_POSTS = "volume_keys_navigate_posts";
|
||||||
|
@ -109,9 +109,9 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="@dimen/fab_margin"
|
android:layout_margin="@dimen/fab_margin"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
app:backgroundTint="?attr/backgroundColor"
|
app:backgroundTint="@color/backgroundColorPrimary"
|
||||||
app:srcCompat="@drawable/ic_add_bottom_app_bar_24dp"
|
app:srcCompat="@drawable/ic_add_bottom_app_bar_24dp"
|
||||||
app:tint="@null"
|
app:tint="@android:color/white"
|
||||||
app:layout_anchor="@id/bottom_navigation_main_activity" />
|
app:layout_anchor="@id/bottom_navigation_main_activity" />
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
@ -382,6 +382,7 @@
|
|||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
|
android:id="@+id/divider_item_post_compact"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1dp"
|
android:layout_height="1dp"
|
||||||
android:background="@color/dividerColor" />
|
android:background="@color/dividerColor" />
|
||||||
|
@ -37,6 +37,16 @@
|
|||||||
<item>2</item>
|
<item>2</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="settings_default_post_layout">
|
||||||
|
<item>Card Layout</item>
|
||||||
|
<item>Compact Layout</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<string-array name="settings_default_post_layout_values">
|
||||||
|
<item>0</item>
|
||||||
|
<item>1</item>
|
||||||
|
</string-array>
|
||||||
|
|
||||||
<string-array name="settings_lazy_mode_interval">
|
<string-array name="settings_lazy_mode_interval">
|
||||||
<item>1s</item>
|
<item>1s</item>
|
||||||
<item>2s</item>
|
<item>2s</item>
|
||||||
|
@ -300,6 +300,8 @@
|
|||||||
<string name="settings_volume_keys_navigate_posts_title">Use Volume Keys to Navigate Posts</string>
|
<string name="settings_volume_keys_navigate_posts_title">Use Volume Keys to Navigate Posts</string>
|
||||||
<string name="settings_mute_video_title">Mute Video</string>
|
<string name="settings_mute_video_title">Mute Video</string>
|
||||||
<string name="settings_show_elapsed_time">Show Elapsed Time in Posts and Comments</string>
|
<string name="settings_show_elapsed_time">Show Elapsed Time in Posts and Comments</string>
|
||||||
|
<string name="settings_default_post_layout">Default Post Layout</string>
|
||||||
|
<string name="settings_show_divider_in_compact_layout">Show Divider in Compact Layout</string>
|
||||||
<string name="swipe_to_go_back_from_post_detail">Swipe Right to Go Back From Comments</string>
|
<string name="swipe_to_go_back_from_post_detail">Swipe Right to Go Back From Comments</string>
|
||||||
<string name="settings_lazy_mode_interval_title">Lazy Mode Interval</string>
|
<string name="settings_lazy_mode_interval_title">Lazy Mode Interval</string>
|
||||||
<string name="settings_font_size_title">Font Size</string>
|
<string name="settings_font_size_title">Font Size</string>
|
||||||
|
@ -41,6 +41,24 @@
|
|||||||
app:key="show_elapsed_time"
|
app:key="show_elapsed_time"
|
||||||
app:title="@string/settings_show_elapsed_time" />
|
app:title="@string/settings_show_elapsed_time" />
|
||||||
|
|
||||||
|
<ListPreference
|
||||||
|
app:defaultValue="0"
|
||||||
|
android:entries="@array/settings_default_post_layout"
|
||||||
|
app:entryValues="@array/settings_default_post_layout_values"
|
||||||
|
app:key="default_post_layout"
|
||||||
|
app:title="@string/settings_default_post_layout"
|
||||||
|
app:useSimpleSummaryProvider="true" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
app:defaultValue="true"
|
||||||
|
app:key="show_divider_in_compact_layout"
|
||||||
|
app:title="@string/settings_show_divider_in_compact_layout" />
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
app:defaultValue="true"
|
||||||
|
app:key="swipe_to_go_back_from_post_detail"
|
||||||
|
app:title="@string/swipe_to_go_back_from_post_detail" />
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
app:defaultValue="true"
|
app:defaultValue="true"
|
||||||
app:key="swipe_to_go_back_from_post_detail"
|
app:key="swipe_to_go_back_from_post_detail"
|
||||||
|
Loading…
Reference in New Issue
Block a user