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
Merge branch 'develop' into folders
  • Loading branch information
ByteHamster committed Mar 5, 2021
commit f76d3ad09e41c544b8af2f33db0529e3bcdabc0e
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ android {
// Version code schema:
// "1.2.3-beta4" -> 1020304
// "1.2.3" -> 1020395
versionCode 2020000
versionName "2.2.0"
versionCode 2020001
versionName "2.2.0-beta1"

multiDexEnabled false
vectorDrawables.useSupportLibrary true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
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;
import de.danoeh.antennapod.fragment.NavDrawerFragment;
import de.danoeh.antennapod.fragment.PlaybackHistoryFragment;
import de.danoeh.antennapod.fragment.QueueFragment;
import de.danoeh.antennapod.fragment.SubscriptionFragment;
import de.danoeh.antennapod.ui.common.ThemeUtils;
import org.apache.commons.lang3.ArrayUtils;

import java.lang.ref.WeakReference;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
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.core.util.ThemeUtils;
import de.danoeh.antennapod.fragment.FeedItemlistFragment;
import de.danoeh.antennapod.ui.common.ThemeUtils;
import jp.shts.android.library.TriangleLabelView;

/**
Expand Down Expand Up @@ -112,7 +112,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
boolean textAndImageCombined = feed.isLocalFeed()
&& LocalFeedUpdater.getDefaultIconUrl(convertView.getContext()).equals(feed.getImageUrl());
new CoverLoader(mainActivityRef.get())
.withUri(feed.getImageLocation())
.withUri(feed.getImageUrl())
.withPlaceholderView(holder.feedTitle, textAndImageCombined)
.withCoverView(holder.imageView)
.load();
Expand All @@ -123,7 +123,6 @@ public View getView(int position, View convertView, ViewGroup parent) {
.withCoverView(holder.imageView)
.load();
}

return convertView;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
setupEpisodeFilterPreference();
setupPlaybackSpeedPreference();
setupFeedAutoSkipPreference();
setupEpisodeNotificationPreference();
setupTags();

updateAutoDeleteSummary();
Expand Down Expand Up @@ -412,14 +413,27 @@ private void setupTags() {
feedPreferences.getTags().clear();
feedPreferences.getTags().addAll(new HashSet<>(Arrays.asList(
foldersString.split(FeedPreferences.TAG_SEPARATOR))));
feed.savePreferences();
DBWriter.setFeedPreferences(feedPreferences);
})
.setNegativeButton(R.string.cancel_label, null)
.show();
return true;
});
}

private void setupEpisodeNotificationPreference() {
SwitchPreferenceCompat pref = findPreference("episodeNotification");

pref.setChecked(feedPreferences.getShowEpisodeNotification());
pref.setOnPreferenceChangeListener((preference, newValue) -> {
boolean checked = newValue == Boolean.TRUE;
feedPreferences.setShowEpisodeNotification(checked);
DBWriter.setFeedPreferences(feedPreferences);
pref.setChecked(checked);
return false;
});
}

private class ApplyToEpisodesDialog extends ConfirmationDialog {
private final boolean autoDownload;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public enum AutoDeleteAction {
YES,
NO
}
private AutoDeleteAction autoDeleteAction;

@NonNull
private FeedFilter filter;
Expand All @@ -39,16 +38,19 @@ public enum AutoDeleteAction {
private float feedPlaybackSpeed;
private int feedSkipIntro;
private int feedSkipEnding;
private boolean showEpisodeNotification;
private final Set<String> tags = new HashSet<>();

public FeedPreferences(long feedID, boolean autoDownload, AutoDeleteAction autoDeleteAction, VolumeAdaptionSetting volumeAdaptionSetting, String username, String password) {
public FeedPreferences(long feedID, boolean autoDownload, AutoDeleteAction autoDeleteAction,
VolumeAdaptionSetting volumeAdaptionSetting, String username, String password) {
this(feedID, autoDownload, true, autoDeleteAction, volumeAdaptionSetting,
username, password, new FeedFilter(), SPEED_USE_GLOBAL, 0, 0, new HashSet<>());
username, password, new FeedFilter(), SPEED_USE_GLOBAL, 0, 0, false, new HashSet<>());
}

private FeedPreferences(long feedID, boolean autoDownload, boolean keepUpdated, AutoDeleteAction autoDeleteAction,
VolumeAdaptionSetting volumeAdaptionSetting, String username, String password,
@NonNull FeedFilter filter, float feedPlaybackSpeed, int feedSkipIntro, int feedSkipEnding,
private FeedPreferences(long feedID, boolean autoDownload, boolean keepUpdated,
AutoDeleteAction autoDeleteAction, VolumeAdaptionSetting volumeAdaptionSetting,
String username, String password, @NonNull FeedFilter filter, float feedPlaybackSpeed,
int feedSkipIntro, int feedSkipEnding, boolean showEpisodeNotification,
Set<String> tags) {
this.feedID = feedID;
this.autoDownload = autoDownload;
Expand All @@ -61,6 +63,7 @@ private FeedPreferences(long feedID, boolean autoDownload, boolean keepUpdated,
this.feedPlaybackSpeed = feedPlaybackSpeed;
this.feedSkipIntro = feedSkipIntro;
this.feedSkipEnding = feedSkipEnding;
this.showEpisodeNotification = showEpisodeNotification;
this.tags.addAll(tags);
}

Expand All @@ -77,6 +80,7 @@ public static FeedPreferences fromCursor(Cursor cursor) {
int indexFeedPlaybackSpeed = cursor.getColumnIndex(PodDBAdapter.KEY_FEED_PLAYBACK_SPEED);
int indexAutoSkipIntro = cursor.getColumnIndex(PodDBAdapter.KEY_FEED_SKIP_INTRO);
int indexAutoSkipEnding = cursor.getColumnIndex(PodDBAdapter.KEY_FEED_SKIP_ENDING);
int indexEpisodeNotification = cursor.getColumnIndex(PodDBAdapter.KEY_EPISODE_NOTIFICATION);
int indexTags = cursor.getColumnIndex(PodDBAdapter.KEY_FEED_TAGS);

long feedId = cursor.getLong(indexId);
Expand All @@ -93,11 +97,11 @@ public static FeedPreferences fromCursor(Cursor cursor) {
float feedPlaybackSpeed = cursor.getFloat(indexFeedPlaybackSpeed);
int feedAutoSkipIntro = cursor.getInt(indexAutoSkipIntro);
int feedAutoSkipEnding = cursor.getInt(indexAutoSkipEnding);
boolean showNotification = cursor.getInt(indexEpisodeNotification) > 0;
String tagsString = cursor.getString(indexTags);
if (TextUtils.isEmpty(tagsString)) {
tagsString = TAG_ROOT;
}

return new FeedPreferences(feedId,
autoDownload,
autoRefresh,
Expand All @@ -109,6 +113,7 @@ public static FeedPreferences fromCursor(Cursor cursor) {
feedPlaybackSpeed,
feedAutoSkipIntro,
feedAutoSkipEnding,
showNotification,
new HashSet<>(Arrays.asList(tagsString.split(TAG_SEPARATOR))));
}

Expand Down Expand Up @@ -189,8 +194,8 @@ public VolumeAdaptionSetting getVolumeAdaptionSetting() {
return volumeAdaptionSetting;
}

public void setAutoDeleteAction(AutoDeleteAction auto_delete_action) {
this.autoDeleteAction = auto_delete_action;
public void setAutoDeleteAction(AutoDeleteAction autoDeleteAction) {
this.autoDeleteAction = autoDeleteAction;
}

public void setVolumeAdaptionSetting(VolumeAdaptionSetting volumeAdaptionSetting) {
Expand Down Expand Up @@ -256,4 +261,16 @@ public Set<String> getTags() {
public String getTagsAsString() {
return TextUtils.join(TAG_SEPARATOR, tags);
}

/**
* getter for preference if notifications should be display for new episodes.
* @return true for displaying notifications
*/
public boolean getShowEpisodeNotification() {
return showEpisodeNotification;
}

public void setShowEpisodeNotification(boolean showEpisodeNotification) {
this.showEpisodeNotification = showEpisodeNotification;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,14 @@ static void upgrade(final SQLiteDatabase db, final int oldVersion, final int new
+ " ADD COLUMN " + PodDBAdapter.KEY_FEED_SKIP_ENDING + " INTEGER DEFAULT 0;");
}
if (oldVersion < 2020000) {
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS
+ " ADD COLUMN " + PodDBAdapter.KEY_EPISODE_NOTIFICATION + " INTEGER DEFAULT 0;");
}
if (oldVersion < 2030000) {
db.execSQL("UPDATE " + PodDBAdapter.TABLE_NAME_FEED_ITEMS
+ " SET " + PodDBAdapter.KEY_DESCRIPTION + " = content_encoded, content_encoded = NULL "
+ "WHERE length(" + PodDBAdapter.KEY_DESCRIPTION + ") < length(content_encoded)");
db.execSQL("UPDATE " + PodDBAdapter.TABLE_NAME_FEED_ITEMS + " SET content_encoded = NULL");
db.execSQL("ALTER TABLE " + PodDBAdapter.TABLE_NAME_FEEDS
+ " ADD COLUMN " + PodDBAdapter.KEY_FEED_TAGS + " TEXT;");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public class PodDBAdapter {

private static final String TAG = "PodDBAdapter";
public static final String DATABASE_NAME = "Antennapod.db";
public static final int VERSION = 2020000;
public static final int VERSION = 2030000;

/**
* Maximum number of arguments for IN-operator.
Expand Down Expand Up @@ -116,6 +116,7 @@ public class PodDBAdapter {
public static final String KEY_FEED_SKIP_INTRO = "feed_skip_intro";
public static final String KEY_FEED_SKIP_ENDING = "feed_skip_ending";
public static final String KEY_FEED_TAGS = "tags";
public static final String KEY_EPISODE_NOTIFICATION = "episode_notification";

// Table names
public static final String TABLE_NAME_FEEDS = "Feeds";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
import de.danoeh.antennapod.core.feed.Feed;
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.preferences.UserPreferences;
import de.danoeh.antennapod.core.util.LongList;
import org.junit.After;
import org.junit.Before;
Expand Down Expand Up @@ -321,11 +319,11 @@ public void testGetPlaybackHistory() {

@Test
public void testGetNavDrawerDataQueueEmptyNoUnreadItems() {
final int NUM_FEEDS = 10;
final int NUM_ITEMS = 10;
DBTestUtils.saveFeedlist(NUM_FEEDS, NUM_ITEMS, true);
final int numFeeds = 10;
final int numItems = 10;
DbTestUtils.saveFeedlist(numFeeds, numItems, true);
NavDrawerData navDrawerData = DBReader.getNavDrawerData();
assertEquals(NUM_FEEDS, navDrawerData.items.size());
assertEquals(numFeeds, navDrawerData.items.size());
assertEquals(0, navDrawerData.numNewItems);
assertEquals(0, navDrawerData.queueSize);
}
Expand Down Expand Up @@ -354,9 +352,9 @@ public void testGetNavDrawerDataQueueNotEmptyWithUnreadItems() {
adapter.close();

NavDrawerData navDrawerData = DBReader.getNavDrawerData();
assertEquals(NUM_FEEDS, navDrawerData.items.size());
assertEquals(NUM_NEW, navDrawerData.numNewItems);
assertEquals(NUM_QUEUE, navDrawerData.queueSize);
assertEquals(numFeeds, navDrawerData.items.size());
assertEquals(numNew, navDrawerData.numNewItems);
assertEquals(numQueue, navDrawerData.queueSize);
}

@Test
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.