Cleanup
This commit is contained in:
parent
8ecbe95e16
commit
639c586a80
|
@ -16,35 +16,33 @@ import de.danoeh.antennapod.core.R;
|
||||||
import de.danoeh.antennapod.core.export.opml.OpmlElement;
|
import de.danoeh.antennapod.core.export.opml.OpmlElement;
|
||||||
import de.danoeh.antennapod.core.export.opml.OpmlReader;
|
import de.danoeh.antennapod.core.export.opml.OpmlReader;
|
||||||
|
|
||||||
public class OpmlImportWorker extends
|
public class OpmlImportWorker extends AsyncTask<Void, Void, ArrayList<OpmlElement>> {
|
||||||
AsyncTask<Void, Void, ArrayList<OpmlElement>> {
|
|
||||||
private static final String TAG = "OpmlImportWorker";
|
private static final String TAG = "OpmlImportWorker";
|
||||||
|
|
||||||
private final Context context;
|
private final Context context;
|
||||||
private Exception exception;
|
private Exception exception;
|
||||||
|
|
||||||
private ProgressDialog progDialog;
|
private ProgressDialog progDialog;
|
||||||
|
|
||||||
private final Reader mReader;
|
private final Reader reader;
|
||||||
|
|
||||||
public OpmlImportWorker(Context context, Reader reader) {
|
public OpmlImportWorker(Context context, Reader reader) {
|
||||||
super();
|
super();
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.mReader=reader;
|
this.reader = reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ArrayList<OpmlElement> doInBackground(Void... params) {
|
protected ArrayList<OpmlElement> doInBackground(Void... params) {
|
||||||
Log.d(TAG, "Starting background work");
|
Log.d(TAG, "Starting background work");
|
||||||
|
|
||||||
if (mReader==null) {
|
if (reader == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
OpmlReader opmlReader = new OpmlReader();
|
OpmlReader opmlReader = new OpmlReader();
|
||||||
try {
|
try {
|
||||||
ArrayList<OpmlElement> result = opmlReader.readDocument(mReader);
|
ArrayList<OpmlElement> result = opmlReader.readDocument(reader);
|
||||||
mReader.close();
|
reader.close();
|
||||||
return result;
|
return result;
|
||||||
} catch (XmlPullParserException e) {
|
} catch (XmlPullParserException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -60,9 +58,9 @@ public class OpmlImportWorker extends
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(ArrayList<OpmlElement> result) {
|
protected void onPostExecute(ArrayList<OpmlElement> result) {
|
||||||
if (mReader != null) {
|
if (reader != null) {
|
||||||
try {
|
try {
|
||||||
mReader.close();
|
reader.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -82,16 +80,12 @@ public class OpmlImportWorker extends
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
progDialog = new ProgressDialog(context);
|
progDialog = new ProgressDialog(context);
|
||||||
progDialog.setMessage(context.getString(R.string.reading_opml_label));
|
progDialog.setMessage(context.getString(R.string.please_wait));
|
||||||
progDialog.setIndeterminate(true);
|
progDialog.setIndeterminate(true);
|
||||||
progDialog.setCancelable(false);
|
progDialog.setCancelable(false);
|
||||||
progDialog.show();
|
progDialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean wasSuccessful() {
|
|
||||||
return exception != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void executeAsync() {
|
public void executeAsync() {
|
||||||
executeOnExecutor(THREAD_POOL_EXECUTOR);
|
executeOnExecutor(THREAD_POOL_EXECUTOR);
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,7 +151,7 @@ public class ImportExportPreferencesFragment extends PreferenceFragmentCompat {
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(() -> {
|
.subscribe(() -> {
|
||||||
Snackbar.make(getView(), R.string.export_ok, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(getView(), R.string.export_success_title, Snackbar.LENGTH_LONG).show();
|
||||||
progressDialog.dismiss();
|
progressDialog.dismiss();
|
||||||
}, this::showExportErrorDialog);
|
}, this::showExportErrorDialog);
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ public class ImportExportPreferencesFragment extends PreferenceFragmentCompat {
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(() -> {
|
.subscribe(() -> {
|
||||||
Snackbar.make(getView(), R.string.export_ok, Snackbar.LENGTH_LONG).show();
|
Snackbar.make(getView(), R.string.export_success_title, Snackbar.LENGTH_LONG).show();
|
||||||
progressDialog.dismiss();
|
progressDialog.dismiss();
|
||||||
}, this::showExportErrorDialog);
|
}, this::showExportErrorDialog);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,17 +3,6 @@
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:search="http://schemas.android.com/apk/com.bytehamster.lib.preferencesearch">
|
xmlns:search="http://schemas.android.com/apk/com.bytehamster.lib.preferencesearch">
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/opml">
|
|
||||||
<Preference
|
|
||||||
android:key="prefOpmlExport"
|
|
||||||
android:title="@string/opml_export_label"
|
|
||||||
android:summary="@string/opml_export_summary"/>
|
|
||||||
<Preference
|
|
||||||
android:key="prefOpmlImport"
|
|
||||||
android:title="@string/opml_import_label"
|
|
||||||
android:summary="@string/opml_import_summary"/>
|
|
||||||
</PreferenceCategory>
|
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/database">
|
<PreferenceCategory android:title="@string/database">
|
||||||
<Preference
|
<Preference
|
||||||
android:key="prefDatabaseExport"
|
android:key="prefDatabaseExport"
|
||||||
|
@ -27,6 +16,17 @@
|
||||||
android:summary="@string/database_import_summary"/>
|
android:summary="@string/database_import_summary"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory android:title="@string/opml">
|
||||||
|
<Preference
|
||||||
|
android:key="prefOpmlExport"
|
||||||
|
android:title="@string/opml_export_label"
|
||||||
|
android:summary="@string/opml_export_summary"/>
|
||||||
|
<Preference
|
||||||
|
android:key="prefOpmlImport"
|
||||||
|
android:title="@string/opml_import_label"
|
||||||
|
android:summary="@string/opml_import_summary"/>
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/html">
|
<PreferenceCategory android:title="@string/html">
|
||||||
<Preference
|
<Preference
|
||||||
android:key="prefHtmlExport"
|
android:key="prefHtmlExport"
|
||||||
|
|
|
@ -558,7 +558,6 @@
|
||||||
<string name="opml_import_explanation_1">Choose a specific file path from the local filesystem.</string>
|
<string name="opml_import_explanation_1">Choose a specific file path from the local filesystem.</string>
|
||||||
<string name="opml_import_explanation_3">Many applications like Google Mail, Dropbox, Google Drive and most file managers can <i>open</i> OPML files <i>with</i> AntennaPod.</string>
|
<string name="opml_import_explanation_3">Many applications like Google Mail, Dropbox, Google Drive and most file managers can <i>open</i> OPML files <i>with</i> AntennaPod.</string>
|
||||||
<string name="opml_import_label">OPML Import</string>
|
<string name="opml_import_label">OPML Import</string>
|
||||||
<string name="reading_opml_label">Reading OPML file</string>
|
|
||||||
<string name="opml_reader_error">An error has occurred while reading the OPML document:</string>
|
<string name="opml_reader_error">An error has occurred while reading the OPML document:</string>
|
||||||
<string name="opml_import_error_no_file">No file selected!</string>
|
<string name="opml_import_error_no_file">No file selected!</string>
|
||||||
<string name="select_all_label">Select all</string>
|
<string name="select_all_label">Select all</string>
|
||||||
|
@ -573,12 +572,7 @@
|
||||||
<string name="export_success_title">Export successful</string>
|
<string name="export_success_title">Export successful</string>
|
||||||
<string name="export_success_sum">The exported file was written to:\n\n%1$s</string>
|
<string name="export_success_sum">The exported file was written to:\n\n%1$s</string>
|
||||||
<string name="opml_import_ask_read_permission">Access to external storage is required to read the OPML file</string>
|
<string name="opml_import_ask_read_permission">Access to external storage is required to read the OPML file</string>
|
||||||
<string name="import_export">Database import/export</string>
|
|
||||||
<string name="import_export_warning">This experimental function can be used to transfer your subscriptions and played episodes to another device.\n\nExported databases can only be imported when using the same version of AntennaPod. Otherwise, this function will lead to unexpected behavior.\n\nAfter importing, episodes might be displayed as downloaded even though they are not. Just press the play button of the episodes to make AntennaPod detect this.</string>
|
|
||||||
<string name="label_import">Import</string>
|
|
||||||
<string name="label_export">Export</string>
|
|
||||||
<string name="import_select_file">Select file to import</string>
|
<string name="import_select_file">Select file to import</string>
|
||||||
<string name="export_ok">Export successful.</string>
|
|
||||||
<string name="import_ok">Import successful.\n\nPlease press OK to restart AntennaPod</string>
|
<string name="import_ok">Import successful.\n\nPlease press OK to restart AntennaPod</string>
|
||||||
|
|
||||||
<!-- Sleep timer -->
|
<!-- Sleep timer -->
|
||||||
|
|
Loading…
Reference in New Issue