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
Calculate layer in makeFlatDrawerData
  • Loading branch information
ByteHamster committed Jan 2, 2021
commit 3104232e5d8c355aa090e13cc9ff871beb200b4e
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ private void bindListItem(NavDrawerData.DrawerItem item, FeedHolder holder) {
holder.count.setVisibility(View.GONE);
}
holder.title.setText(item.getTitle());
holder.itemView.setPadding(item.layer * 50, 0, 0, 0); // TODO
holder.itemView.setPadding(item.getLayer() * 50, 0, 0, 0); // TODO
}

private void bindFeedView(NavDrawerData.FeedDrawerItem drawerItem, FeedHolder holder) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AlertDialog;
import androidx.core.util.Pair;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
Expand Down Expand Up @@ -379,8 +380,15 @@ public void onItemClick(int position) {
} else {
openFolders.add(folder.name);
}
flatItemList = makeFlatDrawerData(navDrawerData.items);
navAdapter.notifyDataSetChanged();

disposable = Observable.fromCallable(() -> makeFlatDrawerData(navDrawerData.items, 0))
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
result -> {
flatItemList = result;
navAdapter.notifyDataSetChanged();
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
}
}
} else if (UserPreferences.getSubscriptionsFilter().isEnabled()
Expand All @@ -403,13 +411,17 @@ public boolean onItemLongClick(int position) {

private void loadData() {
progressBar.setVisibility(View.VISIBLE);
disposable = Observable.fromCallable(DBReader::getNavDrawerData)
disposable = Observable.fromCallable(
() -> {
NavDrawerData data = DBReader.getNavDrawerData();
return new Pair<>(data, makeFlatDrawerData(data.items, 0));
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
result -> {
navDrawerData = result;
flatItemList = makeFlatDrawerData(navDrawerData.items); // TODO: This is the main thread!
navDrawerData = result.first;
flatItemList = result.second;
updateSelection(); // Selected item might be a feed
navAdapter.notifyDataSetChanged();
progressBar.setVisibility(View.GONE);
Expand All @@ -419,15 +431,16 @@ private void loadData() {
});
}

private List<NavDrawerData.DrawerItem> makeFlatDrawerData(List<NavDrawerData.DrawerItem> items) {
private List<NavDrawerData.DrawerItem> makeFlatDrawerData(List<NavDrawerData.DrawerItem> items, int layer) {
List<NavDrawerData.DrawerItem> flatItems = new ArrayList<>();
for (NavDrawerData.DrawerItem item : items) {
item.setLayer(layer);
flatItems.add(item);
if (item.type == NavDrawerData.DrawerItem.Type.FOLDER) {
NavDrawerData.FolderDrawerItem folder = ((NavDrawerData.FolderDrawerItem) item);
folder.isOpen = openFolders.contains(folder.name);
if (folder.isOpen) {
flatItems.addAll(makeFlatDrawerData(((NavDrawerData.FolderDrawerItem) item).children));
flatItems.addAll(makeFlatDrawerData(((NavDrawerData.FolderDrawerItem) item).children, layer + 1));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -868,22 +868,22 @@ public static NavDrawerData getNavDrawerData() {

List<NavDrawerData.DrawerItem> items = new ArrayList<>();
for (int i = 0, feedsSize = feeds.size(); i < feedsSize; i++) {
items.add(new NavDrawerData.FeedDrawerItem(feeds.get(i), 0, i, feedCounters.get(feeds.get(i).getId())));
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), 1, 10001 + 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, 0, 10000));
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), 1, 20001 + i,
folderItems2.add(new NavDrawerData.FeedDrawerItem(feeds.get(i), 20001 + i,
feedCounters.get(feeds.get(i).getId())));
}
items.add(new NavDrawerData.FolderDrawerItem("Folder 2", folderItems2, 0, 20000));
items.add(new NavDrawerData.FolderDrawerItem("Folder 2", folderItems2, 20000));

NavDrawerData result = new NavDrawerData(items, queueSize, numNewItems, numDownloadedItems,
feedCounters, UserPreferences.getEpisodeCleanupAlgorithm().getReclaimableItems());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,22 @@ public enum Type {
}

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

public DrawerItem(Type type, int layer, long id) {
public DrawerItem(Type type, long id) {
this.type = type;
this.layer = layer;
this.id = id;
}

public int getLayer() {
return layer;
}

public void setLayer(int layer) {
this.layer = layer;
}

public abstract String getTitle();

public abstract int getCounter();
Expand All @@ -52,8 +59,8 @@ public static class FolderDrawerItem extends DrawerItem {
public final String name;
public boolean isOpen;

public FolderDrawerItem(String name, List<DrawerItem> children, int layer, long id) {
super(DrawerItem.Type.FOLDER, layer, id);
public FolderDrawerItem(String name, List<DrawerItem> children, long id) {
super(DrawerItem.Type.FOLDER, id);
this.children = children;
this.name = name;
}
Expand All @@ -75,8 +82,8 @@ public static class FeedDrawerItem extends DrawerItem {
public final Feed feed;
public final int counter;

public FeedDrawerItem(Feed feed, int layer, long id, int counter) {
super(DrawerItem.Type.FEED, layer, id);
public FeedDrawerItem(Feed feed, long id, int counter) {
super(DrawerItem.Type.FEED, id);
this.feed = feed;
this.counter = counter;
}
Expand Down