Add reset button to episodes filter (#6825)
This commit is contained in:
parent
8c7d567a0c
commit
c81157f0e6
|
@ -18,11 +18,13 @@ import com.google.android.material.bottomsheet.BottomSheetDialog;
|
|||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import com.google.android.material.button.MaterialButtonToggleGroup;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.core.feed.FeedItemFilterGroup;
|
||||
import de.danoeh.antennapod.databinding.FilterDialogBinding;
|
||||
import de.danoeh.antennapod.databinding.FilterDialogRowBinding;
|
||||
import de.danoeh.antennapod.model.feed.FeedItemFilter;
|
||||
|
||||
|
@ -36,24 +38,36 @@ public abstract class ItemFilterDialog extends BottomSheetDialogFragment {
|
|||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
View layout = inflater.inflate(R.layout.filter_dialog, null, false);
|
||||
rows = layout.findViewById(R.id.filter_rows);
|
||||
FilterDialogBinding binding = FilterDialogBinding.bind(layout);
|
||||
rows = binding.filterRows;
|
||||
FeedItemFilter filter = (FeedItemFilter) getArguments().getSerializable(ARGUMENT_FILTER);
|
||||
|
||||
//add filter rows
|
||||
for (FeedItemFilterGroup item : FeedItemFilterGroup.values()) {
|
||||
FilterDialogRowBinding binding = FilterDialogRowBinding.inflate(inflater);
|
||||
binding.getRoot().addOnButtonCheckedListener(
|
||||
FilterDialogRowBinding rowBinding = FilterDialogRowBinding.inflate(inflater);
|
||||
rowBinding.getRoot().addOnButtonCheckedListener(
|
||||
(group, checkedId, isChecked) -> onFilterChanged(getNewFilterValues()));
|
||||
binding.filterButton1.setText(item.values[0].displayName);
|
||||
binding.filterButton1.setTag(item.values[0].filterId);
|
||||
binding.filterButton2.setText(item.values[1].displayName);
|
||||
binding.filterButton2.setTag(item.values[1].filterId);
|
||||
binding.filterButton1.setMaxLines(3);
|
||||
binding.filterButton1.setSingleLine(false);
|
||||
binding.filterButton2.setMaxLines(3);
|
||||
binding.filterButton2.setSingleLine(false);
|
||||
rows.addView(binding.getRoot());
|
||||
rowBinding.filterButton1.setText(item.values[0].displayName);
|
||||
rowBinding.filterButton1.setTag(item.values[0].filterId);
|
||||
rowBinding.filterButton2.setText(item.values[1].displayName);
|
||||
rowBinding.filterButton2.setTag(item.values[1].filterId);
|
||||
rowBinding.filterButton1.setMaxLines(3);
|
||||
rowBinding.filterButton1.setSingleLine(false);
|
||||
rowBinding.filterButton2.setMaxLines(3);
|
||||
rowBinding.filterButton2.setSingleLine(false);
|
||||
rows.addView(rowBinding.getRoot(), rows.getChildCount() - 1);
|
||||
}
|
||||
|
||||
binding.confirmFiltermenu.setOnClickListener(view1 -> dismiss());
|
||||
binding.resetFiltermenu.setOnClickListener(view1 -> {
|
||||
onFilterChanged(Collections.emptySet());
|
||||
for (int i = 0; i < rows.getChildCount(); i++) {
|
||||
if (rows.getChildAt(i) instanceof MaterialButtonToggleGroup) {
|
||||
((MaterialButtonToggleGroup) rows.getChildAt(i)).clearChecked();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (String filterId : filter.getValues()) {
|
||||
if (!TextUtils.isEmpty(filterId)) {
|
||||
Button button = layout.findViewWithTag(filterId);
|
||||
|
|
|
@ -1,15 +1,42 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<ScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/filter_rows"
|
||||
android:id="@+id/filter_rows"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="24dp"
|
||||
android:paddingTop="24dp"
|
||||
android:paddingRight="24dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingLeft="24dp"
|
||||
android:paddingTop="24dp"
|
||||
android:paddingRight="24dp"
|
||||
android:paddingBottom="8dp">
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/resetFiltermenu"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/reset"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/confirmFiltermenu"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/confirm_label"
|
||||
style="@style/Widget.MaterialComponents.Button.TextButton" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
|
Loading…
Reference in New Issue