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);
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<NavListAdapter.Holder>
}
}
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);
}

View File

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

View File

@ -75,7 +75,7 @@ public class TagSettingsDialog extends DialogFragment {
AlertDialog.Builder dialog = new AlertDialog.Builder(getContext());
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) -> {
addTag(viewBinding.newTagEditText.getText().toString().trim());
preferences.getTags().clear();
@ -96,7 +96,7 @@ public class TagSettingsDialog extends DialogFragment {
List<NavDrawerData.DrawerItem> items = data.items;
List<String> folders = new ArrayList<String>();
for (NavDrawerData.DrawerItem item : items) {
if (item.type == NavDrawerData.DrawerItem.Type.FOLDER) {
if (item.type == NavDrawerData.DrawerItem.Type.TAG) {
folders.add(item.getTitle());
}
}

View File

@ -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));
}
}
}

View File

@ -292,9 +292,9 @@ public class SubscriptionFragment extends Fragment
NavDrawerData data = DBReader.getNavDrawerData();
List<NavDrawerData.DrawerItem> 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) {

View File

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

View File

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

View File

@ -62,7 +62,7 @@
</Match>
<Match>
<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>
<Bug pattern="UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD"/>

View File

@ -881,7 +881,7 @@ public final class DBReader {
int numDownloadedItems = adapter.getNumberOfDownloadedEpisodes();
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 (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<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()));
items.addAll(foldersSorted);

View File

@ -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<DrawerItem> 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;
}

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 -->
<string name="authentication_label">Authentication</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_folders_summary">Change the folders in which this podcast is displayed.</string>
<string name="feed_tags_label">Tags</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="auto_download_settings_label">Auto Download Settings</string>
<string name="episode_filters_label">Episode Filter</string>