Add button to share exported database export (#6746)

Also hide path, is not accessible on recent Android versions anyway.
This commit is contained in:
ByteHamster 2023-11-05 16:06:20 +01:00 committed by GitHub
parent 34c7fd576f
commit 0a6a3d6854
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 19 deletions

View File

@ -147,7 +147,7 @@ public class ImportExportPreferencesFragment extends PreferenceFragmentCompat {
.subscribe(output -> { .subscribe(output -> {
Uri fileUri = FileProvider.getUriForFile(context.getApplicationContext(), Uri fileUri = FileProvider.getUriForFile(context.getApplicationContext(),
context.getString(R.string.provider_authority), output); context.getString(R.string.provider_authority), output);
showExportSuccessDialog(output.toString(), fileUri, exportType); showExportSuccessSnackbar(fileUri, exportType.contentType);
}, this::showExportErrorDialog, progressDialog::dismiss); }, this::showExportErrorDialog, progressDialog::dismiss);
} else { } else {
DocumentFileExportWorker worker = new DocumentFileExportWorker(exportWriter, context, uri); DocumentFileExportWorker worker = new DocumentFileExportWorker(exportWriter, context, uri);
@ -155,7 +155,7 @@ public class ImportExportPreferencesFragment extends PreferenceFragmentCompat {
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(output -> .subscribe(output ->
showExportSuccessDialog(output.getUri().toString(), output.getUri(), exportType), showExportSuccessSnackbar(output.getUri(), exportType.contentType),
this::showExportErrorDialog, progressDialog::dismiss); this::showExportErrorDialog, progressDialog::dismiss);
} }
} }
@ -191,20 +191,15 @@ public class ImportExportPreferencesFragment extends PreferenceFragmentCompat {
builder.show(); builder.show();
} }
private void showExportSuccessDialog(String path, Uri streamUri, Export exportType) { void showExportSuccessSnackbar(Uri uri, String mimeType) {
final MaterialAlertDialogBuilder alert = new MaterialAlertDialogBuilder(getContext()); Snackbar.make(getView(), R.string.export_success_title, Snackbar.LENGTH_LONG)
alert.setNeutralButton(android.R.string.ok, (dialog, which) -> dialog.dismiss()); .setAction(R.string.share_label, v ->
alert.setTitle(R.string.export_success_title); new ShareCompat.IntentBuilder(getContext())
alert.setMessage(getContext().getString(R.string.export_success_sum, path)); .setType(mimeType)
alert.setPositiveButton(R.string.send_label, (dialog, which) -> { .addStream(uri)
new ShareCompat.IntentBuilder(getContext()) .setChooserTitle(R.string.share_label)
.setType(exportType.contentType) .startChooser())
.setSubject(getString(exportType.labelResId)) .show();
.addStream(streamUri)
.setChooserTitle(R.string.send_label)
.startChooser();
});
alert.create().show();
} }
private void showExportErrorDialog(final Throwable error) { private void showExportErrorDialog(final Throwable error) {
@ -264,7 +259,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_success_title, Snackbar.LENGTH_LONG).show(); showExportSuccessSnackbar(uri, "application/x-sqlite3");
progressDialog.dismiss(); progressDialog.dismiss();
}, this::showExportErrorDialog); }, this::showExportErrorDialog);
} }

View File

@ -138,7 +138,6 @@
<string name="feed_auto_download_never">Never</string> <string name="feed_auto_download_never">Never</string>
<string name="feed_new_episodes_action_add_to_inbox">Add to inbox</string> <string name="feed_new_episodes_action_add_to_inbox">Add to inbox</string>
<string name="feed_new_episodes_action_nothing">Nothing</string> <string name="feed_new_episodes_action_nothing">Nothing</string>
<string name="send_label">Send&#8230;</string>
<string name="episode_cleanup_never">Never</string> <string name="episode_cleanup_never">Never</string>
<string name="episode_cleanup_except_favorite_removal">When not favorited</string> <string name="episode_cleanup_except_favorite_removal">When not favorited</string>
<string name="episode_cleanup_queue_removal">When not in queue</string> <string name="episode_cleanup_queue_removal">When not in queue</string>
@ -590,7 +589,6 @@
<string name="please_wait">Please wait&#8230;</string> <string name="please_wait">Please wait&#8230;</string>
<string name="export_error_label">Export error</string> <string name="export_error_label">Export error</string>
<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="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="successful_import_label">Import successful</string> <string name="successful_import_label">Import successful</string>
<string name="import_ok">Please press OK to restart AntennaPod</string> <string name="import_ok">Please press OK to restart AntennaPod</string>