targetSdkVersion 31. Fix sort type problems in anonymous home page and multireddits.

This commit is contained in:
Docile-Alligator 2022-04-30 17:56:31 +08:00
parent d40fc59540
commit 3d374491b3
5 changed files with 20 additions and 24 deletions

View File

@ -5,7 +5,7 @@ android {
defaultConfig { defaultConfig {
applicationId "ml.docilealligator.infinityforreddit" applicationId "ml.docilealligator.infinityforreddit"
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 30 targetSdkVersion 31
versionCode 97 versionCode 97
versionName "5.2.0-beta1" versionName "5.2.0-beta1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

View File

@ -371,26 +371,14 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag()); searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag());
break; break;
case PostPagingSource.TYPE_SUBREDDIT: 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: case PostPagingSource.TYPE_MULTI_REDDIT:
SortTypeBottomSheetFragment multiRedditSortTypeBottomSheetFragment = new SortTypeBottomSheetFragment(); case PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT:
Bundle multiRedditBundle = new Bundle(); case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE:
multiRedditBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true); SortTypeBottomSheetFragment sortTypeBottomSheetFragment = new SortTypeBottomSheetFragment();
multiRedditSortTypeBottomSheetFragment.setArguments(multiRedditBundle); Bundle popularBundle = new Bundle();
multiRedditSortTypeBottomSheetFragment.show(getSupportFragmentManager(), multiRedditSortTypeBottomSheetFragment.getTag()); popularBundle.putBoolean(SortTypeBottomSheetFragment.EXTRA_NO_BEST_TYPE, true);
sortTypeBottomSheetFragment.setArguments(popularBundle);
sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
break; break;
case PostPagingSource.TYPE_USER: case PostPagingSource.TYPE_USER:
UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment = new UserThingSortTypeBottomSheetFragment(); UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment = new UserThingSortTypeBottomSheetFragment();

View File

@ -156,7 +156,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti
int navBarHeight = getNavBarHeight(); int navBarHeight = getNavBarHeight();
if (navBarHeight > 0) { if (navBarHeight > 0) {
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
params.bottomMargin = navBarHeight; params.bottomMargin += navBarHeight;
fab.setLayoutParams(params); fab.setLayoutParams(params);
} }
} }

View File

@ -718,9 +718,9 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
usage = PostFilterUsage.HOME_TYPE; usage = PostFilterUsage.HOME_TYPE;
nameOfUsage = PostFilterUsage.NO_USAGE; 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())) { 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)); sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
} else { } else {
sortType = new SortType(SortType.Type.valueOf(sort)); sortType = new SortType(SortType.Type.valueOf(sort));
@ -778,7 +778,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
usage = PostFilterUsage.MULTIREDDIT_TYPE; usage = PostFilterUsage.MULTIREDDIT_TYPE;
nameOfUsage = multiRedditPath; 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())) { 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()); 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)); sortType = new SortType(SortType.Type.valueOf(sort), SortType.Time.valueOf(sortTime));
@ -1355,6 +1355,7 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
} }
break; break;
case PostPagingSource.TYPE_MULTI_REDDIT: case PostPagingSource.TYPE_MULTI_REDDIT:
case PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT:
mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiRedditPath, mSortTypeSharedPreferences.edit().putString(SharedPreferencesUtils.SORT_TYPE_MULTI_REDDIT_POST_BASE + multiRedditPath,
sortType.getType().name()).apply(); sortType.getType().name()).apply();
if (sortType.getTime() != null) { if (sortType.getTime() != null) {
@ -1362,6 +1363,12 @@ public class PostFragment extends Fragment implements FragmentCommunicator {
sortType.getTime().name()).apply(); sortType.getTime().name()).apply();
} }
break; 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) { if (mFetchPostInfoLinearLayout.getVisibility() != View.GONE) {

View File

@ -49,6 +49,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:drawableTop="@drawable/ic_error_outline_black_24dp" android:drawableTop="@drawable/ic_error_outline_black_24dp"
android:layout_gravity="center" android:layout_gravity="center"
android:gravity="center"
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:text="@string/error_loading_image_tap_to_retry" android:text="@string/error_loading_image_tap_to_retry"