From ae389527b6db51263b0796b9f4d00c554327291b Mon Sep 17 00:00:00 2001 From: Balazs Toldi Date: Fri, 21 Jun 2024 21:19:31 +0200 Subject: [PATCH] Removed "Community Recommended Sort type" option Caused some issues, described in #151. Also, this is not a feature in Lemmy, should have been removed anyway. --- .../fragments/ViewPostDetailFragment.java | 59 ++----------------- .../utils/SharedPreferencesUtils.java | 1 - .../main/res/xml/sort_type_preferences.xml | 6 -- 3 files changed, 5 insertions(+), 61 deletions(-) diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/fragments/ViewPostDetailFragment.java b/app/src/main/java/eu/toldi/infinityforlemmy/fragments/ViewPostDetailFragment.java index ded575d8..10b9a417 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/fragments/ViewPostDetailFragment.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/fragments/ViewPostDetailFragment.java @@ -228,8 +228,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic int mMessageFullname; @State SortType.Type sortType; - @State - boolean mRespectSubredditRecommendedSortType; + @State long viewPostDetailFragmentId; @State @@ -333,7 +332,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic mExpandChildren = !mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_TOP_LEVEL_COMMENTS_FIRST, false); mMarkPostsAsRead = mPostHistorySharedPreferences.getBoolean(mAccountName + SharedPreferencesUtils.MARK_POSTS_AS_READ_BASE, false); if (savedInstanceState == null) { - mRespectSubredditRecommendedSortType = mSharedPreferences.getBoolean(SharedPreferencesUtils.RESPECT_SUBREDDIT_RECOMMENDED_COMMENT_SORT_TYPE, false); viewPostDetailFragmentId = System.currentTimeMillis(); } else { scrollPosition = savedInstanceState.getInt(SCROLL_POSITION_STATE); @@ -577,7 +575,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic } mMessageFullname = getArguments().getInt(EXTRA_MESSAGE_FULLNAME); - if (!mRespectSubredditRecommendedSortType || isSingleCommentThreadMode) { + if (isSingleCommentThreadMode) { sortType = loadSortType(); activity.setTitle(sortType.fullName); } @@ -824,8 +822,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic if (mSharedPreferences.getBoolean(SharedPreferencesUtils.SAVE_SORT_TYPE, true)) { mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_POST_COMMENT, sortType.getType().name()).apply(); } - mRespectSubredditRecommendedSortType = false; - fetchCommentsRespectRecommendedSort(false, sortType.getType()); + fetchComments(false, sortType.getType()); } @NonNull @@ -1400,9 +1397,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic mRecyclerView.setAdapter(mConcatAdapter); } - if (mRespectSubredditRecommendedSortType) { - fetchCommentsRespectRecommendedSort(false); - } + ViewPostDetailFragment.this.children = children; } @@ -1427,49 +1422,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic } - private void fetchCommentsRespectRecommendedSort(boolean changeRefreshState, SortType.Type sortType) { - if (mRespectSubredditRecommendedSortType && mPost != null) { - if (mPost.getSuggestedSort() != null && !mPost.getSuggestedSort().equals("null") && !mPost.getSuggestedSort().equals("")) { - try { - SortType.Type sortTypeType = SortType.Type.valueOf(mPost.getSuggestedSort().toUpperCase(Locale.US)); - activity.setTitle(sortTypeType.fullName); - ViewPostDetailFragment.this.sortType = sortTypeType; - fetchComments(changeRefreshState, ViewPostDetailFragment.this.sortType); - return; - } catch (IllegalArgumentException e) { - e.printStackTrace(); - } - } - FetchSubredditData.fetchSubredditData(mRetrofit.getRetrofit(), mPost.getSubredditNamePrefixed(), mAccessToken, - new FetchSubredditData.FetchSubredditDataListener() { - @Override - public void onFetchSubredditDataSuccess(SubredditData subredditData, int nCurrentOnlineSubscribers) { - String suggestedCommentSort = "top"; - SortType.Type sortTypeType; - try { - sortTypeType = SortType.Type.fromValue(suggestedCommentSort); - } catch (IllegalArgumentException e) { - e.printStackTrace(); - sortTypeType = loadSortType(); - } - activity.setTitle(sortTypeType.fullName); - ViewPostDetailFragment.this.sortType = sortTypeType; - fetchComments(changeRefreshState, ViewPostDetailFragment.this.sortType); - } - - @Override - public void onFetchSubredditDataFail(boolean isQuarantined) { - mRespectSubredditRecommendedSortType = false; - SortType.Type sortTypeType = loadSortType(); - activity.setTitle(sortTypeType.fullName); - ViewPostDetailFragment.this.sortType = sortTypeType; - } - }); - } else { - fetchComments(changeRefreshState, sortType); - } - } - private void fetchComments(boolean changeRefreshState, SortType.Type sortType) { isFetchingComments = true; mCommentsAdapter.setSingleComment(mSingleCommentId, isSingleCommentThreadMode); @@ -1559,7 +1511,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic } private void fetchCommentsRespectRecommendedSort(boolean changeRefreshState) { - fetchCommentsRespectRecommendedSort(changeRefreshState, sortType); + fetchComments(changeRefreshState, sortType); } void fetchMoreComments() { @@ -1783,7 +1735,6 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic isSingleCommentThreadMode = false; mSingleCommentId = null; mSingleCommentParentId = null; - mRespectSubredditRecommendedSortType = mSharedPreferences.getBoolean(SharedPreferencesUtils.RESPECT_SUBREDDIT_RECOMMENDED_COMMENT_SORT_TYPE, false); refresh(false, true); } diff --git a/app/src/main/java/eu/toldi/infinityforlemmy/utils/SharedPreferencesUtils.java b/app/src/main/java/eu/toldi/infinityforlemmy/utils/SharedPreferencesUtils.java index 63300961..d96bbe68 100644 --- a/app/src/main/java/eu/toldi/infinityforlemmy/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/eu/toldi/infinityforlemmy/utils/SharedPreferencesUtils.java @@ -172,7 +172,6 @@ public class SharedPreferencesUtils { public static final String DATA_SAVING_MODE_ONLY_ON_CELLULAR_DATA = "1"; public static final String DATA_SAVING_MODE_ALWAYS = "2"; public static final String NATIONAL_FLAGS = "national_flags"; - public static final String RESPECT_SUBREDDIT_RECOMMENDED_COMMENT_SORT_TYPE = "respect_subreddit_recommended_comment_sort_type"; public static final String UFO_CAPTURING_ANIMATION = "ufo_capturing_animation"; public static final String HIDE_SUBREDDIT_DESCRIPTION = "hide_subreddit_description"; public static final String DISABLE_IMAGE_PREVIEW = "disable_image_preview"; diff --git a/app/src/main/res/xml/sort_type_preferences.xml b/app/src/main/res/xml/sort_type_preferences.xml index 85d0c98f..52b65812 100644 --- a/app/src/main/res/xml/sort_type_preferences.xml +++ b/app/src/main/res/xml/sort_type_preferences.xml @@ -38,10 +38,4 @@ app:title="@string/settings_user_default_sort_time_title" app:useSimpleSummaryProvider="true" /> - - \ No newline at end of file