summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorTacoTheDank <SkytkRSfan3895@gmail.com>2022-02-05 21:15:33 -0500
committerTacoTheDank <SkytkRSfan3895@gmail.com>2022-02-05 21:15:33 -0500
commitefd3ceab1872c4bbc6e8dfa128835ef46c636091 (patch)
treebbbc03bb1323aeefcd7eed17b06950bd60ecc384 /app
parentd953ad0869a74ed84f837aa30272d96cd88a857d (diff)
downloadantennapod-efd3ceab1872c4bbc6e8dfa128835ef46c636091.zip
Fix clipboard deprecation in AddFeedFragment
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java10
1 files changed, 7 insertions, 3 deletions
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 120d1def8..ee56bb9f9 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/AddFeedFragment.java
@@ -1,6 +1,7 @@
package de.danoeh.antennapod.fragment;
import android.content.ActivityNotFoundException;
+import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
@@ -140,9 +141,12 @@ public class AddFeedFragment extends Fragment {
alertViewBinding.urlEditText.setHint(R.string.add_podcast_by_url_hint);
ClipboardManager clipboard = (ClipboardManager) getContext().getSystemService(Context.CLIPBOARD_SERVICE);
- String clipboardContent = clipboard.getText() != null ? clipboard.getText().toString() : "";
- if (clipboardContent.trim().startsWith("http")) {
- alertViewBinding.urlEditText.setText(clipboardContent.trim());
+ final ClipData clipData = clipboard.getPrimaryClip();
+ if (clipData != null && clipData.getItemCount() > 0 && clipData.getItemAt(0).getText() != null) {
+ final String clipboardContent = clipData.getItemAt(0).getText().toString();
+ if (clipboardContent.trim().startsWith("http")) {
+ alertViewBinding.urlEditText.setText(clipboardContent.trim());
+ }
}
builder.setView(alertViewBinding.getRoot());
builder.setPositiveButton(R.string.confirm_label,