diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2022-04-22 20:11:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-22 20:11:37 +0200 |
commit | a01c24984e90434924efb1199a1f39a99cb2f226 (patch) | |
tree | 5a872463b76c39d32fc1e4b4c89e3dd8c06f6ae3 /app | |
parent | 1dd6636a6144722282ea88c3f1e213a77ea4172e (diff) | |
download | AntennaPod-a01c24984e90434924efb1199a1f39a99cb2f226.zip |
Restore episode sharing that only includes a media URL (#5835)
Diffstat (limited to 'app')
10 files changed, 57 insertions, 79 deletions
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,17 +11,22 @@ android:id="@+id/share_dialog_radio_group" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginBottom="16dp" android:orientation="vertical"> <RadioButton - android:id="@+id/share_link_to_episode_radio" + android:id="@+id/share_social_radio" android:layout_width="match_parent" android:layout_height="wrap_content" - android:text="@string/share_dialog_link_to_episode" + android:text="@string/share_dialog_for_social" android:checked="true" /> <RadioButton + android:id="@+id/share_media_receiver_radio" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/share_dialog_media_address" /> + + <RadioButton android:id="@+id/share_media_file_radio" android:layout_width="match_parent" android:layout_height="wrap_content" @@ -29,13 +34,14 @@ </RadioGroup> - <TextView + <View android:layout_width="match_parent" - android:layout_height="match_parent" - android:text="@string/share_dialog_include_label" /> + android:layout_height="1dp" + android:layout_marginVertical="8dp" + android:background="?android:attr/listDivider" /> <CheckBox - android:id="@+id/share_start_at_timer_dialog" + android:id="@+id/share_position_checkbox" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/share_playback_position_dialog_label" /> 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"/> <item - android:id="@+id/share_parent" + android:id="@+id/share_item" custom:showAsAction="ifRoom" - android:title="@string/share_label_with_ellipses" + android:title="@string/share_label" android:icon="@drawable/ic_share" - android:visible="true"> - <menu android:id="@+id/share_submenu"> - <item - android:id="@+id/share_link_item" - custom:showAsAction="collapseActionView" - android:title="@string/share_website_url_label"/> - <item - android:id="@+id/share_download_url_item" - custom:showAsAction="collapseActionView" - android:title="@string/share_feed_url_label"/> - </menu> - </item> + android:visible="true" /> <item android:id="@+id/reconnect_local_folder" custom:showAsAction="collapseActionView" diff --git a/app/src/main/res/menu/feeditem_options.xml b/app/src/main/res/menu/feeditem_options.xml index 70400fe55..bcb2a59b8 100644 --- a/app/src/main/res/menu/feeditem_options.xml +++ b/app/src/main/res/menu/feeditem_options.xml @@ -59,7 +59,7 @@ <item android:id="@+id/share_item" android:menuCategory="container" - android:title="@string/share_label_with_ellipses"> + android:title="@string/share_label"> </item> <item diff --git a/app/src/main/res/menu/feedlist.xml b/app/src/main/res/menu/feedlist.xml index 3c66ec4ba..4c5050f82 100644 --- a/app/src/main/res/menu/feedlist.xml +++ b/app/src/main/res/menu/feedlist.xml @@ -49,19 +49,7 @@ android:id="@+id/share_item" android:menuCategory="container" custom:showAsAction="never" - android:title="@string/share_label_with_ellipses"> - <menu> - <item - android:id="@+id/share_link_item" - android:title="@string/share_website_url_label"> - </item> - <item - android:id="@+id/share_download_url_item" - android:title="@string/share_feed_url_label"> - </item> - </menu> - </item> - + android:title="@string/share_label" /> <item android:id="@+id/rename_item" diff --git a/app/src/main/res/menu/mediaplayer.xml b/app/src/main/res/menu/mediaplayer.xml index e25872ade..7c66a4d10 100644 --- a/app/src/main/res/menu/mediaplayer.xml +++ b/app/src/main/res/menu/mediaplayer.xml @@ -62,6 +62,6 @@ android:id="@+id/share_item" android:menuCategory="container" custom:showAsAction="never" - android:title="@string/share_label_with_ellipses"> + android:title="@string/share_label"> </item> </menu>
\ No newline at end of file |