diff --git a/patches/react-native-fast-image+8.6.3.patch b/patches/react-native-fast-image+8.6.3+001+initial.patch similarity index 100% rename from patches/react-native-fast-image+8.6.3.patch rename to patches/react-native-fast-image+8.6.3+001+initial.patch diff --git a/patches/react-native-fast-image+8.6.3+002+bitmap-downsampling.patch b/patches/react-native-fast-image+8.6.3+002+bitmap-downsampling.patch new file mode 100644 index 000000000000..a626d5b16b2f --- /dev/null +++ b/patches/react-native-fast-image+8.6.3+002+bitmap-downsampling.patch @@ -0,0 +1,62 @@ +diff --git a/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageViewWithUrl.java b/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageViewWithUrl.java +index 1339f5c..9dfec0c 100644 +--- a/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageViewWithUrl.java ++++ b/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/FastImageViewWithUrl.java +@@ -176,7 +176,8 @@ class FastImageViewWithUrl extends AppCompatImageView { + .apply(FastImageViewConverter + .getOptions(context, imageSource, mSource) + .placeholder(mDefaultSource) // show until loaded +- .fallback(mDefaultSource)); // null will not be treated as error ++ .fallback(mDefaultSource)) ++ .transform(new ResizeTransformation()); + + if (key != null) + builder.listener(new FastImageRequestListener(key)); +diff --git a/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/ResizeTransformation.java b/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/ResizeTransformation.java +new file mode 100644 +index 0000000..1daa227 +--- /dev/null ++++ b/node_modules/react-native-fast-image/android/src/main/java/com/dylanvann/fastimage/ResizeTransformation.java +@@ -0,0 +1,41 @@ ++package com.dylanvann.fastimage; ++ ++ import android.content.Context; ++ import android.graphics.Bitmap; ++ ++ import androidx.annotation.NonNull; ++ ++ import com.bumptech.glide.load.Transformation; ++ import com.bumptech.glide.load.engine.Resource; ++ import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; ++ import com.bumptech.glide.load.resource.bitmap.BitmapResource; ++ ++ import java.security.MessageDigest; ++ ++ public class ResizeTransformation implements Transformation { ++ ++ private final double MAX_BYTES = 25000000.0; ++ ++ @NonNull ++ @Override ++ public Resource transform(@NonNull Context context, @NonNull Resource resource, int outWidth, int outHeight) { ++ Bitmap toTransform = resource.get(); ++ ++ if (toTransform.getByteCount() > MAX_BYTES) { ++ double scaleFactor = Math.sqrt(MAX_BYTES / (double) toTransform.getByteCount()); ++ int newHeight = (int) (outHeight * scaleFactor); ++ int newWidth = (int) (outWidth * scaleFactor); ++ ++ BitmapPool pool = GlideApp.get(context).getBitmapPool(); ++ Bitmap scaledBitmap = Bitmap.createScaledBitmap(toTransform, newWidth, newHeight, true); ++ return BitmapResource.obtain(scaledBitmap, pool); ++ } ++ ++ return resource; ++ } ++ ++ @Override ++ public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) { ++ messageDigest.update(("ResizeTransformation").getBytes()); ++ } ++ } +\ No newline at end of file diff --git a/src/components/AttachmentModal.js b/src/components/AttachmentModal.js index 13b3b9f1e836..b1af96561ef5 100755 --- a/src/components/AttachmentModal.js +++ b/src/components/AttachmentModal.js @@ -4,6 +4,7 @@ import lodashGet from 'lodash/get'; import PropTypes from 'prop-types'; import React, {useCallback, useEffect, useMemo, useState} from 'react'; import {Animated, Keyboard, View} from 'react-native'; +import {GestureHandlerRootView} from 'react-native-gesture-handler'; import {withOnyx} from 'react-native-onyx'; import _ from 'underscore'; import useLocalize from '@hooks/useLocalize'; @@ -425,78 +426,80 @@ function AttachmentModal(props) { }} propagateSwipe > - {props.isSmallScreenWidth && } - downloadAttachment(source)} - shouldShowCloseButton={!props.isSmallScreenWidth} - shouldShowBackButton={props.isSmallScreenWidth} - onBackButtonPress={closeModal} - onCloseButtonPress={closeModal} - shouldShowThreeDotsButton={shouldShowThreeDotsButton} - threeDotsAnchorPosition={styles.threeDotsPopoverOffsetAttachmentModal(windowWidth)} - threeDotsMenuItems={threeDotsMenuItems} - shouldOverlay - /> - - {!_.isEmpty(props.report) && !props.isReceiptAttachment ? ( - - ) : ( - Boolean(sourceForAttachmentView) && - shouldLoadAttachment && ( - + {props.isSmallScreenWidth && } + downloadAttachment(source)} + shouldShowCloseButton={!props.isSmallScreenWidth} + shouldShowBackButton={props.isSmallScreenWidth} + onBackButtonPress={closeModal} + onCloseButtonPress={closeModal} + shouldShowThreeDotsButton={shouldShowThreeDotsButton} + threeDotsAnchorPosition={styles.threeDotsPopoverOffsetAttachmentModal(windowWidth)} + threeDotsMenuItems={threeDotsMenuItems} + shouldOverlay + /> + + {!_.isEmpty(props.report) && !props.isReceiptAttachment ? ( + - ) - )} - - {/* If we have an onConfirm method show a confirmation button */} - {Boolean(props.onConfirm) && ( - - {({safeAreaPaddingBottomStyle}) => ( - -