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
Next Next commit
Added basic proof of concept for displaying folders
  • Loading branch information
ByteHamster committed Nov 2, 2020
commit 2a2c4958358514ba5ca56ca4faafdd3bbb55767d
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.feed.FeedMedia;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.NavDrawerData;
import de.danoeh.antennapod.core.storage.PodDBAdapter;
import de.danoeh.antennapod.core.util.LongList;
import org.junit.After;
Expand Down Expand Up @@ -313,8 +314,8 @@ public void testGetNavDrawerDataQueueEmptyNoUnreadItems() {
final int NUM_FEEDS = 10;
final int NUM_ITEMS = 10;
DBTestUtils.saveFeedlist(NUM_FEEDS, NUM_ITEMS, true);
DBReader.NavDrawerData navDrawerData = DBReader.getNavDrawerData();
assertEquals(NUM_FEEDS, navDrawerData.feeds.size());
NavDrawerData navDrawerData = DBReader.getNavDrawerData();
assertEquals(NUM_FEEDS, navDrawerData.items.size());
assertEquals(0, navDrawerData.numNewItems);
assertEquals(0, navDrawerData.queueSize);
}
Expand Down Expand Up @@ -342,8 +343,8 @@ public void testGetNavDrawerDataQueueNotEmptyWithUnreadItems() {

adapter.close();

DBReader.NavDrawerData navDrawerData = DBReader.getNavDrawerData();
assertEquals(NUM_FEEDS, navDrawerData.feeds.size());
NavDrawerData navDrawerData = DBReader.getNavDrawerData();
assertEquals(NUM_FEEDS, navDrawerData.items.size());
assertEquals(NUM_NEW, navDrawerData.numNewItems);
assertEquals(NUM_QUEUE, navDrawerData.queueSize);
}
Expand Down
80 changes: 65 additions & 15 deletions app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.glide.ApGlideSettings;
import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.storage.NavDrawerData;
import de.danoeh.antennapod.core.util.ThemeUtils;
import de.danoeh.antennapod.fragment.AddFeedFragment;
import de.danoeh.antennapod.fragment.DownloadsFragment;
import de.danoeh.antennapod.fragment.EpisodesFragment;
Expand Down Expand Up @@ -56,7 +58,7 @@ public class NavListAdapter extends BaseAdapter
*/
public static final String SUBSCRIPTION_LIST_TAG = "SubscriptionList";

private static List<String> tags;
private static List<String> fragmentTags;
private static String[] titles;

private final ItemAccess itemAccess;
Expand Down Expand Up @@ -96,7 +98,7 @@ private void loadItems() {
showSubscriptionList = false;
}

tags = newTags;
fragmentTags = newTags;
notifyDataSetChanged();
}

Expand Down Expand Up @@ -140,7 +142,7 @@ private Drawable getDrawable(String tag) {
}

public List<String> getTags() {
return Collections.unmodifiableList(tags);
return Collections.unmodifiableList(fragmentTags);
}


Expand All @@ -157,7 +159,7 @@ public int getCount() {
public Object getItem(int position) {
int viewType = getItemViewType(position);
if (viewType == VIEW_TYPE_NAV) {
return getLabel(tags.get(position));
return getLabel(fragmentTags.get(position));
} else if (viewType == VIEW_TYPE_SECTION_DIVIDER) {
return "";
} else {
Expand All @@ -167,12 +169,22 @@ public Object getItem(int position) {

@Override
public long getItemId(int position) {
return position;
int viewType = getItemViewType(position);
if (viewType == VIEW_TYPE_SUBSCRIPTION) {
return itemAccess.getItem(position - getSubscriptionOffset()).id;
} else {
return -position - 1; //TODO
}
}

@Override
public boolean hasStableIds() {
return true;
}

@Override
public int getItemViewType(int position) {
if (0 <= position && position < tags.size()) {
if (0 <= position && position < fragmentTags.size()) {
return VIEW_TYPE_NAV;
} else if (position < getSubscriptionOffset()) {
return VIEW_TYPE_SECTION_DIVIDER;
Expand All @@ -187,7 +199,7 @@ public int getViewTypeCount() {
}

public int getSubscriptionOffset() {
return tags.size() > 0 ? tags.size() + 1 : 0;
return fragmentTags.size() > 0 ? fragmentTags.size() + 1 : 0;
}


Expand All @@ -200,7 +212,13 @@ public View getView(int position, View convertView, ViewGroup parent) {
} else if (viewType == VIEW_TYPE_SECTION_DIVIDER) {
v = getSectionDividerView(convertView, parent);
} else {
v = getFeedView(position, convertView, parent);
int itemPos = position - getSubscriptionOffset();
NavDrawerData.DrawerItem item = itemAccess.getItem(itemPos);
if (item.type == NavDrawerData.DrawerItem.Type.FEED) {
v = getFeedView((NavDrawerData.FeedDrawerItem) item, convertView, parent);
} else {
v = getFolderView((NavDrawerData.FolderDrawerItem) item, convertView, parent);
}
}
if (v != null && viewType != VIEW_TYPE_SECTION_DIVIDER) {
TypedValue typedValue = new TypedValue();
Expand Down Expand Up @@ -243,7 +261,7 @@ private View getNavView(String title, int position, View convertView, ViewGroup
holder.count.setVisibility(View.GONE);
holder.count.setOnClickListener(null);

String tag = tags.get(position);
String tag = fragmentTags.get(position);
if (tag.equals(QueueFragment.TAG)) {
int queueSize = itemAccess.getQueueSize();
if (queueSize > 0) {
Expand Down Expand Up @@ -282,7 +300,7 @@ private View getNavView(String title, int position, View convertView, ViewGroup
}
}

holder.image.setImageDrawable(getDrawable(tags.get(position)));
holder.image.setImageDrawable(getDrawable(fragmentTags.get(position)));

return convertView;
}
Expand Down Expand Up @@ -311,13 +329,12 @@ private View getSectionDividerView(View convertView, ViewGroup parent) {
return convertView;
}

private View getFeedView(int position, View convertView, ViewGroup parent) {
private View getFeedView(NavDrawerData.FeedDrawerItem drawerItem, View convertView, ViewGroup parent) {
Feed feed = drawerItem.feed;
Activity context = activity.get();
if(context == null) {
if (context == null) {
return null;
}
int feedPos = position - getSubscriptionOffset();
Feed feed = itemAccess.getItem(feedPos);

FeedHolder holder;
if (convertView == null) {
Expand Down Expand Up @@ -364,6 +381,39 @@ private View getFeedView(int position, View convertView, ViewGroup parent) {
} else {
holder.count.setVisibility(View.GONE);
}
convertView.setPadding(drawerItem.layer * 50, 0, 0, 0); // TODO
return convertView;
}

private View getFolderView(NavDrawerData.FolderDrawerItem drawerItem, View convertView, ViewGroup parent) {
Activity context = activity.get();
if (context == null) {
return null;
}

FeedHolder holder;
if (convertView == null) {
holder = new FeedHolder();
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

convertView = inflater.inflate(R.layout.nav_listitem, parent, false);

holder.image = convertView.findViewById(R.id.imgvCover);
holder.title = convertView.findViewById(R.id.txtvTitle);
holder.failure = convertView.findViewById(R.id.itxtvFailure);
holder.count = convertView.findViewById(R.id.txtvCount);
convertView.setTag(holder);
} else {
holder = (FeedHolder) convertView.getTag();
}

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

convertView.setPadding(drawerItem.layer * 50, 0, 0, 0); // TODO
return convertView;
}

Expand All @@ -382,7 +432,7 @@ static class FeedHolder {

public interface ItemAccess {
int getCount();
Feed getItem(int position);
NavDrawerData.DrawerItem getItem(int position);
int getSelectedItemIndex();
int getQueueSize();
int getNumberOfNewItems();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.feed.LocalFeedUpdater;
import de.danoeh.antennapod.core.storage.NavDrawerData;
import de.danoeh.antennapod.fragment.AddFeedFragment;
import de.danoeh.antennapod.fragment.FeedItemlistFragment;
import jp.shts.android.library.TriangleLabelView;
Expand Down Expand Up @@ -63,7 +64,7 @@ public boolean hasStableIds() {

@Override
public long getItemId(int position) {
return itemAccess.getItem(position).getId();
return position; // TODO
}

@Override
Expand Down Expand Up @@ -133,7 +134,7 @@ static class Holder {

public interface ItemAccess {
int getCount();
Feed getItem(int position);
NavDrawerData.DrawerItem getItem(int position);
int getFeedCounter(long feedId);
}
}
Loading