From 3d374491b344a77c5bb55d34ce5a86e6e50f5f58 Mon Sep 17 00:00:00 2001 From: Docile-Alligator Date: Sat, 30 Apr 2022 17:56:31 +0800 Subject: targetSdkVersion 31. Fix sort type problems in anonymous home page and multireddits. --- .../activities/FilteredPostsActivity.java | 26 ++++++---------------- .../activities/SubscribedThingListingActivity.java | 2 +- .../infinityforreddit/fragments/PostFragment.java | 13 ++++++++--- 3 files changed, 18 insertions(+), 23 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java index cadadd68..804197e5 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java @@ -371,26 +371,14 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag()); break; case PostPagingSource.TYPE_SUBREDDIT: - if (name.equals("popular") || name.equals("all")) { - SortTypeBottomSheetFragment popularAndAllSortTypeBottomSheetFragment = new SortTypeBottomSheetFragment(); - Bundle popularBundle = new Bundle(); - popularBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true); - popularAndAllSortTypeBottomSheetFragment.setArguments(popularBundle); - popularAndAllSortTypeBottomSheetFragment.show(getSupportFragmentManager(), popularAndAllSortTypeBottomSheetFragment.getTag()); - } else { - SortTypeBottomSheetFragment subredditSortTypeBottomSheetFragment = new SortTypeBottomSheetFragment(); - Bundle subredditSheetBundle = new Bundle(); - subredditSheetBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true); - subredditSortTypeBottomSheetFragment.setArguments(subredditSheetBundle); - subredditSortTypeBottomSheetFragment.show(getSupportFragmentManager(), subredditSortTypeBottomSheetFragment.getTag()); - } - break; case PostPagingSource.TYPE_MULTI_REDDIT: - SortTypeBottomSheetFragment multiRedditSortTypeBottomSheetFragment = new SortTypeBottomSheetFragment(); - Bundle multiRedditBundle = new Bundle(); - multiRedditBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true); - multiRedditSortTypeBottomSheetFragment.setArguments(multiRedditBundle); - multiRedditSortTypeBottomSheetFragment.show(getSupportFragmentManager(), multiRedditSortTypeBottomSheetFragment.getTag()); + case PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT: + case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE: + SortTypeBottomSheetFragment sortTypeBottomSheetFragment = new SortTypeBottomSheetFragment(); + Bundle popularBundle = new Bundle(); + popularBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true); + sortTypeBottomSheetFragment.setArguments(popularBundle); + sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag()); break; case PostPagingSource.TYPE_USER: UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment = new UserThingSortTypeBottomSheetFragment(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java index 957e77ed..ad5d1746 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java @@ -156,7 +156,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti int navBarHeight = getNavBarHeight(); if (navBarHeight > 0) { CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); - params.bottomMargin = navBarHeight; + params.bottomMargin += navBarHeight; fab.setLayoutParams(params); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java index e982a512..b691c4b2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/PostFragment.java @@ -718,9 +718,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator { usage = PostFilterUsage.HOME_TYPE; nameOfUsage = PostFilterUsage.NO_USAGE; - String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_BEST_POST, SortType.Type.BEST.name()); + String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + "-", SortType.Type.HOT.name()); if (sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) { - String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_BEST_POST, SortType.Time.ALL.name()); + String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + "-", SortType.Time.ALL.name()); sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime)); } else { sortType = new SortType(SortType.Type.valueOf(sort)); @@ -778,7 +778,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { usage = PostFilterUsage.MULTIREDDIT_TYPE; nameOfUsage = multiRedditPath; - String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiRedditPath, SortType.Type.BEST.name()); + String sort = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiRedditPath, SortType.Type.HOT.name()); if (sort.equals(SortType.Type.CONTROVERSIAL.name()) || sort.equals(SortType.Type.TOP.name())) { String sortTime = mSortTypeSharedPreferences.getString(SharedPreferencesUtils.SORT_TIME_MULTI_REDDIT_POST_BASE + multiRedditPath, SortType.Time.ALL.name()); sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime)); @@ -1355,6 +1355,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator { } break; case PostPagingSource.TYPE_MULTI_REDDIT: + case PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT: mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiRedditPath, sortType.getType().name()).apply(); if (sortType.getTime() != null) { @@ -1362,6 +1363,12 @@ public class PostFragment extends Fragment implements FragmentCommunicator { sortType.getTime().name()).apply(); } break; + case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE: + mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_SUBREDDIT_POST_BASE + "-", sortType.getType().name()).apply(); + if (sortType.getTime() != null) { + mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TIME_SUBREDDIT_POST_BASE + "-", sortType.getTime().name()).apply(); + } + break; } } if (mFetchPostInfoLinearLayout.getVisibility() != View.GONE) { -- cgit v1.2.3