diff options
author | Adrián Sámson <13379985+adrns@users.noreply.github.com> | 2022-05-24 19:40:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-24 19:40:40 +0200 |
commit | 687ed5f2ffe9536f7451b00468c75a2201f2d04e (patch) | |
tree | 102f9a1dc06337864a8800be9c5330dece566365 | |
parent | 484b6d093245ad08bd27e797c9d0082eabfcffc4 (diff) | |
download | AntennaPod-687ed5f2ffe9536f7451b00468c75a2201f2d04e.zip |
Open podcast from statistics (#5898)
4 files changed, 25 insertions, 2 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java index 62c6bbd79..f666951f0 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -85,6 +85,7 @@ public class MainActivity extends CastEnabledActivity { public static final String EXTRA_FEED_ID = "fragment_feed_id"; public static final String EXTRA_REFRESH_ON_START = "refresh_on_start"; public static final String EXTRA_STARTED_FROM_SEARCH = "started_from_search"; + public static final String EXTRA_ADD_TO_BACK_STACK = "add_to_back_stack"; public static final String KEY_GENERATED_VIEW_ID = "generated_view_id"; private @Nullable DrawerLayout drawerLayout; @@ -524,7 +525,9 @@ public class MainActivity extends CastEnabledActivity { if (tag != null) { loadFragment(tag, args); } else if (feedId > 0) { - if (intent.getBooleanExtra(EXTRA_STARTED_FROM_SEARCH, false)) { + boolean startedFromSearch = intent.getBooleanExtra(EXTRA_STARTED_FROM_SEARCH, false); + boolean addToBackStack = intent.getBooleanExtra(EXTRA_ADD_TO_BACK_STACK, false); + if (startedFromSearch || addToBackStack) { loadChildFragment(FeedItemlistFragment.newInstance(feedId)); } else { loadFeedFragmentById(feedId, args); diff --git a/ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/MainActivityStarter.java b/ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/MainActivityStarter.java index 88c0378c1..f91bb9244 100644 --- a/ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/MainActivityStarter.java +++ b/ui/app-start-intent/src/main/java/de/danoeh/antennapod/ui/appstartintent/MainActivityStarter.java @@ -12,6 +12,8 @@ import android.os.Build; public class MainActivityStarter { public static final String INTENT = "de.danoeh.antennapod.intents.MAIN_ACTIVITY"; public static final String EXTRA_OPEN_PLAYER = "open_player"; + public static final String EXTRA_FEED_ID = "fragment_feed_id"; + public static final String EXTRA_ADD_TO_BACK_STACK = "add_to_back_stack"; private final Intent intent; private final Context context; @@ -39,4 +41,14 @@ public class MainActivityStarter { intent.putExtra(EXTRA_OPEN_PLAYER, true); return this; } + + public MainActivityStarter withOpenFeed(long feedId) { + intent.putExtra(EXTRA_FEED_ID, feedId); + return this; + } + + public MainActivityStarter withAddToBackStack() { + intent.putExtra(EXTRA_ADD_TO_BACK_STACK, true); + return this; + } } diff --git a/ui/statistics/build.gradle b/ui/statistics/build.gradle index cca840989..72b4b807b 100644 --- a/ui/statistics/build.gradle +++ b/ui/statistics/build.gradle @@ -13,8 +13,9 @@ android { dependencies { implementation project(":core") - implementation project(':event') + implementation project(":event") implementation project(":model") + implementation project(":ui:app-start-intent") implementation project(":ui:common") annotationProcessor "androidx.annotation:annotation:$annotationVersion" diff --git a/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/feed/FeedStatisticsDialogFragment.java b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/feed/FeedStatisticsDialogFragment.java index 7109bd6a1..f0308e364 100644 --- a/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/feed/FeedStatisticsDialogFragment.java +++ b/ui/statistics/src/main/java/de/danoeh/antennapod/ui/statistics/feed/FeedStatisticsDialogFragment.java @@ -2,10 +2,13 @@ package de.danoeh.antennapod.ui.statistics.feed; import android.app.Dialog; import android.os.Bundle; + import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.DialogFragment; + +import de.danoeh.antennapod.ui.appstartintent.MainActivityStarter; import de.danoeh.antennapod.ui.statistics.R; public class FeedStatisticsDialogFragment extends DialogFragment { @@ -26,6 +29,10 @@ public class FeedStatisticsDialogFragment extends DialogFragment { public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { AlertDialog.Builder dialog = new AlertDialog.Builder(getContext()); dialog.setPositiveButton(android.R.string.ok, null); + dialog.setNeutralButton(R.string.open_podcast, (dialogInterface, i) -> { + long feedId = getArguments().getLong(EXTRA_FEED_ID); + new MainActivityStarter(getContext()).withOpenFeed(feedId).withAddToBackStack().start(); + }); dialog.setTitle(getArguments().getString(EXTRA_FEED_TITLE)); dialog.setView(R.layout.feed_statistics_dialog); return dialog.create(); |