diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2023-12-31 11:09:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-31 11:09:12 +0100 |
commit | 8c7d567a0cb1e6f52ed1256aff2326da58199fe9 (patch) | |
tree | 91413d56d8dcb7195fcbc14e30a23ba969ee9a97 /app/src/main | |
parent | 28edb71fd61bf65677e039130011c6fd332a9dd1 (diff) | |
download | AntennaPod-8c7d567a0cb1e6f52ed1256aff2326da58199fe9.zip |
If feed url was typed manually, show edit url button on error (#6833)
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java | 28 | ||||
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java | 1 |
2 files changed, 27 insertions, 2 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java index c5d656aa0..031117170 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/OnlineFeedViewActivity.java @@ -36,6 +36,7 @@ import de.danoeh.antennapod.core.feed.FeedUrlNotFoundException; import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.core.service.playback.PlaybackServiceInterface; import de.danoeh.antennapod.core.util.DownloadErrorLabel; +import de.danoeh.antennapod.databinding.EditTextDialogBinding; import de.danoeh.antennapod.databinding.OnlinefeedviewHeaderBinding; import de.danoeh.antennapod.event.EpisodeDownloadEvent; import de.danoeh.antennapod.event.FeedListUpdateEvent; @@ -95,7 +96,7 @@ import java.util.Map; public class OnlineFeedViewActivity extends AppCompatActivity { public static final String ARG_FEEDURL = "arg.feedurl"; - // Optional argument: specify a title for the actionbar. + public static final String ARG_WAS_MANUAL_URL = "manual_url"; private static final int RESULT_ERROR = 2; private static final String TAG = "OnlineFeedViewActivity"; private static final String PREFS = "OnlineFeedViewActivityPreferences"; @@ -598,7 +599,10 @@ public class OnlineFeedViewActivity extends AppCompatActivity { builder.setMessage(R.string.download_error_error_unknown); } builder.setPositiveButton(android.R.string.ok, (dialog, which) -> dialog.cancel()); - builder.setOnDismissListener(dialog -> { + if (getIntent().getBooleanExtra(ARG_WAS_MANUAL_URL, false)) { + builder.setNeutralButton(R.string.edit_url_menu, (dialog, which) -> editUrl()); + } + builder.setOnCancelListener(dialog -> { setResult(RESULT_ERROR); finish(); }); @@ -609,6 +613,26 @@ public class OnlineFeedViewActivity extends AppCompatActivity { } } + private void editUrl() { + MaterialAlertDialogBuilder builder = new MaterialAlertDialogBuilder(this); + builder.setTitle(R.string.edit_url_menu); + final EditTextDialogBinding dialogBinding = EditTextDialogBinding.inflate(getLayoutInflater()); + if (downloader != null) { + dialogBinding.urlEditText.setText(downloader.getDownloadRequest().getSource()); + } + builder.setView(dialogBinding.getRoot()); + builder.setPositiveButton(R.string.confirm_label, (dialog, which) -> { + setLoadingLayout(); + lookupUrlAndDownload(dialogBinding.urlEditText.getText().toString()); + }); + builder.setNegativeButton(R.string.cancel_label, (dialog1, which) -> dialog1.cancel()); + builder.setOnCancelListener(dialog1 -> { + setResult(RESULT_ERROR); + finish(); + }); + builder.show(); + } + @Subscribe(threadMode = ThreadMode.MAIN) public void playbackStateChanged(PlayerStatusEvent event) { boolean isPlayingPreview = diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java index 29be41727..20cdd2718 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java @@ -147,6 +147,7 @@ public class AddFeedFragment extends Fragment { private void addUrl(String url) { Intent intent = new Intent(getActivity(), OnlineFeedViewActivity.class); intent.putExtra(OnlineFeedViewActivity.ARG_FEEDURL, url); + intent.putExtra(OnlineFeedViewActivity.ARG_WAS_MANUAL_URL, true); startActivity(intent); } |