Fix crash when opening deeplink that does not have a url (#7466)
This commit is contained in:
parent
5c47fd2468
commit
c36cdafad6
|
@ -102,15 +102,11 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
|||
feedUrl = getIntent().getDataString();
|
||||
}
|
||||
|
||||
if (feedUrl == null) {
|
||||
if (feedUrl == null || UrlChecker.isDeeplinkWithoutUrl(feedUrl)) {
|
||||
Log.e(TAG, "feedUrl is null.");
|
||||
showNoPodcastFoundError();
|
||||
} else {
|
||||
Log.d(TAG, "Activity was started with url " + feedUrl);
|
||||
// Remove subscribeonandroid.com from feed URL in order to subscribe to the actual feed URL
|
||||
if (feedUrl.contains("subscribeonandroid.com")) {
|
||||
feedUrl = feedUrl.replaceFirst("((www.)?(subscribeonandroid.com/))", "");
|
||||
}
|
||||
if (savedInstanceState != null) {
|
||||
username = savedInstanceState.getString("username");
|
||||
password = savedInstanceState.getString("password");
|
||||
|
|
|
@ -62,6 +62,8 @@ public final class UrlChecker {
|
|||
} catch (UnsupportedEncodingException e) {
|
||||
return prepareUrl(query);
|
||||
}
|
||||
} else if (lowerCaseUrl.contains("subscribeonandroid.com")) {
|
||||
return prepareUrl(url.replaceFirst("((www.)?(subscribeonandroid.com/))", ""));
|
||||
} else if (!(lowerCaseUrl.startsWith("http://") || lowerCaseUrl.startsWith("https://"))) {
|
||||
Log.d(TAG, "Adding http:// at the beginning of the URL");
|
||||
return "http://" + url;
|
||||
|
@ -70,6 +72,11 @@ public final class UrlChecker {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean isDeeplinkWithoutUrl(String url) {
|
||||
return url.toLowerCase(Locale.ROOT).contains(AP_SUBSCRIBE_DEEPLINK)
|
||||
&& Uri.parse(url).getQueryParameter("url") == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if URL is valid and modifies it if necessary.
|
||||
* This method also handles protocol relative URLs.
|
||||
|
|
|
@ -317,7 +317,7 @@
|
|||
<string name="download_log_title_unknown">Unknown title</string>
|
||||
<string name="download_type_feed">Feed</string>
|
||||
<string name="download_type_media">Media file</string>
|
||||
<string name="null_value_podcast_error">No podcast was provided that could be shown.</string>
|
||||
<string name="null_value_podcast_error">The link you tapped does not contain a valid podcast URL. Please verify the link and try again, or search for the podcast manually.</string>
|
||||
<string name="no_feed_url_podcast_found_by_search">The suggested podcast did not have an RSS link, AntennaPod found a podcast that could match</string>
|
||||
<string name="authentication_notification_title">Authentication required</string>
|
||||
<string name="confirm_mobile_download_dialog_title">Confirm mobile download</string>
|
||||
|
|
Loading…
Reference in New Issue