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.
This commit is contained in:
orionlee 2018-04-30 14:59:45 -07:00
parent 9d3d92cc9d
commit 4bba6b30a1
2 changed files with 22 additions and 3 deletions

View File

@ -324,7 +324,7 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
menu.findItem(R.id.visit_website_item).setVisible(hasWebsiteLink);
boolean isItemAndHasLink = isFeedMedia &&
((FeedMedia) media).getItem() != null && ((FeedMedia) media).getItem().getLink() != null;
ShareUtils.hasLinkToShare(((FeedMedia) media).getItem());
menu.findItem(R.id.share_link_item).setVisible(isItemAndHasLink);
menu.findItem(R.id.share_link_with_position_item).setVisible(isItemAndHasLink);

View File

@ -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);
}