Added "Most comments" and "new comments" sort type

This commit is contained in:
Balazs Toldi 2024-01-06 11:39:33 +01:00
parent 133dc4a69c
commit ba5b533cb9
No known key found for this signature in database
GPG Key ID: 6C7D440036F99D58
5 changed files with 76 additions and 2 deletions

View File

@ -35,8 +35,8 @@ public class SortType {
NEW("New", "New"),
OLD("Old", "Old"),
TOP("Top", "Top"),
MOST_COMMENTS("MostCommentes", "Most Commentes"),
NEW_COMMENTS("NewCommentes", "New Commentes"),
MOST_COMMENTS("MostComments", "Most Comments"),
NEW_COMMENTS("NewComments", "New Comments"),
TOP_HOUR("TopHour", "Top"),
TOP_SIX_HOURS("TopSixHour", "Top"),

View File

@ -58,6 +58,12 @@ public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
@BindView(R.id.controversial_type_text_view_sort_type_bottom_sheet_fragment)
TextView controversialTypeTextView;
@BindView(R.id.most_comments_type_text_view_sort_type_bottom_sheet_fragment)
TextView mostCommentsTypeTextView;
@BindView(R.id.new_comments_type_text_view_sort_type_bottom_sheet_fragment)
TextView newCommentsTypeTextView;
private BaseActivity activity;
public SortTypeBottomSheetFragment() {
@ -93,6 +99,10 @@ public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
case PAGE_TYPE_ANONYMOUS_FRONT_PAGE:
activeTypeTextView.setVisibility(View.GONE);
hotTypeTextView.setVisibility(View.GONE);
scaledTypeTextView.setVisibility(View.GONE);
controversialTypeTextView.setVisibility(View.GONE);
mostCommentsTypeTextView.setVisibility(View.GONE);
newCommentsTypeTextView.setVisibility(View.GONE);
break;
default:
@ -117,6 +127,10 @@ public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
scaledTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(scaledTypeTextView.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);
} else if (currentSortType.equals(SortType.Type.MOST_COMMENTS.fullName)) {
mostCommentsTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(mostCommentsTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
} else if (currentSortType.equals(SortType.Type.NEW_COMMENTS.fullName)) {
newCommentsTypeTextView.setCompoundDrawablesRelativeWithIntrinsicBounds(newCommentsTypeTextView.getCompoundDrawablesRelative()[0], null, AppCompatResources.getDrawable(activity, R.drawable.ic_round_check_circle_day_night_24dp), null);
}
activeTypeTextView.setOnClickListener(view -> {
@ -154,6 +168,16 @@ public class SortTypeBottomSheetFragment extends LandscapeExpandedRoundedBottomS
dismiss();
});
mostCommentsTypeTextView.setOnClickListener(view -> {
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.MOST_COMMENTS));
dismiss();
});
newCommentsTypeTextView.setOnClickListener(view -> {
((SortTypeSelectionCallback) activity).sortTypeSelected(new SortType(SortType.Type.NEW_COMMENTS));
dismiss();
});
if (activity.typeface != null) {
Utils.setFontToAllTextViews(rootView, activity.typeface);

View File

@ -0,0 +1,10 @@
<vector android:height="24dp"
android:tint="#000000"
android:viewportHeight="24"
android:viewportWidth="24"
android:width="24dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path
android:fillColor="@android:color/white"
android:pathData="M21.99,4c0,-1.1 -0.89,-2 -1.99,-2H4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h14l4,4 -0.01,-18zM17,11h-4v4h-2v-4H7V9h4V5h2v4h4v2z" />
</vector>

View File

@ -144,6 +144,44 @@
android:textSize="?attr/font_default"
app:drawableTint="?attr/primaryTextColor" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/most_comments_type_text_view_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_comment_black_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_most_comments"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
app:drawableTint="?attr/primaryTextColor" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/new_comments_type_text_view_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_new_comments_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_new_comments"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
app:drawableTint="?attr/primaryTextColor" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View File

@ -1321,4 +1321,6 @@
<string name="sort_scaled">Scaled</string>
<string name="token_expired">Token Expired</string>
<string name="token_expired_message">"Your token has been expired. As Eternity does not store your password, you need to manually log back in! "</string>
<string name="sort_most_comments">Most Comments</string>
<string name="sort_new_comments">New Comments</string>
</resources>