Improved no stream handling

This commit is contained in:
M66B
2022-03-18 17:22:25 +01:00
parent 13b8cf5791
commit 477a7996ce
14 changed files with 208 additions and 141 deletions

View File

@@ -21,7 +21,6 @@ package eu.faircode.email;
import static android.app.Activity.RESULT_OK;
import android.Manifest;
import android.app.Dialog;
import android.content.ContentResolver;
import android.content.Context;
@@ -328,14 +327,7 @@ public class FragmentContacts extends FragmentBase {
Uri uri = args.getParcelable("uri");
long account = args.getLong("account");
if (uri == null)
throw new FileNotFoundException();
if (!"content".equals(uri.getScheme()) &&
!Helper.hasPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE)) {
Log.w("Import uri=" + uri);
throw new IllegalArgumentException(context.getString(R.string.title_no_stream));
}
NoStreamException.check(uri, context);
long now = new Date().getTime();
@@ -380,7 +372,10 @@ public class FragmentContacts extends FragmentBase {
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(getParentFragmentManager(), ex);
if (ex instanceof NoStreamException)
((NoStreamException) ex).report(getContext());
else
Log.unexpectedError(getParentFragmentManager(), ex);
}
}.execute(this, args, "setup:import");
}