This commit is contained in:
Grishka 2022-04-29 15:17:29 +03:00
parent 2a65bdb08f
commit 089e297656

View File

@ -714,12 +714,13 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
return false; return false;
} }
String type=getActivity().getContentResolver().getType(uri); String type=getActivity().getContentResolver().getType(uri);
if(instance.configuration!=null && instance.configuration.mediaAttachments!=null){ if(instance!=null && instance.configuration!=null && instance.configuration.mediaAttachments!=null){
if(instance.configuration.mediaAttachments.supportedMimeTypes!=null && !instance.configuration.mediaAttachments.supportedMimeTypes.contains(type)){ if(instance.configuration.mediaAttachments.supportedMimeTypes!=null && !instance.configuration.mediaAttachments.supportedMimeTypes.contains(type)){
showMediaAttachmentError(getString(R.string.media_attachment_unsupported_type, UiUtils.getFileName(uri))); showMediaAttachmentError(getString(R.string.media_attachment_unsupported_type, UiUtils.getFileName(uri)));
return false; return false;
} }
int sizeLimit=type.startsWith("image/") ? instance.configuration.mediaAttachments.imageSizeLimit : instance.configuration.mediaAttachments.videoSizeLimit; if(!type.startsWith("image/")){
int sizeLimit=instance.configuration.mediaAttachments.videoSizeLimit;
int size; int size;
try(Cursor cursor=MastodonApp.context.getContentResolver().query(uri, new String[]{OpenableColumns.SIZE}, null, null, null)){ try(Cursor cursor=MastodonApp.context.getContentResolver().query(uri, new String[]{OpenableColumns.SIZE}, null, null, null)){
cursor.moveToFirst(); cursor.moveToFirst();
@ -735,6 +736,7 @@ public class ComposeFragment extends MastodonToolbarFragment implements OnBackPr
return false; return false;
} }
} }
}
pollBtn.setEnabled(false); pollBtn.setEnabled(false);
DraftMediaAttachment draft=new DraftMediaAttachment(); DraftMediaAttachment draft=new DraftMediaAttachment();
draft.uri=uri; draft.uri=uri;