summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorByteHamster <ByteHamster@users.noreply.github.com>2024-09-26 22:46:22 +0200
committerGitHub <noreply@github.com>2024-09-26 22:46:22 +0200
commitf6bc8d2c515c9ca4b690a5cb9c7901e41b6739a3 (patch)
treecb7fc5e564f7585e7b133101e55def34c89a1a86
parenta4bc5a64423730088e23f870b76a47e79a2c047a (diff)
downloadAntennaPod-f6bc8d2c515c9ca4b690a5cb9c7901e41b6739a3.zip
Allow sharing feeds from subscriptions page (#7427)
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/screen/drawer/NavDrawerFragment.java30
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/screen/feed/FeedItemlistFragment.java36
-rw-r--r--app/src/main/java/de/danoeh/antennapod/ui/screen/subscriptions/FeedMenuHandler.java13
-rw-r--r--app/src/main/res/menu/feedlist.xml2
-rw-r--r--app/src/main/res/menu/nav_feed_context.xml5
5 files changed, 32 insertions, 54 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/drawer/NavDrawerFragment.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/drawer/NavDrawerFragment.java
index d6d8bea93..81d58c514 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/screen/drawer/NavDrawerFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/drawer/NavDrawerFragment.java
@@ -2,7 +2,6 @@ package de.danoeh.antennapod.ui.screen.drawer;
import android.app.Activity;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.ColorStateList;
@@ -34,13 +33,13 @@ import com.google.android.material.shape.MaterialShapeDrawable;
import com.google.android.material.shape.ShapeAppearanceModel;
import de.danoeh.antennapod.net.download.service.episode.autodownload.EpisodeCleanupAlgorithmFactory;
+import de.danoeh.antennapod.ui.screen.subscriptions.FeedMenuHandler;
import org.apache.commons.lang3.StringUtils;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -48,15 +47,12 @@ import java.util.Set;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.ui.screen.preferences.PreferenceActivity;
-import de.danoeh.antennapod.ui.common.ConfirmationDialog;
import de.danoeh.antennapod.ui.MenuItemUtils;
import de.danoeh.antennapod.storage.database.DBReader;
-import de.danoeh.antennapod.storage.database.DBWriter;
import de.danoeh.antennapod.storage.database.NavDrawerData;
import de.danoeh.antennapod.ui.screen.feed.RemoveFeedDialog;
import de.danoeh.antennapod.ui.screen.feed.RenameFeedDialog;
import de.danoeh.antennapod.ui.screen.subscriptions.SubscriptionsFilterDialog;
-import de.danoeh.antennapod.ui.screen.feed.preferences.TagSettingsDialog;
import de.danoeh.antennapod.event.FeedListUpdateEvent;
import de.danoeh.antennapod.event.QueueEvent;
import de.danoeh.antennapod.event.UnreadItemsUpdateEvent;
@@ -188,26 +184,7 @@ public class NavDrawerFragment extends Fragment implements SharedPreferences.OnS
private boolean onFeedContextMenuClicked(Feed feed, MenuItem item) {
final int itemId = item.getItemId();
- if (itemId == R.id.remove_all_inbox_item) {
- ConfirmationDialog removeAllNewFlagsConfirmationDialog = new ConfirmationDialog(getContext(),
- R.string.remove_all_inbox_label,
- R.string.remove_all_inbox_confirmation_msg) {
- @Override
- public void onConfirmButtonPressed(DialogInterface dialog) {
- dialog.dismiss();
- DBWriter.removeFeedNewFlag(feed.getId());
- }
- };
- removeAllNewFlagsConfirmationDialog.createNewDialog().show();
- return true;
- } else if (itemId == R.id.edit_tags) {
- TagSettingsDialog.newInstance(Collections.singletonList(feed.getPreferences()))
- .show(getChildFragmentManager(), TagSettingsDialog.TAG);
- return true;
- } else if (itemId == R.id.rename_item) {
- new RenameFeedDialog(getActivity(), feed).show();
- return true;
- } else if (itemId == R.id.remove_feed) {
+ if (itemId == R.id.remove_feed) {
RemoveFeedDialog.show(getContext(), feed, () -> {
if (String.valueOf(feed.getId()).equals(getLastNavFragment(getContext()))) {
((MainActivity) getActivity()).loadFragment(UserPreferences.getDefaultPage(), null);
@@ -217,6 +194,9 @@ public class NavDrawerFragment extends Fragment implements SharedPreferences.OnS
});
return true;
}
+ if (FeedMenuHandler.onMenuItemClicked(this, itemId, feed, null)) {
+ return true;
+ }
return super.onContextItemSelected(item);
}
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/feed/FeedItemlistFragment.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/feed/FeedItemlistFragment.java
index e4e64ffc5..6dabaa054 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/screen/feed/FeedItemlistFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/feed/FeedItemlistFragment.java
@@ -21,7 +21,6 @@ import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.appbar.MaterialToolbar;
-import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.google.android.material.snackbar.Snackbar;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
@@ -63,7 +62,7 @@ import de.danoeh.antennapod.ui.screen.download.DownloadLogDetailsDialog;
import de.danoeh.antennapod.ui.screen.download.DownloadLogFragment;
import de.danoeh.antennapod.ui.screen.episode.ItemPagerFragment;
import de.danoeh.antennapod.ui.screen.feed.preferences.FeedSettingsFragment;
-import de.danoeh.antennapod.ui.share.ShareUtils;
+import de.danoeh.antennapod.ui.screen.subscriptions.FeedMenuHandler;
import de.danoeh.antennapod.ui.swipeactions.SwipeActions;
import io.reactivex.Maybe;
import io.reactivex.Observable;
@@ -280,10 +279,10 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
}
if (item.getItemId() == R.id.visit_website_item) {
IntentUtils.openInBrowser(getContext(), feed.getLink());
- } else if (item.getItemId() == R.id.share_item) {
- ShareUtils.shareFeedLink(getContext(), feed);
+ return true;
} else if (item.getItemId() == R.id.refresh_item) {
FeedUpdateManager.getInstance().runOnceOrAsk(getContext(), feed);
+ return true;
} else if (item.getItemId() == R.id.refresh_complete_item) {
new Thread(() -> {
feed.setNextPageLink(feed.getDownloadUrl());
@@ -295,24 +294,25 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
throw new RuntimeException(e);
}
}).start();
+ return true;
} else if (item.getItemId() == R.id.sort_items) {
SingleFeedSortDialog.newInstance(feed).show(getChildFragmentManager(), "SortDialog");
- } else if (item.getItemId() == R.id.rename_item) {
- new RenameFeedDialog(getActivity(), feed).show();
+ return true;
} else if (item.getItemId() == R.id.remove_feed) {
RemoveFeedDialog.show(getContext(), feed, () -> {
((MainActivity) getActivity()).loadFragment(UserPreferences.getDefaultPage(), null);
// Make sure fragment is hidden before actually starting to delete
getActivity().getSupportFragmentManager().executePendingTransactions();
});
- } else if (item.getItemId() == R.id.remove_all_inbox_item) {
- showRemoveAllDialog();
+ return true;
} else if (item.getItemId() == R.id.action_search) {
((MainActivity) getActivity()).loadChildFragment(SearchFragment.newInstance(feed.getId(), feed.getTitle()));
- } else {
- return false;
+ return true;
}
- return true;
+
+ Runnable showRemovedAllSnackbar = () -> ((MainActivity) getActivity())
+ .showSnackbarAbovePlayer(R.string.removed_all_inbox_msg, Toast.LENGTH_SHORT);
+ return FeedMenuHandler.onMenuItemClicked(this, item.getItemId(), feed, showRemovedAllSnackbar);
}
@Override
@@ -561,20 +561,6 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
}
}
- private void showRemoveAllDialog() {
- MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(getContext());
- builder.setTitle(R.string.remove_all_inbox_label);
- builder.setMessage(R.string.remove_all_inbox_confirmation_msg);
-
- builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> {
- dialog.dismiss();
- DBWriter.removeFeedNewFlag(feedID);
- ((MainActivity) getActivity()).showSnackbarAbovePlayer(R.string.removed_all_inbox_msg, Toast.LENGTH_SHORT);
- });
- builder.setNegativeButton(R.string.cancel_label, null);
- builder.show();
- }
-
private void loadFeedImage() {
Glide.with(this)
.load(feed.getImageUrl())
diff --git a/app/src/main/java/de/danoeh/antennapod/ui/screen/subscriptions/FeedMenuHandler.java b/app/src/main/java/de/danoeh/antennapod/ui/screen/subscriptions/FeedMenuHandler.java
index f5761020c..9b57f9716 100644
--- a/app/src/main/java/de/danoeh/antennapod/ui/screen/subscriptions/FeedMenuHandler.java
+++ b/app/src/main/java/de/danoeh/antennapod/ui/screen/subscriptions/FeedMenuHandler.java
@@ -5,6 +5,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.util.Log;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.ui.common.ConfirmationDialog;
@@ -13,6 +14,7 @@ import de.danoeh.antennapod.ui.screen.feed.RemoveFeedDialog;
import de.danoeh.antennapod.ui.screen.feed.RenameFeedDialog;
import de.danoeh.antennapod.ui.screen.feed.preferences.TagSettingsDialog;
import de.danoeh.antennapod.model.feed.Feed;
+import de.danoeh.antennapod.ui.share.ShareUtils;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
@@ -28,7 +30,7 @@ public abstract class FeedMenuHandler {
private static final String TAG = "FeedMenuHandler";
public static boolean onMenuItemClicked(@NonNull Fragment fragment, int menuItemId,
- @NonNull Feed selectedFeed, Runnable callback) {
+ @NonNull Feed selectedFeed, @Nullable Runnable removeFromInboxCallback) {
@NonNull Context context = fragment.requireContext();
if (menuItemId == R.id.rename_folder_item) {
new RenameFeedDialog(fragment.getActivity(), selectedFeed).show();
@@ -42,8 +44,11 @@ public abstract class FeedMenuHandler {
Observable.fromCallable((Callable<Future>) () -> DBWriter.removeFeedNewFlag(selectedFeed.getId()))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
- .subscribe(result -> callback.run(),
- error -> Log.e(TAG, Log.getStackTraceString(error)));
+ .subscribe(result -> {
+ if (removeFromInboxCallback != null) {
+ removeFromInboxCallback.run();
+ }
+ }, error -> Log.e(TAG, Log.getStackTraceString(error)));
}
};
dialog.createNewDialog().show();
@@ -55,6 +60,8 @@ public abstract class FeedMenuHandler {
new RenameFeedDialog(fragment.getActivity(), selectedFeed).show();
} else if (menuItemId == R.id.remove_feed) {
RemoveFeedDialog.show(context, selectedFeed, null);
+ } else if (menuItemId == R.id.share_feed) {
+ ShareUtils.shareFeedLink(context, selectedFeed);
} else {
return false;
}
diff --git a/app/src/main/res/menu/feedlist.xml b/app/src/main/res/menu/feedlist.xml
index 92a426b90..3ba923384 100644
--- a/app/src/main/res/menu/feedlist.xml
+++ b/app/src/main/res/menu/feedlist.xml
@@ -37,7 +37,7 @@
</item>
<item
- android:id="@+id/share_item"
+ android:id="@+id/share_feed"
android:menuCategory="container"
custom:showAsAction="never"
android:title="@string/share_label" />
diff --git a/app/src/main/res/menu/nav_feed_context.xml b/app/src/main/res/menu/nav_feed_context.xml
index 606860d5e..fba299c98 100644
--- a/app/src/main/res/menu/nav_feed_context.xml
+++ b/app/src/main/res/menu/nav_feed_context.xml
@@ -22,6 +22,11 @@
android:title="@string/remove_feed_label" />
<item
+ android:id="@+id/share_feed"
+ android:menuCategory="container"
+ android:title="@string/share_label" />
+
+ <item
android:id="@+id/multi_select"
android:menuCategory="container"
android:title="@string/multi_select"