diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/ShareDialog.java b/app/src/main/java/de/danoeh/antennapod/dialog/ShareDialog.java
index 8104d3539..614cc1e71 100644
--- a/app/src/main/java/de/danoeh/antennapod/dialog/ShareDialog.java
+++ b/app/src/main/java/de/danoeh/antennapod/dialog/ShareDialog.java
@@ -18,21 +18,21 @@ import de.danoeh.antennapod.core.feed.FeedItem;
import de.danoeh.antennapod.core.util.ShareUtils;
public class ShareDialog extends DialogFragment {
-
private static final String ARGUMENT_FEED_ITEM = "feedItem";
-
- private static final String TAG = "ShareDialog";
- private Context ctx;
- private FeedItem item;
-
+ private static final String PREF_NAME = "ShareDialog";
private static final String PREF_SHARE_DIALOG_OPTION = "prefShareDialogOption";
private static final String PREF_SHARE_EPISODE_START_AT = "prefShareEpisodeStartAt";
+ private static final String PREF_VALUE_WEBSITE = "website";
+ private static final String PREF_VALUE_MEDIA_URL = "media";
+
+ private Context ctx;
+ private FeedItem item;
+ private SharedPreferences prefs;
- private RadioGroup radioGroup;
private RadioButton radioEpisodeWebsite;
+ private RadioButton radioMediaFileUrl;
private RadioButton radioMediaFile;
private CheckBox checkBoxStartAt;
- private SharedPreferences prefs;
public ShareDialog() {
// Empty constructor required for DialogFragment
@@ -52,7 +52,7 @@ public class ShareDialog extends DialogFragment {
if (getArguments() != null) {
ctx = getActivity();
item = (FeedItem) getArguments().getSerializable(ARGUMENT_FEED_ITEM);
- prefs = getActivity().getSharedPreferences("ShareDialog", Context.MODE_PRIVATE);
+ prefs = getActivity().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
}
View content = View.inflate(ctx, R.layout.share_episode_dialog, null);
@@ -60,8 +60,12 @@ public class ShareDialog extends DialogFragment {
builder.setTitle(R.string.share_label);
builder.setView(content);
- radioGroup = content.findViewById(R.id.share_dialog_radio_group);
+ RadioGroup radioGroup = content.findViewById(R.id.share_dialog_radio_group);
+ radioGroup.setOnCheckedChangeListener((group, checkedId) ->
+ checkBoxStartAt.setEnabled(checkedId != R.id.share_media_file_radio));
+
radioEpisodeWebsite = content.findViewById(R.id.share_episode_website_radio);
+ radioMediaFileUrl = content.findViewById(R.id.share_media_file_url_radio);
radioMediaFile = content.findViewById(R.id.share_media_file_radio);
checkBoxStartAt = content.findViewById(R.id.share_start_at_timer_dialog);
@@ -71,10 +75,14 @@ public class ShareDialog extends DialogFragment {
boolean includePlaybackPosition = checkBoxStartAt.isChecked();
if (radioEpisodeWebsite.isChecked()) {
ShareUtils.shareFeedItemLink(ctx, item, includePlaybackPosition);
- prefs.edit().putString(PREF_SHARE_DIALOG_OPTION, "website").apply();
- } else {
+ prefs.edit().putString(PREF_SHARE_DIALOG_OPTION, PREF_VALUE_WEBSITE).apply();
+ } else if (radioMediaFileUrl.isChecked()) {
ShareUtils.shareFeedItemDownloadLink(ctx, item, includePlaybackPosition);
- prefs.edit().putString(PREF_SHARE_DIALOG_OPTION, "media").apply();
+ prefs.edit().putString(PREF_SHARE_DIALOG_OPTION, PREF_VALUE_MEDIA_URL).apply();
+ } else if (radioMediaFile.isChecked()) {
+ ShareUtils.shareFeedItemFile(ctx, item.getMedia());
+ } else {
+ throw new IllegalStateException("Unknown share method");
}
prefs.edit().putBoolean(PREF_SHARE_EPISODE_START_AT, includePlaybackPosition).apply();
}).setNegativeButton(R.string.cancel_label, (dialog, id) -> dialog.dismiss());
@@ -85,26 +93,23 @@ public class ShareDialog extends DialogFragment {
private void setupOptions() {
final boolean hasMedia = item.getMedia() != null;
- if (!ShareUtils.hasLinkToShare(item)) {
- radioEpisodeWebsite.setVisibility(View.GONE);
- radioMediaFile.setChecked(true);
- }
+ boolean downloaded = hasMedia && item.getMedia().isDownloaded();
+ radioMediaFile.setVisibility(downloaded ? View.VISIBLE : View.GONE);
- if (!hasMedia || item.getMedia().getDownload_url() == null) {
- radioMediaFile.setVisibility(View.GONE);
+ radioEpisodeWebsite.setVisibility(ShareUtils.hasLinkToShare(item) ? View.VISIBLE : View.GONE);
+
+ boolean hasDownloadUrl = hasMedia && item.getMedia().getDownload_url() != null;
+ radioMediaFileUrl.setVisibility(hasDownloadUrl ? View.VISIBLE : View.GONE);
+
+ String option = prefs.getString(PREF_SHARE_DIALOG_OPTION, PREF_VALUE_WEBSITE);
+ if (option.equals(PREF_VALUE_WEBSITE)) {
radioEpisodeWebsite.setChecked(true);
+ radioMediaFileUrl.setChecked(false);
+ } else {
+ radioEpisodeWebsite.setChecked(false);
+ radioMediaFileUrl.setChecked(true);
}
-
- if (radioEpisodeWebsite.getVisibility() == View.VISIBLE && radioMediaFile.getVisibility() == View.VISIBLE) {
- String option = prefs.getString(PREF_SHARE_DIALOG_OPTION, "website");
- if (option.equals("website")) {
- radioEpisodeWebsite.setChecked(true);
- radioMediaFile.setChecked(false);
- } else {
- radioEpisodeWebsite.setChecked(false);
- radioMediaFile.setChecked(true);
- }
- }
+ radioMediaFile.setChecked(false);
boolean switchIsChecked = prefs.getBoolean(PREF_SHARE_EPISODE_START_AT, false);
checkBoxStartAt.setChecked(switchIsChecked);
diff --git a/app/src/main/res/layout/share_episode_dialog.xml b/app/src/main/res/layout/share_episode_dialog.xml
index 8cf955d4c..539efa5c8 100644
--- a/app/src/main/res/layout/share_episode_dialog.xml
+++ b/app/src/main/res/layout/share_episode_dialog.xml
@@ -13,17 +13,22 @@
android:layout_marginBottom="16dp"
android:orientation="vertical">
-
-
+
+ android:text="@string/share_dialog_media_file_url_label" />
+
-
-
+ android:title="@string/share_label" />
\ No newline at end of file
diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml
index dc6136fdc..bdc9eb8ed 100644
--- a/core/src/main/res/values/strings.xml
+++ b/core/src/main/res/values/strings.xml
@@ -143,13 +143,9 @@
Remove podcast
Share
Share…
- Share Episode URL
- Share Episode URL with Position
Share File
Website address
Podcast feed URL
- Share Media File URL
- Share Media File URL with Position
Please confirm that you want to delete the podcast \"%1$s\" and ALL its episodes (including downloaded episodes).
Please confirm that you want to remove the podcast \"%1$s\". The files in the local source folder will not be deleted.
Removing podcast
@@ -808,8 +804,9 @@
Include:
Playback position
- Media file URL
+ Media file address
Episode webpage
+ Media file
Audio controls