From f243bcd4cce1f3af9449c74fa38f6c90f2ea9d22 Mon Sep 17 00:00:00 2001 From: bws9000 Date: Sun, 21 Jun 2020 12:52:15 +0200 Subject: [PATCH 01/14] Redesign filter dialog --- .../antennapod/dialog/FilterDialog.java | 121 ++++++++++++++---- .../main/res/layout/filter_dialog_layout.xml | 11 ++ .../filter_dialog_relative_cardview.xml | 55 ++++++++ .../core/feed/FeedItemFilterGroup.java | 84 ++++++++++++ .../main/res/drawable-hdpi/x_custom_off.png | Bin 0 -> 1062 bytes .../main/res/drawable-hdpi/x_custom_on.png | Bin 0 -> 1093 bytes .../main/res/drawable/filter_dialog_x_off.xml | 56 ++++++++ .../main/res/drawable/filter_dialog_x_on.xml | 56 ++++++++ core/src/main/res/values/arrays.xml | 12 -- core/src/main/res/values/strings.xml | 21 +-- 10 files changed, 371 insertions(+), 45 deletions(-) create mode 100644 app/src/main/res/layout/filter_dialog_layout.xml create mode 100644 app/src/main/res/layout/filter_dialog_relative_cardview.xml create mode 100644 core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilterGroup.java create mode 100644 core/src/main/res/drawable-hdpi/x_custom_off.png create mode 100644 core/src/main/res/drawable-hdpi/x_custom_on.png create mode 100644 core/src/main/res/drawable/filter_dialog_x_off.xml create mode 100644 core/src/main/res/drawable/filter_dialog_x_on.xml diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/FilterDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/FilterDialog.java index d2912f90f..ece286eb4 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/FilterDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/FilterDialog.java @@ -1,15 +1,22 @@ package de.danoeh.antennapod.dialog; import android.content.Context; +import android.graphics.Color; +import android.view.LayoutInflater; +import android.widget.LinearLayout; +import android.widget.RadioButton; +import android.widget.RelativeLayout; + import androidx.appcompat.app.AlertDialog; -import android.text.TextUtils; import java.util.Arrays; import java.util.HashSet; +import java.util.Iterator; import java.util.Set; import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.feed.FeedItemFilter; +import de.danoeh.antennapod.core.feed.FeedItemFilterGroup; public abstract class FilterDialog { @@ -22,38 +29,102 @@ public abstract class FilterDialog { } public void openDialog() { - final String[] items = context.getResources().getStringArray(R.array.episode_filter_options); - final String[] values = context.getResources().getStringArray(R.array.episode_filter_values); - final boolean[] checkedItems = new boolean[items.length]; final Set filterValues = new HashSet<>(Arrays.asList(filter.getValues())); - - // make sure we have no empty strings in the filter list - for (String filterValue : filterValues) { - if (TextUtils.isEmpty(filterValue)) { - filterValues.remove(filterValue); - } - } - - for (int i = 0; i < values.length; i++) { - String value = values[i]; - if (filterValues.contains(value)) { - checkedItems[i] = true; - } - } - AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.filter); - builder.setMultiChoiceItems(items, checkedItems, (dialog, which, isChecked) -> { - if (isChecked) { - filterValues.add(values[which]); - } else { - filterValues.remove(values[which]); + + LayoutInflater inflater = LayoutInflater.from(this.context); + LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.filter_dialog_layout, null, false); + builder.setView(layout); + + for (FeedItemFilterGroup.FeedItemEnum item : FeedItemFilterGroup.FeedItemEnum.values()) { + + RelativeLayout row = (RelativeLayout) inflater.inflate(R.layout.filter_dialog_relative_cardview, null); + RadioButton radioButton1 = row.findViewById(R.id.filter_dialog_radioButton1); + RadioButton radioButton2 = row.findViewById(R.id.filter_dialog_radioButton2); + RadioButton radioButton3 = row.findViewById(R.id.filter_dialog_radioButton3); + radioButton1.setText(item.values[1].displayName); + radioButton1.setTextColor(Color.BLACK); + radioButton2.setText(item.values[0].displayName); + radioButton2.setTextColor(Color.BLACK); + + Iterator filterIterator = filterValues.iterator(); + while (filterIterator.hasNext()) { + String nextItem = filterIterator.next(); + if (item.values[1].filterId.equals(nextItem)) { + item.values[1].setSelected(true); + item.values[0].setSelected(false); + radioButton1.setBackgroundResource(R.color.accent_light); + radioButton2.setBackgroundResource(R.color.master_switch_background_light); + radioButton3.setBackgroundResource(R.drawable.filter_dialog_x_on); + radioButton1.setSelected(true); + radioButton2.setSelected(false); + radioButton1.setTextColor(Color.WHITE); + radioButton2.setTextColor(Color.BLACK); + } + if (item.values[0].filterId.equals(nextItem)) { + item.values[0].setSelected(true); + item.values[1].setSelected(false); + radioButton2.setBackgroundResource(R.color.accent_light); + radioButton1.setBackgroundResource(R.color.master_switch_background_light); + radioButton3.setBackgroundResource(R.drawable.filter_dialog_x_on); + radioButton2.setSelected(true); + radioButton1.setSelected(false); + radioButton2.setTextColor(Color.WHITE); + radioButton1.setTextColor(Color.BLACK); + } } - }); + + radioButton1.setOnClickListener(arg0 -> { + item.values[1].setSelected(true); + item.values[0].setSelected(false); + radioButton1.setBackgroundResource(R.color.accent_light); + radioButton2.setBackgroundResource(R.color.master_switch_background_light); + radioButton3.setBackgroundResource(R.drawable.filter_dialog_x_on); + radioButton2.setSelected(false); + radioButton2.setTextColor(Color.BLACK); + radioButton1.setSelected(true); + radioButton1.setTextColor(Color.WHITE); + }); + radioButton2.setOnClickListener(arg0 -> { + item.values[0].setSelected(true); + item.values[1].setSelected(false); + radioButton2.setBackgroundResource(R.color.accent_light); + radioButton1.setBackgroundResource(R.color.master_switch_background_light); + radioButton3.setBackgroundResource(R.drawable.filter_dialog_x_on); + radioButton1.setSelected(false); + radioButton1.setTextColor(Color.BLACK); + radioButton2.setSelected(true); + radioButton2.setTextColor(Color.WHITE); + }); + radioButton3.setOnClickListener(arg0 -> { + item.values[0].setSelected(false); + item.values[1].setSelected(false); + radioButton1.setBackgroundResource(R.color.master_switch_background_light); + radioButton2.setBackgroundResource(R.color.master_switch_background_light); + radioButton3.setBackgroundResource(R.drawable.filter_dialog_x_off); + radioButton2.setTextColor(Color.BLACK); + radioButton2.setSelected(false); + radioButton1.setTextColor(Color.BLACK); + radioButton1.setSelected(false); + }); + layout.addView(row); + } + + builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> { + filterValues.clear(); + for (FeedItemFilterGroup.FeedItemEnum item : FeedItemFilterGroup.FeedItemEnum.values()) { + for (int i = 0; i < item.values.length; i++) { + if (item.values[i].getSelected()) { + filterValues.add(item.values[i].filterId); + } + } + } updateFilter(filterValues); }); + builder.setNegativeButton(R.string.cancel_label, null); builder.create().show(); } diff --git a/app/src/main/res/layout/filter_dialog_layout.xml b/app/src/main/res/layout/filter_dialog_layout.xml new file mode 100644 index 000000000..c50e08814 --- /dev/null +++ b/app/src/main/res/layout/filter_dialog_layout.xml @@ -0,0 +1,11 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/filter_dialog_relative_cardview.xml b/app/src/main/res/layout/filter_dialog_relative_cardview.xml new file mode 100644 index 000000000..e3dc94f64 --- /dev/null +++ b/app/src/main/res/layout/filter_dialog_relative_cardview.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilterGroup.java b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilterGroup.java new file mode 100644 index 000000000..18c1c186d --- /dev/null +++ b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilterGroup.java @@ -0,0 +1,84 @@ +package de.danoeh.antennapod.core.feed; + +import de.danoeh.antennapod.core.R; + +public class FeedItemFilterGroup { + + private static boolean DEFAULT_SELECTED_STATE = false; + + private static final String NO_FILTERID = ""; + private static final int HASMEDIA_LABEL = R.string.has_media; + private static final int NOTPAUSED_LABEL = R.string.not_paused; + private static final int NOTFAVORITE_LABEL = R.string.not_favorite; + + private static final int UNPLAYED_LABEL = R.string.not_played; + private static final String UNPLAYED_FILTERID = "unplayed"; + + private static final int PLAYED_LABEL = R.string.hide_played_episodes_label; + private static final String PLAYED_FILTERID = "played"; + + private static final int PAUSED_LABEL = R.string.hide_paused_episodes_label; + private static final String PAUSED_FILTERID = "paused"; + + private static final int ISFAVORITE_LABEL = R.string.hide_is_favorite_label; + private static final String ISFAVORITE_FILTERID = "is_favorite"; + + private static final int NOMEDIA_LABEL = R.string.no_media; + private static final String NOMEDIA_FILTERID = "no_media"; + + private static final int QUEUED_LABEL = R.string.queue_label; + private static final String QUEUED_FILTERID = "queued"; + + private static final int NOTQUEUED_LABEL = R.string.not_queued_label; + private static final String NOTQUEUED_FILTERID = "not_queued"; + + private static final int NOTDOWNLOADED_LABEL = R.string.hide_downloaded_episodes_label; + private static final String NOTDOWNLOADED_FILTERID = "not_downloaded"; + + private static final int DOWNLOADED_LABEL = R.string.hide_downloaded_episodes_label; + private static final String DOWNLOADED_FILTERID = "downloaded"; + + public enum FeedItemEnum { + + PLAYED(new ItemProperties(DEFAULT_SELECTED_STATE, UNPLAYED_LABEL, UNPLAYED_FILTERID), + new ItemProperties(DEFAULT_SELECTED_STATE, PLAYED_LABEL, PLAYED_FILTERID)), + PAUSED(new ItemProperties(DEFAULT_SELECTED_STATE, NOTPAUSED_LABEL, NO_FILTERID), + new ItemProperties(DEFAULT_SELECTED_STATE, PAUSED_LABEL, PAUSED_FILTERID)), + FAVORITE(new ItemProperties(DEFAULT_SELECTED_STATE, NOTFAVORITE_LABEL, NO_FILTERID), + new ItemProperties(DEFAULT_SELECTED_STATE, ISFAVORITE_LABEL, ISFAVORITE_FILTERID)), + MEDIA(new ItemProperties(DEFAULT_SELECTED_STATE, NOMEDIA_LABEL, NOMEDIA_FILTERID), + new ItemProperties(DEFAULT_SELECTED_STATE, HASMEDIA_LABEL, NO_FILTERID)), + QUEUED(new ItemProperties(DEFAULT_SELECTED_STATE, NOTQUEUED_LABEL, NOTQUEUED_FILTERID), + new ItemProperties(DEFAULT_SELECTED_STATE, QUEUED_LABEL, QUEUED_FILTERID)), + DOWNLOADED(new ItemProperties(DEFAULT_SELECTED_STATE, NOTDOWNLOADED_LABEL, NOTDOWNLOADED_FILTERID), + new ItemProperties(DEFAULT_SELECTED_STATE, DOWNLOADED_LABEL, DOWNLOADED_FILTERID)); + + public final ItemProperties[] values; + + FeedItemEnum(ItemProperties... values) { + this.values = values; + } + + public static class ItemProperties { + + public final int displayName; + public boolean selected; + public final String filterId; + + public void setSelected(boolean value) { + this.selected = value; + } + + public boolean getSelected() { + return this.selected; + } + + public ItemProperties(boolean selected, int displayName, String filterId) { + this.selected = selected; + this.displayName = displayName; + this.filterId = filterId; + } + + } + } +} diff --git a/core/src/main/res/drawable-hdpi/x_custom_off.png b/core/src/main/res/drawable-hdpi/x_custom_off.png new file mode 100644 index 0000000000000000000000000000000000000000..2450d2e89eed9bd7de795a75e99dc1f24412b23c GIT binary patch literal 1062 zcmV+>1ljwEP)-z3xW^Qq$na*P<&`q@P-u|#1qkIwNa-08y1^$*|SelBb^U6?7h#LHS?b{vu4dY z1OkCTAP@)y0)apv5D4@FN_>XU*w~oFtPGf<>vLc@P@&IW0FQxNz%^ZO3puQ>ulM?< z%Dk-e;|5*}R0D%@Sbm~wB2WW#0B3-c65K6xm#8XWnFj2`KwuH@HP8&S^afF-zzY33 zmcM{sf$P8nAOrLP1_MKZN?;Z+Ol{nk;pW&RU=Pssp+q@B-vcvZV)g^SWf|BT;GwSH zfrG$IUt^))oFs6uc#^J zS9%hgE{;pUA=zvK`e*SmTkG*pU~86)qE)_;AJ?ZBX+%ZjigL&F*%)AbEEW3#SgGv6 z1&8NZ+IPh^;i;Zu^cFSV+~3Gy66Ugqb&7~_ zs^l9*L3j4*QBiI%r_J-XCLu*Roy!3JP;#1$=(E0N?~3RrpAl!16lUV2Ir*M6#T9pA zty6|jt}LNRIpCW-J}xLC4$}I|Xxi18Q*b8Xp4Kg*UZ{@Hpl3G)pXoew&cn|ob6=v9 zw4Kg-(^i<$ZoaK5ZAH{*DwU`3)n9FE%)2wiRF;a#DBL%B(L8?%?AAh0QY0;vZIjwY zT$JzB6jM#=Qq{+n$cAX6U1CaP_f0P6*3c+z%(g@parQ%($WZ6M05_FAM3Kyio3ASg z8T~rFqL>-cqT|FoRe}a2Z1-I2=R|KTJEK7z29B6N2qxtCgP_gl4}$+afj}S-2m}Iw gKp+qZ1U^21_c&zC|81?Z!2kdN07*qoM6N<$g0kH8y#N3J literal 0 HcmV?d00001 diff --git a/core/src/main/res/drawable-hdpi/x_custom_on.png b/core/src/main/res/drawable-hdpi/x_custom_on.png new file mode 100644 index 0000000000000000000000000000000000000000..07525f9253edfb493b78f3059ac61597bdb319de GIT binary patch literal 1093 zcmV-L1iJf)P)5 z_FfV%5Nlzze`rz(QcI-i-s-fqvi|a2B{* zOkrDFo7XQj%}cs4ZsM&#Gq4~*vQF32Knrja=mz%4;Ic5aOnRDtA>iEt2IZqheTJlC zQW#YQ^ZURoL>8mw#wO4!ulHZpNvLnDbVYQTP~b%tquk)NYX1Uk0`BX6 zIq;;MLm{dq=dPKOyDwcMy06t(6*p?S;!s4pmQTb|1=axt-6TE*E&(3{6Gq1A+F|aS zHD*PPYBX`^=h$*_90PVr=D6H=oK4z~Kgr8Y#NPKxH`3$AthiAThZDTqhw^I96Yh_t zV$TAf1Gj;ffm?a{=cGHr#X2v1jaq5i=M!Yy-q;9yFR%8#p1XZ^RPoJa4_6C}V|Cjx zQ{fwYA2aR20&@QVYk>>ETfjBoO)aPGz?mZBSlvrJ=ji>V=9u=)BC@~Auz!KCfhT~k z6ts&mmM~^2%9YS2;g(>Z-rduFt2n+!-8Su-6!M#aSAoB^)Ll;aP>Oyw)3;-$!q=!_ z({3mt`@C{E7ki$OM|8pVn-s;V)osVDh*1Nk{agXL#ri7F(`^8Llt=7WY}#359IN{W z&pCP<)o0pG3AK;g*e8Mcz&mOqkLWV+-+=ezM3UxY3r0I;DzX?A15S<3lw zodiYsnOlOtD^vKwL(ehOc0cZCvE|&7^@J&F@a@&nmYu)}V0H#wv(&f6JnN1nwO*8x zQEXF!8nFtv47`?7Zg(bZ4d%qjHKl`^+=99}epHt3##A!>V+v)o#?gVae8; z{`*QjNumrVv^iC$-zj^DJXyV};`Wq!M)h?vFF8xO657Km<##0%eo5R?pQYt8h%%q0 zkLw8e1I4OF^9R8^$^2pdAn4QO9ftyeKp+qZ1OkCTAP@)yCOyFaN72cooI-*O00000 LNkvXXu0mjf4#5+W literal 0 HcmV?d00001 diff --git a/core/src/main/res/drawable/filter_dialog_x_off.xml b/core/src/main/res/drawable/filter_dialog_x_off.xml new file mode 100644 index 000000000..8368ffa51 --- /dev/null +++ b/core/src/main/res/drawable/filter_dialog_x_off.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/src/main/res/drawable/filter_dialog_x_on.xml b/core/src/main/res/drawable/filter_dialog_x_on.xml new file mode 100644 index 000000000..b25b42df3 --- /dev/null +++ b/core/src/main/res/drawable/filter_dialog_x_on.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/src/main/res/values/arrays.xml b/core/src/main/res/values/arrays.xml index dc79905cd..8e8d70525 100644 --- a/core/src/main/res/values/arrays.xml +++ b/core/src/main/res/values/arrays.xml @@ -257,18 +257,6 @@ @string/hide_is_favorite_label - - unplayed - paused - played - queued - not_queued - downloaded - not_downloaded - has_media - is_favorite - - @string/sort_date_new_old diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 93a21ef13..e46004664 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -151,14 +151,9 @@ Select all above Select all below Unplayed - Paused - Played Queued Not queued - Downloaded - Not downloaded Has media - Is favorite Filtered {fa-exclamation-circle} Last Refresh failed Open Podcast @@ -736,13 +731,23 @@ Selected downloaded Episodes Not downloaded Selected not downloaded Episodes - Queued Selected queued Episodes - Not queued Selected not queued Episodes - Has media Selected episodes with media + Is favorite + Not favorite + Downloaded + Not downloaded + Queued + Not queued + Has media + No media + Paused + Not paused + Played + Not played + Title (A \u2192 Z) Title (Z \u2192 A) From 7de9e0d4c1807bff054c1aef999fc600088ab521 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Sun, 21 Jun 2020 12:49:02 +0200 Subject: [PATCH 02/14] Using state lists for colors --- .../antennapod/dialog/FilterDialog.java | 112 ++++-------------- .../antennapod/view/RecursiveRadioGroup.java | 68 +++++++++++ ...er_dialog_layout.xml => filter_dialog.xml} | 0 .../filter_dialog_relative_cardview.xml | 55 --------- app/src/main/res/layout/filter_dialog_row.xml | 63 ++++++++++ .../core/feed/FeedItemFilterGroup.java | 94 ++++----------- .../filter_dialog_button_background_light.xml | 5 + .../res/color/filter_dialog_button_clear.xml | 5 + .../color/filter_dialog_button_text_light.xml | 5 + .../main/res/drawable/filter_dialog_x_off.xml | 56 --------- ...log_x_on.xml => ic_filter_close_light.xml} | 8 +- core/src/main/res/values/arrays.xml | 12 -- 12 files changed, 198 insertions(+), 285 deletions(-) create mode 100644 app/src/main/java/de/danoeh/antennapod/view/RecursiveRadioGroup.java rename app/src/main/res/layout/{filter_dialog_layout.xml => filter_dialog.xml} (100%) delete mode 100644 app/src/main/res/layout/filter_dialog_relative_cardview.xml create mode 100644 app/src/main/res/layout/filter_dialog_row.xml create mode 100644 core/src/main/res/color/filter_dialog_button_background_light.xml create mode 100644 core/src/main/res/color/filter_dialog_button_clear.xml create mode 100644 core/src/main/res/color/filter_dialog_button_text_light.xml delete mode 100644 core/src/main/res/drawable/filter_dialog_x_off.xml rename core/src/main/res/drawable/{filter_dialog_x_on.xml => ic_filter_close_light.xml} (84%) diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/FilterDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/FilterDialog.java index ece286eb4..2448742ca 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/FilterDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/FilterDialog.java @@ -1,22 +1,18 @@ package de.danoeh.antennapod.dialog; import android.content.Context; -import android.graphics.Color; +import android.text.TextUtils; import android.view.LayoutInflater; import android.widget.LinearLayout; import android.widget.RadioButton; -import android.widget.RelativeLayout; - import androidx.appcompat.app.AlertDialog; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.feed.FeedItemFilter; import de.danoeh.antennapod.core.feed.FeedItemFilterGroup; +import de.danoeh.antennapod.view.RecursiveRadioGroup; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; public abstract class FilterDialog { @@ -35,91 +31,35 @@ public abstract class FilterDialog { builder.setTitle(R.string.filter); LayoutInflater inflater = LayoutInflater.from(this.context); - LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.filter_dialog_layout, null, false); + LinearLayout layout = (LinearLayout) inflater.inflate(R.layout.filter_dialog, null, false); builder.setView(layout); - for (FeedItemFilterGroup.FeedItemEnum item : FeedItemFilterGroup.FeedItemEnum.values()) { - - RelativeLayout row = (RelativeLayout) inflater.inflate(R.layout.filter_dialog_relative_cardview, null); - RadioButton radioButton1 = row.findViewById(R.id.filter_dialog_radioButton1); - RadioButton radioButton2 = row.findViewById(R.id.filter_dialog_radioButton2); - RadioButton radioButton3 = row.findViewById(R.id.filter_dialog_radioButton3); - radioButton1.setText(item.values[1].displayName); - radioButton1.setTextColor(Color.BLACK); - radioButton2.setText(item.values[0].displayName); - radioButton2.setTextColor(Color.BLACK); - - Iterator filterIterator = filterValues.iterator(); - while (filterIterator.hasNext()) { - String nextItem = filterIterator.next(); - if (item.values[1].filterId.equals(nextItem)) { - item.values[1].setSelected(true); - item.values[0].setSelected(false); - radioButton1.setBackgroundResource(R.color.accent_light); - radioButton2.setBackgroundResource(R.color.master_switch_background_light); - radioButton3.setBackgroundResource(R.drawable.filter_dialog_x_on); - radioButton1.setSelected(true); - radioButton2.setSelected(false); - radioButton1.setTextColor(Color.WHITE); - radioButton2.setTextColor(Color.BLACK); - } - if (item.values[0].filterId.equals(nextItem)) { - item.values[0].setSelected(true); - item.values[1].setSelected(false); - radioButton2.setBackgroundResource(R.color.accent_light); - radioButton1.setBackgroundResource(R.color.master_switch_background_light); - radioButton3.setBackgroundResource(R.drawable.filter_dialog_x_on); - radioButton2.setSelected(true); - radioButton1.setSelected(false); - radioButton2.setTextColor(Color.WHITE); - radioButton1.setTextColor(Color.BLACK); - } - } - - radioButton1.setOnClickListener(arg0 -> { - item.values[1].setSelected(true); - item.values[0].setSelected(false); - radioButton1.setBackgroundResource(R.color.accent_light); - radioButton2.setBackgroundResource(R.color.master_switch_background_light); - radioButton3.setBackgroundResource(R.drawable.filter_dialog_x_on); - radioButton2.setSelected(false); - radioButton2.setTextColor(Color.BLACK); - radioButton1.setSelected(true); - radioButton1.setTextColor(Color.WHITE); - }); - radioButton2.setOnClickListener(arg0 -> { - item.values[0].setSelected(true); - item.values[1].setSelected(false); - radioButton2.setBackgroundResource(R.color.accent_light); - radioButton1.setBackgroundResource(R.color.master_switch_background_light); - radioButton3.setBackgroundResource(R.drawable.filter_dialog_x_on); - radioButton1.setSelected(false); - radioButton1.setTextColor(Color.BLACK); - radioButton2.setSelected(true); - radioButton2.setTextColor(Color.WHITE); - }); - radioButton3.setOnClickListener(arg0 -> { - item.values[0].setSelected(false); - item.values[1].setSelected(false); - radioButton1.setBackgroundResource(R.color.master_switch_background_light); - radioButton2.setBackgroundResource(R.color.master_switch_background_light); - radioButton3.setBackgroundResource(R.drawable.filter_dialog_x_off); - radioButton2.setTextColor(Color.BLACK); - radioButton2.setSelected(false); - radioButton1.setTextColor(Color.BLACK); - radioButton1.setSelected(false); - }); + for (FeedItemFilterGroup item : FeedItemFilterGroup.values()) { + RecursiveRadioGroup row = (RecursiveRadioGroup) inflater.inflate(R.layout.filter_dialog_row, null); + RadioButton filter1 = row.findViewById(R.id.filter_dialog_radioButton1); + RadioButton filter2 = row.findViewById(R.id.filter_dialog_radioButton2); + filter1.setText(item.values[0].displayName); + filter1.setTag(item.values[0].filterId); + filter2.setText(item.values[1].displayName); + filter2.setTag(item.values[1].filterId); layout.addView(row); } + for (String filterId : filterValues) { + if (!TextUtils.isEmpty(filterId)) { + ((RadioButton) layout.findViewWithTag(filterId)).setChecked(true); + } + } builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> { filterValues.clear(); - for (FeedItemFilterGroup.FeedItemEnum item : FeedItemFilterGroup.FeedItemEnum.values()) { - for (int i = 0; i < item.values.length; i++) { - if (item.values[i].getSelected()) { - filterValues.add(item.values[i].filterId); - } + for (int i = 0; i < layout.getChildCount(); i++) { + if (!(layout.getChildAt(i) instanceof RecursiveRadioGroup)) { + continue; + } + RecursiveRadioGroup group = (RecursiveRadioGroup) layout.getChildAt(i); + if (group.getCheckedButton() != null) { + filterValues.add((String) group.getCheckedButton().getTag()); } } updateFilter(filterValues); diff --git a/app/src/main/java/de/danoeh/antennapod/view/RecursiveRadioGroup.java b/app/src/main/java/de/danoeh/antennapod/view/RecursiveRadioGroup.java new file mode 100644 index 000000000..162f524bf --- /dev/null +++ b/app/src/main/java/de/danoeh/antennapod/view/RecursiveRadioGroup.java @@ -0,0 +1,68 @@ +package de.danoeh.antennapod.view; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.ActionMode; +import android.view.View; +import android.view.ViewGroup; +import android.widget.LinearLayout; +import android.widget.RadioButton; +import java.util.ArrayList; + +/** + * An alternative to {@link android.widget.RadioGroup} that allows to nest children. + * Basend on https://stackoverflow.com/a/14309274. + */ +public class RecursiveRadioGroup extends LinearLayout { + private final ArrayList radioButtons = new ArrayList<>(); + private RadioButton checkedButton = null; + + public RecursiveRadioGroup(Context context) { + super(context); + } + + public RecursiveRadioGroup(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public RecursiveRadioGroup(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + @Override + public void addView(View child, int index, ViewGroup.LayoutParams params) { + super.addView(child, index, params); + parseChild(child); + } + + public void parseChild(final View child) { + if (child instanceof RadioButton) { + RadioButton button = (RadioButton) child; + radioButtons.add(button); + button.setOnCheckedChangeListener((buttonView, isChecked) -> { + if (!isChecked) { + return; + } + checkedButton = (RadioButton) buttonView; + + for (RadioButton view : radioButtons) { + if (view != buttonView) { + view.setChecked(false); + } + } + }); + } else if (child instanceof ViewGroup) { + parseChildren((ViewGroup) child); + } + } + + public void parseChildren(final ViewGroup child) { + for (int i = 0; i < child.getChildCount(); i++) { + parseChild(child.getChildAt(i)); + } + } + + public RadioButton getCheckedButton() { + return checkedButton; + } +} diff --git a/app/src/main/res/layout/filter_dialog_layout.xml b/app/src/main/res/layout/filter_dialog.xml similarity index 100% rename from app/src/main/res/layout/filter_dialog_layout.xml rename to app/src/main/res/layout/filter_dialog.xml diff --git a/app/src/main/res/layout/filter_dialog_relative_cardview.xml b/app/src/main/res/layout/filter_dialog_relative_cardview.xml deleted file mode 100644 index e3dc94f64..000000000 --- a/app/src/main/res/layout/filter_dialog_relative_cardview.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/filter_dialog_row.xml b/app/src/main/res/layout/filter_dialog_row.xml new file mode 100644 index 000000000..bf90e17e0 --- /dev/null +++ b/app/src/main/res/layout/filter_dialog_row.xml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilterGroup.java b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilterGroup.java index 18c1c186d..7a0eac2e3 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilterGroup.java +++ b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilterGroup.java @@ -2,83 +2,35 @@ package de.danoeh.antennapod.core.feed; import de.danoeh.antennapod.core.R; -public class FeedItemFilterGroup { +public enum FeedItemFilterGroup { + PLAYED(new ItemProperties(R.string.hide_played_episodes_label, "played"), + new ItemProperties(R.string.not_played, "unplayed")), + PAUSED(new ItemProperties(R.string.hide_paused_episodes_label, "paused"), + new ItemProperties(R.string.not_paused, "")), + FAVORITE(new ItemProperties(R.string.hide_is_favorite_label, "is_favorite"), + new ItemProperties(R.string.not_favorite, "")), + MEDIA(new ItemProperties(R.string.has_media, ""), + new ItemProperties(R.string.no_media, "no_media")), + QUEUED(new ItemProperties(R.string.queued_label, "queued"), + new ItemProperties(R.string.not_queued_label, "not_queued")), + DOWNLOADED(new ItemProperties(R.string.hide_downloaded_episodes_label, "downloaded"), + new ItemProperties(R.string.hide_not_downloaded_episodes_label, "not_downloaded")); - private static boolean DEFAULT_SELECTED_STATE = false; + public final ItemProperties[] values; - private static final String NO_FILTERID = ""; - private static final int HASMEDIA_LABEL = R.string.has_media; - private static final int NOTPAUSED_LABEL = R.string.not_paused; - private static final int NOTFAVORITE_LABEL = R.string.not_favorite; + FeedItemFilterGroup(ItemProperties... values) { + this.values = values; + } - private static final int UNPLAYED_LABEL = R.string.not_played; - private static final String UNPLAYED_FILTERID = "unplayed"; + public static class ItemProperties { - private static final int PLAYED_LABEL = R.string.hide_played_episodes_label; - private static final String PLAYED_FILTERID = "played"; + public final int displayName; + public final String filterId; - private static final int PAUSED_LABEL = R.string.hide_paused_episodes_label; - private static final String PAUSED_FILTERID = "paused"; - - private static final int ISFAVORITE_LABEL = R.string.hide_is_favorite_label; - private static final String ISFAVORITE_FILTERID = "is_favorite"; - - private static final int NOMEDIA_LABEL = R.string.no_media; - private static final String NOMEDIA_FILTERID = "no_media"; - - private static final int QUEUED_LABEL = R.string.queue_label; - private static final String QUEUED_FILTERID = "queued"; - - private static final int NOTQUEUED_LABEL = R.string.not_queued_label; - private static final String NOTQUEUED_FILTERID = "not_queued"; - - private static final int NOTDOWNLOADED_LABEL = R.string.hide_downloaded_episodes_label; - private static final String NOTDOWNLOADED_FILTERID = "not_downloaded"; - - private static final int DOWNLOADED_LABEL = R.string.hide_downloaded_episodes_label; - private static final String DOWNLOADED_FILTERID = "downloaded"; - - public enum FeedItemEnum { - - PLAYED(new ItemProperties(DEFAULT_SELECTED_STATE, UNPLAYED_LABEL, UNPLAYED_FILTERID), - new ItemProperties(DEFAULT_SELECTED_STATE, PLAYED_LABEL, PLAYED_FILTERID)), - PAUSED(new ItemProperties(DEFAULT_SELECTED_STATE, NOTPAUSED_LABEL, NO_FILTERID), - new ItemProperties(DEFAULT_SELECTED_STATE, PAUSED_LABEL, PAUSED_FILTERID)), - FAVORITE(new ItemProperties(DEFAULT_SELECTED_STATE, NOTFAVORITE_LABEL, NO_FILTERID), - new ItemProperties(DEFAULT_SELECTED_STATE, ISFAVORITE_LABEL, ISFAVORITE_FILTERID)), - MEDIA(new ItemProperties(DEFAULT_SELECTED_STATE, NOMEDIA_LABEL, NOMEDIA_FILTERID), - new ItemProperties(DEFAULT_SELECTED_STATE, HASMEDIA_LABEL, NO_FILTERID)), - QUEUED(new ItemProperties(DEFAULT_SELECTED_STATE, NOTQUEUED_LABEL, NOTQUEUED_FILTERID), - new ItemProperties(DEFAULT_SELECTED_STATE, QUEUED_LABEL, QUEUED_FILTERID)), - DOWNLOADED(new ItemProperties(DEFAULT_SELECTED_STATE, NOTDOWNLOADED_LABEL, NOTDOWNLOADED_FILTERID), - new ItemProperties(DEFAULT_SELECTED_STATE, DOWNLOADED_LABEL, DOWNLOADED_FILTERID)); - - public final ItemProperties[] values; - - FeedItemEnum(ItemProperties... values) { - this.values = values; + public ItemProperties(int displayName, String filterId) { + this.displayName = displayName; + this.filterId = filterId; } - public static class ItemProperties { - - public final int displayName; - public boolean selected; - public final String filterId; - - public void setSelected(boolean value) { - this.selected = value; - } - - public boolean getSelected() { - return this.selected; - } - - public ItemProperties(boolean selected, int displayName, String filterId) { - this.selected = selected; - this.displayName = displayName; - this.filterId = filterId; - } - - } } } diff --git a/core/src/main/res/color/filter_dialog_button_background_light.xml b/core/src/main/res/color/filter_dialog_button_background_light.xml new file mode 100644 index 000000000..c6dd0d6cb --- /dev/null +++ b/core/src/main/res/color/filter_dialog_button_background_light.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/core/src/main/res/color/filter_dialog_button_clear.xml b/core/src/main/res/color/filter_dialog_button_clear.xml new file mode 100644 index 000000000..1ef3e3e57 --- /dev/null +++ b/core/src/main/res/color/filter_dialog_button_clear.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/core/src/main/res/color/filter_dialog_button_text_light.xml b/core/src/main/res/color/filter_dialog_button_text_light.xml new file mode 100644 index 000000000..0a5388eb9 --- /dev/null +++ b/core/src/main/res/color/filter_dialog_button_text_light.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/core/src/main/res/drawable/filter_dialog_x_off.xml b/core/src/main/res/drawable/filter_dialog_x_off.xml deleted file mode 100644 index 8368ffa51..000000000 --- a/core/src/main/res/drawable/filter_dialog_x_off.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/core/src/main/res/drawable/filter_dialog_x_on.xml b/core/src/main/res/drawable/ic_filter_close_light.xml similarity index 84% rename from core/src/main/res/drawable/filter_dialog_x_on.xml rename to core/src/main/res/drawable/ic_filter_close_light.xml index b25b42df3..1d695cd0f 100644 --- a/core/src/main/res/drawable/filter_dialog_x_on.xml +++ b/core/src/main/res/drawable/ic_filter_close_light.xml @@ -10,9 +10,8 @@ + android:color="@color/filter_dialog_button_clear" /> - @@ -29,7 +28,7 @@ + android:color="@color/filter_dialog_button_clear" /> @@ -47,9 +46,8 @@ + android:color="@color/filter_dialog_button_clear" /> - diff --git a/core/src/main/res/values/arrays.xml b/core/src/main/res/values/arrays.xml index 8e8d70525..13ff092b0 100644 --- a/core/src/main/res/values/arrays.xml +++ b/core/src/main/res/values/arrays.xml @@ -245,18 +245,6 @@ exoplayer - - @string/hide_unplayed_episodes_label - @string/hide_paused_episodes_label - @string/hide_played_episodes_label - @string/hide_queued_episodes_label - @string/hide_not_queued_episodes_label - @string/hide_downloaded_episodes_label - @string/hide_not_downloaded_episodes_label - @string/hide_has_media_label - @string/hide_is_favorite_label - - @string/sort_date_new_old From a4ce162491cb93535ee1a03d526c8d1228d58fd2 Mon Sep 17 00:00:00 2001 From: bws9000 Date: Sat, 27 Jun 2020 10:24:26 -0400 Subject: [PATCH 03/14] Redesign filter dialog --- .../antennapod/view/RecursiveRadioGroup.java | 1 - app/src/main/res/layout/filter_dialog_row.xml | 10 ++-- .../core/feed/FeedItemFilterGroup.java | 6 +- .../filter_dialog_button_background_light.xml | 5 -- .../res/color/filter_dialog_button_clear.xml | 5 -- .../filter_dialog_button_background_light.xml | 5 ++ .../drawable/filter_dialog_button_clear.xml | 5 ++ .../filter_dialog_button_text_light.xml | 4 +- .../res/drawable/ic_filter_close_dark.xml | 56 +++++++++++++++++++ .../res/drawable/ic_filter_close_light.xml | 7 ++- 10 files changed, 80 insertions(+), 24 deletions(-) delete mode 100644 core/src/main/res/color/filter_dialog_button_background_light.xml delete mode 100644 core/src/main/res/color/filter_dialog_button_clear.xml create mode 100644 core/src/main/res/drawable/filter_dialog_button_background_light.xml create mode 100644 core/src/main/res/drawable/filter_dialog_button_clear.xml rename core/src/main/res/{color => drawable}/filter_dialog_button_text_light.xml (64%) create mode 100644 core/src/main/res/drawable/ic_filter_close_dark.xml diff --git a/app/src/main/java/de/danoeh/antennapod/view/RecursiveRadioGroup.java b/app/src/main/java/de/danoeh/antennapod/view/RecursiveRadioGroup.java index 162f524bf..ee5e7c51d 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/RecursiveRadioGroup.java +++ b/app/src/main/java/de/danoeh/antennapod/view/RecursiveRadioGroup.java @@ -2,7 +2,6 @@ package de.danoeh.antennapod.view; import android.content.Context; import android.util.AttributeSet; -import android.view.ActionMode; import android.view.View; import android.view.ViewGroup; import android.widget.LinearLayout; diff --git a/app/src/main/res/layout/filter_dialog_row.xml b/app/src/main/res/layout/filter_dialog_row.xml index bf90e17e0..ef0ceb9a4 100644 --- a/app/src/main/res/layout/filter_dialog_row.xml +++ b/app/src/main/res/layout/filter_dialog_row.xml @@ -25,8 +25,8 @@ android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" - android:background="@color/filter_dialog_button_background_light" - android:textColor="@color/filter_dialog_button_text_light" + android:background="@drawable/filter_dialog_button_background_light" + android:textColor="@drawable/filter_dialog_button_text_light" android:button="@android:color/transparent" android:layout_marginRight="2dp" android:layout_marginEnd="2dp" @@ -40,8 +40,8 @@ android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" - android:background="@color/filter_dialog_button_background_light" - android:textColor="@color/filter_dialog_button_text_light" + android:background="@drawable/filter_dialog_button_background_light" + android:textColor="@drawable/filter_dialog_button_text_light" android:button="@android:color/transparent" android:checked="false" android:foreground="?attr/selectableItemBackground" @@ -54,7 +54,7 @@ android:id="@+id/filter_dialog_clear" android:layout_width="48dp" android:layout_height="48dp" - android:background="@drawable/ic_filter_close_light" + android:background="@drawable/filter_dialog_button_clear" android:button="@android:color/transparent" android:foreground="?attr/selectableItemBackground" android:tag="" diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilterGroup.java b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilterGroup.java index 7a0eac2e3..45f22ef00 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilterGroup.java +++ b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilterGroup.java @@ -6,10 +6,10 @@ public enum FeedItemFilterGroup { PLAYED(new ItemProperties(R.string.hide_played_episodes_label, "played"), new ItemProperties(R.string.not_played, "unplayed")), PAUSED(new ItemProperties(R.string.hide_paused_episodes_label, "paused"), - new ItemProperties(R.string.not_paused, "")), + new ItemProperties(R.string.not_paused, "_no_id_not_paused")), FAVORITE(new ItemProperties(R.string.hide_is_favorite_label, "is_favorite"), - new ItemProperties(R.string.not_favorite, "")), - MEDIA(new ItemProperties(R.string.has_media, ""), + new ItemProperties(R.string.not_favorite, "_no_id_not_favorite")), + MEDIA(new ItemProperties(R.string.has_media, "_no_id_no_media"), new ItemProperties(R.string.no_media, "no_media")), QUEUED(new ItemProperties(R.string.queued_label, "queued"), new ItemProperties(R.string.not_queued_label, "not_queued")), diff --git a/core/src/main/res/color/filter_dialog_button_background_light.xml b/core/src/main/res/color/filter_dialog_button_background_light.xml deleted file mode 100644 index c6dd0d6cb..000000000 --- a/core/src/main/res/color/filter_dialog_button_background_light.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/core/src/main/res/color/filter_dialog_button_clear.xml b/core/src/main/res/color/filter_dialog_button_clear.xml deleted file mode 100644 index 1ef3e3e57..000000000 --- a/core/src/main/res/color/filter_dialog_button_clear.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/core/src/main/res/drawable/filter_dialog_button_background_light.xml b/core/src/main/res/drawable/filter_dialog_button_background_light.xml new file mode 100644 index 000000000..c3a1b385e --- /dev/null +++ b/core/src/main/res/drawable/filter_dialog_button_background_light.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/core/src/main/res/drawable/filter_dialog_button_clear.xml b/core/src/main/res/drawable/filter_dialog_button_clear.xml new file mode 100644 index 000000000..33e3888b9 --- /dev/null +++ b/core/src/main/res/drawable/filter_dialog_button_clear.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/core/src/main/res/color/filter_dialog_button_text_light.xml b/core/src/main/res/drawable/filter_dialog_button_text_light.xml similarity index 64% rename from core/src/main/res/color/filter_dialog_button_text_light.xml rename to core/src/main/res/drawable/filter_dialog_button_text_light.xml index 0a5388eb9..4d75670b7 100644 --- a/core/src/main/res/color/filter_dialog_button_text_light.xml +++ b/core/src/main/res/drawable/filter_dialog_button_text_light.xml @@ -1,5 +1,5 @@ - + - + \ No newline at end of file diff --git a/core/src/main/res/drawable/ic_filter_close_dark.xml b/core/src/main/res/drawable/ic_filter_close_dark.xml new file mode 100644 index 000000000..b25b42df3 --- /dev/null +++ b/core/src/main/res/drawable/ic_filter_close_dark.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core/src/main/res/drawable/ic_filter_close_light.xml b/core/src/main/res/drawable/ic_filter_close_light.xml index 1d695cd0f..003b82834 100644 --- a/core/src/main/res/drawable/ic_filter_close_light.xml +++ b/core/src/main/res/drawable/ic_filter_close_light.xml @@ -10,7 +10,7 @@ + android:color="@color/master_switch_background_light" /> @@ -28,7 +28,7 @@ + android:color="@color/master_switch_background_light" /> @@ -46,8 +46,9 @@ + android:color="@color/master_switch_background_light" /> + From f4677c0d9a7812b7c6e0c3f473bd8f50e7c03901 Mon Sep 17 00:00:00 2001 From: bws9000 Date: Thu, 2 Jul 2020 20:34:11 -0400 Subject: [PATCH 04/14] Redesign filter dialog --- .../antennapod/dialog/FilterDialog.java | 13 +- app/src/main/res/layout/filter_dialog_row.xml | 29 ++--- .../antennapod/core/feed/FeedItemFilter.java | 28 ++++- .../core/feed/FeedItemFilterGroup.java | 6 +- .../filter_dialog_button_background_dark.xml | 5 + .../filter_dialog_button_background_light.xml | 4 +- .../res/drawable/ic_filter_close_dark.xml | 6 +- .../res/drawable/ic_filter_close_light.xml | 6 +- core/src/main/res/values/attrs.xml | 118 +++++++++--------- core/src/main/res/values/colors.xml | 12 ++ core/src/main/res/values/styles.xml | 14 ++- 11 files changed, 145 insertions(+), 96 deletions(-) create mode 100644 core/src/main/res/drawable/filter_dialog_button_background_dark.xml diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/FilterDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/FilterDialog.java index 2448742ca..82bdfaafe 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/FilterDialog.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/FilterDialog.java @@ -5,14 +5,17 @@ import android.text.TextUtils; import android.view.LayoutInflater; import android.widget.LinearLayout; import android.widget.RadioButton; + import androidx.appcompat.app.AlertDialog; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + import de.danoeh.antennapod.R; import de.danoeh.antennapod.core.feed.FeedItemFilter; import de.danoeh.antennapod.core.feed.FeedItemFilterGroup; import de.danoeh.antennapod.view.RecursiveRadioGroup; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; public abstract class FilterDialog { @@ -47,7 +50,9 @@ public abstract class FilterDialog { for (String filterId : filterValues) { if (!TextUtils.isEmpty(filterId)) { - ((RadioButton) layout.findViewWithTag(filterId)).setChecked(true); + if (layout.findViewWithTag(filterId) != null) { + ((RadioButton) layout.findViewWithTag(filterId)).setChecked(true); + } } } diff --git a/app/src/main/res/layout/filter_dialog_row.xml b/app/src/main/res/layout/filter_dialog_row.xml index ef0ceb9a4..5a92ae8d9 100644 --- a/app/src/main/res/layout/filter_dialog_row.xml +++ b/app/src/main/res/layout/filter_dialog_row.xml @@ -1,6 +1,5 @@ - + android:gravity="center" + android:textColor="@drawable/filter_dialog_button_text_light" /> + android:gravity="center" + android:textColor="@drawable/filter_dialog_button_text_light" /> @@ -54,10 +49,8 @@ android:id="@+id/filter_dialog_clear" android:layout_width="48dp" android:layout_height="48dp" - android:background="@drawable/filter_dialog_button_clear" + android:background="?attr/filter_dialog_button_clear" android:button="@android:color/transparent" - android:foreground="?attr/selectableItemBackground" - android:tag="" android:checked="true" /> diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilter.java b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilter.java index 719383d23..d9bfd846a 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilter.java +++ b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilter.java @@ -1,8 +1,10 @@ package de.danoeh.antennapod.core.feed; import android.text.TextUtils; +import android.util.Log; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import de.danoeh.antennapod.core.storage.DBReader; @@ -11,17 +13,21 @@ import de.danoeh.antennapod.core.util.LongList; import static de.danoeh.antennapod.core.feed.FeedItem.TAG_FAVORITE; public class FeedItemFilter { + private final String[] mProperties; private boolean showPlayed = false; private boolean showUnplayed = false; private boolean showPaused = false; + private boolean showNotPaused = false; private boolean showQueued = false; private boolean showNotQueued = false; private boolean showDownloaded = false; private boolean showNotDownloaded = false; private boolean showHasMedia = false; + private boolean showNoMedia = false; private boolean showIsFavorite = false; + private boolean showNotFavorite = false; public FeedItemFilter(String properties) { this(TextUtils.split(properties, ",")); @@ -29,14 +35,17 @@ public class FeedItemFilter { public FeedItemFilter(String[] properties) { this.mProperties = properties; - for(String property : properties) { + Log.d("***xxx***", Arrays.toString(properties)); + for (String property : properties) { // see R.arrays.feed_filter_values - switch(property) { + switch ("" + property) { case "unplayed": showUnplayed = true; break; case "paused": showPaused = true; + case "not_paused": + showNotPaused = true; break; case "played": showPlayed = true; @@ -55,10 +64,14 @@ public class FeedItemFilter { break; case "has_media": showHasMedia = true; + case "no_media": + showNoMedia = true; break; case "is_favorite": showIsFavorite = true; break; + case "not_favorite": + showNotFavorite = true; } } } @@ -67,7 +80,7 @@ public class FeedItemFilter { * Run a list of feed items through the filter. */ public List filter(List items) { - if(mProperties.length == 0) return items; + if (mProperties.length == 0) return items; List result = new ArrayList<>(); @@ -77,12 +90,15 @@ public class FeedItemFilter { if (showQueued && showNotQueued) return result; if (showDownloaded && showNotDownloaded) return result; - final LongList queuedIds = DBReader.getQueueIDList(); - for(FeedItem item : items) { + final LongList queuedIds = DBReader.getQueueIDList(); + for (FeedItem item : items) { // If the item does not meet a requirement, skip it. + if (showPlayed && !item.isPlayed()) continue; if (showUnplayed && item.isPlayed()) continue; + if (showPaused && item.getState() != FeedItem.State.IN_PROGRESS) continue; + if (showNotPaused && item.getState() == FeedItem.State.IN_PROGRESS) continue; boolean queued = queuedIds.contains(item.getId()); if (showQueued && !queued) continue; @@ -93,8 +109,10 @@ public class FeedItemFilter { if (showNotDownloaded && downloaded) continue; if (showHasMedia && !item.hasMedia()) continue; + if (showNoMedia && item.hasMedia()) continue; if (showIsFavorite && !item.isTagged(TAG_FAVORITE)) continue; + if (showNotFavorite && item.isTagged(TAG_FAVORITE)) continue; // If the item reaches here, it meets all criteria result.add(item); diff --git a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilterGroup.java b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilterGroup.java index 45f22ef00..fcbe2e4ab 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilterGroup.java +++ b/core/src/main/java/de/danoeh/antennapod/core/feed/FeedItemFilterGroup.java @@ -6,10 +6,10 @@ public enum FeedItemFilterGroup { PLAYED(new ItemProperties(R.string.hide_played_episodes_label, "played"), new ItemProperties(R.string.not_played, "unplayed")), PAUSED(new ItemProperties(R.string.hide_paused_episodes_label, "paused"), - new ItemProperties(R.string.not_paused, "_no_id_not_paused")), + new ItemProperties(R.string.not_paused, "not_paused")), FAVORITE(new ItemProperties(R.string.hide_is_favorite_label, "is_favorite"), - new ItemProperties(R.string.not_favorite, "_no_id_not_favorite")), - MEDIA(new ItemProperties(R.string.has_media, "_no_id_no_media"), + new ItemProperties(R.string.not_favorite, "not_favorite")), + MEDIA(new ItemProperties(R.string.has_media, "has_media"), new ItemProperties(R.string.no_media, "no_media")), QUEUED(new ItemProperties(R.string.queued_label, "queued"), new ItemProperties(R.string.not_queued_label, "not_queued")), diff --git a/core/src/main/res/drawable/filter_dialog_button_background_dark.xml b/core/src/main/res/drawable/filter_dialog_button_background_dark.xml new file mode 100644 index 000000000..046e34caf --- /dev/null +++ b/core/src/main/res/drawable/filter_dialog_button_background_dark.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/core/src/main/res/drawable/filter_dialog_button_background_light.xml b/core/src/main/res/drawable/filter_dialog_button_background_light.xml index c3a1b385e..5e58d3a26 100644 --- a/core/src/main/res/drawable/filter_dialog_button_background_light.xml +++ b/core/src/main/res/drawable/filter_dialog_button_background_light.xml @@ -1,5 +1,5 @@ - - + + \ No newline at end of file diff --git a/core/src/main/res/drawable/ic_filter_close_dark.xml b/core/src/main/res/drawable/ic_filter_close_dark.xml index b25b42df3..fb2c5cf81 100644 --- a/core/src/main/res/drawable/ic_filter_close_dark.xml +++ b/core/src/main/res/drawable/ic_filter_close_dark.xml @@ -10,7 +10,7 @@ + android:color="?attr/filter_dialog_clear_active" /> @@ -29,7 +29,7 @@ + android:color="?attr/filter_dialog_clear_active" /> @@ -47,7 +47,7 @@ + android:color="?attr/filter_dialog_clear_active" /> diff --git a/core/src/main/res/drawable/ic_filter_close_light.xml b/core/src/main/res/drawable/ic_filter_close_light.xml index 003b82834..63e9a29b9 100644 --- a/core/src/main/res/drawable/ic_filter_close_light.xml +++ b/core/src/main/res/drawable/ic_filter_close_light.xml @@ -10,7 +10,7 @@ + android:color="?attr/filter_dialog_clear_inactive" /> @@ -28,7 +28,7 @@ + android:color="?attr/filter_dialog_clear_inactive" /> @@ -46,7 +46,7 @@ + android:color="?attr/filter_dialog_clear_inactive" /> diff --git a/core/src/main/res/values/attrs.xml b/core/src/main/res/values/attrs.xml index b89a819f1..998b086c6 100644 --- a/core/src/main/res/values/attrs.xml +++ b/core/src/main/res/values/attrs.xml @@ -1,69 +1,73 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - + + + - - - - - + + + + + - - - + + + diff --git a/core/src/main/res/values/colors.xml b/core/src/main/res/values/colors.xml index a86d61eba..148919db7 100644 --- a/core/src/main/res/values/colors.xml +++ b/core/src/main/res/values/colors.xml @@ -28,4 +28,16 @@ #DDDDDD #191919 + + #757575 + #DDDDDD + #3D8BFF + #0078C2 + + #46C6C6C6 + #43707070 + + #757575 + #46C6C6C6 + diff --git a/core/src/main/res/values/styles.xml b/core/src/main/res/values/styles.xml index ab78eac47..1aaa67e2d 100644 --- a/core/src/main/res/values/styles.xml +++ b/core/src/main/res/values/styles.xml @@ -1,11 +1,17 @@ - + @@ -153,11 +150,8 @@ @drawable/ic_key_white @drawable/ic_volume_adaption_white @drawable/scrollbar_thumb_dark - - @color/dialog_filter_clear_active_dark - @color/dialog_filter_clear_inactive_dark - @color/filter_dialog_close - @color/filter_dialog_background_light + @color/filter_dialog_clear_dark + @color/filter_dialog_background_dark