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
Added support for folder counter
  • Loading branch information
ByteHamster committed Jan 2, 2021
commit c4db0ffb1faf526e5e15ad4ed97dd579d05c32c4
33 changes: 17 additions & 16 deletions app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public void onBindViewHolder(@NonNull Holder holder, int position) {
} else {
int itemPos = position - getSubscriptionOffset();
NavDrawerData.DrawerItem item = itemAccess.getItem(itemPos);
bindListItem(item, (FeedHolder) holder);
if (item.type == NavDrawerData.DrawerItem.Type.FEED) {
bindFeedView((NavDrawerData.FeedDrawerItem) item, (FeedHolder) holder);
} else {
Expand Down Expand Up @@ -292,6 +293,17 @@ private void bindSectionDivider(DividerHolder holder) {
}
}

private void bindListItem(NavDrawerData.DrawerItem item, FeedHolder holder) {
if (item.getCounter() > 0) {
holder.count.setVisibility(View.VISIBLE);
holder.count.setText(NumberFormat.getInstance().format(item.getCounter()));
} else {
holder.count.setVisibility(View.GONE);
}
holder.title.setText(item.getTitle());
holder.itemView.setPadding(item.layer * 50, 0, 0, 0); // TODO
}

private void bindFeedView(NavDrawerData.FeedDrawerItem drawerItem, FeedHolder holder) {
Feed feed = drawerItem.feed;
Activity context = activity.get();
Expand All @@ -309,9 +321,7 @@ private void bindFeedView(NavDrawerData.FeedDrawerItem drawerItem, FeedHolder ho
.dontAnimate())
.into(holder.image);

holder.title.setText(feed.getTitle());

if(feed.hasLastUpdateFailed()) {
if (feed.hasLastUpdateFailed()) {
RelativeLayout.LayoutParams p = (RelativeLayout.LayoutParams) holder.title.getLayoutParams();
p.addRule(RelativeLayout.LEFT_OF, R.id.itxtvFailure);
holder.failure.setVisibility(View.VISIBLE);
Expand All @@ -320,28 +330,19 @@ private void bindFeedView(NavDrawerData.FeedDrawerItem drawerItem, FeedHolder ho
p.addRule(RelativeLayout.LEFT_OF, R.id.txtvCount);
holder.failure.setVisibility(View.GONE);
}
int counter = itemAccess.getFeedCounter(feed.getId());
if(counter > 0) {
holder.count.setVisibility(View.VISIBLE);
holder.count.setText(NumberFormat.getInstance().format(counter));
} else {
holder.count.setVisibility(View.GONE);
}
holder.itemView.setPadding(drawerItem.layer * 50, 0, 0, 0); // TODO
}

private void bindFolderView(NavDrawerData.FolderDrawerItem drawerItem, FeedHolder holder) {
private void bindFolderView(NavDrawerData.FolderDrawerItem folder, FeedHolder holder) {
Activity context = activity.get();
if (context == null) {
return;
}
if (folder.isOpen) {
holder.count.setVisibility(View.GONE);
}

holder.image.setImageResource(ThemeUtils.getDrawableFromAttr(context, R.attr.ic_folder));
holder.title.setText(drawerItem.name);
holder.failure.setVisibility(View.GONE);
holder.count.setText("?");

holder.itemView.setPadding(drawerItem.layer * 50, 0, 0, 0); // TODO
}

static class Holder extends RecyclerView.ViewHolder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,8 @@ private List<NavDrawerData.DrawerItem> makeFlatDrawerData(List<NavDrawerData.Dra
flatItems.add(item);
if (item.type == NavDrawerData.DrawerItem.Type.FOLDER) {
NavDrawerData.FolderDrawerItem folder = ((NavDrawerData.FolderDrawerItem) item);
if (openFolders.contains(folder.name)) {
folder.isOpen = openFolders.contains(folder.name);
if (folder.isOpen) {
flatItems.addAll(makeFlatDrawerData(((NavDrawerData.FolderDrawerItem) item).children));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public DrawerItem(Type type, int layer, long id) {
public static class FolderDrawerItem extends DrawerItem {
public final List<DrawerItem> children;
public final String name;
public boolean isOpen;

public FolderDrawerItem(String name, List<DrawerItem> children, int layer, long id) {
super(DrawerItem.Type.FOLDER, layer, id);
Expand All @@ -62,7 +63,11 @@ public String getTitle() {
}

public int getCounter() {
return -1;
int sum = 0;
for (DrawerItem item : children) {
sum += item.getCounter();
}
return sum;
}
}

Expand Down