Fix filter dialog on old Android versions
This commit is contained in:
parent
0dcf44f67e
commit
a510cb00fd
|
@ -3,6 +3,7 @@ package de.danoeh.antennapod.dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
|
|
||||||
|
@ -34,18 +35,19 @@ public abstract class FilterDialog {
|
||||||
builder.setTitle(R.string.filter);
|
builder.setTitle(R.string.filter);
|
||||||
|
|
||||||
LayoutInflater inflater = LayoutInflater.from(this.context);
|
LayoutInflater inflater = LayoutInflater.from(this.context);
|
||||||
LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.filter_dialog, null, false);
|
View layout = inflater.inflate(R.layout.filter_dialog, null, false);
|
||||||
|
LinearLayout rows = layout.findViewById(R.id.filter_rows);
|
||||||
builder.setView(layout);
|
builder.setView(layout);
|
||||||
|
|
||||||
for (FeedItemFilterGroup item : FeedItemFilterGroup.values()) {
|
for (FeedItemFilterGroup item : FeedItemFilterGroup.values()) {
|
||||||
RecursiveRadioGroup row = (RecursiveRadioGroup) inflater.inflate(R.layout.filter_dialog_row, null);
|
RecursiveRadioGroup row = (RecursiveRadioGroup) inflater.inflate(R.layout.filter_dialog_row, null, false);
|
||||||
RadioButton filter1 = row.findViewById(R.id.filter_dialog_radioButton1);
|
RadioButton filter1 = row.findViewById(R.id.filter_dialog_radioButton1);
|
||||||
RadioButton filter2 = row.findViewById(R.id.filter_dialog_radioButton2);
|
RadioButton filter2 = row.findViewById(R.id.filter_dialog_radioButton2);
|
||||||
filter1.setText(item.values[0].displayName);
|
filter1.setText(item.values[0].displayName);
|
||||||
filter1.setTag(item.values[0].filterId);
|
filter1.setTag(item.values[0].filterId);
|
||||||
filter2.setText(item.values[1].displayName);
|
filter2.setText(item.values[1].displayName);
|
||||||
filter2.setTag(item.values[1].filterId);
|
filter2.setTag(item.values[1].filterId);
|
||||||
layout.addView(row);
|
rows.addView(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String filterId : filterValues) {
|
for (String filterId : filterValues) {
|
||||||
|
@ -56,11 +58,11 @@ public abstract class FilterDialog {
|
||||||
|
|
||||||
builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> {
|
builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> {
|
||||||
filterValues.clear();
|
filterValues.clear();
|
||||||
for (int i = 0; i < layout.getChildCount(); i++) {
|
for (int i = 0; i < rows.getChildCount(); i++) {
|
||||||
if (!(layout.getChildAt(i) instanceof RecursiveRadioGroup)) {
|
if (!(rows.getChildAt(i) instanceof RecursiveRadioGroup)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
RecursiveRadioGroup group = (RecursiveRadioGroup) layout.getChildAt(i);
|
RecursiveRadioGroup group = (RecursiveRadioGroup) rows.getChildAt(i);
|
||||||
if (group.getCheckedButton() != null) {
|
if (group.getCheckedButton() != null) {
|
||||||
String tag = (String) group.getCheckedButton().getTag();
|
String tag = (String) group.getCheckedButton().getTag();
|
||||||
if (tag != null) { // Clear buttons use no tag
|
if (tag != null) { // Clear buttons use no tag
|
||||||
|
|
|
@ -30,7 +30,8 @@ public class SubscriptionsFilterDialog {
|
||||||
builder.setTitle(context.getString(R.string.pref_filter_feed_title));
|
builder.setTitle(context.getString(R.string.pref_filter_feed_title));
|
||||||
|
|
||||||
LayoutInflater inflater = LayoutInflater.from(context);
|
LayoutInflater inflater = LayoutInflater.from(context);
|
||||||
LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.filter_dialog, null, false);
|
View layout = inflater.inflate(R.layout.filter_dialog, null, false);
|
||||||
|
LinearLayout rows = layout.findViewById(R.id.filter_rows);
|
||||||
builder.setView(layout);
|
builder.setView(layout);
|
||||||
|
|
||||||
for (SubscriptionsFilterGroup item : SubscriptionsFilterGroup.values()) {
|
for (SubscriptionsFilterGroup item : SubscriptionsFilterGroup.values()) {
|
||||||
|
@ -45,7 +46,7 @@ public class SubscriptionsFilterDialog {
|
||||||
} else {
|
} else {
|
||||||
filter2.setVisibility(View.GONE);
|
filter2.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
layout.addView(row);
|
rows.addView(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String filterId : filterValues) {
|
for (String filterId : filterValues) {
|
||||||
|
@ -56,11 +57,11 @@ public class SubscriptionsFilterDialog {
|
||||||
|
|
||||||
builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> {
|
builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> {
|
||||||
filterValues.clear();
|
filterValues.clear();
|
||||||
for (int i = 0; i < layout.getChildCount(); i++) {
|
for (int i = 0; i < rows.getChildCount(); i++) {
|
||||||
if (!(layout.getChildAt(i) instanceof RecursiveRadioGroup)) {
|
if (!(rows.getChildAt(i) instanceof RecursiveRadioGroup)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
RecursiveRadioGroup group = (RecursiveRadioGroup) layout.getChildAt(i);
|
RecursiveRadioGroup group = (RecursiveRadioGroup) rows.getChildAt(i);
|
||||||
if (group.getCheckedButton() != null) {
|
if (group.getCheckedButton() != null) {
|
||||||
String tag = (String) group.getCheckedButton().getTag();
|
String tag = (String) group.getCheckedButton().getTag();
|
||||||
if (tag != null) { // Clear buttons use no tag
|
if (tag != null) { // Clear buttons use no tag
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:orientation="vertical"
|
<LinearLayout
|
||||||
android:paddingLeft="24dp"
|
android:id="@+id/filter_rows"
|
||||||
android:paddingTop="24dp"
|
android:layout_width="match_parent"
|
||||||
android:paddingRight="24dp"
|
android:layout_height="wrap_content"
|
||||||
android:paddingBottom="8dp">
|
android:orientation="vertical"
|
||||||
|
android:paddingLeft="24dp"
|
||||||
</LinearLayout>
|
android:paddingTop="24dp"
|
||||||
|
android:paddingRight="24dp"
|
||||||
|
android:paddingBottom="8dp">
|
||||||
|
</LinearLayout>
|
||||||
|
</ScrollView>
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
android:layout_marginRight="2dp"
|
android:layout_marginRight="2dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:background="?attr/filter_dialog_button_background"
|
android:background="?attr/filter_dialog_button_background"
|
||||||
android:button="@android:color/transparent"
|
style="@style/NoButtonRadio"
|
||||||
android:foreground="?android:attr/selectableItemBackground"
|
android:foreground="?android:attr/selectableItemBackground"
|
||||||
android:checked="false"
|
android:checked="false"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:background="?attr/filter_dialog_button_background"
|
android:background="?attr/filter_dialog_button_background"
|
||||||
android:button="@android:color/transparent"
|
style="@style/NoButtonRadio"
|
||||||
android:foreground="?android:attr/selectableItemBackground"
|
android:foreground="?android:attr/selectableItemBackground"
|
||||||
android:checked="false"
|
android:checked="false"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:background="@drawable/ic_filter_close"
|
android:background="@drawable/ic_filter_close"
|
||||||
android:button="@android:color/transparent"
|
style="@style/NoButtonRadio"
|
||||||
android:foreground="?android:attr/selectableItemBackground"
|
android:foreground="?android:attr/selectableItemBackground"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:checked="true" />
|
android:checked="true" />
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:bottom="5dp"
|
||||||
|
android:left="5dp"
|
||||||
|
android:right="5dp"
|
||||||
|
android:top="5dp">
|
||||||
|
|
||||||
|
<shape android:shape="oval">
|
||||||
|
<stroke
|
||||||
|
android:width="4dp"
|
||||||
|
android:color="?attr/filter_dialog_clear" />
|
||||||
|
</shape>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<!-- x -->
|
||||||
|
<item
|
||||||
|
android:bottom="12dp"
|
||||||
|
android:left="12dp"
|
||||||
|
android:right="12dp"
|
||||||
|
android:top="12dp">
|
||||||
|
<rotate
|
||||||
|
android:fromDegrees="135"
|
||||||
|
android:pivotX="50%"
|
||||||
|
android:pivotY="50%"
|
||||||
|
android:toDegrees="135">
|
||||||
|
<shape android:shape="line">
|
||||||
|
<stroke
|
||||||
|
android:width="4dp"
|
||||||
|
android:color="?attr/filter_dialog_clear" />
|
||||||
|
</shape>
|
||||||
|
</rotate>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:bottom="12dp"
|
||||||
|
android:left="12dp"
|
||||||
|
android:right="12dp"
|
||||||
|
android:top="12dp">
|
||||||
|
<rotate
|
||||||
|
android:fromDegrees="45"
|
||||||
|
android:pivotX="50%"
|
||||||
|
android:pivotY="50%"
|
||||||
|
android:toDegrees="45">
|
||||||
|
<shape android:shape="line">
|
||||||
|
<stroke
|
||||||
|
android:width="4dp"
|
||||||
|
android:color="?attr/filter_dialog_clear" />
|
||||||
|
</shape>
|
||||||
|
|
||||||
|
</rotate>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
</layer-list>
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<!-- Fall-back for old Android devices that do not support attrs as colors -->
|
||||||
<item
|
<item
|
||||||
android:bottom="5dp"
|
android:bottom="5dp"
|
||||||
android:left="5dp"
|
android:left="5dp"
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
<shape android:shape="oval">
|
<shape android:shape="oval">
|
||||||
<stroke
|
<stroke
|
||||||
android:width="4dp"
|
android:width="4dp"
|
||||||
android:color="?attr/filter_dialog_clear" />
|
android:color="#555" />
|
||||||
</shape>
|
</shape>
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
<shape android:shape="line">
|
<shape android:shape="line">
|
||||||
<stroke
|
<stroke
|
||||||
android:width="4dp"
|
android:width="4dp"
|
||||||
android:color="?attr/filter_dialog_clear" />
|
android:color="#555" />
|
||||||
</shape>
|
</shape>
|
||||||
</rotate>
|
</rotate>
|
||||||
</item>
|
</item>
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
<shape android:shape="line">
|
<shape android:shape="line">
|
||||||
<stroke
|
<stroke
|
||||||
android:width="4dp"
|
android:width="4dp"
|
||||||
android:color="?attr/filter_dialog_clear" />
|
android:color="#555" />
|
||||||
</shape>
|
</shape>
|
||||||
|
|
||||||
</rotate>
|
</rotate>
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
<attr name="action_icon_color" format="color"/>
|
<attr name="action_icon_color" format="color"/>
|
||||||
<attr name="scrollbar_thumb" format="reference"/>
|
<attr name="scrollbar_thumb" format="reference"/>
|
||||||
<attr name="background_elevated" format="color"/>
|
<attr name="background_elevated" format="color"/>
|
||||||
<attr name="filter_dialog_clear" format="reference"/>
|
<attr name="filter_dialog_clear" format="color"/>
|
||||||
<attr name="filter_dialog_button_background" format="reference"/>
|
<attr name="filter_dialog_button_background" format="reference"/>
|
||||||
<attr name="ic_notifications" format="reference"/>
|
<attr name="ic_notifications" format="reference"/>
|
||||||
|
|
||||||
|
|
|
@ -318,4 +318,9 @@
|
||||||
<item name="android:clickable">true</item>
|
<item name="android:clickable">true</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="NoButtonRadio" parent="Widget.MaterialComponents.CompoundButton.RadioButton">
|
||||||
|
<item name="buttonCompat">@null</item> <!-- For Android 4.4 -->
|
||||||
|
<item name="android:button">@null</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue