From 4bba6b30a1b5e82b93edc27742ec35362b08d1c7 Mon Sep 17 00:00:00 2001 From: orionlee Date: Mon, 30 Apr 2018 14:59:45 -0700 Subject: Issue #2579: Provide share Link in episode playback screen even when the episode has no link - Use podcast link as the fallback. Also bug fix share link with position: to include epsiode and podcast title. --- .../de/danoeh/antennapod/core/util/ShareUtils.java | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'core/src/main/java/de') diff --git a/core/src/main/java/de/danoeh/antennapod/core/util/ShareUtils.java b/core/src/main/java/de/danoeh/antennapod/core/util/ShareUtils.java index 898f7bedb..149cdcbc6 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/util/ShareUtils.java +++ b/core/src/main/java/de/danoeh/antennapod/core/util/ShareUtils.java @@ -50,11 +50,30 @@ public class ShareUtils { return item.getFeed().getTitle() + ": " + item.getTitle(); } + /** + * Get the link for the feed item for the purpose of Share. It fallbacks to + * use the feed's link if the named feed item has no link. + */ + private static String getItemShareLink(FeedItem item) { + String link = item.getLink(); + if (link == null) { + Feed feed = item.getFeed(); + if (feed != null) { + link = feed.getLink(); + } + } + return link; + } + + public static boolean hasLinkToShare(FeedItem item) { + return ( item != null && getItemShareLink(item) != null ); + } + public static void shareFeedItemLink(Context context, FeedItem item, boolean withPosition) { - String text = getItemShareText(item) + " " + item.getLink(); + String text = getItemShareText(item) + " " + getItemShareLink(item); if(withPosition) { int pos = item.getMedia().getPosition(); - text = item.getLink() + " [" + Converter.getDurationStringLong(pos) + "]"; + text += " [" + Converter.getDurationStringLong(pos) + "]"; } shareLink(context, text); } -- cgit v1.2.3