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 -> {
Intent intent = new Intent(EditMultiRedditActivity.this, SelectedSubredditsAndUsersActivity.class);
if (multiReddit.getSubreddits() != null) {
if (multiReddit.getSubreddits().isEmpty()) {
if (multiReddit.getSubreddits().isEmpty() && !multiReddit.getPath().equals("")) {
String[] communities = multiReddit.getPath().split(",");
ArrayList<SubredditWithSelection> communitiesList = new ArrayList<>();
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) {
switch (postType) {
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());
break;
case PostPagingSource.TYPE_SEARCH:
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());
sortTypeBottomSheetFragment.show(getSupportFragmentManager(), sortTypeBottomSheetFragment.getTag());
break;
case PostPagingSource.TYPE_USER:
UserThingSortTypeBottomSheetFragment userThingSortTypeBottomSheetFragment = UserThingSortTypeBottomSheetFragment.getNewInstance(mFragment.getSortType());
userThingSortTypeBottomSheetFragment.show(getSupportFragmentManager(), userThingSortTypeBottomSheetFragment.getTag());

View File

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

View File

@ -590,7 +590,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
private void showSortTypeBottomSheetFragment() {
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());
}
}
@ -676,7 +676,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
-> {
Utils.hideKeyboard(this);
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);
})
.setNegativeButton(R.string.cancel, (dialogInterface, i) -> {
@ -697,7 +697,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT
if (i == EditorInfo.IME_ACTION_DONE) {
Utils.hideKeyboard(this);
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);
return true;
}

View File

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

View File

@ -29,11 +29,20 @@ import eu.toldi.infinityforlemmy.utils.Utils;
*/
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_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)
TextView bestTypeTextView;
TextView activeTypeTextView;
@BindView(R.id.hot_type_text_view_sort_type_bottom_sheet_fragment)
TextView hotTypeTextView;
@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
}
public static SortTypeBottomSheetFragment getNewInstance(boolean isNoBestType, SortType currentSortType) {
public static SortTypeBottomSheetFragment getNewInstance(int pageType, SortType currentSortType) {
SortTypeBottomSheetFragment fragment = new SortTypeBottomSheetFragment();
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);
fragment.setArguments(bundle);
return fragment;
@ -69,18 +78,27 @@ public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
rootView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
}
if (getArguments().getBoolean(EXTRA_NO_BEST_TYPE)) {
bestTypeTextView.setVisibility(View.GONE);
} else {
bestTypeTextView.setOnClickListener(view -> {
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.ACTIVE));
dismiss();
});
int pageType = getArguments().getInt(EXTRA_PAGE_TYPE, PAGE_TYPE_USER);
switch (pageType) {
case PAGE_TYPE_MULTICOMMUNITY:
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);
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)) {
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)) {
@ -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);
}
activeTypeTextView.setOnClickListener(view -> {
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.ACTIVE));
dismiss();
});
hotTypeTextView.setOnClickListener(view -> {
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.HOT));
dismiss();

View File

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

View File

@ -63,23 +63,4 @@
android:textSize="?attr/font_default"
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>