move the save-attachment-toast to onPostExecute()

This commit is contained in:
B. Petersen 2020-01-06 22:08:44 +01:00
parent 3edb0cd79c
commit 5f7f9f57c6
No known key found for this signature in database
GPG key ID: 3B88E92DEA8E9AFC
2 changed files with 3 additions and 12 deletions

View file

@ -198,7 +198,7 @@
<string name="share_location_for_two_hours">for 2 hours</string> <string name="share_location_for_two_hours">for 2 hours</string>
<string name="share_location_for_six_hours">for 6 hours</string> <string name="share_location_for_six_hours">for 6 hours</string>
<string name="exported_attachment_to">Saved file to %1$s</string> <string name="file_saved_to">File saved to \"%1$s\".</string>
<!-- get confirmations --> <!-- get confirmations -->
<string name="ask_leave_group">Are you sure you want to leave this group?</string> <string name="ask_leave_group">Are you sure you want to leave this group?</string>

View file

@ -63,12 +63,6 @@ public class SaveAttachmentTask extends ProgressDialogAsyncTask<SaveAttachmentTa
if (directory == null) return new Pair<>(FAILURE, null); if (directory == null) return new Pair<>(FAILURE, null);
} }
} }
final String displayDir = directory;
Util.runOnMain(() -> {
// Tell the user where the file went
// "Saved to " + displayDir
Toast.makeText(context, context.getString(R.string.exported_attachment_to, displayDir), Toast.LENGTH_LONG).show();
});
if (attachments.length > 1) return new Pair<>(SUCCESS, null); if (attachments.length > 1) return new Pair<>(SUCCESS, null);
else return new Pair<>(SUCCESS, directory); else return new Pair<>(SUCCESS, directory);
} catch (NoExternalStorageException|IOException ioe) { } catch (NoExternalStorageException|IOException ioe) {
@ -182,8 +176,9 @@ public class SaveAttachmentTask extends ProgressDialogAsyncTask<SaveAttachmentTa
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
break; break;
case SUCCESS: case SUCCESS:
String dir = result.second();
Toast.makeText(context, Toast.makeText(context,
context.getResources().getString(R.string.done), dir==null? context.getString(R.string.done) : context.getString(R.string.file_saved_to, dir),
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
break; break;
case WRITE_ACCESS_FAILURE: case WRITE_ACCESS_FAILURE:
@ -213,10 +208,6 @@ public class SaveAttachmentTask extends ProgressDialogAsyncTask<SaveAttachmentTa
} }
public static void showWarningDialog(Context context, OnClickListener onAcceptListener) { public static void showWarningDialog(Context context, OnClickListener onAcceptListener) {
showWarningDialog(context, onAcceptListener, 1);
}
public static void showWarningDialog(Context context, OnClickListener onAcceptListener, int count) {
AlertDialog.Builder builder = new AlertDialog.Builder(context); AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setCancelable(true); builder.setCancelable(true);
builder.setMessage(R.string.ask_export_attachment); builder.setMessage(R.string.ask_export_attachment);