Minor changes to multi-communities

This commit is contained in:
Balazs Toldi 2024-01-05 18:37:43 +01:00
parent 4f3e09c84b
commit 3f0862c5e5
No known key found for this signature in database
GPG Key ID: 6C7D440036F99D58
8 changed files with 46 additions and 53 deletions

View File

@ -166,7 +166,7 @@ public class EditMultiRedditActivity extends BaseActivity {
selectSubredditTextView.setOnClickListener(view -> { selectSubredditTextView.setOnClickListener(view -> {
Intent intent = new Intent(EditMultiRedditActivity.this, SelectedSubredditsAndUsersActivity.class); Intent intent = new Intent(EditMultiRedditActivity.this, SelectedSubredditsAndUsersActivity.class);
if (multiReddit.getSubreddits() != null) { if (multiReddit.getSubreddits() != null) {
if (multiReddit.getSubreddits().isEmpty()) { if (multiReddit.getSubreddits().isEmpty() && !multiReddit.getPath().equals("")) {
String[] communities = multiReddit.getPath().split(","); String[] communities = multiReddit.getPath().split(",");
ArrayList<SubredditWithSelection> communitiesList = new ArrayList<>(); ArrayList<SubredditWithSelection> communitiesList = new ArrayList<>();
for (String community : communities) { for (String community : communities) {

View File

@ -371,20 +371,17 @@ 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()); case PostPagingSource.TYPE_SUBREDDIT:
case PostPagingSource.TYPE_MULTI_REDDIT:
case PostPagingSource.TYPE_ANONYMOUS_MULTIREDDIT:
case PostPagingSource.TYPE_ANONYMOUS_FRONT_PAGE:
SortTypeBottomSheetFragment bestSortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(postType, mFragment.getSortType());
bestSortTypeBottomSheetFragment.show(getSupportFragmentManager(), bestSortTypeBottomSheetFragment.getTag()); bestSortTypeBottomSheetFragment.show(getSupportFragmentManager(), bestSortTypeBottomSheetFragment.getTag());
break; break;
case PostPagingSource.TYPE_SEARCH: case PostPagingSource.TYPE_SEARCH:
SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = SearchPostSortTypeBottomSheetFragment.getNewInstance(mFragment.getSortType()); SearchPostSortTypeBottomSheetFragment searchPostSortTypeBottomSheetFragment = SearchPostSortTypeBottomSheetFragment.getNewInstance(mFragment.getSortType());
searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag()); searchPostSortTypeBottomSheetFragment.show(getSupportFragmentManager(), searchPostSortTypeBottomSheetFragment.getTag());
break; 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());
sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
break;
case PostPagingSource.TYPE_USER: case PostPagingSource.TYPE_USER:
UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment = UserThingSortTypeBottomSheetFragment.getNewInstance(mFragment.getSortType()); UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment = UserThingSortTypeBottomSheetFragment.getNewInstance(mFragment.getSortType());
userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag()); userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag());

View File

@ -1134,7 +1134,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()); SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(currentPostType, postFragment.getSortType());
sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag()); sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
} }
} }

View File

@ -590,7 +590,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()); SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(SortTypeBottomSheetFragment.PAGE_TYPE_MULTICOMMUNITY, ((PostFragment) mFragment).getSortType());
sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag()); sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
} }
} }
@ -676,7 +676,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
-> { -> {
Utils.hideKeyboard(this); Utils.hideKeyboard(this);
Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class); Intent subredditIntent = new Intent(this, ViewSubredditDetailActivity.class);
subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, thingEditText.getText().toString()); subredditIntent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, thingEditText.getText().toString());
startActivity(subredditIntent); startActivity(subredditIntent);
}) })
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> { .setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
@ -697,7 +697,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
if (i == EditorInfo.IME_ACTION_DONE) { if (i == EditorInfo.IME_ACTION_DONE) {
Utils.hideKeyboard(this); Utils.hideKeyboard(this);
Intent userIntent = new Intent(this, ViewUserDetailActivity.class); Intent userIntent = new Intent(this, ViewUserDetailActivity.class);
userIntent.putExtra(ViewUserDetailActivity.EXTRA_USER_NAME_KEY, thingEditText.getText().toString()); userIntent.putExtra(ViewUserDetailActivity.EXTRA_QUALIFIED_USER_NAME_KEY, thingEditText.getText().toString());
startActivity(userIntent); startActivity(userIntent);
return true; return true;
} }

View File

@ -1206,7 +1206,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()); SortTypeBottomSheetFragment sortTypeBottomSheetFragment = SortTypeBottomSheetFragment.getNewInstance(SortTypeBottomSheetFragment.PAGE_TYPE_COMMUNITY, ((PostFragment) fragment).getSortType());
sortTypeBottomSheetFragment.show(fragmentManager, sortTypeBottomSheetFragment.getTag()); sortTypeBottomSheetFragment.show(fragmentManager, sortTypeBottomSheetFragment.getTag());
} }
} }

View File

@ -29,11 +29,20 @@ import eu.toldi.infinityforlemmy.utils.Utils;
*/ */
public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment { public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
public static final String EXTRA_NO_BEST_TYPE = "ENBT";
public static final String EXTRA_CURRENT_SORT_TYPE = "ECST"; public static final String EXTRA_CURRENT_SORT_TYPE = "ECST";
public static final String EXTRA_PAGE_TYPE = "EPT";
public static final int PAGE_TYPE_FRONT_PAGE = 0;
public static final int PAGE_TYPE_COMMUNITY = 1;
public static final int PAGE_TYPE_USER = 2;
public static final int PAGE_TYPE_SEARCH = 3;
public static final int PAGE_TYPE_MULTICOMMUNITY = 4;
public static final int PAGE_TYPE_ANONYMOUS_FRONT_PAGE = 5;
@BindView(R.id.best_type_text_view_sort_type_bottom_sheet_fragment) @BindView(R.id.best_type_text_view_sort_type_bottom_sheet_fragment)
TextView bestTypeTextView; TextView activeTypeTextView;
@BindView(R.id.hot_type_text_view_sort_type_bottom_sheet_fragment) @BindView(R.id.hot_type_text_view_sort_type_bottom_sheet_fragment)
TextView hotTypeTextView; TextView hotTypeTextView;
@BindView(R.id.new_type_text_view_sort_type_bottom_sheet_fragment) @BindView(R.id.new_type_text_view_sort_type_bottom_sheet_fragment)
@ -49,10 +58,10 @@ public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
// Required empty public constructor // Required empty public constructor
} }
public static SortTypeBottomSheetFragment getNewInstance(boolean isNoBestType, SortType currentSortType) { public static SortTypeBottomSheetFragment getNewInstance(int pageType, 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.putInt(EXTRA_PAGE_TYPE, pageType);
bundle.putString(EXTRA_CURRENT_SORT_TYPE, currentSortType.getType().fullName); bundle.putString(EXTRA_CURRENT_SORT_TYPE, currentSortType.getType().fullName);
fragment.setArguments(bundle); fragment.setArguments(bundle);
return fragment; return fragment;
@ -69,18 +78,27 @@ public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR); rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
} }
if (getArguments().getBoolean(EXTRA_NO_BEST_TYPE)) { int pageType = getArguments().getInt(EXTRA_PAGE_TYPE, PAGE_TYPE_USER);
bestTypeTextView.setVisibility(View.GONE);
} else { switch (pageType) {
bestTypeTextView.setOnClickListener(view -> {
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.ACTIVE)); case PAGE_TYPE_MULTICOMMUNITY:
dismiss(); case PAGE_TYPE_USER:
}); case PAGE_TYPE_ANONYMOUS_FRONT_PAGE:
activeTypeTextView.setVisibility(View.GONE);
hotTypeTextView.setVisibility(View.GONE);
break;
default:
case PAGE_TYPE_COMMUNITY:
case PAGE_TYPE_FRONT_PAGE:
break;
} }
String currentSortType = getArguments().getString(EXTRA_CURRENT_SORT_TYPE); String currentSortType = getArguments().getString(EXTRA_CURRENT_SORT_TYPE);
if (currentSortType.equals(SortType.Type.ACTIVE.fullName)) { if (currentSortType.equals(SortType.Type.ACTIVE.fullName)) {
bestTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(bestTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); activeTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(activeTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.HOT.fullName)) { } 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); 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.NEW.fullName)) { } else if (currentSortType.equals(SortType.Type.NEW.fullName)) {
@ -91,6 +109,11 @@ public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
topTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(topTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null); topTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(topTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} }
activeTypeTextView.setOnClickListener(view -> {
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.ACTIVE));
dismiss();
});
hotTypeTextView.setOnClickListener(view -> { hotTypeTextView.setOnClickListener(view -> {
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.HOT)); ((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.HOT));
dismiss(); dismiss();

View File

@ -37,8 +37,6 @@ public class UserThingSortTypeBottomSheetFragment extends LandscapeExpandedRound
TextView hotTypeTextView; TextView hotTypeTextView;
@BindView(R.id.top_type_text_view_user_thing_sort_type_bottom_sheet_fragment) @BindView(R.id.top_type_text_view_user_thing_sort_type_bottom_sheet_fragment)
TextView topTypeTextView; TextView topTypeTextView;
@BindView(R.id.controversial_type_text_view_user_thing_sort_type_bottom_sheet_fragment)
TextView controversialTypeTextView;
private BaseActivity activity; private BaseActivity activity;
public UserThingSortTypeBottomSheetFragment() { public UserThingSortTypeBottomSheetFragment() {
@ -95,12 +93,6 @@ public class UserThingSortTypeBottomSheetFragment extends LandscapeExpandedRound
dismiss(); dismiss();
}); });
/* controversialTypeTextView.setOnClickListener(view -> {
if (activity != null) {
((SortTypeSelectionCallback) activity).sortTypeSelected(SortType.Type.CONTROVERSIAL.name());
}
dismiss();
});*/
if (activity.typeface != null) { if (activity.typeface != null) {
Utils.setFontToAllTextViews(rootView, activity.typeface); Utils.setFontToAllTextViews(rootView, activity.typeface);

View File

@ -63,23 +63,4 @@
android:textSize="?attr/font_default" android:textSize="?attr/font_default"
app:drawableTint="?attr/primaryTextColor" /> app:drawableTint="?attr/primaryTextColor" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/controversial_type_text_view_user_thing_sort_type_bottom_sheet_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:drawableStart="@drawable/ic_controversial_24"
android:drawablePadding="48dp"
android:focusable="true"
android:fontFamily="?attr/font_family"
android:paddingStart="32dp"
android:paddingTop="16dp"
android:paddingEnd="32dp"
android:paddingBottom="16dp"
android:text="@string/sort_controversial"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
app:drawableTint="?attr/primaryTextColor" />
</LinearLayout> </LinearLayout>