Added support for "pcast"-protocol, start FeedViewActivity immediately when clicking on a link. closes #425
This commit is contained in:
parent
eb0f48d3c3
commit
dbff918e3a
|
@ -41,7 +41,8 @@
|
||||||
android:theme="@style/Theme.AntennaPod.Light">
|
android:theme="@style/Theme.AntennaPod.Light">
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="com.google.android.backup.api_key"
|
android:name="com.google.android.backup.api_key"
|
||||||
android:value="AEdPqrEAAAAI3a05VToCTlqBymJrbFGaKQMvF-bBAuLsOdavBA" />
|
android:value="AEdPqrEAAAAI3a05VToCTlqBymJrbFGaKQMvF-bBAuLsOdavBA"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.MainActivity"
|
android:name=".activity.MainActivity"
|
||||||
android:configChanges="keyboardHidden|orientation"
|
android:configChanges="keyboardHidden|orientation"
|
||||||
|
@ -51,54 +52,6 @@
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.VIEW"/>
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
|
||||||
<category android:name="android.intent.category.BROWSABLE"/>
|
|
||||||
|
|
||||||
<data android:scheme="http"/>
|
|
||||||
<data android:scheme="https"/>
|
|
||||||
<data android:host="*"/>
|
|
||||||
<data android:pathPattern=".*\\.xml"/>
|
|
||||||
<data android:pathPattern=".*\\.rss"/>
|
|
||||||
</intent-filter>
|
|
||||||
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.VIEW"/>
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
|
||||||
<category android:name="android.intent.category.BROWSABLE"/>
|
|
||||||
|
|
||||||
<data android:scheme="http"/>
|
|
||||||
<data android:scheme="https"/>
|
|
||||||
<data android:host="feeds.feedburner.com"/>
|
|
||||||
<data android:host="feedproxy.google.com"/>
|
|
||||||
<data android:host="feeds2.feedburner.com"/>
|
|
||||||
<data android:host="feedsproxy.google.com"/>
|
|
||||||
</intent-filter>
|
|
||||||
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.VIEW"/>
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
|
||||||
<category android:name="android.intent.category.BROWSABLE"/>
|
|
||||||
|
|
||||||
<data android:scheme="http"/>
|
|
||||||
<data android:scheme="https"/>
|
|
||||||
<data android:mimeType="text/xml"/>
|
|
||||||
<data android:mimeType="application/rss+xml"/>
|
|
||||||
<data android:mimeType="application/atom+xml"/>
|
|
||||||
<data android:mimeType="application/xml"/>
|
|
||||||
</intent-filter>
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.SEND"/>
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
|
||||||
|
|
||||||
<data android:mimeType="text/plain"/>
|
|
||||||
</intent-filter>
|
|
||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.AudioplayerActivity"
|
android:name=".activity.AudioplayerActivity"
|
||||||
|
@ -274,13 +227,86 @@
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value="de.danoeh.antennapod.activity.PreferenceActivity"/>
|
android:value="de.danoeh.antennapod.activity.PreferenceActivity"/>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.PARENT_ACTIVITY"
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
android:value="de.danoeh.antennapod.activity.PreferenceActivity"/>
|
android:value="de.danoeh.antennapod.activity.PreferenceActivity"/>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.DefaultOnlineFeedViewActivity"
|
android:name=".activity.DefaultOnlineFeedViewActivity"
|
||||||
android:configChanges="orientation"/>
|
android:configChanges="orientation">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.PARENT_ACTIVITY"
|
||||||
|
android:value="de.danoeh.antennapod.activity.MainActivity"/>
|
||||||
|
|
||||||
|
<!-- URLs ending with '.xml' or '.rss' -->
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
<category android:name="android.intent.category.BROWSABLE"/>
|
||||||
|
|
||||||
|
<data android:scheme="http"/>
|
||||||
|
<data android:scheme="https"/>
|
||||||
|
<data android:host="*"/>
|
||||||
|
<data android:pathPattern=".*\\.xml"/>
|
||||||
|
<data android:pathPattern=".*\\.rss"/>
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
<!-- Feedburner URLs -->
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
<category android:name="android.intent.category.BROWSABLE"/>
|
||||||
|
|
||||||
|
<data android:scheme="http"/>
|
||||||
|
<data android:scheme="https"/>
|
||||||
|
<data android:host="feeds.feedburner.com"/>
|
||||||
|
<data android:host="feedproxy.google.com"/>
|
||||||
|
<data android:host="feeds2.feedburner.com"/>
|
||||||
|
<data android:host="feedsproxy.google.com"/>
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
<!-- Files with mimeType rss/xml/atom -->
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
<category android:name="android.intent.category.BROWSABLE"/>
|
||||||
|
|
||||||
|
<data android:scheme="http"/>
|
||||||
|
<data android:scheme="https"/>
|
||||||
|
<data android:mimeType="text/xml"/>
|
||||||
|
<data android:mimeType="application/rss+xml"/>
|
||||||
|
<data android:mimeType="application/atom+xml"/>
|
||||||
|
<data android:mimeType="application/xml"/>
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
<!-- Podcast protocols -->
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW"/>
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
<category android:name="android.intent.category.BROWSABLE"/>
|
||||||
|
|
||||||
|
<data android:scheme="pcast"/>
|
||||||
|
<data android:scheme="feed"/>
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.SEND"/>
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.DEFAULT"/>
|
||||||
|
|
||||||
|
<data android:mimeType="text/plain"/>
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.gpoddernet.GpodnetAuthenticationActivity"
|
android:name=".activity.gpoddernet.GpodnetAuthenticationActivity"
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package de.danoeh.antennapod.activity;
|
package de.danoeh.antennapod.activity;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.support.v4.app.NavUtils;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -44,7 +46,12 @@ public class DefaultOnlineFeedViewActivity extends OnlineFeedViewActivity {
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
switch (item.getItemId()) {
|
switch (item.getItemId()) {
|
||||||
case android.R.id.home:
|
case android.R.id.home:
|
||||||
finish();
|
Intent destIntent = new Intent(this, MainActivity.class);
|
||||||
|
if (NavUtils.shouldUpRecreateTask(this, destIntent)) {
|
||||||
|
startActivity(destIntent);
|
||||||
|
} else {
|
||||||
|
NavUtils.navigateUpFromSameTask(this);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
|
|
|
@ -28,7 +28,6 @@ import de.danoeh.antennapod.fragment.*;
|
||||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||||
import de.danoeh.antennapod.storage.DBReader;
|
import de.danoeh.antennapod.storage.DBReader;
|
||||||
import de.danoeh.antennapod.util.StorageUtils;
|
import de.danoeh.antennapod.util.StorageUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -280,18 +279,7 @@ public class MainActivity extends ActionBarActivity {
|
||||||
EventDistributor.getInstance().register(contentUpdate);
|
EventDistributor.getInstance().register(contentUpdate);
|
||||||
|
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
if (StringUtils.equals(intent.getAction(), Intent.ACTION_SEND)
|
if (feeds != null && intent.hasExtra(EXTRA_NAV_INDEX) && intent.hasExtra(EXTRA_NAV_TYPE)) {
|
||||||
|| StringUtils.equals(intent.getAction(), Intent.ACTION_VIEW)) {
|
|
||||||
String extra = (StringUtils.equals(intent.getAction(), Intent.ACTION_SEND))
|
|
||||||
? intent.getStringExtra(Intent.EXTRA_TEXT) : intent.getDataString();
|
|
||||||
if (extra != null) {
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putString(AddFeedFragment.ARG_FEED_URL, extra);
|
|
||||||
loadFragment(NavListAdapter.VIEW_TYPE_NAV, POS_ADD, args);
|
|
||||||
selectedNavListIndex = POS_ADD;
|
|
||||||
navAdapter.notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
} else if (feeds != null && intent.hasExtra(EXTRA_NAV_INDEX) && intent.hasExtra(EXTRA_NAV_TYPE)) {
|
|
||||||
handleNavIntent();
|
handleNavIntent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.app.Dialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.DialogInterface.OnCancelListener;
|
import android.content.DialogInterface.OnCancelListener;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.app.ActionBarActivity;
|
import android.support.v7.app.ActionBarActivity;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -27,6 +28,7 @@ import de.danoeh.antennapod.util.DownloadError;
|
||||||
import de.danoeh.antennapod.util.FileNameGenerator;
|
import de.danoeh.antennapod.util.FileNameGenerator;
|
||||||
import de.danoeh.antennapod.util.StorageUtils;
|
import de.danoeh.antennapod.util.StorageUtils;
|
||||||
import de.danoeh.antennapod.util.URLChecker;
|
import de.danoeh.antennapod.util.URLChecker;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
@ -46,7 +48,9 @@ public abstract class OnlineFeedViewActivity extends ActionBarActivity {
|
||||||
private static final String TAG = "OnlineFeedViewActivity";
|
private static final String TAG = "OnlineFeedViewActivity";
|
||||||
public static final String ARG_FEEDURL = "arg.feedurl";
|
public static final String ARG_FEEDURL = "arg.feedurl";
|
||||||
|
|
||||||
/** Optional argument: specify a title for the actionbar. */
|
/**
|
||||||
|
* Optional argument: specify a title for the actionbar.
|
||||||
|
*/
|
||||||
public static final String ARG_TITLE = "title";
|
public static final String ARG_TITLE = "title";
|
||||||
|
|
||||||
public static final int RESULT_ERROR = 2;
|
public static final int RESULT_ERROR = 2;
|
||||||
|
@ -64,11 +68,21 @@ public abstract class OnlineFeedViewActivity extends ActionBarActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
StorageUtils.checkStorageAvailability(this);
|
StorageUtils.checkStorageAvailability(this);
|
||||||
final String feedUrl = getIntent().getStringExtra(ARG_FEEDURL);
|
|
||||||
if (feedUrl == null) {
|
final String feedUrl;
|
||||||
|
if (getIntent().hasExtra(ARG_FEEDURL)) {
|
||||||
|
feedUrl = getIntent().getStringExtra(ARG_FEEDURL);
|
||||||
|
} else if (StringUtils.equals(getIntent().getAction(), Intent.ACTION_SEND)
|
||||||
|
|| StringUtils.equals(getIntent().getAction(), Intent.ACTION_VIEW)) {
|
||||||
|
feedUrl = (StringUtils.equals(getIntent().getAction(), Intent.ACTION_SEND))
|
||||||
|
? getIntent().getStringExtra(Intent.EXTRA_TEXT) : getIntent().getDataString();
|
||||||
|
|
||||||
|
getSupportActionBar().setTitle(R.string.add_new_feed_label);
|
||||||
|
} else {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Activity must be started with feedurl argument!");
|
"Activity must be started with feedurl argument!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BuildConfig.DEBUG)
|
if (BuildConfig.DEBUG)
|
||||||
Log.d(TAG, "Activity was started with url " + feedUrl);
|
Log.d(TAG, "Activity was started with url " + feedUrl);
|
||||||
setLoadingLayout();
|
setLoadingLayout();
|
||||||
|
@ -244,7 +258,7 @@ public abstract class OnlineFeedViewActivity extends ActionBarActivity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can be used to load data asynchronously.
|
* Can be used to load data asynchronously.
|
||||||
* */
|
*/
|
||||||
protected void loadData() {
|
protected void loadData() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -271,7 +285,8 @@ public abstract class OnlineFeedViewActivity extends ActionBarActivity {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
dialog.cancel();
|
dialog.cancel();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
);
|
||||||
builder.setOnCancelListener(new OnCancelListener() {
|
builder.setOnCancelListener(new OnCancelListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCancel(DialogInterface dialog) {
|
public void onCancel(DialogInterface dialog) {
|
||||||
|
|
|
@ -3,25 +3,36 @@ package de.danoeh.antennapod.util;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import de.danoeh.antennapod.BuildConfig;
|
import de.danoeh.antennapod.BuildConfig;
|
||||||
|
|
||||||
/** Provides methods for checking and editing a URL.*/
|
/**
|
||||||
|
* Provides methods for checking and editing a URL.
|
||||||
|
*/
|
||||||
public final class URLChecker {
|
public final class URLChecker {
|
||||||
|
|
||||||
/**Class shall not be instantiated.*/
|
/**
|
||||||
|
* Class shall not be instantiated.
|
||||||
|
*/
|
||||||
private URLChecker() {
|
private URLChecker() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Logging tag.*/
|
/**
|
||||||
|
* Logging tag.
|
||||||
|
*/
|
||||||
private static final String TAG = "URLChecker";
|
private static final String TAG = "URLChecker";
|
||||||
|
|
||||||
/** Checks if URL is valid and modifies it if necessary.
|
/**
|
||||||
* @param url The url which is going to be prepared
|
* Checks if URL is valid and modifies it if necessary.
|
||||||
* @return The prepared url
|
*
|
||||||
* */
|
* @param url The url which is going to be prepared
|
||||||
|
* @return The prepared url
|
||||||
|
*/
|
||||||
public static String prepareURL(String url) {
|
public static String prepareURL(String url) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
if (url.startsWith("feed://")) {
|
if (url.startsWith("feed://")) {
|
||||||
if (BuildConfig.DEBUG) Log.d(TAG, "Replacing feed:// with http://");
|
if (BuildConfig.DEBUG) Log.d(TAG, "Replacing feed:// with http://");
|
||||||
url = url.replace("feed://", "http://");
|
url = url.replaceFirst("feed://", "http://");
|
||||||
|
} else if (url.startsWith("pcast://")) {
|
||||||
|
if (BuildConfig.DEBUG) Log.d(TAG, "Replacing pcast:// with http://");
|
||||||
|
url = url.replaceFirst("pcast://", "http://");
|
||||||
} else if (!(url.startsWith("http://") || url.startsWith("https://"))) {
|
} else if (!(url.startsWith("http://") || url.startsWith("https://"))) {
|
||||||
if (BuildConfig.DEBUG) Log.d(TAG, "Adding http:// at the beginning of the URL");
|
if (BuildConfig.DEBUG) Log.d(TAG, "Adding http:// at the beginning of the URL");
|
||||||
builder.append("http://");
|
builder.append("http://");
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package instrumentationTest.de.test.antennapod.util;
|
||||||
|
|
||||||
|
import android.test.AndroidTestCase;
|
||||||
|
import de.danoeh.antennapod.util.URLChecker;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test class for URLChecker
|
||||||
|
*/
|
||||||
|
public class URLCheckerTest extends AndroidTestCase {
|
||||||
|
|
||||||
|
public void testCorrectURLHttp() {
|
||||||
|
final String in = "http://example.com";
|
||||||
|
final String out = URLChecker.prepareURL(in);
|
||||||
|
assertEquals(in, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCorrectURLHttps() {
|
||||||
|
final String in = "https://example.com";
|
||||||
|
final String out = URLChecker.prepareURL(in);
|
||||||
|
assertEquals(in, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMissingProtocol() {
|
||||||
|
final String in = "example.com";
|
||||||
|
final String out = URLChecker.prepareURL(in);
|
||||||
|
assertEquals("http://example.com", out);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testFeedProtocol() {
|
||||||
|
final String in = "feed://example.com";
|
||||||
|
final String out = URLChecker.prepareURL(in);
|
||||||
|
assertEquals("http://example.com", out);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testPcastProtocol() {
|
||||||
|
final String in = "pcast://example.com";
|
||||||
|
final String out = URLChecker.prepareURL(in);
|
||||||
|
assertEquals("http://example.com", out);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue