Simplification

master
M66B 3 months ago
parent b724113798
commit 04d25ef527

@ -258,8 +258,7 @@ public class ActivityCompose extends ActivityBase implements FragmentManager.OnB
ClipData.Item item = clip.getItemAt(i); ClipData.Item item = clip.getItemAt(i);
Uri stream = (item == null ? null : item.getUri()); Uri stream = (item == null ? null : item.getUri());
if (stream != null) if (stream != null)
uris.add(new UriType(stream, uris.add(new UriType(stream, description, this));
description != null && i < description.getMimeTypeCount() ? description.getMimeType(i) : null, this));
} }
if (intent.hasExtra(Intent.EXTRA_STREAM)) { if (intent.hasExtra(Intent.EXTRA_STREAM)) {

@ -580,7 +580,7 @@ public class EntityAnswer implements Serializable {
for (Uri file : attachments) for (Uri file : attachments)
try { try {
EntityAttachment attachment = new EntityAttachment(); EntityAttachment attachment = new EntityAttachment();
Helper.UriInfo info = Helper.getInfo(new UriType(file, null, null), context); Helper.UriInfo info = Helper.getInfo(new UriType(file, (String) null, null), context);
attachment.message = id; attachment.message = id;
attachment.sequence = db.attachment().getAttachmentSequence(id) + 1; attachment.sequence = db.attachment().getAttachmentSequence(id) + 1;

@ -3382,7 +3382,7 @@ public class FragmentCompose extends FragmentBase {
case REQUEST_TAKE_PHOTO: case REQUEST_TAKE_PHOTO:
if (resultCode == RESULT_OK) { if (resultCode == RESULT_OK) {
if (photoURI != null) if (photoURI != null)
onAddImageFile(Arrays.asList(new UriType(photoURI, null, null)), false); onAddImageFile(Arrays.asList(new UriType(photoURI, (String) null, getContext())), false);
} }
break; break;
case REQUEST_ATTACHMENT: case REQUEST_ATTACHMENT:
@ -3951,9 +3951,7 @@ public class FragmentCompose extends FragmentBase {
ClipData.Item item = clipData.getItemAt(i); ClipData.Item item = clipData.getItemAt(i);
Uri uri = item.getUri(); Uri uri = item.getUri();
if (uri != null) if (uri != null)
result.add(new UriType(uri, result.add(new UriType(uri, description, getContext()));
description != null && i < description.getMimeTypeCount() ? description.getMimeType(i) : null,
getContext()));
} }
} }

@ -19,6 +19,7 @@ package eu.faircode.email;
Copyright 2018-2025 by Marcel Bokhorst (M66B) Copyright 2018-2025 by Marcel Bokhorst (M66B)
*/ */
import android.content.ClipDescription;
import android.content.Context; import android.content.Context;
import android.net.Uri; import android.net.Uri;
import android.os.Parcel; import android.os.Parcel;
@ -39,6 +40,10 @@ public class UriType implements Parcelable {
this.type = in.readString(); this.type = in.readString();
} }
public UriType(Uri uri, ClipDescription description, Context context) {
this(uri, description == null || description.getMimeTypeCount() <= 0 ? null : description.getMimeType(0), context);
}
public UriType(Uri uri, String type, Context context) { public UriType(Uri uri, String type, Context context) {
this.uri = uri; this.uri = uri;
if (!TextUtils.isEmpty(type)) if (!TextUtils.isEmpty(type))
@ -85,7 +90,7 @@ public class UriType implements Parcelable {
List<UriType> result = new ArrayList<>(); List<UriType> result = new ArrayList<>();
if (uris != null) if (uris != null)
for (Uri uri : uris) for (Uri uri : uris)
result.add(new UriType(uri, null, context)); result.add(new UriType(uri, (String) null, context));
return result; return result;
} }

Loading…
Cancel
Save