Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add subscriptions to tags/folders #4634

Merged
merged 26 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2a2c495
Added basic proof of concept for displaying folders
ByteHamster Nov 2, 2020
f978d30
Converted nav list to RecyclerView
ByteHamster Nov 2, 2020
c963547
Fixed checkstyle
ByteHamster Nov 3, 2020
3ed3379
Merge branch 'develop' into folders
ByteHamster Jan 2, 2021
b107e6d
Fixed crash when opening subscriptions screen
ByteHamster Jan 2, 2021
c4db0ff
Added support for folder counter
ByteHamster Jan 2, 2021
0bbeda9
Fixed nav item width
ByteHamster Jan 2, 2021
052884e
Clear glide when loading image manually
ByteHamster Jan 2, 2021
3104232
Calculate layer in makeFlatDrawerData
ByteHamster Jan 2, 2021
1eb47a2
Build tags based on feed properties
ByteHamster Jan 2, 2021
19e427b
Store tags in the database
ByteHamster Jan 2, 2021
f4bbc55
Added basic UI for editing tags
ByteHamster Jan 2, 2021
5a8bfc0
Fix checkstyle
ByteHamster Jan 2, 2021
f76d3ad
Merge branch 'develop' into folders
ByteHamster Mar 5, 2021
27c4364
Fixed long-pressing drawer items
ByteHamster Mar 5, 2021
627bd35
Fixed folder ID generation
ByteHamster Mar 5, 2021
d1d5974
Fix selection highlighting
ByteHamster Mar 5, 2021
4b7cb20
Fixed long-pressing items on subscriptions page
ByteHamster Mar 5, 2021
e86905e
Sort folders to the end
ByteHamster Mar 5, 2021
20f4d97
Store opened folders across app launches
ByteHamster Mar 5, 2021
bbde3ff
Fixed test
ByteHamster Mar 5, 2021
4b7f788
Use dp for padding
ByteHamster Mar 5, 2021
8586c76
Make folders work on subscriptions page
ByteHamster Mar 5, 2021
3f21ef5
Added basic tag editor UI
ByteHamster Mar 5, 2021
3a2a2ab
Test fixes
ByteHamster Mar 5, 2021
d54ce2f
Code cleanup
ByteHamster Mar 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Build tags based on feed properties
  • Loading branch information
ByteHamster committed Jan 2, 2021
commit 1eb47a2d6b2c4e54b2f7140995bab0b743f19dc5
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
public class FeedPreferences {

public static final float SPEED_USE_GLOBAL = -1;
public static final String TAG_ROOT = "#root";

@NonNull
private FeedFilter filter;
Expand All @@ -36,6 +37,7 @@ public enum AutoDeleteAction {
private float feedPlaybackSpeed;
private int feedSkipIntro;
private int feedSkipEnding;
private String[] tags = {TAG_ROOT, "Test 1", "Test 2"};

public FeedPreferences(long feedID, boolean autoDownload, AutoDeleteAction auto_delete_action, VolumeAdaptionSetting volumeAdaptionSetting, String username, String password) {
this(feedID, autoDownload, true, auto_delete_action, volumeAdaptionSetting,
Expand Down Expand Up @@ -240,4 +242,12 @@ public void setFeedSkipEnding(int skipEnding) {
public int getFeedSkipEnding() {
return feedSkipEnding;
}

public String[] getTags() {
return tags;
}

public void setTags(String[] tags) {
this.tags = tags;
}
}
38 changes: 21 additions & 17 deletions core/src/main/java/de/danoeh/antennapod/core/storage/DBReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -867,24 +868,27 @@ public static NavDrawerData getNavDrawerData() {
int numDownloadedItems = adapter.getNumberOfDownloadedEpisodes();

List<NavDrawerData.DrawerItem> items = new ArrayList<>();
for (int i = 0, feedsSize = feeds.size(); i < feedsSize; i++) {
items.add(new NavDrawerData.FeedDrawerItem(feeds.get(i), i, feedCounters.get(feeds.get(i).getId())));
}

List<NavDrawerData.DrawerItem> folderItems = new ArrayList<>();
for (int i = 0, feedsSize = feeds.size(); i < feedsSize; i++) {
folderItems.add(new NavDrawerData.FeedDrawerItem(feeds.get(i), 10001 + i,
feedCounters.get(feeds.get(i).getId())));
}
items.add(new NavDrawerData.FolderDrawerItem("Folder 1", folderItems, 10000));

List<NavDrawerData.DrawerItem> folderItems2 = new ArrayList<>();
for (int i = 0, feedsSize = feeds.size(); i < feedsSize; i++) {
folderItems2.add(new NavDrawerData.FeedDrawerItem(feeds.get(i), 20001 + i,
feedCounters.get(feeds.get(i).getId())));
Map<String, NavDrawerData.FolderDrawerItem> folders = new HashMap<>();
for (Feed feed : feeds) {
for (String tag : feed.getPreferences().getTags()) {
NavDrawerData.FeedDrawerItem drawerItem = new NavDrawerData.FeedDrawerItem(feed, feed.getId(),
feedCounters.get(feed.getId()));
if (FeedPreferences.TAG_ROOT.equals(tag)) {
items.add(drawerItem);
continue;
}
NavDrawerData.FolderDrawerItem folder;
if (folders.containsKey(tag)) {
folder = folders.get(tag);
} else {
folder = new NavDrawerData.FolderDrawerItem(tag);
folders.put(tag, folder);
items.add(folder);
}
drawerItem.id |= folder.id;
folder.children.add(drawerItem);
}
}
items.add(new NavDrawerData.FolderDrawerItem("Folder 2", folderItems2, 20000));

NavDrawerData result = new NavDrawerData(items, queueSize, numNewItems, numDownloadedItems,
feedCounters, UserPreferences.getEpisodeCleanupAlgorithm().getReclaimableItems());
adapter.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.util.LongIntMap;

import java.util.ArrayList;
import java.util.List;

public class NavDrawerData {
Expand Down Expand Up @@ -34,7 +35,7 @@ public enum Type {

public final Type type;
private int layer;
public final long id;
public long id;

public DrawerItem(Type type, long id) {
this.type = type;
Expand All @@ -55,13 +56,12 @@ public void setLayer(int layer) {
}

public static class FolderDrawerItem extends DrawerItem {
public final List<DrawerItem> children;
public final List<DrawerItem> children = new ArrayList<>();
public final String name;
public boolean isOpen;

public FolderDrawerItem(String name, List<DrawerItem> children, long id) {
super(DrawerItem.Type.FOLDER, id);
this.children = children;
public FolderDrawerItem(String name) {
super(DrawerItem.Type.FOLDER, name.hashCode() & ~0xFFF); // Drop lower 12 bits for item ids
this.name = name;
}

Expand Down