Added error message

pull/147/head
M66B 6 years ago
parent ed5d31252c
commit 2be2017bd4

@ -1589,6 +1589,9 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
long id = args.getLong("id");
Uri uri = args.getParcelable("uri");
if ("file".equals(uri.getScheme()))
throw new IllegalArgumentException(context.getString(R.string.title_no_stream));
File file = EntityAttachment.getFile(context, id);
ParcelFileDescriptor pfd = null;
@ -1601,9 +1604,8 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
byte[] buffer = new byte[ATTACHMENT_BUFFER_SIZE];
int read;
while ((read = fis.read(buffer)) != -1) {
while ((read = fis.read(buffer)) != -1)
fos.write(buffer, 0, read);
}
} finally {
try {
if (pfd != null)
@ -1635,7 +1637,10 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(ActivityView.this, ActivityView.this, ex);
if (ex instanceof IllegalArgumentException)
Snackbar.make(getVisibleView(), ex.getMessage(), Snackbar.LENGTH_LONG).show();
else
Helper.unexpectedError(ActivityView.this, ActivityView.this, ex);
}
}.load(this, args);
}

@ -80,7 +80,6 @@ import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@ -882,7 +881,7 @@ public class FragmentCompose extends FragmentEx {
@Override
protected void onException(Bundle args, Throwable ex) {
// External app sending absolute file
if (ex instanceof FileNotFoundException)
if (ex instanceof IllegalArgumentException)
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show();
else
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
@ -967,6 +966,9 @@ public class FragmentCompose extends FragmentEx {
private static EntityAttachment addAttachment(Context context, long id, Uri uri,
boolean image) throws IOException {
if ("file".equals(uri.getScheme()))
throw new IllegalArgumentException(context.getString(R.string.title_no_stream));
EntityAttachment attachment = new EntityAttachment();
String name = null;
@ -1518,8 +1520,7 @@ public class FragmentCompose extends FragmentEx {
@Override
protected void onException(Bundle args, Throwable ex) {
// External app sending absolute file
if (ex instanceof FileNotFoundException)
if (ex instanceof IllegalArgumentException)
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show();
else
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);

@ -609,6 +609,9 @@ public class FragmentSetup extends FragmentEx {
Uri uri = args.getParcelable("uri");
String password = args.getString("password");
if ("file".equals(uri.getScheme()))
throw new IllegalArgumentException(context.getString(R.string.title_no_stream));
OutputStream out = null;
try {
Log.i(Helper.TAG, "Writing URI=" + uri);
@ -691,7 +694,10 @@ public class FragmentSetup extends FragmentEx {
@Override
protected void onException(Bundle args, Throwable ex) {
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
if (ex instanceof IllegalArgumentException)
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show();
else
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}
}.load(this, args);
}
@ -705,9 +711,11 @@ public class FragmentSetup extends FragmentEx {
@Override
protected Void onLoad(Context context, Bundle args) throws Throwable {
Uri uri = args.getParcelable("uri");
String password = args.getString("password");
if ("file".equals(uri.getScheme()))
throw new IllegalArgumentException(context.getString(R.string.title_no_stream));
InputStream in = null;
try {
Log.i(Helper.TAG, "Reading URI=" + uri);
@ -826,6 +834,8 @@ public class FragmentSetup extends FragmentEx {
protected void onException(Bundle args, Throwable ex) {
if (ex.getCause() instanceof BadPaddingException)
Snackbar.make(view, R.string.title_setup_password_invalid, Snackbar.LENGTH_LONG).show();
else if (ex instanceof IllegalArgumentException)
Snackbar.make(view, ex.getMessage(), Snackbar.LENGTH_LONG).show();
else
Helper.unexpectedError(getContext(), getViewLifecycleOwner(), ex);
}

@ -262,6 +262,7 @@
<string name="title_no_answers">No reply templates defined</string>
<string name="title_no_viewer">No viewer app available for %1$s</string>
<string name="title_no_saf">Storage access framework not available</string>
<string name="title_no_stream">An outdated app sent a file path instead of a file stream</string>
<string name="title_no_contacts">Contact picker not available</string>
<string name="title_attachment_saved">Attachment saved</string>
<string name="title_attachment_unavailable">Some attachments are not downloaded and will not be added, continue?</string>

Loading…
Cancel
Save