make share just an option of the old dialog

This commit is contained in:
Tom Hennen 2015-09-07 20:42:15 -04:00
parent 0617115a6f
commit de879e1dd9
1 changed files with 26 additions and 14 deletions

View File

@ -78,25 +78,37 @@ public class OpmlExportWorker extends AsyncTask<Void, Void, Void> {
@Override @Override
protected void onPostExecute(Void result) { protected void onPostExecute(Void result) {
progDialog.dismiss(); progDialog.dismiss();
if (exception != null) {
AlertDialog.Builder alert = new AlertDialog.Builder(context) AlertDialog.Builder alert = new AlertDialog.Builder(context)
.setNeutralButton(android.R.string.ok, .setNeutralButton(android.R.string.ok,
(dialog, which) -> { new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
dialog.dismiss(); dialog.dismiss();
}
}); });
if (exception != null) {
alert.setTitle(R.string.export_error_label); alert.setTitle(R.string.export_error_label);
alert.setMessage(exception.getMessage()); alert.setMessage(exception.getMessage());
alert.create().show(); } else {
return; alert.setTitle(R.string.opml_export_success_title);
} alert.setMessage(context
.getString(R.string.opml_export_success_sum)
Uri outputUri = Uri.fromFile(output); + output.toString())
.setPositiveButton(R.string.share_label, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {Uri outputUri = Uri.fromFile(output);
Intent sendIntent = new Intent(Intent.ACTION_SEND); Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_SUBJECT, "OPML Export"); sendIntent.putExtra(Intent.EXTRA_SUBJECT, "OPML Export");
sendIntent.putExtra(Intent.EXTRA_STREAM, outputUri); sendIntent.putExtra(Intent.EXTRA_STREAM, outputUri);
sendIntent.setType("text/plain"); sendIntent.setType("text/plain");
context.startActivity(Intent.createChooser(sendIntent, context.getResources().getText(R.string.share_label))); context.startActivity(Intent.createChooser(sendIntent, context.getResources().getText(R.string.share_label)));
} }
});
}
alert.create().show();
}
@Override @Override
protected void onPreExecute() { protected void onPreExecute() {