diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2022-08-21 01:59:14 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2022-08-21 01:59:14 +0000 |
commit | 965d8ab8aec779d9a300434dd20840f481e3941c (patch) | |
tree | 0486d4cad82eeb3b779fcaee0ecc19d552f2660a /app | |
parent | 0c7e5bc16f72a2f3bf1b5c5ec2446f1f74556c14 (diff) | |
download | infinity-for-reddit-965d8ab8aec779d9a300434dd20840f481e3941c.tar infinity-for-reddit-965d8ab8aec779d9a300434dd20840f481e3941c.tar.gz infinity-for-reddit-965d8ab8aec779d9a300434dd20840f481e3941c.tar.bz2 infinity-for-reddit-965d8ab8aec779d9a300434dd20840f481e3941c.tar.lz infinity-for-reddit-965d8ab8aec779d9a300434dd20840f481e3941c.tar.xz infinity-for-reddit-965d8ab8aec779d9a300434dd20840f481e3941c.tar.zst infinity-for-reddit-965d8ab8aec779d9a300434dd20840f481e3941c.zip |
Show an indicator for the current sort type.
Diffstat (limited to 'app')
13 files changed, 145 insertions, 39 deletions
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 1d59eb8d..4f60003b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java @@ -355,24 +355,22 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec } else if (itemId == R.id.action_sort_filtered_thing_activity) { switch (postType) { 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()); break; case PostPagingSource.TYPE_SEARCH: - SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = new SearchPostSortTypeBottomSheetFragment(); - Bundle searchBundle = new Bundle(); - searchPostSortTypeBottomSheetFragment.setArguments(searchBundle); + SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = SearchPostSortTypeBottomSheetFragment.getNewInstance(mFragment.getSortType()); searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag()); break; case PostPagingSource.TYPE_SUBREDDIT: case PostPagingSource.TYPE_MULTI_REDDIT: case PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT: 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()); break; case PostPagingSource.TYPE_USER: - UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment = new UserThingSortTypeBottomSheetFragment(); + UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment = UserThingSortTypeBottomSheetFragment.getNewInstance(mFragment.getSortType()); userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag()); } return true; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java index 1a453f35..5b87ec69 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java @@ -1067,7 +1067,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb int currentPostType = sectionsPagerAdapter.getCurrentPostType(); PostFragment postFragment = sectionsPagerAdapter.getCurrentFragment(); 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()); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java index 0efb6be2..c497f30c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java @@ -324,8 +324,11 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect break; } case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_CHANGE_SORT_TYPE: { - SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = new SearchPostSortTypeBottomSheetFragment(); - searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag()); + Fragment fragment = sectionsPagerAdapter.getCurrentFragment(); + if (fragment instanceof PostFragment) { + SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = SearchPostSortTypeBottomSheetFragment.getNewInstance(((PostFragment) fragment).getSortType()); + searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag()); + } break; } 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() { - switch (viewPager2.getCurrentItem()) { - case 0: { - SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = new SearchPostSortTypeBottomSheetFragment(); - searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag()); - break; - } - case 1: - case 2: + Fragment fragment = sectionsPagerAdapter.getCurrentFragment(); + if (fragment instanceof PostFragment) { + SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = SearchPostSortTypeBottomSheetFragment.getNewInstance(((PostFragment) fragment).getSortType()); + searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag()); + } else { + if (fragment instanceof SubredditListingFragment) { SearchUserAndSubredditSortTypeBottomSheetFragment searchUserAndSubredditSortTypeBottomSheetFragment - = new SearchUserAndSubredditSortTypeBottomSheetFragment(); - Bundle bundle = new Bundle(); - bundle.putInt(SearchUserAndSubredditSortTypeBottomSheetFragment.EXTRA_FRAGMENT_POSITION, viewPager2.getCurrentItem()); - searchUserAndSubredditSortTypeBottomSheetFragment.setArguments(bundle); + = SearchUserAndSubredditSortTypeBottomSheetFragment.getNewInstance(viewPager2.getCurrentItem(), ((SubredditListingFragment) fragment).getSortType()); 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()); + } } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java index e3cf7c63..bf21ef7d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java @@ -576,7 +576,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT private void showSortTypeBottomSheetFragment() { 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()); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java index d266145a..4e1188fc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java @@ -1093,7 +1093,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp private void displaySortTypeBottomSheetFragment() { Fragment fragment = fragmentManager.findFragmentByTag("f0"); 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()); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java index 7d533cba..c30a86e2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java @@ -208,9 +208,6 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele private FragmentManager fragmentManager; private SectionsPagerAdapter sectionsPagerAdapter; private RequestManager glide; - private UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment; - private SortTimeBottomSheetFragment sortTimeBottomSheetFragment; - private PostLayoutBottomSheetFragment postLayoutBottomSheetFragment; private NavigationWrapper navigationWrapper; private Call<String> subredditAutocompleteCall; 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 -> { UserData userData = userViewModel.getUserLiveData().getValue(); if (userData != null) { @@ -862,10 +855,11 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele break; } case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_CHANGE_SORT_TYPE: { - userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag()); + break; } case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_CHANGE_POST_LAYOUT: { + PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment(); postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag()); break; } @@ -944,7 +938,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele break; } case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_CHANGE_SORT_TYPE: { - userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag()); + displaySortTypeBottomSheetFragment(); break; } 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() { if (!mFetchUserInfoSuccess) { FetchUserData.fetchUserData(mRetrofit, username, new FetchUserData.FetchUserDataListener() { @@ -1123,7 +1128,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele finish(); return true; } else if (itemId == R.id.action_sort_view_user_detail_activity) { - userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag()); + displaySortTypeBottomSheetFragment(); return true; } else if (itemId == R.id.action_search_view_user_detail_activity) { Intent intent = new Intent(this, SearchActivity.class); @@ -1137,6 +1142,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele fetchUserInfo(); return true; } else if (itemId == R.id.action_change_post_layout_view_user_detail_activity) { + PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment(); postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag()); return true; } else if (itemId == R.id.action_share_view_user_detail_activity) { @@ -1262,6 +1268,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele @Override public void sortTypeSelected(String sortType) { + SortTimeBottomSheetFragment sortTimeBottomSheetFragment = new SortTimeBottomSheetFragment(); Bundle bundle = new Bundle(); bundle.putString(SortTimeBottomSheetFragment.EXTRA_SORT_TYPE, sortType); sortTimeBottomSheetFragment.setArguments(bundle); @@ -1286,9 +1293,10 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele } break; case FABMoreOptionsBottomSheetFragment.FAB_OPTION_CHANGE_SORT_TYPE: - userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag()); + displaySortTypeBottomSheetFragment(); break; case FABMoreOptionsBottomSheetFragment.FAB_OPTION_CHANGE_POST_LAYOUT: + PostLayoutBottomSheetFragment postLayoutBottomSheetFragment = new PostLayoutBottomSheetFragment(); postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag()); break; case FABMoreOptionsBottomSheetFragment.FAB_OPTION_SEARCH: diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostCommentSortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostCommentSortTypeBottomSheetFragment.java index 544b97ca..20871a1f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostCommentSortTypeBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/PostCommentSortTypeBottomSheetFragment.java @@ -11,6 +11,7 @@ import android.view.ViewGroup; import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.appcompat.content.res.AppCompatResources; import androidx.fragment.app.Fragment; import butterknife.BindView; @@ -27,6 +28,8 @@ import ml.docilealligator.infinityforreddit.utils.Utils; */ 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) TextView bestTypeTextView; @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) TextView liveTypeTextView; private BaseActivity activity; + public PostCommentSortTypeBottomSheetFragment() { // 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 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); 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 && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SearchPostSortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SearchPostSortTypeBottomSheetFragment.java index 90f2a15b..618701fa 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SearchPostSortTypeBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SearchPostSortTypeBottomSheetFragment.java @@ -11,6 +11,7 @@ import android.view.ViewGroup; import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.appcompat.content.res.AppCompatResources; import androidx.fragment.app.Fragment; import butterknife.BindView; @@ -28,6 +29,8 @@ import ml.docilealligator.infinityforreddit.utils.Utils; */ 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) TextView relevanceTypeTextView; @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 } + 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 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_search_post_sort_type_bottom_sheet, container, false); 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 && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SearchUserAndSubredditSortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SearchUserAndSubredditSortTypeBottomSheetFragment.java index 4b7f82b0..56498538 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SearchUserAndSubredditSortTypeBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SearchUserAndSubredditSortTypeBottomSheetFragment.java @@ -11,6 +11,7 @@ import android.view.ViewGroup; import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.appcompat.content.res.AppCompatResources; import androidx.fragment.app.Fragment; import butterknife.BindView; @@ -29,21 +30,40 @@ import ml.docilealligator.infinityforreddit.utils.Utils; public class SearchUserAndSubredditSortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment { 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) TextView relevanceTypeTextView; @BindView(R.id.activity_type_text_view_search_user_and_subreddit_sort_type_bottom_sheet_fragment) TextView activityTypeTextView; private BaseActivity activity; + public SearchUserAndSubredditSortTypeBottomSheetFragment() { // 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 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_search_user_and_subreddit_sort_type_bottom_sheet, container, false); 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 && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SortTypeBottomSheetFragment.java index 881b1910..4c35cde7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SortTypeBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/SortTypeBottomSheetFragment.java @@ -49,11 +49,11 @@ public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS // Required empty public constructor } - public static SortTypeBottomSheetFragment getNewInstance(boolean isNoBestType, String currentSortType) { + public static SortTypeBottomSheetFragment getNewInstance(boolean isNoBestType, SortType currentSortType) { SortTypeBottomSheetFragment fragment = new SortTypeBottomSheetFragment(); Bundle bundle = new Bundle(); 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); return fragment; } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/UserThingSortTypeBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/UserThingSortTypeBottomSheetFragment.java index ff4888c7..63175be1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/UserThingSortTypeBottomSheetFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/UserThingSortTypeBottomSheetFragment.java @@ -11,6 +11,7 @@ import android.view.ViewGroup; import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.appcompat.content.res.AppCompatResources; import androidx.fragment.app.Fragment; import butterknife.BindView; @@ -28,6 +29,8 @@ import ml.docilealligator.infinityforreddit.utils.Utils; */ 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) TextView newTypeTextView; @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 } + 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 public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -49,6 +60,17 @@ public class UserThingSortTypeBottomSheetFragment extends LandscapeExpandedRound 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 && (getResources().getConfiguration().uiMode & Configuration.UI_MODE_NIGHT_MASK) != Configuration.UI_MODE_NIGHT_YES) { rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java index 5562cdb8..5821b2fd 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java @@ -958,7 +958,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic return true; } else if (itemId == R.id.action_sort_view_post_detail_fragment) { if (mPost != null) { - PostCommentSortTypeBottomSheetFragment postCommentSortTypeBottomSheetFragment = new PostCommentSortTypeBottomSheetFragment(); + PostCommentSortTypeBottomSheetFragment postCommentSortTypeBottomSheetFragment = PostCommentSortTypeBottomSheetFragment.getNewInstance(sortType); postCommentSortTypeBottomSheetFragment.show(activity.getSupportFragmentManager(), postCommentSortTypeBottomSheetFragment.getTag()); } return true; diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java b/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java index ba44b1ab..725d0c30 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/services/DownloadRedditVideoService.java @@ -339,7 +339,6 @@ public class DownloadRedditVideoService extends Service { } private boolean muxVideoAndAudio(String videoFilePath, String audioFilePath, String outputFilePath) { - Log.i("asdfasdf", "sasdfasdf"); try { File file = new File(outputFilePath); file.createNewFile(); |