Rename folder to tag (#5381)

This commit is contained in:
seeto 2021-10-02 08:13:23 -07:00 committed by GitHub
parent 0a22e9fc38
commit dab44b6843
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 83 additions and 75 deletions

View File

@ -196,7 +196,7 @@ public class NavListAdapter extends RecyclerView.Adapter<NavListAdapter.Holder>
bindFeedView((NavDrawerData.FeedDrawerItem) item, (FeedHolder) holder); bindFeedView((NavDrawerData.FeedDrawerItem) item, (FeedHolder) holder);
holder.itemView.setOnCreateContextMenuListener(itemAccess); holder.itemView.setOnCreateContextMenuListener(itemAccess);
} else { } else {
bindFolderView((NavDrawerData.FolderDrawerItem) item, (FeedHolder) holder); bindTagView((NavDrawerData.TagDrawerItem) item, (FeedHolder) holder);
} }
} }
if (viewType != VIEW_TYPE_SECTION_DIVIDER) { if (viewType != VIEW_TYPE_SECTION_DIVIDER) {
@ -327,16 +327,16 @@ public class NavListAdapter extends RecyclerView.Adapter<NavListAdapter.Holder>
} }
} }
private void bindFolderView(NavDrawerData.FolderDrawerItem folder, FeedHolder holder) { private void bindTagView(NavDrawerData.TagDrawerItem tag, FeedHolder holder) {
Activity context = activity.get(); Activity context = activity.get();
if (context == null) { if (context == null) {
return; return;
} }
if (folder.isOpen) { if (tag.isOpen) {
holder.count.setVisibility(View.GONE); holder.count.setVisibility(View.GONE);
} }
Glide.with(context).clear(holder.image); 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); holder.failure.setVisibility(View.GONE);
} }

View File

@ -213,7 +213,7 @@ public class SubscriptionsRecyclerAdapter extends SelectableAdapter<Subscription
.load(); .load();
} else { } else {
new CoverLoader(mainActivityRef.get()) new CoverLoader(mainActivityRef.get())
.withResource(R.drawable.ic_folder) .withResource(R.drawable.ic_tag)
.withPlaceholderView(feedTitle, true) .withPlaceholderView(feedTitle, true)
.withCoverView(imageView) .withCoverView(imageView)
.load(); .load();

View File

@ -75,7 +75,7 @@ public class TagSettingsDialog extends DialogFragment {
AlertDialog.Builder dialog = new AlertDialog.Builder(getContext()); AlertDialog.Builder dialog = new AlertDialog.Builder(getContext());
dialog.setView(viewBinding.getRoot()); dialog.setView(viewBinding.getRoot());
dialog.setTitle(R.string.feed_folders_label); dialog.setTitle(R.string.feed_tags_label);
dialog.setPositiveButton(android.R.string.ok, (d, input) -> { dialog.setPositiveButton(android.R.string.ok, (d, input) -> {
addTag(viewBinding.newTagEditText.getText().toString().trim()); addTag(viewBinding.newTagEditText.getText().toString().trim());
preferences.getTags().clear(); preferences.getTags().clear();
@ -96,7 +96,7 @@ public class TagSettingsDialog extends DialogFragment {
List<NavDrawerData.DrawerItem> items = data.items; List<NavDrawerData.DrawerItem> items = data.items;
List<String> folders = new ArrayList<String>(); List<String> folders = new ArrayList<String>();
for (NavDrawerData.DrawerItem item : items) { for (NavDrawerData.DrawerItem item : items) {
if (item.type == NavDrawerData.DrawerItem.Type.FOLDER) { if (item.type == NavDrawerData.DrawerItem.Type.TAG) {
folders.add(item.getTitle()); folders.add(item.getTitle());
} }
} }

View File

@ -157,7 +157,7 @@ public class NavDrawerFragment extends Fragment implements SharedPreferences.OnS
}; };
removeAllNewFlagsConfirmationDialog.createNewDialog().show(); removeAllNewFlagsConfirmationDialog.createNewDialog().show();
return true; 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); TagSettingsDialog.newInstance(feed.getPreferences()).show(getChildFragmentManager(), TagSettingsDialog.TAG);
return true; return true;
} else if (itemId == R.id.rename_item) { } else if (itemId == R.id.rename_item) {
@ -318,7 +318,7 @@ public class NavDrawerFragment extends Fragment implements SharedPreferences.OnS
((MainActivity) getActivity()).getBottomSheet() ((MainActivity) getActivity()).getBottomSheet()
.setState(BottomSheetBehavior.STATE_COLLAPSED); .setState(BottomSheetBehavior.STATE_COLLAPSED);
} else { } else {
NavDrawerData.FolderDrawerItem folder = ((NavDrawerData.FolderDrawerItem) clickedItem); NavDrawerData.TagDrawerItem folder = ((NavDrawerData.TagDrawerItem) clickedItem);
if (openFolders.contains(folder.name)) { if (openFolders.contains(folder.name)) {
openFolders.remove(folder.name); openFolders.remove(folder.name);
} else { } else {
@ -388,11 +388,11 @@ public class NavDrawerFragment extends Fragment implements SharedPreferences.OnS
for (NavDrawerData.DrawerItem item : items) { for (NavDrawerData.DrawerItem item : items) {
item.setLayer(layer); item.setLayer(layer);
flatItems.add(item); flatItems.add(item);
if (item.type == NavDrawerData.DrawerItem.Type.FOLDER) { if (item.type == NavDrawerData.DrawerItem.Type.TAG) {
NavDrawerData.FolderDrawerItem folder = ((NavDrawerData.FolderDrawerItem) item); NavDrawerData.TagDrawerItem folder = ((NavDrawerData.TagDrawerItem) item);
folder.isOpen = openFolders.contains(folder.name); folder.isOpen = openFolders.contains(folder.name);
if (folder.isOpen) { if (folder.isOpen) {
flatItems.addAll(makeFlatDrawerData(((NavDrawerData.FolderDrawerItem) item).children, layer + 1)); flatItems.addAll(makeFlatDrawerData(((NavDrawerData.TagDrawerItem) item).children, layer + 1));
} }
} }
} }

View File

@ -292,9 +292,9 @@ public class SubscriptionFragment extends Fragment
NavDrawerData data = DBReader.getNavDrawerData(); NavDrawerData data = DBReader.getNavDrawerData();
List<NavDrawerData.DrawerItem> items = data.items; List<NavDrawerData.DrawerItem> items = data.items;
for (NavDrawerData.DrawerItem item : items) { for (NavDrawerData.DrawerItem item : items) {
if (item.type == NavDrawerData.DrawerItem.Type.FOLDER if (item.type == NavDrawerData.DrawerItem.Type.TAG
&& item.getTitle().equals(displayedFolder)) { && item.getTitle().equals(displayedFolder)) {
return ((NavDrawerData.FolderDrawerItem) item).children; return ((NavDrawerData.TagDrawerItem) item).children;
} }
} }
return items; return items;
@ -339,7 +339,7 @@ public class SubscriptionFragment extends Fragment
R.string.remove_all_new_flags_confirmation_msg, R.string.remove_all_new_flags_confirmation_msg,
() -> DBWriter.removeFeedNewFlag(feed.getId())); () -> DBWriter.removeFeedNewFlag(feed.getId()));
return true; 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); TagSettingsDialog.newInstance(feed.getPreferences()).show(getChildFragmentManager(), TagSettingsDialog.TAG);
return true; return true;
} else if (itemId == R.id.rename_item) { } else if (itemId == R.id.rename_item) {

View File

@ -7,7 +7,7 @@
android:title="@string/remove_all_new_flags_label" /> android:title="@string/remove_all_new_flags_label" />
<item <item
android:id="@+id/add_to_folder" android:id="@+id/edit_tags"
android:menuCategory="container" android:menuCategory="container"
android:title="@string/add_to_folder" /> android:title="@string/add_to_folder" />

View File

@ -1,72 +1,71 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:android="http://schemas.android.com/apk/res/android"
android:key="feedSettingsScreen"> android:key="feedSettingsScreen">
<SwitchPreferenceCompat <SwitchPreferenceCompat
android:key="keepUpdated" android:icon="@drawable/ic_refresh"
android:icon="@drawable/ic_refresh" android:key="keepUpdated"
android:title="@string/keep_updated" android:summary="@string/keep_updated_summary"
android:summary="@string/keep_updated_summary"/> android:title="@string/keep_updated" />
<SwitchPreferenceCompat <SwitchPreferenceCompat
android:key="episodeNotification" android:defaultValue="false"
android:defaultValue="false" android:dependency="keepUpdated"
android:dependency="keepUpdated" android:icon="@drawable/ic_notifications"
android:icon="@drawable/ic_notifications" android:key="episodeNotification"
android:title="@string/episode_notification" android:summary="@string/episode_notification_summary"
android:summary="@string/episode_notification_summary"/> android:title="@string/episode_notification" />
<Preference <Preference
android:key="authentication" android:icon="@drawable/ic_key"
android:icon="@drawable/ic_key" android:key="authentication"
android:title="@string/authentication_label" android:summary="@string/authentication_descr"
android:summary="@string/authentication_descr"/> android:title="@string/authentication_label" />
<Preference <Preference
android:key="tags" android:icon="@drawable/ic_tag"
android:icon="@drawable/ic_folder" android:key="tags"
android:title="@string/feed_folders_label" android:summary="@string/feed_tags_summary"
android:summary="@string/feed_folders_summary"/> android:title="@string/feed_tags_label" />
<ListPreference <ListPreference
android:key="feedPlaybackSpeed" android:icon="@drawable/ic_playback_speed"
android:icon="@drawable/ic_playback_speed" android:key="feedPlaybackSpeed"
android:title="@string/playback_speed" android:summary="@string/pref_feed_playback_speed_sum"
android:summary="@string/pref_feed_playback_speed_sum"/> android:title="@string/playback_speed" />
<Preference <Preference
android:key="feedAutoSkip" android:icon="@drawable/ic_skip_24dp"
android:icon="@drawable/ic_skip_24dp" android:key="feedAutoSkip"
android:summary="@string/pref_feed_skip_sum" android:summary="@string/pref_feed_skip_sum"
android:title="@string/pref_feed_skip" /> android:title="@string/pref_feed_skip" />
<ListPreference <ListPreference
android:entries="@array/spnAutoDeleteItems" android:entries="@array/spnAutoDeleteItems"
android:entryValues="@array/spnAutoDeleteValues" android:entryValues="@array/spnAutoDeleteValues"
android:icon="@drawable/ic_delete" android:icon="@drawable/ic_delete"
android:title="@string/auto_delete_label" android:key="autoDelete"
android:summary="@string/feed_auto_download_global" android:summary="@string/feed_auto_download_global"
android:key="autoDelete"/> android:title="@string/auto_delete_label" />
<ListPreference <ListPreference
android:entries="@array/spnVolumeReductionItems" android:defaultValue="off"
android:entryValues="@array/spnVolumeReductionValues" android:entries="@array/spnVolumeReductionItems"
android:icon="@drawable/ic_volume_adaption" android:entryValues="@array/spnVolumeReductionValues"
android:summary="@string/feed_volume_reduction_summary" android:icon="@drawable/ic_volume_adaption"
android:title="@string/feed_volume_reduction" android:key="volumeReduction"
android:defaultValue="off" android:summary="@string/feed_volume_reduction_summary"
android:key="volumeReduction"/> android:title="@string/feed_volume_reduction" />
<PreferenceCategory <PreferenceCategory
android:title="@string/auto_download_settings_label" android:key="autoDownloadCategory"
android:key="autoDownloadCategory"> android:title="@string/auto_download_settings_label">
<SwitchPreferenceCompat <SwitchPreferenceCompat
android:key="autoDownload" android:key="autoDownload"
android:title="@string/auto_download_label"/> android:title="@string/auto_download_label" />
<Preference <Preference
android:key="episodeFilter" android:key="episodeFilter"
android:title="@string/episode_filters_label" android:summary="@string/episode_filters_description"
android:summary="@string/episode_filters_description"/> android:title="@string/episode_filters_label" />
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View File

@ -62,7 +62,7 @@
</Match> </Match>
<Match> <Match>
<Bug pattern="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD"/> <Bug pattern="UUF_UNUSED_PUBLIC_OR_PROTECTED_FIELD"/>
<Class name="de.danoeh.antennapod.core.storage.NavDrawerData$FolderDrawerItem"/> <Class name="de.danoeh.antennapod.core.storage.NavDrawerData$TagDrawerItem"/>
</Match> </Match>
<Match> <Match>
<Bug pattern="UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD"/> <Bug pattern="UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD"/>

View File

@ -881,7 +881,7 @@ public final class DBReader {
int numDownloadedItems = adapter.getNumberOfDownloadedEpisodes(); int numDownloadedItems = adapter.getNumberOfDownloadedEpisodes();
List<NavDrawerData.DrawerItem> items = new ArrayList<>(); List<NavDrawerData.DrawerItem> items = new ArrayList<>();
Map<String, NavDrawerData.FolderDrawerItem> folders = new HashMap<>(); Map<String, NavDrawerData.TagDrawerItem> folders = new HashMap<>();
for (Feed feed : feeds) { for (Feed feed : feeds) {
for (String tag : feed.getPreferences().getTags()) { for (String tag : feed.getPreferences().getTags()) {
NavDrawerData.FeedDrawerItem drawerItem = new NavDrawerData.FeedDrawerItem(feed, feed.getId(), NavDrawerData.FeedDrawerItem drawerItem = new NavDrawerData.FeedDrawerItem(feed, feed.getId(),
@ -890,18 +890,18 @@ public final class DBReader {
items.add(drawerItem); items.add(drawerItem);
continue; continue;
} }
NavDrawerData.FolderDrawerItem folder; NavDrawerData.TagDrawerItem folder;
if (folders.containsKey(tag)) { if (folders.containsKey(tag)) {
folder = folders.get(tag); folder = folders.get(tag);
} else { } else {
folder = new NavDrawerData.FolderDrawerItem(tag); folder = new NavDrawerData.TagDrawerItem(tag);
folders.put(tag, folder); folders.put(tag, folder);
} }
drawerItem.id |= folder.id; drawerItem.id |= folder.id;
folder.children.add(drawerItem); folder.children.add(drawerItem);
} }
} }
List<NavDrawerData.FolderDrawerItem> foldersSorted = new ArrayList<>(folders.values()); List<NavDrawerData.TagDrawerItem> foldersSorted = new ArrayList<>(folders.values());
Collections.sort(foldersSorted, (o1, o2) -> o1.getTitle().compareToIgnoreCase(o2.getTitle())); Collections.sort(foldersSorted, (o1, o2) -> o1.getTitle().compareToIgnoreCase(o2.getTitle()));
items.addAll(foldersSorted); items.addAll(foldersSorted);

View File

@ -30,7 +30,7 @@ public class NavDrawerData {
public abstract static class DrawerItem { public abstract static class DrawerItem {
public enum Type { public enum Type {
FOLDER, FEED TAG, FEED
} }
public final Type type; public final Type type;
@ -55,14 +55,14 @@ public class NavDrawerData {
public abstract int getCounter(); public abstract int getCounter();
} }
public static class FolderDrawerItem extends DrawerItem { public static class TagDrawerItem extends DrawerItem {
public final List<DrawerItem> children = new ArrayList<>(); public final List<DrawerItem> children = new ArrayList<>();
public final String name; public final String name;
public boolean isOpen; public boolean isOpen;
public FolderDrawerItem(String name) { public TagDrawerItem(String name) {
// Keep IDs >0 but make room for many feeds // 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; this.name = name;
} }

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="?attr/action_icon_color"
android:pathData="M21.41,11.58L12.41,2.58A2,2 0,0 0,11 2H4A2,2 0,0 0,2 4V11A2,2 0,0 0,2.59 12.42L11.59,21.42A2,2 0,0 0,13 22A2,2 0,0 0,14.41 21.41L21.41,14.41A2,2 0,0 0,22 13A2,2 0,0 0,21.41 11.58M13,20L4,11V4H11L20,13M6.5,5A1.5,1.5 0,1 1,5 6.5A1.5,1.5 0,0 1,6.5 5Z"/>
</vector>

View File

@ -689,8 +689,8 @@
<!-- Feed settings/information screen --> <!-- Feed settings/information screen -->
<string name="authentication_label">Authentication</string> <string name="authentication_label">Authentication</string>
<string name="authentication_descr">Change your username and password for this podcast and its episodes.</string> <string name="authentication_descr">Change your username and password for this podcast and its episodes.</string>
<string name="feed_folders_label">Folders</string> <string name="feed_tags_label">Tags</string>
<string name="feed_folders_summary">Change the folders in which this podcast is displayed.</string> <string name="feed_tags_summary">Change the tags of this podcast to help organize your subscriptions</string>
<string name="feed_folders_include_root">Show in main list</string> <string name="feed_folders_include_root">Show in main list</string>
<string name="auto_download_settings_label">Auto Download Settings</string> <string name="auto_download_settings_label">Auto Download Settings</string>
<string name="episode_filters_label">Episode Filter</string> <string name="episode_filters_label">Episode Filter</string>