Removed OPML import activity with only one button
This commit is contained in:
parent
639c586a80
commit
bb8a7a2ac0
|
@ -140,11 +140,6 @@
|
|||
|
||||
<activity android:name=".activity.StorageErrorActivity">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.OpmlImportFromPathActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
android:label="@string/opml_import_label">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".activity.OpmlImportFromIntentActivity"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
|
|
|
@ -1,111 +0,0 @@
|
|||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||
import de.danoeh.antennapod.core.util.StorageUtils;
|
||||
|
||||
/**
|
||||
* Lets the user start the OPML-import process from a path
|
||||
*/
|
||||
public class OpmlImportFromPathActivity extends OpmlImportBaseActivity {
|
||||
|
||||
private static final String TAG = "OpmlImportFromPathAct";
|
||||
|
||||
private static final int CHOOSE_OPML_FILE = 1;
|
||||
|
||||
private Intent intentGetContentAction;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
setTheme(UserPreferences.getTheme());
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
setContentView(R.layout.opml_import);
|
||||
|
||||
final TextView txtvHeaderExplanation = findViewById(R.id.txtvHeadingExplanation);
|
||||
final TextView txtvExplanation = findViewById(R.id.txtvExplanation);
|
||||
final TextView txtvHeaderExplanationOpenWith = findViewById(R.id.txtvHeadingExplanationOpenWith);
|
||||
|
||||
Button butChooseFilesystem = findViewById(R.id.butChooseFileFromFilesystem);
|
||||
butChooseFilesystem.setOnClickListener(v -> chooseFileFromExternal());
|
||||
|
||||
int nextOption = 1;
|
||||
String optionLabel = getString(R.string.opml_import_option);
|
||||
intentGetContentAction = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
intentGetContentAction.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intentGetContentAction.setType("*/*");
|
||||
|
||||
if (IntentUtils.isCallable(getApplicationContext(), intentGetContentAction)) {
|
||||
txtvHeaderExplanation.setText(String.format(optionLabel, nextOption));
|
||||
nextOption++;
|
||||
} else {
|
||||
txtvHeaderExplanation.setVisibility(View.GONE);
|
||||
txtvExplanation.setVisibility(View.GONE);
|
||||
findViewById(R.id.divider).setVisibility(View.GONE);
|
||||
butChooseFilesystem.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
txtvHeaderExplanationOpenWith.setText(String.format(optionLabel, nextOption));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
StorageUtils.checkStorageAvailability(this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
super.onCreateOptionsMenu(menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void chooseFileFromExternal() {
|
||||
try {
|
||||
startActivityForResult(intentGetContentAction, CHOOSE_OPML_FILE);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Log.e(TAG, "No activity found. Should never happen...");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the path of the file chosen with chooseFileToImport()
|
||||
*/
|
||||
@Override
|
||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (resultCode == RESULT_OK && requestCode == CHOOSE_OPML_FILE) {
|
||||
Uri uri = data.getData();
|
||||
if(uri != null && uri.toString().startsWith("/")) {
|
||||
uri = Uri.parse("file://" + uri.toString());
|
||||
}
|
||||
importUri(uri);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,11 @@
|
|||
package de.danoeh.antennapod.fragment;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -11,11 +15,18 @@ import android.view.ViewGroup;
|
|||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.activity.OnlineFeedViewActivity;
|
||||
import de.danoeh.antennapod.activity.OpmlImportFromPathActivity;
|
||||
import de.danoeh.antennapod.activity.OpmlImportFromIntentActivity;
|
||||
import de.danoeh.antennapod.core.export.html.HtmlWriter;
|
||||
import de.danoeh.antennapod.core.export.opml.OpmlWriter;
|
||||
import de.danoeh.antennapod.core.storage.DatabaseExporter;
|
||||
import de.danoeh.antennapod.fragment.gpodnet.GpodnetMainFragment;
|
||||
import io.reactivex.Completable;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
/**
|
||||
* Provides actions for adding new podcast subscriptions
|
||||
|
@ -28,6 +39,7 @@ public class AddFeedFragment extends Fragment {
|
|||
* Preset value for url text field.
|
||||
*/
|
||||
private static final String ARG_FEED_URL = "feedurl";
|
||||
private static final int REQUEST_CODE_CHOOSE_OPML_IMPORT_PATH = 1;
|
||||
|
||||
private EditText combinedFeedSearchBox;
|
||||
private MainActivity activity;
|
||||
|
@ -44,8 +56,16 @@ public class AddFeedFragment extends Fragment {
|
|||
setupSeachBox(root);
|
||||
|
||||
View butOpmlImport = root.findViewById(R.id.btn_opml_import);
|
||||
butOpmlImport.setOnClickListener(v -> startActivity(new Intent(getActivity(),
|
||||
OpmlImportFromPathActivity.class)));
|
||||
butOpmlImport.setOnClickListener(v -> {
|
||||
try {
|
||||
Intent intentGetContentAction = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
intentGetContentAction.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intentGetContentAction.setType("*/*");
|
||||
startActivityForResult(intentGetContentAction, REQUEST_CODE_CHOOSE_OPML_IMPORT_PATH);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Log.e(TAG, "No activity found. Should never happen...");
|
||||
}
|
||||
});
|
||||
root.findViewById(R.id.search_icon).setOnClickListener(view -> performSearch());
|
||||
return root;
|
||||
}
|
||||
|
@ -130,4 +150,18 @@ public class AddFeedFragment extends Fragment {
|
|||
// persist. mfietz thinks this causes the ActionBar to be invalidated
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (resultCode != Activity.RESULT_OK || data == null) {
|
||||
return;
|
||||
}
|
||||
Uri uri = data.getData();
|
||||
|
||||
if (requestCode == REQUEST_CODE_CHOOSE_OPML_IMPORT_PATH) {
|
||||
Intent intent = new Intent(getContext(), OpmlImportFromIntentActivity.class);
|
||||
intent.setData(uri);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import androidx.core.content.FileProvider;
|
|||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.OpmlImportFromPathActivity;
|
||||
import de.danoeh.antennapod.activity.OpmlImportFromIntentActivity;
|
||||
import de.danoeh.antennapod.activity.PreferenceActivity;
|
||||
import de.danoeh.antennapod.activity.SplashActivity;
|
||||
import de.danoeh.antennapod.asynctask.DocumentFileExportWorker;
|
||||
|
@ -44,14 +44,15 @@ public class ImportExportPreferencesFragment extends PreferenceFragmentCompat {
|
|||
private static final String PREF_HTML_EXPORT = "prefHtmlExport";
|
||||
private static final String PREF_DATABASE_IMPORT = "prefDatabaseImport";
|
||||
private static final String PREF_DATABASE_EXPORT = "prefDatabaseExport";
|
||||
private static final int REQUEST_CODE_CHOOSE_OPML_EXPORT_PATH = 1;
|
||||
private static final String DEFAULT_OPML_OUTPUT_NAME = "antennapod-feeds.opml";
|
||||
private static final String CONTENT_TYPE_OPML = "text/x-opml";
|
||||
private static final int REQUEST_CODE_CHOOSE_HTML_EXPORT_PATH = 2;
|
||||
private static final String DEFAULT_HTML_OUTPUT_NAME = "antennapod-feeds.html";
|
||||
private static final String CONTENT_TYPE_HTML = "text/html";
|
||||
private static final int REQUEST_CODE_RESTORE_DATABASE = 3;
|
||||
private static final int REQUEST_CODE_BACKUP_DATABASE = 4;
|
||||
private static final int REQUEST_CODE_CHOOSE_OPML_EXPORT_PATH = 1;
|
||||
private static final int REQUEST_CODE_CHOOSE_OPML_IMPORT_PATH = 2;
|
||||
private static final int REQUEST_CODE_CHOOSE_HTML_EXPORT_PATH = 3;
|
||||
private static final int REQUEST_CODE_RESTORE_DATABASE = 4;
|
||||
private static final int REQUEST_CODE_BACKUP_DATABASE = 5;
|
||||
private static final String DATABASE_EXPORT_FILENAME = "AntennaPodBackup.db";
|
||||
private Disposable disposable;
|
||||
private ProgressDialog progressDialog;
|
||||
|
@ -96,7 +97,14 @@ public class ImportExportPreferencesFragment extends PreferenceFragmentCompat {
|
|||
});
|
||||
findPreference(PREF_OPML_IMPORT).setOnPreferenceClickListener(
|
||||
preference -> {
|
||||
activity.startActivity(new Intent(activity, OpmlImportFromPathActivity.class));
|
||||
try {
|
||||
Intent intentGetContentAction = new Intent(Intent.ACTION_GET_CONTENT);
|
||||
intentGetContentAction.addCategory(Intent.CATEGORY_OPENABLE);
|
||||
intentGetContentAction.setType("*/*");
|
||||
startActivityForResult(intentGetContentAction, REQUEST_CODE_CHOOSE_OPML_IMPORT_PATH);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
Log.e(TAG, "No activity found. Should never happen...");
|
||||
}
|
||||
return true;
|
||||
});
|
||||
findPreference(PREF_DATABASE_IMPORT).setOnPreferenceClickListener(
|
||||
|
@ -245,6 +253,10 @@ public class ImportExportPreferencesFragment extends PreferenceFragmentCompat {
|
|||
Snackbar.make(getView(), R.string.export_success_title, Snackbar.LENGTH_LONG).show();
|
||||
progressDialog.dismiss();
|
||||
}, this::showExportErrorDialog);
|
||||
} else if (requestCode == REQUEST_CODE_CHOOSE_OPML_IMPORT_PATH) {
|
||||
Intent intent = new Intent(getContext(), OpmlImportFromIntentActivity.class);
|
||||
intent.setData(uri);
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/import_export_layout"
|
||||
android:padding="8dp"
|
||||
android:clipToPadding="false">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/import_export_warning"
|
||||
android:gravity="center_horizontal"/>
|
||||
|
||||
<Button
|
||||
android:text="@string/label_export"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/button_export"
|
||||
android:layout_marginTop="24dp"/>
|
||||
|
||||
<Button
|
||||
android:text="@string/label_import"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/button_import"/>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
|
@ -1,65 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingLeft="16dp"
|
||||
android:paddingRight="16dp"
|
||||
android:paddingBottom="8dp"
|
||||
tools:background="@android:color/darker_gray">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvHeadingExplanation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/AntennaPod.TextView.Heading"
|
||||
android:text="@string/txtvfeedurl_label"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvExplanation"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/opml_import_explanation_1"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
android:layout_marginTop="4dp"
|
||||
tools:background="@android:color/holo_green_dark" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/butChooseFileFromFilesystem"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/choose_file_from_filesystem" />
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_margin="16dp"
|
||||
android:background="?android:attr/listDivider"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvHeadingExplanationOpenWith"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/AntennaPod.TextView.Heading"
|
||||
android:text="@string/txtvfeedurl_label"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtvExplanationOpenWith"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/opml_import_explanation_3"
|
||||
android:textSize="@dimen/text_size_medium"
|
||||
android:layout_marginTop="4dp"
|
||||
tools:background="@android:color/holo_green_dark" />
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
|
@ -554,15 +554,11 @@
|
|||
<string name="opml_import_summary">Import your subscriptions from another podcast app</string>
|
||||
<string name="database_export_summary">Transfer subscriptions, listened episodes and queue to AntennaPod on another device</string>
|
||||
<string name="database_import_summary">Import AntennaPod database from another device</string>
|
||||
<string name="opml_import_option">Option %1$d</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_label">OPML Import</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="select_all_label">Select all</string>
|
||||
<string name="deselect_all_label">Deselect all</string>
|
||||
<string name="choose_file_from_filesystem">From local filesystem</string>
|
||||
<string name="opml_export_label">OPML export</string>
|
||||
<string name="html_export_label">HTML export</string>
|
||||
<string name="database_export_label">Database export</string>
|
||||
|
|
Loading…
Reference in New Issue