mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 16:49:40 +01:00
Use media forward sheet when forwarding in Media preview.
This commit is contained in:
committed by
Cody Henthorne
parent
d865b5d7b5
commit
477698f917
@@ -77,6 +77,19 @@ public abstract class MediaConstraints {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSatisfied(@NonNull Context context, @NonNull Uri uri, @NonNull String contentType, long size) {
|
||||
try {
|
||||
return (MediaUtil.isGif(contentType) && size <= getGifMaxSize(context) && isWithinBounds(context, uri)) ||
|
||||
(MediaUtil.isImageType(contentType) && size <= getImageMaxSize(context) && isWithinBounds(context, uri)) ||
|
||||
(MediaUtil.isAudioType(contentType) && size <= getAudioMaxSize(context)) ||
|
||||
(MediaUtil.isVideoType(contentType) && size <= getVideoMaxSize(context)) ||
|
||||
size <= getDocumentMaxSize(context);
|
||||
} catch (IOException ioe) {
|
||||
Log.w(TAG, "Failed to determine if media's constraints are satisfied.", ioe);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isWithinBounds(Context context, Uri uri) throws IOException {
|
||||
try {
|
||||
InputStream is = PartAuthority.getAttachmentStream(context, uri);
|
||||
@@ -93,6 +106,11 @@ public abstract class MediaConstraints {
|
||||
MediaUtil.isVideo(attachment) && isVideoTranscodeAvailable();
|
||||
}
|
||||
|
||||
public boolean canResize(@NonNull String mediaType) {
|
||||
return MediaUtil.isImageType(mediaType) && !MediaUtil.isGif(mediaType) ||
|
||||
MediaUtil.isVideoType(mediaType) && isVideoTranscodeAvailable();
|
||||
}
|
||||
|
||||
public static boolean isVideoTranscodeAvailable() {
|
||||
return Build.VERSION.SDK_INT >= 26 && (FeatureFlags.useStreamingVideoMuxer() || MemoryFileDescriptor.supported());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user