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
Make folders work on subscriptions page
  • Loading branch information
ByteHamster committed Mar 5, 2021
commit 8586c7672053e45d2bfce29909a6a99cd68c4b8f
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import de.danoeh.antennapod.core.feed.LocalFeedUpdater;
import de.danoeh.antennapod.core.storage.NavDrawerData;
import de.danoeh.antennapod.fragment.FeedItemlistFragment;
import de.danoeh.antennapod.fragment.SubscriptionFragment;
import de.danoeh.antennapod.ui.common.ThemeUtils;
import jp.shts.android.library.TriangleLabelView;

Expand Down Expand Up @@ -132,6 +133,9 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
Feed feed = ((NavDrawerData.FeedDrawerItem) drawerItem).feed;
Fragment fragment = FeedItemlistFragment.newInstance(feed.getId());
mainActivityRef.get().loadChildFragment(fragment);
} else if (drawerItem.type == NavDrawerData.DrawerItem.Type.FOLDER) {
Fragment fragment = SubscriptionFragment.newInstance(drawerItem.getTitle());
mainActivityRef.get().loadChildFragment(fragment);
}
}

Expand All @@ -145,7 +149,5 @@ public interface ItemAccess {
int getCount();

NavDrawerData.DrawerItem getItem(int position);

int getFeedCounter(long feedId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.joanzapata.iconify.Iconify;

import java.util.List;
import java.util.Locale;
import java.util.concurrent.Callable;

Expand Down Expand Up @@ -69,6 +70,7 @@ public class SubscriptionFragment extends Fragment implements Toolbar.OnMenuItem
private static final String PREFS = "SubscriptionFragment";
private static final String PREF_NUM_COLUMNS = "columns";
private static final String KEY_UP_ARROW = "up_arrow";
private static final String ARGUMENT_FOLDER = "folder";

private static final int MIN_NUM_COLUMNS = 2;
private static final int[] COLUMN_CHECKBOX_IDS = {
Expand All @@ -78,13 +80,14 @@ public class SubscriptionFragment extends Fragment implements Toolbar.OnMenuItem
R.id.subscription_num_columns_5};

private GridView subscriptionGridLayout;
private NavDrawerData navDrawerData;
private List<NavDrawerData.DrawerItem> listItems;
private SubscriptionsAdapter subscriptionAdapter;
private FloatingActionButton subscriptionAddButton;
private ProgressBar progressBar;
private EmptyViewHandler emptyView;
private TextView feedsFilteredMsg;
private Toolbar toolbar;
private String displayedFolder = null;

private Feed selectedFeed = null;
private boolean isUpdatingFeeds = false;
Expand All @@ -93,6 +96,14 @@ public class SubscriptionFragment extends Fragment implements Toolbar.OnMenuItem
private Disposable disposable;
private SharedPreferences prefs;

public static SubscriptionFragment newInstance(String folderTitle) {
SubscriptionFragment fragment = new SubscriptionFragment();
Bundle args = new Bundle();
args.putString(ARGUMENT_FOLDER, folderTitle);
fragment.setArguments(args);
return fragment;
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand Down Expand Up @@ -120,6 +131,13 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
}
refreshToolbarState();

if (getArguments() != null) {
displayedFolder = getArguments().getString(ARGUMENT_FOLDER, null);
if (displayedFolder != null) {
toolbar.setTitle(displayedFolder);
}
}

subscriptionGridLayout = root.findViewById(R.id.subscriptions_grid);
subscriptionGridLayout.setNumColumns(prefs.getInt(PREF_NUM_COLUMNS, getDefaultNumOfColumns()));
registerForContextMenu(subscriptionGridLayout);
Expand Down Expand Up @@ -232,12 +250,23 @@ private void loadSubscriptions() {
disposable.dispose();
}
emptyView.hide();
disposable = Observable.fromCallable(DBReader::getNavDrawerData)
disposable = Observable.fromCallable(
() -> {
NavDrawerData data = DBReader.getNavDrawerData();
List<NavDrawerData.DrawerItem> items = data.items;
for (NavDrawerData.DrawerItem item : items) {
if (item.type == NavDrawerData.DrawerItem.Type.FOLDER
&& item.getTitle().equals(displayedFolder)) {
return ((NavDrawerData.FolderDrawerItem) item).children;
}
}
return items;
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
result -> {
navDrawerData = result;
listItems = result;
subscriptionAdapter.notifyDataSetChanged();
emptyView.updateVisibility();
progressBar.setVisibility(View.GONE); // Keep hidden to avoid flickering while refreshing
Expand Down Expand Up @@ -347,25 +376,20 @@ public void onEventMainThread(DownloadEvent event) {
private final SubscriptionsAdapter.ItemAccess itemAccess = new SubscriptionsAdapter.ItemAccess() {
@Override
public int getCount() {
if (navDrawerData != null) {
return navDrawerData.items.size();
if (listItems != null) {
return listItems.size();
} else {
return 0;
}
}

@Override
public NavDrawerData.DrawerItem getItem(int position) {
if (navDrawerData != null && 0 <= position && position < navDrawerData.items.size()) {
return navDrawerData.items.get(position);
if (listItems != null && 0 <= position && position < listItems.size()) {
return listItems.get(position);
} else {
return null;
}
}

@Override
public int getFeedCounter(long feedId) {
return navDrawerData != null ? navDrawerData.feedCounters.get(feedId) : 0;
}
};
}
1 change: 1 addition & 0 deletions app/src/main/res/layout/fragment_subscriptions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
android:theme="?attr/actionBarTheme"
android:layout_alignParentTop="true"
app:title="@string/subscriptions_label"
app:navigationIcon="?homeAsUpIndicator"
android:id="@+id/toolbar"/>

<TextView
Expand Down