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
Code cleanup
  • Loading branch information
ByteHamster committed Mar 5, 2021
commit d54ce2f8b161acd5b7e68ade793e29674351ffa7
30 changes: 13 additions & 17 deletions app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ private Drawable getDrawable(String tag) {
default:
return null;
}
TypedArray ta = context.obtainStyledAttributes(new int[] { icon } );
TypedArray ta = context.obtainStyledAttributes(new int[] { icon });
Drawable result = ta.getDrawable(0);
ta.recycle();
return result;
}

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

Expand All @@ -160,7 +160,7 @@ public long getItemId(int position) {
if (viewType == VIEW_TYPE_SUBSCRIPTION) {
return itemAccess.getItem(position - getSubscriptionOffset()).id;
} else {
return -position - 1; //TODO
return -position - 1; // IDs are >0
}
}

Expand Down Expand Up @@ -215,13 +215,9 @@ public void onBindViewHolder(@NonNull Holder holder, int position) {
if (viewType != VIEW_TYPE_SECTION_DIVIDER) {
TypedValue typedValue = new TypedValue();

if (itemAccess.isSelected(position)) {
activity.get().getTheme().resolveAttribute(R.attr.drawer_activated_color, typedValue, true);
holder.itemView.setBackgroundResource(typedValue.resourceId);
} else {
activity.get().getTheme().resolveAttribute(android.R.attr.windowBackground, typedValue, true);
holder.itemView.setBackgroundResource(typedValue.resourceId);
}
activity.get().getTheme().resolveAttribute(itemAccess.isSelected(position)
? R.attr.drawer_activated_color : android.R.attr.windowBackground, typedValue, true);
holder.itemView.setBackgroundResource(typedValue.resourceId);

holder.itemView.setOnClickListener(v -> itemAccess.onItemClick(position));
holder.itemView.setOnLongClickListener(v -> itemAccess.onItemLongClick(position));
Expand All @@ -230,7 +226,7 @@ public void onBindViewHolder(@NonNull Holder holder, int position) {

private void bindNavView(String title, int position, NavHolder holder) {
Activity context = activity.get();
if(context == null) {
if (context == null) {
return;
}
holder.title.setText(title);
Expand Down Expand Up @@ -258,21 +254,21 @@ private void bindNavView(String title, int position, NavHolder holder) {
holder.count.setText(NumberFormat.getInstance().format(sum));
holder.count.setVisibility(View.VISIBLE);
}
} else if(tag.equals(DownloadsFragment.TAG) && UserPreferences.isEnableAutodownload()) {
} else if (tag.equals(DownloadsFragment.TAG) && UserPreferences.isEnableAutodownload()) {
int epCacheSize = UserPreferences.getEpisodeCacheSize();
// don't count episodes that can be reclaimed
int spaceUsed = itemAccess.getNumberOfDownloadedItems() -
itemAccess.getReclaimableItems();
int spaceUsed = itemAccess.getNumberOfDownloadedItems()
- itemAccess.getReclaimableItems();

if (epCacheSize > 0 && spaceUsed >= epCacheSize) {
holder.count.setText("{md-disc-full 150%}");
Iconify.addIcons(holder.count);
holder.count.setVisibility(View.VISIBLE);
holder.count.setOnClickListener(v ->
new AlertDialog.Builder(context)
new AlertDialog.Builder(context)
.setTitle(R.string.episode_cache_full_title)
.setMessage(R.string.episode_cache_full_message)
.setPositiveButton(android.R.string.ok, (dialog, which) -> {})
.setPositiveButton(android.R.string.ok, (dialog, which) -> { })
.show()
);
}
Expand All @@ -283,7 +279,7 @@ private void bindNavView(String title, int position, NavHolder holder) {

private void bindSectionDivider(DividerHolder holder) {
Activity context = activity.get();
if(context == null) {
if (context == null) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,13 @@ public void onDestroyView() {
@Override
public void onCreateContextMenu(@NonNull ContextMenu menu, @NonNull View v, ContextMenu.ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
if (contextPressedItem.type != NavDrawerData.DrawerItem.Type.FEED) {
return; // Should actually never happen because the context menu is not set up for other items
}

MenuInflater inflater = getActivity().getMenuInflater();
inflater.inflate(R.menu.nav_feed_context, menu);

if (contextPressedItem.type == NavDrawerData.DrawerItem.Type.FEED) {
menu.setHeaderTitle(((NavDrawerData.FeedDrawerItem) contextPressedItem).feed.getTitle());
}
menu.setHeaderTitle(((NavDrawerData.FeedDrawerItem) contextPressedItem).feed.getTitle());
// episodes are not loaded, so we cannot check if the podcast has new or unplayed ones!
}

Expand Down Expand Up @@ -179,12 +180,6 @@ public void onConfirmButtonPressed(DialogInterface dialog) {
}
}

private void showMainActivity(String tag) {
Intent intent = new Intent(getActivity(), MainActivity.class);
intent.putExtra(MainActivity.EXTRA_FRAGMENT_TAG, tag);
startActivity(intent);
}

@Subscribe(threadMode = ThreadMode.MAIN)
public void onUnreadItemsChanged(UnreadItemsUpdateEvent event) {
loadData();
Expand Down Expand Up @@ -266,7 +261,7 @@ public NavDrawerData.DrawerItem getItem(int position) {
public boolean isSelected(int position) {
String lastNavFragment = getLastNavFragment(getContext());
if (position < navAdapter.getSubscriptionOffset()) {
return navAdapter.getTags().get(position).equals(lastNavFragment);
return navAdapter.getFragmentTags().get(position).equals(lastNavFragment);
} else if (StringUtils.isNumeric(lastNavFragment)) { // last fragment was not a list, but a feed
long feedId = Long.parseLong(lastNavFragment);
if (navDrawerData != null) {
Expand Down Expand Up @@ -318,28 +313,18 @@ public void onItemClick(int position) {
int viewType = navAdapter.getItemViewType(position);
if (viewType != NavListAdapter.VIEW_TYPE_SECTION_DIVIDER) {
if (position < navAdapter.getSubscriptionOffset()) {
String tag = navAdapter.getTags().get(position);
if (getActivity() instanceof MainActivity) {
((MainActivity) getActivity()).loadFragment(tag, null);
((MainActivity) getActivity()).getBottomSheet().setState(BottomSheetBehavior.STATE_COLLAPSED);
} else {
showMainActivity(tag);
}
String tag = navAdapter.getFragmentTags().get(position);
((MainActivity) getActivity()).loadFragment(tag, null);
((MainActivity) getActivity()).getBottomSheet().setState(BottomSheetBehavior.STATE_COLLAPSED);
} else {
int pos = position - navAdapter.getSubscriptionOffset();
NavDrawerData.DrawerItem clickedItem = flatItemList.get(pos);

if (clickedItem.type == NavDrawerData.DrawerItem.Type.FEED) {
long feedId = ((NavDrawerData.FeedDrawerItem) clickedItem).feed.getId();
if (getActivity() instanceof MainActivity) {
((MainActivity) getActivity()).loadFeedFragmentById(feedId, null);
((MainActivity) getActivity()).getBottomSheet()
.setState(BottomSheetBehavior.STATE_COLLAPSED);
} else {
Intent intent = new Intent(getActivity(), MainActivity.class);
intent.putExtra(MainActivity.EXTRA_FEED_ID, feedId);
startActivity(intent);
}
((MainActivity) getActivity()).loadFeedFragmentById(feedId, null);
((MainActivity) getActivity()).getBottomSheet()
.setState(BottomSheetBehavior.STATE_COLLAPSED);
} else {
NavDrawerData.FolderDrawerItem folder = ((NavDrawerData.FolderDrawerItem) clickedItem);
if (openFolders.contains(folder.name)) {
Expand Down Expand Up @@ -371,7 +356,7 @@ public void onItemClick(int position) {

@Override
public boolean onItemLongClick(int position) {
if (position < navAdapter.getTags().size()) {
if (position < navAdapter.getFragmentTags().size()) {
showDrawerPreferencesDialog();
return true;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static class FolderDrawerItem extends DrawerItem {
public boolean isOpen;

public FolderDrawerItem(String name) {
super(DrawerItem.Type.FOLDER, (long) name.hashCode() << 32);
super(DrawerItem.Type.FOLDER, (long) name.hashCode() << 20); // Keep IDs >0 but make room for many feeds
this.name = name;
}

Expand Down