* Less picky about the mime type's we accept.
* Handling content and files the same way * Improved support for sharing files in fixes AntennaPod/AntennaPod#827
This commit is contained in:
parent
bafdc86ca0
commit
dfcfe15dd0
|
@ -155,21 +155,14 @@
|
|||
|
||||
<data
|
||||
android:host="*"
|
||||
android:mimeType="*/*"
|
||||
android:pathPattern=".*\\.opml"
|
||||
android:scheme="file"/>
|
||||
</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"/>
|
||||
|
||||
android:scheme="file"
|
||||
android:mimeType="*/*"/>
|
||||
<data
|
||||
android:host="*"
|
||||
android:pathPattern=".*\\.opml"
|
||||
android:scheme="file"
|
||||
android:mimeType="text/*"/>
|
||||
android:scheme="content"
|
||||
android:mimeType="*/*"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity
|
||||
|
|
|
@ -1,17 +1,26 @@
|
|||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.util.LangUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.net.URL;
|
||||
|
||||
/** Lets the user start the OPML-import process. */
|
||||
public class OpmlImportFromIntentActivity extends OpmlImportBaseActivity {
|
||||
|
||||
private static final String TAG = "OpmlImportFromIntentAct";
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(UserPreferences.getTheme());
|
||||
|
@ -20,10 +29,10 @@ public class OpmlImportFromIntentActivity extends OpmlImportBaseActivity {
|
|||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
try {
|
||||
URL mOpmlURL = new URL(getIntent().getData().toString());
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(mOpmlURL.openStream(),
|
||||
LangUtils.UTF_8));
|
||||
startImport(in);
|
||||
Uri uri = getIntent().getData();
|
||||
|
||||
Reader mReader = new InputStreamReader(getContentResolver().openInputStream(uri), LangUtils.UTF_8);
|
||||
startImport(mReader);
|
||||
} catch (Exception e) {
|
||||
new AlertDialog.Builder(this).setMessage("Cannot open XML - Reason: " + e.getMessage()).show();
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ import de.danoeh.antennapod.core.util.StorageUtils;
|
|||
*/
|
||||
public class OpmlImportFromPathActivity extends OpmlImportBaseActivity {
|
||||
|
||||
private static final String TAG = "OpmlImportFromPathActivity";
|
||||
private static final String TAG = "OpmlImportFromPathAct";
|
||||
|
||||
private static final int CHOOSE_OPML_FILE = 1;
|
||||
|
||||
|
@ -174,17 +174,12 @@ public class OpmlImportFromPathActivity extends OpmlImportBaseActivity {
|
|||
if (resultCode == RESULT_OK && requestCode == CHOOSE_OPML_FILE) {
|
||||
Uri uri = data.getData();
|
||||
|
||||
if ("content".equals(uri.getScheme())) {
|
||||
try {
|
||||
Reader mReader = new InputStreamReader(getContentResolver().openInputStream(uri), LangUtils.UTF_8);
|
||||
startImport(mReader);
|
||||
} catch (FileNotFoundException e) {
|
||||
Log.d(TAG, "File not found");
|
||||
}
|
||||
} else {
|
||||
String filename = uri.getPath();
|
||||
startImport(new File(filename));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue