summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java17
-rw-r--r--app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java5
-rw-r--r--app/src/main/res/menu/allepisodes_context.xml4
-rw-r--r--app/src/main/res/menu/feeditem_options.xml4
-rw-r--r--app/src/main/res/menu/feeditemlist_context.xml4
-rw-r--r--app/src/main/res/menu/mediaplayer.xml4
-rw-r--r--app/src/main/res/menu/queue_context.xml4
-rw-r--r--core/src/main/java/de/danoeh/antennapod/core/util/ShareUtils.java11
-rw-r--r--core/src/main/res/values/strings.xml1
9 files changed, 48 insertions, 6 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java
index 818864f79..21a0fa66f 100644
--- a/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java
+++ b/app/src/main/java/de/danoeh/antennapod/activity/MediaplayerActivity.java
@@ -309,10 +309,9 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
return false;
}
Playable media = controller.getMedia();
+ boolean isFeedMedia = media != null && (media instanceof FeedMedia);
- menu.findItem(R.id.support_item).setVisible(
- media != null && media.getPaymentLink() != null &&
- (media instanceof FeedMedia) &&
+ menu.findItem(R.id.support_item).setVisible(isFeedMedia && media.getPaymentLink() != null &&
((FeedMedia) media).getItem() != null &&
((FeedMedia) media).getItem().getFlattrStatus().flattrable()
);
@@ -320,20 +319,21 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
boolean hasWebsiteLink = media != null && media.getWebsiteLink() != null;
menu.findItem(R.id.visit_website_item).setVisible(hasWebsiteLink);
- boolean isItemAndHasLink = media != null && (media instanceof FeedMedia) &&
+ boolean isItemAndHasLink = isFeedMedia &&
((FeedMedia) media).getItem() != null && ((FeedMedia) media).getItem().getLink() != null;
menu.findItem(R.id.share_link_item).setVisible(isItemAndHasLink);
menu.findItem(R.id.share_link_with_position_item).setVisible(isItemAndHasLink);
- boolean isItemHasDownloadLink = media != null && (media instanceof FeedMedia) && ((FeedMedia) media).getDownload_url() != null;
+ boolean isItemHasDownloadLink = isFeedMedia && ((FeedMedia) media).getDownload_url() != null;
menu.findItem(R.id.share_download_url_item).setVisible(isItemHasDownloadLink);
menu.findItem(R.id.share_download_url_with_position_item).setVisible(isItemHasDownloadLink);
+ menu.findItem(R.id.share_file).setVisible(isFeedMedia && ((FeedMedia) media).fileExists());
menu.findItem(R.id.share_item).setVisible(hasWebsiteLink || isItemAndHasLink || isItemHasDownloadLink);
menu.findItem(R.id.add_to_favorites_item).setVisible(false);
menu.findItem(R.id.remove_from_favorites_item).setVisible(false);
- if(media != null && media instanceof FeedMedia) {
+ if (isFeedMedia) {
menu.findItem(R.id.add_to_favorites_item).setVisible(!isFavorite);
menu.findItem(R.id.remove_from_favorites_item).setVisible(isFavorite);
}
@@ -574,6 +574,11 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
ShareUtils.shareFeedItemDownloadLink(this, ((FeedMedia) media).getItem(), true);
}
break;
+ case R.id.share_file:
+ if (media instanceof FeedMedia) {
+ ShareUtils.shareFeedItemFile(this, ((FeedMedia) media));
+ }
+ break;
default:
return false;
}
diff --git a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java
index 6799114f7..57b7c359c 100644
--- a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java
+++ b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedItemMenuHandler.java
@@ -101,6 +101,8 @@ public class FeedItemMenuHandler {
mi.setItemVisibility(R.id.share_download_url_with_position_item, false);
}
+ mi.setItemVisibility(R.id.share_file, hasMedia && selectedItem.getMedia().fileExists());
+
if (selectedItem.isPlayed()) {
mi.setItemVisibility(R.id.mark_read_item, false);
} else {
@@ -239,6 +241,9 @@ public class FeedItemMenuHandler {
case R.id.share_download_url_with_position_item:
ShareUtils.shareFeedItemDownloadLink(context, selectedItem, true);
break;
+ case R.id.share_file:
+ ShareUtils.shareFeedItemFile(context, selectedItem.getMedia());
+ break;
default:
Log.d(TAG, "Unknown menuItemId: " + menuItemId);
return false;
diff --git a/app/src/main/res/menu/allepisodes_context.xml b/app/src/main/res/menu/allepisodes_context.xml
index c5356535c..7398b9118 100644
--- a/app/src/main/res/menu/allepisodes_context.xml
+++ b/app/src/main/res/menu/allepisodes_context.xml
@@ -71,6 +71,10 @@
android:id="@+id/share_download_url_with_position_item"
android:menuCategory="container"
android:title="@string/share_item_url_with_position_label" />
+ <item
+ android:id="@+id/share_file"
+ android:menuCategory="container"
+ android:title="@string/share_file_label" />
</menu>
</item>
diff --git a/app/src/main/res/menu/feeditem_options.xml b/app/src/main/res/menu/feeditem_options.xml
index 511758c2e..7e111d816 100644
--- a/app/src/main/res/menu/feeditem_options.xml
+++ b/app/src/main/res/menu/feeditem_options.xml
@@ -84,6 +84,10 @@
android:id="@+id/share_download_url_with_position_item"
android:menuCategory="container"
android:title="@string/share_item_url_with_position_label" />
+ <item
+ android:id="@+id/share_file"
+ android:menuCategory="container"
+ android:title="@string/share_file_label" />
</menu>
</item>
diff --git a/app/src/main/res/menu/feeditemlist_context.xml b/app/src/main/res/menu/feeditemlist_context.xml
index 271cb96a7..d3ec88bc7 100644
--- a/app/src/main/res/menu/feeditemlist_context.xml
+++ b/app/src/main/res/menu/feeditemlist_context.xml
@@ -73,6 +73,10 @@
android:id="@+id/share_download_url_with_position_item"
android:menuCategory="container"
android:title="@string/share_item_url_with_position_label" />
+ <item
+ android:id="@+id/share_file"
+ android:menuCategory="container"
+ android:title="@string/share_file_label" />
</menu>
</item>
diff --git a/app/src/main/res/menu/mediaplayer.xml b/app/src/main/res/menu/mediaplayer.xml
index c4086bf5e..530eb3400 100644
--- a/app/src/main/res/menu/mediaplayer.xml
+++ b/app/src/main/res/menu/mediaplayer.xml
@@ -64,6 +64,10 @@
android:id="@+id/share_download_url_with_position_item"
android:menuCategory="container"
android:title="@string/share_item_url_with_position_label" />
+ <item
+ android:id="@+id/share_file"
+ android:menuCategory="container"
+ android:title="@string/share_file_label" />
</menu>
</item>
<item
diff --git a/app/src/main/res/menu/queue_context.xml b/app/src/main/res/menu/queue_context.xml
index 3eb1d9d5e..e93d808c1 100644
--- a/app/src/main/res/menu/queue_context.xml
+++ b/app/src/main/res/menu/queue_context.xml
@@ -74,6 +74,10 @@
android:id="@+id/share_download_url_with_position_item"
android:menuCategory="container"
android:title="@string/share_item_url_with_position_label" />
+ <item
+ android:id="@+id/share_file"
+ android:menuCategory="container"
+ android:title="@string/share_file_label" />
</menu>
</item>
<item
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 35916a604..887c0055c 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
@@ -3,9 +3,13 @@ package de.danoeh.antennapod.core.util;
import android.content.Context;
import android.content.Intent;
+import android.net.Uri;
import de.danoeh.antennapod.core.R;
import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.feed.FeedItem;
+import de.danoeh.antennapod.core.feed.FeedMedia;
+
+import java.io.File;
/** Utility methods for sharing data */
public class ShareUtils {
@@ -58,4 +62,11 @@ public class ShareUtils {
shareLink(context, text);
}
+ public static void shareFeedItemFile(Context context, FeedMedia media) {
+ Intent i = new Intent(Intent.ACTION_SEND);
+ i.setType(media.getMime_type());
+ i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(new File(media.getLocalMediaUrl())));
+ i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+ context.startActivity(Intent.createChooser(i, context.getString(R.string.share_file_label)));
+ }
}
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index b82a03801..86cff515f 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -126,6 +126,7 @@
<string name="remove_feed_label">Remove Podcast</string>
<string name="share_label">Share&#8230;</string>
<string name="share_link_label">Share Link</string>
+ <string name="share_file_label">Share File</string>
<string name="share_link_with_position_label">Share Link with Position</string>
<string name="share_feed_url_label">Share Feed URL</string>
<string name="share_item_url_label">Share Episode File URL</string>