diff --git a/app/src/androidTest/java/de/test/antennapod/dialogs/ShareDialogTest.java b/app/src/androidTest/java/de/test/antennapod/dialogs/ShareDialogTest.java
index e31838671..29cea18dc 100644
--- a/app/src/androidTest/java/de/test/antennapod/dialogs/ShareDialogTest.java
+++ b/app/src/androidTest/java/de/test/antennapod/dialogs/ShareDialogTest.java
@@ -74,13 +74,13 @@ public class ShareDialogTest {
@Test
public void testShareDialogDisplayed() throws InterruptedException {
- onView(withText(R.string.share_label_with_ellipses)).perform(click());
+ onView(withText(R.string.share_label)).perform(click());
onView(allOf(isDisplayed(), withText(R.string.share_label)));
}
@Test
public void testShareDialogCancelButton() {
- onView(withText(R.string.share_label_with_ellipses)).perform(scrollTo()).perform(click());
+ onView(withText(R.string.share_label)).perform(scrollTo()).perform(click());
onView(withText(R.string.cancel_label)).check(matches(isDisplayed())).perform(scrollTo()).perform(click());
}
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 699e40e71..dbd4cdb59 100644
--- a/app/src/main/java/de/danoeh/antennapod/dialog/ShareDialog.java
+++ b/app/src/main/java/de/danoeh/antennapod/dialog/ShareDialog.java
@@ -5,15 +5,13 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
-import android.widget.CheckBox;
-import android.widget.RadioButton;
-import android.widget.RadioGroup;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;
import de.danoeh.antennapod.R;
+import de.danoeh.antennapod.databinding.ShareEpisodeDialogBinding;
import de.danoeh.antennapod.model.feed.FeedItem;
import de.danoeh.antennapod.core.util.ShareUtils;
@@ -21,14 +19,13 @@ public class ShareDialog extends DialogFragment {
private static final String ARGUMENT_FEED_ITEM = "feedItem";
private static final String PREF_NAME = "ShareDialog";
private static final String PREF_SHARE_EPISODE_START_AT = "prefShareEpisodeStartAt";
+ private static final String PREF_SHARE_EPISODE_TYPE = "prefShareEpisodeType";
private Context ctx;
private FeedItem item;
private SharedPreferences prefs;
- private RadioButton radioMediaFile;
- private RadioButton radioLinkToEpisode;
- private CheckBox checkBoxStartAt;
+ ShareEpisodeDialogBinding viewBinding;
public ShareDialog() {
// Empty constructor required for DialogFragment
@@ -51,31 +48,34 @@ public class ShareDialog extends DialogFragment {
prefs = getActivity().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE);
}
- View content = View.inflate(ctx, R.layout.share_episode_dialog, null);
+ viewBinding = ShareEpisodeDialogBinding.inflate(getLayoutInflater());
+ viewBinding.shareDialogRadioGroup.setOnCheckedChangeListener((group, checkedId) ->
+ viewBinding.sharePositionCheckbox.setEnabled(checkedId == viewBinding.shareSocialRadio.getId()));
+
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
builder.setTitle(R.string.share_label);
- builder.setView(content);
-
- RadioGroup radioGroup = content.findViewById(R.id.share_dialog_radio_group);
- radioGroup.setOnCheckedChangeListener((group, checkedId) ->
- checkBoxStartAt.setEnabled(checkedId != R.id.share_media_file_radio));
-
- radioLinkToEpisode = content.findViewById(R.id.share_link_to_episode_radio);
- radioMediaFile = content.findViewById(R.id.share_media_file_radio);
- checkBoxStartAt = content.findViewById(R.id.share_start_at_timer_dialog);
-
+ builder.setView(viewBinding.getRoot());
setupOptions();
builder.setPositiveButton(R.string.share_label, (dialog, id) -> {
- boolean includePlaybackPosition = checkBoxStartAt.isChecked();
- if (radioLinkToEpisode.isChecked()) {
+ boolean includePlaybackPosition = viewBinding.sharePositionCheckbox.isChecked();
+ int position;
+ if (viewBinding.shareSocialRadio.isChecked()) {
ShareUtils.shareFeedItemLinkWithDownloadLink(ctx, item, includePlaybackPosition);
- } else if (radioMediaFile.isChecked()) {
+ position = 1;
+ } else if (viewBinding.shareMediaReceiverRadio.isChecked()) {
+ ShareUtils.shareMediaDownloadLink(ctx, item.getMedia());
+ position = 2;
+ } else if (viewBinding.shareMediaFileRadio.isChecked()) {
ShareUtils.shareFeedItemFile(ctx, item.getMedia());
+ position = 3;
} else {
throw new IllegalStateException("Unknown share method");
}
- prefs.edit().putBoolean(PREF_SHARE_EPISODE_START_AT, includePlaybackPosition).apply();
+ prefs.edit()
+ .putBoolean(PREF_SHARE_EPISODE_START_AT, includePlaybackPosition)
+ .putInt(PREF_SHARE_EPISODE_TYPE, position)
+ .apply();
}).setNegativeButton(R.string.cancel_label, (dialog, id) -> dialog.dismiss());
return builder.create();
@@ -83,18 +83,22 @@ public class ShareDialog extends DialogFragment {
private void setupOptions() {
final boolean hasMedia = item.getMedia() != null;
-
boolean downloaded = hasMedia && item.getMedia().isDownloaded();
- radioMediaFile.setVisibility(downloaded ? View.VISIBLE : View.GONE);
+ viewBinding.shareMediaFileRadio.setVisibility(downloaded ? View.VISIBLE : View.GONE);
boolean hasDownloadUrl = hasMedia && item.getMedia().getDownload_url() != null;
- if (!ShareUtils.hasLinkToShare(item) && !hasDownloadUrl) {
- radioLinkToEpisode.setVisibility(View.GONE);
+ if (!hasDownloadUrl) {
+ viewBinding.shareMediaReceiverRadio.setVisibility(View.GONE);
}
-
- radioMediaFile.setChecked(false);
+ int type = prefs.getInt(PREF_SHARE_EPISODE_TYPE, 1);
+ if ((type == 2 && !hasDownloadUrl) || (type == 3 && !downloaded)) {
+ type = 1;
+ }
+ viewBinding.shareSocialRadio.setChecked(type == 1);
+ viewBinding.shareMediaReceiverRadio.setChecked(type == 2);
+ viewBinding.shareMediaFileRadio.setChecked(type == 3);
boolean switchIsChecked = prefs.getBoolean(PREF_SHARE_EPISODE_START_AT, false);
- checkBoxStartAt.setChecked(switchIsChecked);
+ viewBinding.sharePositionCheckbox.setChecked(switchIsChecked);
}
}
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/FeedInfoFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/FeedInfoFragment.java
index d396a3cd4..f070baebf 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/FeedInfoFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/FeedInfoFragment.java
@@ -124,7 +124,7 @@ public class FeedInfoFragment extends Fragment implements Toolbar.OnMenuItemClic
protected void doTint(Context themedContext) {
toolbar.getMenu().findItem(R.id.visit_website_item)
.setIcon(AppCompatResources.getDrawable(themedContext, R.drawable.ic_web));
- toolbar.getMenu().findItem(R.id.share_parent)
+ toolbar.getMenu().findItem(R.id.share_item)
.setIcon(AppCompatResources.getDrawable(themedContext, R.drawable.ic_share));
}
};
@@ -261,13 +261,8 @@ public class FeedInfoFragment extends Fragment implements Toolbar.OnMenuItemClic
}
private void refreshToolbarState() {
- boolean shareLinkVisible = feed != null && feed.getLink() != null;
- boolean downloadUrlVisible = feed != null && !feed.isLocalFeed();
-
toolbar.getMenu().findItem(R.id.reconnect_local_folder).setVisible(feed != null && feed.isLocalFeed());
- toolbar.getMenu().findItem(R.id.share_download_url_item).setVisible(downloadUrlVisible);
- toolbar.getMenu().findItem(R.id.share_link_item).setVisible(shareLinkVisible);
- toolbar.getMenu().findItem(R.id.share_parent).setVisible(downloadUrlVisible || shareLinkVisible);
+ toolbar.getMenu().findItem(R.id.share_item).setVisible(feed != null && !feed.isLocalFeed());
toolbar.getMenu().findItem(R.id.visit_website_item).setVisible(feed != null && feed.getLink() != null
&& IntentUtils.isCallable(getContext(), new Intent(Intent.ACTION_VIEW, Uri.parse(feed.getLink()))));
}
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java
index fbba99663..111664262 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/FeedItemlistFragment.java
@@ -279,7 +279,6 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
if (feed == null) {
return;
}
- toolbar.getMenu().findItem(R.id.share_link_item).setVisible(feed.getLink() != null);
toolbar.getMenu().findItem(R.id.visit_website_item).setVisible(feed.getLink() != null);
isUpdatingFeed = MenuItemUtils.updateRefreshMenuItem(toolbar.getMenu(),
diff --git a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java
index f59be601c..3396040f9 100644
--- a/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java
+++ b/app/src/main/java/de/danoeh/antennapod/menuhandler/FeedMenuHandler.java
@@ -42,7 +42,6 @@ public class FeedMenuHandler {
menu.findItem(R.id.refresh_complete_item).setVisible(selectedFeed.isPaged());
if (StringUtils.isBlank(selectedFeed.getLink())) {
menu.findItem(R.id.visit_website_item).setVisible(false);
- menu.findItem(R.id.share_link_item).setVisible(false);
}
if (selectedFeed.isLocalFeed()) {
// hide complete submenu "Share..." as both sub menu items are not visible
@@ -80,10 +79,8 @@ public class FeedMenuHandler {
conDialog.createNewDialog().show();
} else if (itemId == R.id.visit_website_item) {
IntentUtils.openInBrowser(context, selectedFeed.getLink());
- } else if (itemId == R.id.share_link_item) {
- ShareUtils.shareFeedlink(context, selectedFeed);
- } else if (itemId == R.id.share_download_url_item) {
- ShareUtils.shareFeedDownloadLink(context, selectedFeed);
+ } else if (itemId == R.id.share_item) {
+ ShareUtils.shareFeedLink(context, selectedFeed);
} else {
return false;
}
diff --git a/app/src/main/res/layout/share_episode_dialog.xml b/app/src/main/res/layout/share_episode_dialog.xml
index d79854972..f03899671 100644
--- a/app/src/main/res/layout/share_episode_dialog.xml
+++ b/app/src/main/res/layout/share_episode_dialog.xml
@@ -11,16 +11,21 @@
android:id="@+id/share_dialog_radio_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_marginBottom="16dp"
android:orientation="vertical">
+
+
-
+ android:layout_height="1dp"
+ android:layout_marginVertical="8dp"
+ android:background="?android:attr/listDivider" />
diff --git a/app/src/main/res/menu/feedinfo.xml b/app/src/main/res/menu/feedinfo.xml
index 83ad079b4..254e1834b 100644
--- a/app/src/main/res/menu/feedinfo.xml
+++ b/app/src/main/res/menu/feedinfo.xml
@@ -8,22 +8,11 @@
android:title="@string/visit_website_label"
android:visible="true"/>
-
-
-
+ android:visible="true" />
-
+ android:title="@string/share_label">
-
-
-
-
+ android:title="@string/share_label" />
-
+ android:title="@string/share_label">
\ No newline at end of file
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 482243826..13f2af762 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
@@ -32,24 +32,26 @@ public class ShareUtils {
context.startActivity(intent);
}
- public static void shareFeedlink(Context context, Feed feed) {
- shareLink(context, feed.getTitle() + ": " + feed.getLink());
- }
-
- public static void shareFeedDownloadLink(Context context, Feed feed) {
- shareLink(context, feed.getTitle() + ": " + feed.getDownload_url());
- }
-
- private static String getItemShareText(FeedItem item) {
- return item.getFeed().getTitle() + ": " + item.getTitle();
+ public static void shareFeedLink(Context context, Feed feed) {
+ String text = feed.getTitle();
+ if (feed.getLink() != null) {
+ text += "\n" + feed.getLink();
+ }
+ text += "\n\n" + context.getResources().getString(R.string.share_rss_address_label)
+ + " " + feed.getDownload_url();
+ shareLink(context, text);
}
public static boolean hasLinkToShare(FeedItem item) {
return FeedItemUtil.getLinkWithFallback(item) != null;
}
+ public static void shareMediaDownloadLink(Context context, FeedMedia media) {
+ shareLink(context, media.getDownload_url());
+ }
+
public static void shareFeedItemLinkWithDownloadLink(Context context, FeedItem item, boolean withPosition) {
- String text = getItemShareText(item);
+ String text = item.getFeed().getTitle() + ": " + item.getTitle();
int pos = 0;
if (item.getMedia() != null && withPosition) {
text += "\n" + context.getResources().getString(R.string.share_starting_position_label) + ": ";
diff --git a/ui/i18n/src/main/res/values/strings.xml b/ui/i18n/src/main/res/values/strings.xml
index 88e5dc144..0073eebf5 100644
--- a/ui/i18n/src/main/res/values/strings.xml
+++ b/ui/i18n/src/main/res/values/strings.xml
@@ -167,10 +167,8 @@
Rename podcast
Remove podcast
Share
- Share…
Share File
- Website address
- Podcast feed URL
+ RSS address:
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 selected podcasts and ALL their 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.
@@ -777,10 +775,10 @@
Sure, let\'s do this!
- Include:
- Playback position
+ Include playback position
Episode webpage
- Link to episode
+ Social message
+ Media address
Media file
Starting from