summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/build.gradle1
-rw-r--r--app/src/main/assets/licenses.xml6
-rw-r--r--app/src/main/java/de/danoeh/antennapod/dialog/SwipeActionsDialog.java52
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/SwipeActions.java22
-rw-r--r--build.gradle1
-rw-r--r--core/build.gradle1
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/service/FeedUpdateWorker.java11
7 files changed, 53 insertions, 41 deletions
diff --git a/app/build.gradle b/app/build.gradle
index cfa62c006..c4265f995 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -123,7 +123,6 @@ dependencies {
implementation 'com.github.ByteHamster:SearchPreference:v2.5.0'
implementation 'com.github.skydoves:balloon:1.5.3'
implementation 'com.github.xabaras:RecyclerViewSwipeDecorator:1.3'
- implementation "com.annimon:stream:$annimonStreamVersion"
// Non-free dependencies:
playImplementation 'com.google.android.play:core:1.8.0'
diff --git a/app/src/main/assets/licenses.xml b/app/src/main/assets/licenses.xml
index 30f1e06d9..e6745e4f5 100644
--- a/app/src/main/assets/licenses.xml
+++ b/app/src/main/assets/licenses.xml
@@ -67,12 +67,6 @@
license="MIT"
licenseText="LICENSE_JSOUP.txt" />
<library
- name="Lightweight-Stream-API"
- author="Victor Melnik"
- website="https://github.com/aNNiMON/Lightweight-Stream-API"
- license="Apache 2.0"
- licenseText="LICENSE_APACHE-2.0.txt" />
- <library
name="Material Components for Android"
author="Google"
website="https://github.com/material-components/material-components-android"
diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/SwipeActionsDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/SwipeActionsDialog.java
index 257158f15..2cd03e21d 100644
--- a/app/src/main/java/de/danoeh/antennapod/dialog/SwipeActionsDialog.java
+++ b/app/src/main/java/de/danoeh/antennapod/dialog/SwipeActionsDialog.java
@@ -13,8 +13,7 @@ import androidx.appcompat.content.res.AppCompatResources;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.gridlayout.widget.GridLayout;
-import com.annimon.stream.Stream;
-
+import java.util.ArrayList;
import java.util.List;
import de.danoeh.antennapod.R;
@@ -29,8 +28,16 @@ import de.danoeh.antennapod.fragment.FeedItemlistFragment;
import de.danoeh.antennapod.fragment.InboxFragment;
import de.danoeh.antennapod.fragment.PlaybackHistoryFragment;
import de.danoeh.antennapod.fragment.QueueFragment;
+import de.danoeh.antennapod.fragment.swipeactions.AddToQueueSwipeAction;
+import de.danoeh.antennapod.fragment.swipeactions.DeleteSwipeAction;
+import de.danoeh.antennapod.fragment.swipeactions.MarkFavoriteSwipeAction;
+import de.danoeh.antennapod.fragment.swipeactions.RemoveFromHistorySwipeAction;
+import de.danoeh.antennapod.fragment.swipeactions.RemoveFromInboxSwipeAction;
+import de.danoeh.antennapod.fragment.swipeactions.RemoveFromQueueSwipeAction;
+import de.danoeh.antennapod.fragment.swipeactions.StartDownloadSwipeAction;
import de.danoeh.antennapod.fragment.swipeactions.SwipeAction;
import de.danoeh.antennapod.fragment.swipeactions.SwipeActions;
+import de.danoeh.antennapod.fragment.swipeactions.TogglePlaybackStateSwipeAction;
import de.danoeh.antennapod.ui.common.ThemeUtils;
public class SwipeActionsDialog {
@@ -56,47 +63,54 @@ public class SwipeActionsDialog {
final MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(context);
- keys = SwipeActions.swipeActions;
+ keys = new ArrayList<>();
+ if (tag.equals(QueueFragment.TAG)) {
+ keys.add(new RemoveFromQueueSwipeAction());
+ } else {
+ keys.add(new AddToQueueSwipeAction());
+ }
+ if (!tag.equals(CompletedDownloadsFragment.TAG)) {
+ keys.add(new StartDownloadSwipeAction());
+ }
+ if (!tag.equals(CompletedDownloadsFragment.TAG)
+ && ! tag.equals(QueueFragment.TAG)
+ && !tag.equals(PlaybackHistoryFragment.TAG)) {
+ keys.add(new RemoveFromInboxSwipeAction());
+ }
+ if (!tag.equals(InboxFragment.TAG)) {
+ keys.add(new DeleteSwipeAction());
+ }
+ keys.add(new MarkFavoriteSwipeAction());
+ if (tag.equals(PlaybackHistoryFragment.TAG)) {
+ keys.add(new RemoveFromHistorySwipeAction());
+ }
+ if (!tag.equals(InboxFragment.TAG)) {
+ keys.add(new TogglePlaybackStateSwipeAction());
+ }
String forFragment = "";
switch (tag) {
case InboxFragment.TAG:
forFragment = context.getString(R.string.inbox_label);
- keys = Stream.of(keys).filter(a -> !a.getId().equals(SwipeAction.TOGGLE_PLAYED)
- && !a.getId().equals(SwipeAction.DELETE)
- && !a.getId().equals(SwipeAction.REMOVE_FROM_HISTORY)).toList();
break;
case AllEpisodesFragment.TAG:
forFragment = context.getString(R.string.episodes_label);
- keys = Stream.of(keys).filter(a -> !a.getId().equals(SwipeAction.REMOVE_FROM_HISTORY)).toList();
break;
case CompletedDownloadsFragment.TAG:
forFragment = context.getString(R.string.downloads_label);
- keys = Stream.of(keys).filter(a -> !a.getId().equals(SwipeAction.REMOVE_FROM_INBOX)
- && !a.getId().equals(SwipeAction.REMOVE_FROM_HISTORY)
- && !a.getId().equals(SwipeAction.START_DOWNLOAD)).toList();
break;
case FeedItemlistFragment.TAG:
forFragment = context.getString(R.string.individual_subscription);
- keys = Stream.of(keys).filter(a -> !a.getId().equals(SwipeAction.REMOVE_FROM_HISTORY)).toList();
break;
case QueueFragment.TAG:
forFragment = context.getString(R.string.queue_label);
- keys = Stream.of(keys).filter(a -> !a.getId().equals(SwipeAction.ADD_TO_QUEUE)
- && !a.getId().equals(SwipeAction.REMOVE_FROM_INBOX)
- && !a.getId().equals(SwipeAction.REMOVE_FROM_HISTORY)).toList();
break;
case PlaybackHistoryFragment.TAG:
forFragment = context.getString(R.string.playback_history_label);
- keys = Stream.of(keys).filter(a -> !a.getId().equals(SwipeAction.REMOVE_FROM_INBOX)).toList();
break;
default: break;
}
- if (!tag.equals(QueueFragment.TAG)) {
- keys = Stream.of(keys).filter(a -> !a.getId().equals(SwipeAction.REMOVE_FROM_QUEUE)).toList();
- }
-
builder.setTitle(context.getString(R.string.swipeactions_label) + " - " + forFragment);
SwipeactionsDialogBinding viewBinding = SwipeactionsDialogBinding.inflate(LayoutInflater.from(context));
builder.setView(viewBinding.getRoot());
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/SwipeActions.java b/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/SwipeActions.java
index beafe2604..bc8cd75c4 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/SwipeActions.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/swipeactions/SwipeActions.java
@@ -13,8 +13,6 @@ import androidx.lifecycle.OnLifecycleEvent;
import androidx.recyclerview.widget.ItemTouchHelper;
import androidx.recyclerview.widget.RecyclerView;
-import com.annimon.stream.Stream;
-
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -37,12 +35,11 @@ public class SwipeActions extends ItemTouchHelper.SimpleCallback implements Life
public static final String KEY_PREFIX_SWIPEACTIONS = "PrefSwipeActions";
public static final String KEY_PREFIX_NO_ACTION = "PrefNoSwipeAction";
- public static final List<SwipeAction> swipeActions = Collections.unmodifiableList(
+ private static final List<SwipeAction> swipeActions = Collections.unmodifiableList(
Arrays.asList(new AddToQueueSwipeAction(), new RemoveFromInboxSwipeAction(),
new StartDownloadSwipeAction(), new MarkFavoriteSwipeAction(),
new TogglePlaybackStateSwipeAction(), new RemoveFromQueueSwipeAction(),
- new DeleteSwipeAction(), new RemoveFromHistorySwipeAction())
- );
+ new DeleteSwipeAction(), new RemoveFromHistorySwipeAction()));
private final Fragment fragment;
private final String tag;
@@ -65,6 +62,15 @@ public class SwipeActions extends ItemTouchHelper.SimpleCallback implements Life
this(0, fragment, tag);
}
+ public static SwipeAction getAction(String key) {
+ for (SwipeAction action : swipeActions) {
+ if (action.getId().equals(key)) {
+ return action;
+ }
+ }
+ return null;
+ }
+
@OnLifecycleEvent(Lifecycle.Event.ON_START)
public void reloadPreference() {
actions = getPrefs(fragment.requireContext(), tag);
@@ -255,10 +261,8 @@ public class SwipeActions extends ItemTouchHelper.SimpleCallback implements Life
public Actions(String prefs) {
String[] actions = prefs.split(",");
if (actions.length == 2) {
- this.right = Stream.of(swipeActions)
- .filter(a -> a.getId().equals(actions[0])).single();
- this.left = Stream.of(swipeActions)
- .filter(a -> a.getId().equals(actions[1])).single();
+ right = getAction(actions[0]);
+ left = getAction(actions[1]);
}
}
diff --git a/build.gradle b/build.gradle
index 9b02b079f..ebaac9d9e 100644
--- a/build.gradle
+++ b/build.gradle
@@ -32,7 +32,6 @@ project.ext {
eventbusVersion = "3.3.1"
rxAndroidVersion = "2.1.1"
rxJavaVersion = "2.2.2"
- annimonStreamVersion = "1.2.2"
// Google Play build
wearableSupportVersion = "2.6.0"
diff --git a/core/build.gradle b/core/build.gradle
index c4cdf28f2..b864c4455 100644
--- a/core/build.gradle
+++ b/core/build.gradle
@@ -66,7 +66,6 @@ dependencies {
annotationProcessor "org.greenrobot:eventbus-annotation-processor:$eventbusVersion"
implementation "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion"
implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
- implementation "com.annimon:stream:$annimonStreamVersion"
// Non-free dependencies:
playApi "com.google.android.support:wearable:$wearableSupportVersion"
diff --git a/core/src/main/java/de/danoeh/antennapod/core/service/FeedUpdateWorker.java b/core/src/main/java/de/danoeh/antennapod/core/service/FeedUpdateWorker.java
index b01def584..4f9efdb9c 100644
--- a/core/src/main/java/de/danoeh/antennapod/core/service/FeedUpdateWorker.java
+++ b/core/src/main/java/de/danoeh/antennapod/core/service/FeedUpdateWorker.java
@@ -11,8 +11,6 @@ import androidx.work.ForegroundInfo;
import androidx.work.WorkManager;
import androidx.work.Worker;
import androidx.work.WorkerParameters;
-import com.annimon.stream.Collectors;
-import com.annimon.stream.Stream;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import de.danoeh.antennapod.core.ClientConfigurator;
@@ -104,11 +102,16 @@ public class FeedUpdateWorker extends Worker {
private Notification createNotification(@Nullable List<Feed> toUpdate) {
Context context = getApplicationContext();
String contentText = "";
- String bigText = "";
+ StringBuilder bigText = new StringBuilder();
if (toUpdate != null) {
contentText = context.getResources().getQuantityString(R.plurals.downloads_left,
toUpdate.size(), toUpdate.size());
- bigText = Stream.of(toUpdate).map(feed -> "• " + feed.getTitle()).collect(Collectors.joining("\n"));
+ for (int i = 0; i < toUpdate.size(); i++) {
+ bigText.append("• ").append(toUpdate.get(i).getTitle());
+ if (i != toUpdate.size() - 1) {
+ bigText.append("\n");
+ }
+ }
}
return new NotificationCompat.Builder(context, NotificationUtils.CHANNEL_ID_DOWNLOADING)
.setContentTitle(context.getString(R.string.download_notification_title_feeds))