From dab44b68436601f415edb095da605811e985eb00 Mon Sep 17 00:00:00 2001 From: seeto <65185819+peakvalleytech@users.noreply.github.com> Date: Sat, 2 Oct 2021 08:13:23 -0700 Subject: [PATCH] Rename folder to tag (#5381) --- .../antennapod/adapter/NavListAdapter.java | 8 +- .../adapter/SubscriptionsRecyclerAdapter.java | 2 +- .../antennapod/dialog/TagSettingsDialog.java | 4 +- .../fragment/NavDrawerFragment.java | 10 +- .../fragment/SubscriptionFragment.java | 6 +- app/src/main/res/menu/nav_feed_context.xml | 2 +- app/src/main/res/xml/feed_settings.xml | 95 +++++++++---------- config/spotbugs/exclude.xml | 2 +- .../antennapod/core/storage/DBReader.java | 8 +- .../core/storage/NavDrawerData.java | 8 +- core/src/main/res/drawable/ic_tag.xml | 9 ++ core/src/main/res/values/strings.xml | 4 +- 12 files changed, 83 insertions(+), 75 deletions(-) create mode 100644 core/src/main/res/drawable/ic_tag.xml diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java index ff0311ab6..7854f7aa9 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java @@ -196,7 +196,7 @@ public class NavListAdapter extends RecyclerView.Adapter bindFeedView((NavDrawerData.FeedDrawerItem) item, (FeedHolder) holder); holder.itemView.setOnCreateContextMenuListener(itemAccess); } else { - bindFolderView((NavDrawerData.FolderDrawerItem) item, (FeedHolder) holder); + bindTagView((NavDrawerData.TagDrawerItem) item, (FeedHolder) holder); } } if (viewType != VIEW_TYPE_SECTION_DIVIDER) { @@ -327,16 +327,16 @@ public class NavListAdapter extends RecyclerView.Adapter } } - private void bindFolderView(NavDrawerData.FolderDrawerItem folder, FeedHolder holder) { + private void bindTagView(NavDrawerData.TagDrawerItem tag, FeedHolder holder) { Activity context = activity.get(); if (context == null) { return; } - if (folder.isOpen) { + if (tag.isOpen) { holder.count.setVisibility(View.GONE); } Glide.with(context).clear(holder.image); - holder.image.setImageResource(R.drawable.ic_folder); + holder.image.setImageResource(R.drawable.ic_tag); holder.failure.setVisibility(View.GONE); } diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsRecyclerAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsRecyclerAdapter.java index 689f4fcbc..773f15dcb 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsRecyclerAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/SubscriptionsRecyclerAdapter.java @@ -213,7 +213,7 @@ public class SubscriptionsRecyclerAdapter extends SelectableAdapter { addTag(viewBinding.newTagEditText.getText().toString().trim()); preferences.getTags().clear(); @@ -96,7 +96,7 @@ public class TagSettingsDialog extends DialogFragment { List items = data.items; List folders = new ArrayList(); for (NavDrawerData.DrawerItem item : items) { - if (item.type == NavDrawerData.DrawerItem.Type.FOLDER) { + if (item.type == NavDrawerData.DrawerItem.Type.TAG) { folders.add(item.getTitle()); } } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/NavDrawerFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/NavDrawerFragment.java index 826a7e0ab..911f262cb 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/NavDrawerFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/NavDrawerFragment.java @@ -157,7 +157,7 @@ public class NavDrawerFragment extends Fragment implements SharedPreferences.OnS }; removeAllNewFlagsConfirmationDialog.createNewDialog().show(); return true; - } else if (itemId == R.id.add_to_folder) { + } else if (itemId == R.id.edit_tags) { TagSettingsDialog.newInstance(feed.getPreferences()).show(getChildFragmentManager(), TagSettingsDialog.TAG); return true; } else if (itemId == R.id.rename_item) { @@ -318,7 +318,7 @@ public class NavDrawerFragment extends Fragment implements SharedPreferences.OnS ((MainActivity) getActivity()).getBottomSheet() .setState(BottomSheetBehavior.STATE_COLLAPSED); } else { - NavDrawerData.FolderDrawerItem folder = ((NavDrawerData.FolderDrawerItem) clickedItem); + NavDrawerData.TagDrawerItem folder = ((NavDrawerData.TagDrawerItem) clickedItem); if (openFolders.contains(folder.name)) { openFolders.remove(folder.name); } else { @@ -388,11 +388,11 @@ public class NavDrawerFragment extends Fragment implements SharedPreferences.OnS for (NavDrawerData.DrawerItem item : items) { item.setLayer(layer); flatItems.add(item); - if (item.type == NavDrawerData.DrawerItem.Type.FOLDER) { - NavDrawerData.FolderDrawerItem folder = ((NavDrawerData.FolderDrawerItem) item); + if (item.type == NavDrawerData.DrawerItem.Type.TAG) { + NavDrawerData.TagDrawerItem folder = ((NavDrawerData.TagDrawerItem) item); folder.isOpen = openFolders.contains(folder.name); if (folder.isOpen) { - flatItems.addAll(makeFlatDrawerData(((NavDrawerData.FolderDrawerItem) item).children, layer + 1)); + flatItems.addAll(makeFlatDrawerData(((NavDrawerData.TagDrawerItem) item).children, layer + 1)); } } } diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java index 90ed2a8bd..68cc04a28 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/SubscriptionFragment.java @@ -292,9 +292,9 @@ public class SubscriptionFragment extends Fragment NavDrawerData data = DBReader.getNavDrawerData(); List items = data.items; for (NavDrawerData.DrawerItem item : items) { - if (item.type == NavDrawerData.DrawerItem.Type.FOLDER + if (item.type == NavDrawerData.DrawerItem.Type.TAG && item.getTitle().equals(displayedFolder)) { - return ((NavDrawerData.FolderDrawerItem) item).children; + return ((NavDrawerData.TagDrawerItem) item).children; } } return items; @@ -339,7 +339,7 @@ public class SubscriptionFragment extends Fragment R.string.remove_all_new_flags_confirmation_msg, () -> DBWriter.removeFeedNewFlag(feed.getId())); return true; - } else if (itemId == R.id.add_to_folder) { + } else if (itemId == R.id.edit_tags) { TagSettingsDialog.newInstance(feed.getPreferences()).show(getChildFragmentManager(), TagSettingsDialog.TAG); return true; } else if (itemId == R.id.rename_item) { diff --git a/app/src/main/res/menu/nav_feed_context.xml b/app/src/main/res/menu/nav_feed_context.xml index e2b990023..ac3b24d0d 100644 --- a/app/src/main/res/menu/nav_feed_context.xml +++ b/app/src/main/res/menu/nav_feed_context.xml @@ -7,7 +7,7 @@ android:title="@string/remove_all_new_flags_label" /> diff --git a/app/src/main/res/xml/feed_settings.xml b/app/src/main/res/xml/feed_settings.xml index 457ff6e5b..5b81ddd54 100644 --- a/app/src/main/res/xml/feed_settings.xml +++ b/app/src/main/res/xml/feed_settings.xml @@ -1,72 +1,71 @@ - + android:icon="@drawable/ic_refresh" + android:key="keepUpdated" + android:summary="@string/keep_updated_summary" + android:title="@string/keep_updated" /> + android:defaultValue="false" + android:dependency="keepUpdated" + android:icon="@drawable/ic_notifications" + android:key="episodeNotification" + android:summary="@string/episode_notification_summary" + android:title="@string/episode_notification" /> + android:icon="@drawable/ic_key" + android:key="authentication" + android:summary="@string/authentication_descr" + android:title="@string/authentication_label" /> + android:icon="@drawable/ic_tag" + android:key="tags" + android:summary="@string/feed_tags_summary" + android:title="@string/feed_tags_label" /> + android:icon="@drawable/ic_playback_speed" + android:key="feedPlaybackSpeed" + android:summary="@string/pref_feed_playback_speed_sum" + android:title="@string/playback_speed" /> + android:icon="@drawable/ic_skip_24dp" + android:key="feedAutoSkip" + android:summary="@string/pref_feed_skip_sum" + android:title="@string/pref_feed_skip" /> + android:entries="@array/spnAutoDeleteItems" + android:entryValues="@array/spnAutoDeleteValues" + android:icon="@drawable/ic_delete" + android:key="autoDelete" + android:summary="@string/feed_auto_download_global" + android:title="@string/auto_delete_label" /> + android:defaultValue="off" + android:entries="@array/spnVolumeReductionItems" + android:entryValues="@array/spnVolumeReductionValues" + android:icon="@drawable/ic_volume_adaption" + android:key="volumeReduction" + android:summary="@string/feed_volume_reduction_summary" + android:title="@string/feed_volume_reduction" /> + android:key="autoDownloadCategory" + android:title="@string/auto_download_settings_label"> + android:key="autoDownload" + android:title="@string/auto_download_label" /> + android:key="episodeFilter" + android:summary="@string/episode_filters_description" + android:title="@string/episode_filters_label" /> diff --git a/config/spotbugs/exclude.xml b/config/spotbugs/exclude.xml index 1f06877a6..97a7481f5 100644 --- a/config/spotbugs/exclude.xml +++ b/config/spotbugs/exclude.xml @@ -62,7 +62,7 @@ - + diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java index 49eca1027..185d85e7a 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java @@ -881,7 +881,7 @@ public final class DBReader { int numDownloadedItems = adapter.getNumberOfDownloadedEpisodes(); List items = new ArrayList<>(); - Map folders = new HashMap<>(); + Map folders = new HashMap<>(); for (Feed feed : feeds) { for (String tag : feed.getPreferences().getTags()) { NavDrawerData.FeedDrawerItem drawerItem = new NavDrawerData.FeedDrawerItem(feed, feed.getId(), @@ -890,18 +890,18 @@ public final class DBReader { items.add(drawerItem); continue; } - NavDrawerData.FolderDrawerItem folder; + NavDrawerData.TagDrawerItem folder; if (folders.containsKey(tag)) { folder = folders.get(tag); } else { - folder = new NavDrawerData.FolderDrawerItem(tag); + folder = new NavDrawerData.TagDrawerItem(tag); folders.put(tag, folder); } drawerItem.id |= folder.id; folder.children.add(drawerItem); } } - List foldersSorted = new ArrayList<>(folders.values()); + List foldersSorted = new ArrayList<>(folders.values()); Collections.sort(foldersSorted, (o1, o2) -> o1.getTitle().compareToIgnoreCase(o2.getTitle())); items.addAll(foldersSorted); diff --git a/core/src/main/java/de/danoeh/antennapod/core/storage/NavDrawerData.java b/core/src/main/java/de/danoeh/antennapod/core/storage/NavDrawerData.java index 7ca90d687..1ec58216a 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/storage/NavDrawerData.java +++ b/core/src/main/java/de/danoeh/antennapod/core/storage/NavDrawerData.java @@ -30,7 +30,7 @@ public class NavDrawerData { public abstract static class DrawerItem { public enum Type { - FOLDER, FEED + TAG, FEED } public final Type type; @@ -55,14 +55,14 @@ public class NavDrawerData { public abstract int getCounter(); } - public static class FolderDrawerItem extends DrawerItem { + public static class TagDrawerItem extends DrawerItem { public final List children = new ArrayList<>(); public final String name; public boolean isOpen; - public FolderDrawerItem(String name) { + public TagDrawerItem(String name) { // Keep IDs >0 but make room for many feeds - super(DrawerItem.Type.FOLDER, Math.abs((long) name.hashCode()) << 20); + super(DrawerItem.Type.TAG, Math.abs((long) name.hashCode()) << 20); this.name = name; } diff --git a/core/src/main/res/drawable/ic_tag.xml b/core/src/main/res/drawable/ic_tag.xml new file mode 100644 index 000000000..95db04e93 --- /dev/null +++ b/core/src/main/res/drawable/ic_tag.xml @@ -0,0 +1,9 @@ + + + diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index e407b700a..5f509a9b6 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -689,8 +689,8 @@ Authentication Change your username and password for this podcast and its episodes. - Folders - Change the folders in which this podcast is displayed. + Tags + Change the tags of this podcast to help organize your subscriptions Show in main list Auto Download Settings Episode Filter