Show an indicator for the current sort type.

This commit is contained in:
Docile-Alligator 2022-08-21 11:59:14 +10:00
parent 0c7e5bc16f
commit 965d8ab8ae
13 changed files with 145 additions and 39 deletions

View File

@ -355,24 +355,22 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec
} else if (itemId == R.id.action_sort_filtered_thing_activity) { } else if (itemId == R.id.action_sort_filtered_thing_activity) {
switch (postType) { switch (postType) {
case PostPagingSource.TYPE_FRONT_PAGE: case PostPagingSource.TYPE_FRONT_PAGE:
SortTypeBottomSheetFragment bestSortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(false, mFragment.getSortType().getType().fullName); SortTypeBottomSheetFragment bestSortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(false, mFragment.getSortType());
bestSortTypeBottomSheetFragment.show(getSupportFragmentManager(), bestSortTypeBottomSheetFragment.getTag()); bestSortTypeBottomSheetFragment.show(getSupportFragmentManager(), bestSortTypeBottomSheetFragment.getTag());
break; break;
case PostPagingSource.TYPE_SEARCH: case PostPagingSource.TYPE_SEARCH:
SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = new SearchPostSortTypeBottomSheetFragment(); SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = SearchPostSortTypeBottomSheetFragment.getNewInstance(mFragment.getSortType());
Bundle searchBundle = new Bundle();
searchPostSortTypeBottomSheetFragment.setArguments(searchBundle);
searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag()); searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag());
break; break;
case PostPagingSource.TYPE_SUBREDDIT: case PostPagingSource.TYPE_SUBREDDIT:
case PostPagingSource.TYPE_MULTI_REDDIT: case PostPagingSource.TYPE_MULTI_REDDIT:
case PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT: case PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT:
case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE: case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE:
SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(true, mFragment.getSortType().getType().fullName); SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(true, mFragment.getSortType());
sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag()); sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
break; break;
case PostPagingSource.TYPE_USER: case PostPagingSource.TYPE_USER:
UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment = new UserThingSortTypeBottomSheetFragment(); UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment = UserThingSortTypeBottomSheetFragment.getNewInstance(mFragment.getSortType());
userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag()); userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag());
} }
return true; return true;

View File

@ -1067,7 +1067,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
int currentPostType = sectionsPagerAdapter.getCurrentPostType(); int currentPostType = sectionsPagerAdapter.getCurrentPostType();
PostFragment postFragment = sectionsPagerAdapter.getCurrentFragment(); PostFragment postFragment = sectionsPagerAdapter.getCurrentFragment();
if (postFragment != null) { if (postFragment != null) {
SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(currentPostType != PostPagingSource.TYPE_FRONT_PAGE, postFragment.getSortType().getType().fullName); SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(currentPostType != PostPagingSource.TYPE_FRONT_PAGE, postFragment.getSortType());
sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag()); sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
} }
} }

View File

@ -324,8 +324,11 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
break; break;
} }
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_CHANGE_SORT_TYPE: { case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_CHANGE_SORT_TYPE: {
SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = new SearchPostSortTypeBottomSheetFragment(); Fragment fragment = sectionsPagerAdapter.getCurrentFragment();
searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag()); if (fragment instanceof PostFragment) {
SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = SearchPostSortTypeBottomSheetFragment.getNewInstance(((PostFragment) fragment).getSortType());
searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag());
}
break; break;
} }
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_CHANGE_POST_LAYOUT: { case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_CHANGE_POST_LAYOUT: {
@ -382,21 +385,20 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
} }
private void displaySortTypeBottomSheetFragment() { private void displaySortTypeBottomSheetFragment() {
switch (viewPager2.getCurrentItem()) { Fragment fragment = sectionsPagerAdapter.getCurrentFragment();
case 0: { if (fragment instanceof PostFragment) {
SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = new SearchPostSortTypeBottomSheetFragment(); SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = SearchPostSortTypeBottomSheetFragment.getNewInstance(((PostFragment) fragment).getSortType());
searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag()); searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag());
break; } else {
} if (fragment instanceof SubredditListingFragment) {
case 1:
case 2:
SearchUserAndSubredditSortTypeBottomSheetFragment searchUserAndSubredditSortTypeBottomSheetFragment SearchUserAndSubredditSortTypeBottomSheetFragment searchUserAndSubredditSortTypeBottomSheetFragment
= new SearchUserAndSubredditSortTypeBottomSheetFragment(); = SearchUserAndSubredditSortTypeBottomSheetFragment.getNewInstance(viewPager2.getCurrentItem(), ((SubredditListingFragment) fragment).getSortType());
Bundle bundle = new Bundle();
bundle.putInt(SearchUserAndSubredditSortTypeBottomSheetFragment.EXTRA_FRAGMENT_POSITION, viewPager2.getCurrentItem());
searchUserAndSubredditSortTypeBottomSheetFragment.setArguments(bundle);
searchUserAndSubredditSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchUserAndSubredditSortTypeBottomSheetFragment.getTag()); searchUserAndSubredditSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchUserAndSubredditSortTypeBottomSheetFragment.getTag());
break; } else if (fragment instanceof UserListingFragment) {
SearchUserAndSubredditSortTypeBottomSheetFragment searchUserAndSubredditSortTypeBottomSheetFragment
= SearchUserAndSubredditSortTypeBottomSheetFragment.getNewInstance(viewPager2.getCurrentItem(), ((UserListingFragment) fragment).getSortType());
searchUserAndSubredditSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchUserAndSubredditSortTypeBottomSheetFragment.getTag());
}
} }
} }

View File

@ -576,7 +576,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
private void showSortTypeBottomSheetFragment() { private void showSortTypeBottomSheetFragment() {
if (mFragment instanceof PostFragment) { if (mFragment instanceof PostFragment) {
SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(true, ((PostFragment) mFragment).getSortType().getType().fullName); SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(true, ((PostFragment) mFragment).getSortType());
sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag()); sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
} }
} }

View File

@ -1093,7 +1093,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
private void displaySortTypeBottomSheetFragment() { private void displaySortTypeBottomSheetFragment() {
Fragment fragment = fragmentManager.findFragmentByTag("f0"); Fragment fragment = fragmentManager.findFragmentByTag("f0");
if (fragment instanceof PostFragment) { if (fragment instanceof PostFragment) {
SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(true, ((PostFragment) fragment).getSortType().getType().fullName); SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(true, ((PostFragment) fragment).getSortType());
sortTypeBottomSheetFragment.show(fragmentManager, sortTypeBottomSheetFragment.getTag()); sortTypeBottomSheetFragment.show(fragmentManager, sortTypeBottomSheetFragment.getTag());
} }
} }

View File

@ -208,9 +208,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
private FragmentManager fragmentManager; private FragmentManager fragmentManager;
private SectionsPagerAdapter sectionsPagerAdapter; private SectionsPagerAdapter sectionsPagerAdapter;
private RequestManager glide; private RequestManager glide;
private UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment;
private SortTimeBottomSheetFragment sortTimeBottomSheetFragment;
private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment;
private NavigationWrapper navigationWrapper; private NavigationWrapper navigationWrapper;
private Call<String> subredditAutocompleteCall; private Call<String> subredditAutocompleteCall;
private String mAccessToken; private String mAccessToken;
@ -585,10 +582,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
} }
}); });
userThingSortTypeBottomSheetFragment = new UserThingSortTypeBottomSheetFragment();
sortTimeBottomSheetFragment = new SortTimeBottomSheetFragment();
postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
karmaTextView.setOnClickListener(view -> { karmaTextView.setOnClickListener(view -> {
UserData userData = userViewModel.getUserLiveData().getValue(); UserData userData = userViewModel.getUserLiveData().getValue();
if (userData != null) { if (userData != null) {
@ -862,10 +855,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
break; break;
} }
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_CHANGE_SORT_TYPE: { case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_CHANGE_SORT_TYPE: {
userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag());
break; break;
} }
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_CHANGE_POST_LAYOUT: { case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_CHANGE_POST_LAYOUT: {
PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag()); postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
break; break;
} }
@ -944,7 +938,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
break; break;
} }
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_CHANGE_SORT_TYPE: { case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_CHANGE_SORT_TYPE: {
userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag()); displaySortTypeBottomSheetFragment();
break; break;
} }
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_CHANGE_POST_LAYOUT: { case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_CHANGE_POST_LAYOUT: {
@ -1065,6 +1059,17 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
} }
} }
private void displaySortTypeBottomSheetFragment() {
Fragment fragment = sectionsPagerAdapter.getCurrentFragment();
if (fragment instanceof PostFragment) {
UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment = UserThingSortTypeBottomSheetFragment.getNewInstance(((PostFragment) fragment).getSortType());
userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag());
} else if (fragment instanceof CommentsListingFragment) {
UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment = UserThingSortTypeBottomSheetFragment.getNewInstance(((CommentsListingFragment) fragment).getSortType());
userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag());
}
}
private void fetchUserInfo() { private void fetchUserInfo() {
if (!mFetchUserInfoSuccess) { if (!mFetchUserInfoSuccess) {
FetchUserData.fetchUserData(mRetrofit, username, new FetchUserData.FetchUserDataListener() { FetchUserData.fetchUserData(mRetrofit, username, new FetchUserData.FetchUserDataListener() {
@ -1123,7 +1128,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
finish(); finish();
return true; return true;
} else if (itemId == R.id.action_sort_view_user_detail_activity) { } else if (itemId == R.id.action_sort_view_user_detail_activity) {
userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag()); displaySortTypeBottomSheetFragment();
return true; return true;
} else if (itemId == R.id.action_search_view_user_detail_activity) { } else if (itemId == R.id.action_search_view_user_detail_activity) {
Intent intent = new Intent(this, SearchActivity.class); Intent intent = new Intent(this, SearchActivity.class);
@ -1137,6 +1142,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
fetchUserInfo(); fetchUserInfo();
return true; return true;
} else if (itemId == R.id.action_change_post_layout_view_user_detail_activity) { } else if (itemId == R.id.action_change_post_layout_view_user_detail_activity) {
PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag()); postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
return true; return true;
} else if (itemId == R.id.action_share_view_user_detail_activity) { } else if (itemId == R.id.action_share_view_user_detail_activity) {
@ -1262,6 +1268,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
@Override @Override
public void sortTypeSelected(String sortType) { public void sortTypeSelected(String sortType) {
SortTimeBottomSheetFragment sortTimeBottomSheetFragment = new SortTimeBottomSheetFragment();
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putString(SortTimeBottomSheetFragment.EXTRA_SORT_TYPE, sortType); bundle.putString(SortTimeBottomSheetFragment.EXTRA_SORT_TYPE, sortType);
sortTimeBottomSheetFragment.setArguments(bundle); sortTimeBottomSheetFragment.setArguments(bundle);
@ -1286,9 +1293,10 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
} }
break; break;
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_CHANGE_SORT_TYPE: case FABMoreOptionsBottomSheetFragment.FAB_OPTION_CHANGE_SORT_TYPE:
userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag()); displaySortTypeBottomSheetFragment();
break; break;
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_CHANGE_POST_LAYOUT: case FABMoreOptionsBottomSheetFragment.FAB_OPTION_CHANGE_POST_LAYOUT:
PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment();
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag()); postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
break; break;
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_SEARCH: case FABMoreOptionsBottomSheetFragment.FAB_OPTION_SEARCH:

View File

@ -11,6 +11,7 @@ import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import butterknife.BindView; import butterknife.BindView;
@ -27,6 +28,8 @@ import ml.docilealligator.infinityforreddit.utils.Utils;
*/ */
public class PostCommentSortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment { public class PostCommentSortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
public static final String EXTRA_CURRENT_SORT_TYPE = "ECST";
@BindView(R.id.best_type_text_view_post_comment_sort_type_bottom_sheet_fragment) @BindView(R.id.best_type_text_view_post_comment_sort_type_bottom_sheet_fragment)
TextView bestTypeTextView; TextView bestTypeTextView;
@BindView(R.id.confidence_type_text_view_post_comment_sort_type_bottom_sheet_fragment) @BindView(R.id.confidence_type_text_view_post_comment_sort_type_bottom_sheet_fragment)
@ -46,10 +49,19 @@ public class PostCommentSortTypeBottomSheetFragment extends LandscapeExpandedRou
@BindView(R.id.live_type_text_view_post_comment_sort_type_bottom_sheet_fragment) @BindView(R.id.live_type_text_view_post_comment_sort_type_bottom_sheet_fragment)
TextView liveTypeTextView; TextView liveTypeTextView;
private BaseActivity activity; private BaseActivity activity;
public PostCommentSortTypeBottomSheetFragment() { public PostCommentSortTypeBottomSheetFragment() {
// Required empty public constructor // Required empty public constructor
} }
public static PostCommentSortTypeBottomSheetFragment getNewInstance(String currentSortTypeValue) {
PostCommentSortTypeBottomSheetFragment fragment = new PostCommentSortTypeBottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putString(EXTRA_CURRENT_SORT_TYPE, currentSortTypeValue);
fragment.setArguments(bundle);
return fragment;
}
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
@ -58,6 +70,27 @@ public class PostCommentSortTypeBottomSheetFragment extends LandscapeExpandedRou
View rootView = inflater.inflate(R.layout.fragment_post_comment_sort_type_bottom_sheet, container, false); View rootView = inflater.inflate(R.layout.fragment_post_comment_sort_type_bottom_sheet, container, false);
ButterKnife.bind(this, rootView); ButterKnife.bind(this, rootView);
String currentSortType = getArguments().getString(EXTRA_CURRENT_SORT_TYPE);
if (currentSortType.equals(SortType.Type.BEST.value)) {
bestTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(bestTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.CONFIDENCE.value)) {
confidenceTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(confidenceTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.TOP.value)) {
topTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(topTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.NEW.value)) {
newTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(newTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.CONTROVERSIAL.value)) {
controversialTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(controversialTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.OLD.value)) {
oldTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(oldTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.RANDOM.value)) {
randomTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(randomTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.QA.value)) {
qaTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(qaTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.LIVE.value)) {
liveTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(liveTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
&& (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) {
rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);

View File

@ -11,6 +11,7 @@ import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import butterknife.BindView; import butterknife.BindView;
@ -28,6 +29,8 @@ import ml.docilealligator.infinityforreddit.utils.Utils;
*/ */
public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment { public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
public static final String EXTRA_CURRENT_SORT_TYPE = "ECST";
@BindView(R.id.relevance_type_text_view_search_sort_type_bottom_sheet_fragment) @BindView(R.id.relevance_type_text_view_search_sort_type_bottom_sheet_fragment)
TextView relevanceTypeTextView; TextView relevanceTypeTextView;
@BindView(R.id.hot_type_text_view_search_sort_type_bottom_sheet_fragment) @BindView(R.id.hot_type_text_view_search_sort_type_bottom_sheet_fragment)
@ -43,12 +46,33 @@ public class SearchPostSortTypeBottomSheetFragment extends LandscapeExpandedRoun
// Required empty public constructor // Required empty public constructor
} }
public static SearchPostSortTypeBottomSheetFragment getNewInstance(SortType currentSortType) {
SearchPostSortTypeBottomSheetFragment fragment = new SearchPostSortTypeBottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putString(EXTRA_CURRENT_SORT_TYPE, currentSortType.getType().fullName);
fragment.setArguments(bundle);
return fragment;
}
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_search_post_sort_type_bottom_sheet, container, false); View rootView = inflater.inflate(R.layout.fragment_search_post_sort_type_bottom_sheet, container, false);
ButterKnife.bind(this, rootView); ButterKnife.bind(this, rootView);
String currentSortType = getArguments().getString(EXTRA_CURRENT_SORT_TYPE);
if (currentSortType.equals(SortType.Type.RELEVANCE.fullName)) {
relevanceTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(relevanceTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.HOT.fullName)) {
hotTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(hotTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.TOP.fullName)) {
topTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(topTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.NEW.fullName)) {
newTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(newTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.RISING.fullName)) {
commentsTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(commentsTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
&& (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) {
rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);

View File

@ -11,6 +11,7 @@ import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import butterknife.BindView; import butterknife.BindView;
@ -29,21 +30,40 @@ import ml.docilealligator.infinityforreddit.utils.Utils;
public class SearchUserAndSubredditSortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment { public class SearchUserAndSubredditSortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
public static final String EXTRA_FRAGMENT_POSITION = "EFP"; public static final String EXTRA_FRAGMENT_POSITION = "EFP";
public static final String EXTRA_CURRENT_SORT_TYPE = "ECST";
@BindView(R.id.relevance_type_text_view_search_user_and_subreddit_sort_type_bottom_sheet_fragment) @BindView(R.id.relevance_type_text_view_search_user_and_subreddit_sort_type_bottom_sheet_fragment)
TextView relevanceTypeTextView; TextView relevanceTypeTextView;
@BindView(R.id.activity_type_text_view_search_user_and_subreddit_sort_type_bottom_sheet_fragment) @BindView(R.id.activity_type_text_view_search_user_and_subreddit_sort_type_bottom_sheet_fragment)
TextView activityTypeTextView; TextView activityTypeTextView;
private BaseActivity activity; private BaseActivity activity;
public SearchUserAndSubredditSortTypeBottomSheetFragment() { public SearchUserAndSubredditSortTypeBottomSheetFragment() {
// Required empty public constructor // Required empty public constructor
} }
public static SearchUserAndSubredditSortTypeBottomSheetFragment getNewInstance(int fragmentPosition, SortType currentSortType) {
SearchUserAndSubredditSortTypeBottomSheetFragment fragment = new SearchUserAndSubredditSortTypeBottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putInt(EXTRA_FRAGMENT_POSITION, fragmentPosition);
bundle.putString(EXTRA_CURRENT_SORT_TYPE, currentSortType.getType().fullName);
fragment.setArguments(bundle);
return fragment;
}
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_search_user_and_subreddit_sort_type_bottom_sheet, container, false); View rootView = inflater.inflate(R.layout.fragment_search_user_and_subreddit_sort_type_bottom_sheet, container, false);
ButterKnife.bind(this, rootView); ButterKnife.bind(this, rootView);
String currentSortType = getArguments().getString(EXTRA_CURRENT_SORT_TYPE);
if (currentSortType.equals(SortType.Type.RELEVANCE.fullName)) {
relevanceTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(relevanceTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.ACTIVITY.fullName)) {
activityTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(activityTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
&& (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) {
rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);

View File

@ -49,11 +49,11 @@ public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
// Required empty public constructor // Required empty public constructor
} }
public static SortTypeBottomSheetFragment getNewInstance(boolean isNoBestType, String currentSortType) { public static SortTypeBottomSheetFragment getNewInstance(boolean isNoBestType, SortType currentSortType) {
SortTypeBottomSheetFragment fragment = new SortTypeBottomSheetFragment(); SortTypeBottomSheetFragment fragment = new SortTypeBottomSheetFragment();
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putBoolean(EXTRA_NO_BEST_TYPE, isNoBestType); bundle.putBoolean(EXTRA_NO_BEST_TYPE, isNoBestType);
bundle.putString(EXTRA_CURRENT_SORT_TYPE, currentSortType); bundle.putString(EXTRA_CURRENT_SORT_TYPE, currentSortType.getType().fullName);
fragment.setArguments(bundle); fragment.setArguments(bundle);
return fragment; return fragment;
} }

View File

@ -11,6 +11,7 @@ import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.content.res.AppCompatResources;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import butterknife.BindView; import butterknife.BindView;
@ -28,6 +29,8 @@ import ml.docilealligator.infinityforreddit.utils.Utils;
*/ */
public class UserThingSortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment { public class UserThingSortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
public static final String EXTRA_CURRENT_SORT_TYPE = "ECST";
@BindView(R.id.new_type_text_view_user_thing_sort_type_bottom_sheet_fragment) @BindView(R.id.new_type_text_view_user_thing_sort_type_bottom_sheet_fragment)
TextView newTypeTextView; TextView newTypeTextView;
@BindView(R.id.hot_type_text_view_user_thing_sort_type_bottom_sheet_fragment) @BindView(R.id.hot_type_text_view_user_thing_sort_type_bottom_sheet_fragment)
@ -42,6 +45,14 @@ public class UserThingSortTypeBottomSheetFragment extends LandscapeExpandedRound
// Required empty public constructor // Required empty public constructor
} }
public static UserThingSortTypeBottomSheetFragment getNewInstance(SortType currentSortType) {
UserThingSortTypeBottomSheetFragment fragment = new UserThingSortTypeBottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putString(EXTRA_CURRENT_SORT_TYPE, currentSortType.getType().fullName);
fragment.setArguments(bundle);
return fragment;
}
@Override @Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
@ -49,6 +60,17 @@ public class UserThingSortTypeBottomSheetFragment extends LandscapeExpandedRound
ButterKnife.bind(this, rootView); ButterKnife.bind(this, rootView);
String currentSortType = getArguments().getString(EXTRA_CURRENT_SORT_TYPE);
if (currentSortType.equals(SortType.Type.NEW.fullName)) {
newTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(newTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.HOT.fullName)) {
hotTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(hotTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.TOP.fullName)) {
topTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(topTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.CONTROVERSIAL.fullName)) {
controversialTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(controversialTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
&& (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) {
rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);

View File

@ -958,7 +958,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
return true; return true;
} else if (itemId == R.id.action_sort_view_post_detail_fragment) { } else if (itemId == R.id.action_sort_view_post_detail_fragment) {
if (mPost != null) { if (mPost != null) {
PostCommentSortTypeBottomSheetFragment postCommentSortTypeBottomSheetFragment = new PostCommentSortTypeBottomSheetFragment(); PostCommentSortTypeBottomSheetFragment postCommentSortTypeBottomSheetFragment = PostCommentSortTypeBottomSheetFragment.getNewInstance(sortType);
postCommentSortTypeBottomSheetFragment.show(activity.getSupportFragmentManager(), postCommentSortTypeBottomSheetFragment.getTag()); postCommentSortTypeBottomSheetFragment.show(activity.getSupportFragmentManager(), postCommentSortTypeBottomSheetFragment.getTag());
} }
return true; return true;

View File

@ -339,7 +339,6 @@ public class DownloadRedditVideoService extends Service {
} }
private boolean muxVideoAndAudio(String videoFilePath, String audioFilePath, String outputFilePath) { private boolean muxVideoAndAudio(String videoFilePath, String audioFilePath, String outputFilePath) {
Log.i("asdfasdf", "sasdfasdf");
try { try {
File file = new File(outputFilePath); File file = new File(outputFilePath);
file.createNewFile(); file.createNewFile();